Skip to content

Commit 23751ad

Browse files
committed
Plugins::FreeRDP: modify settings diaglog
1 parent 574247f commit 23751ad

4 files changed

Lines changed: 90 additions & 7 deletions

File tree

Plugins/FreeRDP/Client/DlgSetFreeRDP.cpp

Lines changed: 83 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ CDlgSetFreeRDP::CDlgSetFreeRDP(CParameterFreeRDP *pSettings, QWidget *parent) :
5050

5151
m_pProxyUI = new CParameterProxyUI(ui->tabWidget);
5252
m_pProxyUI->SetParameter(&m_pSettings->m_Proxy);
53-
ui->tabWidget->insertTab(1, m_pProxyUI, m_pProxyUI->windowIcon(), tr("Proxy"));
54-
53+
InsertView(m_pProxyUI, 1);
54+
5555
m_pRecordUI = new CParameterRecordUI(ui->tabWidget);
5656
m_pRecordUI->SetParameter(&m_pSettings->m_Record);
57-
ui->tabWidget->addTab(m_pRecordUI, m_pRecordUI->windowIcon(), tr("Record"));
57+
QList<QWidget *> ws;
58+
ws << m_pRecordUI;
59+
AddViewers(ws);
5860

5961
// Display
6062
// It has to be the first. GetScreenGeometry depends on it
@@ -647,3 +649,81 @@ void CDlgSetFreeRDP::on_cbConnectType_currentIndexChanged(int index)
647649
ui->cbDesktopCompositing->setEnabled(!(CONNECTION_TYPE_AUTODETECT == type));
648650
}
649651

652+
void CDlgSetFreeRDP::InsertView(QWidget* pView, int pos)
653+
{
654+
int nWidth = 0;
655+
int nHeigth = 0;
656+
if(!pView) return;
657+
nWidth = qMax(nWidth, pView->frameSize().width());
658+
nHeigth = qMax(nHeigth, pView->frameSize().height());
659+
660+
bool bScroll = false;
661+
QScreen* pScreen = QApplication::primaryScreen();
662+
QSize size = this->size();
663+
if(nWidth > size.width() || nHeigth > size.height())
664+
bScroll = true;
665+
// [connect accepted to slotAccept of widget]
666+
667+
QString szMsg;
668+
if(bScroll)
669+
{
670+
QScrollArea* pScroll = new QScrollArea(ui->tabWidget);
671+
if(!pScroll) return;
672+
pScroll->setWidget(pView);
673+
pView = pScroll;
674+
}
675+
ui->tabWidget->insertTab(pos, pView, pView->windowIcon(), pView->windowTitle());
676+
bool check = false;
677+
check = connect(this, SIGNAL(accepted()), pView, SLOT(slotAccept()));
678+
if(!check)
679+
{
680+
szMsg = "Class '" + QString(pView->metaObject()->className())
681+
+ "' must has slot slotAccept(), please add it. "
682+
+ "Or the class derived from CParameterUI";
683+
qCritical(log) << szMsg;
684+
}
685+
Q_ASSERT_X(check, "CParameterDlgSettings", szMsg.toStdString().c_str());
686+
687+
// [connect accepted to slotAccept of widget]
688+
}
689+
690+
void CDlgSetFreeRDP::AddViewers(const QList<QWidget *> &wViewer)
691+
{
692+
int nWidth = 0;
693+
int nHeigth = 0;
694+
foreach(auto p, wViewer) {
695+
if(!p) continue;
696+
nWidth = qMax(nWidth, p->frameSize().width());
697+
nHeigth = qMax(nHeigth, p->frameSize().height());
698+
}
699+
bool bScroll = false;
700+
QScreen* pScreen = QApplication::primaryScreen();
701+
QSize size = this->size();
702+
if(nWidth > size.width() || nHeigth > size.height())
703+
bScroll = true;
704+
// [connect accepted to slotAccept of widget]
705+
foreach(auto p, wViewer)
706+
{
707+
QString szMsg;
708+
QWidget* pView = p;
709+
if(bScroll)
710+
{
711+
QScrollArea* pScroll = new QScrollArea(ui->tabWidget);
712+
if(!pScroll) continue;
713+
pScroll->setWidget(p);
714+
pView = pScroll;
715+
}
716+
ui->tabWidget->addTab(pView, p->windowIcon(), p->windowTitle());
717+
bool check = false;
718+
check = connect(this, SIGNAL(accepted()), p, SLOT(slotAccept()));
719+
if(!check)
720+
{
721+
szMsg = "Class '" + QString(p->metaObject()->className())
722+
+ "' must has slot slotAccept(), please add it. "
723+
+ "Or the class derived from CParameterUI";
724+
qCritical(log) << szMsg;
725+
}
726+
Q_ASSERT_X(check, "CParameterDlgSettings", szMsg.toStdString().c_str());
727+
}
728+
// [connect accepted to slotAccept of widget]
729+
}

Plugins/FreeRDP/Client/DlgSetFreeRDP.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ private slots:
4747
void on_cbSecurityEnable_stateChanged(int arg1);
4848

4949
private:
50+
void InsertView(QWidget *p, int pos);
51+
void AddViewers(const QList<QWidget*> &wViewer);
5052
QRect GetScreenGeometry();
5153
int UpdateDesktopSize();
5254
int InsertDesktopSize(QString szSize);

Plugins/FreeRDP/Client/DlgSetFreeRDP.ui

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>550</width>
10-
<height>550</height>
9+
<width>600</width>
10+
<height>500</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -468,8 +468,8 @@
468468
<rect>
469469
<x>0</x>
470470
<y>0</y>
471-
<width>510</width>
472-
<height>524</height>
471+
<width>544</width>
472+
<height>485</height>
473473
</rect>
474474
</property>
475475
<layout class="QGridLayout" name="gridLayout_12">

Src/ParameterCompone/ParameterProxyUI.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CParameterProxyUI::CParameterProxyUI(QWidget *parent)
1010
, m_uiSSH(nullptr)
1111
{
1212
bool bCheck = false;
13+
setWindowTitle(tr("Proxy"));
1314
setLayout(new QBoxLayout(QBoxLayout::TopToBottom, this));
1415
Q_ASSERT(layout());
1516

0 commit comments

Comments
 (0)