@@ -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+ }
0 commit comments