@@ -47,7 +47,7 @@ const QString COperateDesktop::Id()
4747 if (!GetParameter ()->m_Net .GetHost ().isEmpty ())
4848 szId += " _" + GetParameter ()->m_Net .GetHost ()
4949 + " _" + QString::number (GetParameter ()->m_Net .GetPort ());
50-
50+
5151 CParameterNet* net = nullptr ;
5252 QString szType;
5353 switch (GetParameter ()->m_Proxy .GetUsedType ())
@@ -72,7 +72,7 @@ const QString COperateDesktop::Id()
7272 default :
7373 break ;
7474 }
75-
75+
7676 if (!szType.isEmpty () && !net->GetHost ().isEmpty ()) {
7777 szId += " _" + szType + " _" ;
7878 szId += net->GetHost () + " _" + QString::number (net->GetPort ());
@@ -89,7 +89,7 @@ const QString COperateDesktop::Name()
8989 if (GetParameter () && GetParameter ()->GetGlobalParameters ()
9090 && GetParameter ()->GetGlobalParameters ()->GetShowProtocolPrefix ())
9191 szName = Protocol () + " :" ;
92-
92+
9393 if (GetParameter () && !(GetParameter ()->GetName ().isEmpty ()))
9494 szName += GetParameter ()->GetName ();
9595 else
@@ -102,10 +102,10 @@ const QString COperateDesktop::Description()
102102 QString szDescription;
103103 if (!Name ().isEmpty ())
104104 szDescription = tr (" Name: " ) + Name () + " \n " ;
105-
105+
106106 if (!GetTypeName ().isEmpty ())
107107 szDescription += tr (" Type:" ) + GetTypeName () + " \n " ;
108-
108+
109109 if (!Protocol ().isEmpty ()) {
110110 szDescription += tr (" Protocol: " ) + Protocol ();
111111#ifdef DEBUG
@@ -165,21 +165,21 @@ int COperateDesktop::Initial()
165165 qDebug (log) << Q_FUNC_INFO;
166166 int nRet = 0 ;
167167 bool check = false ;
168-
168+
169169 nRet = COperate::Initial ();
170170 if (nRet)
171171 return nRet;
172-
172+
173173 Q_ASSERT (!(m_pFrmViewer && m_pScroll));
174174 m_pFrmViewer = new CFrmViewer (); // The owner is m_pScroll
175175 m_pScroll = new CFrmScroll (m_pFrmViewer);
176-
176+
177177 check = connect (m_pFrmViewer, SIGNAL (sigViewerFocusIn (QWidget*)),
178178 this , SIGNAL (sigViewerFocusIn (QWidget*)));
179179 Q_ASSERT (check);
180-
180+
181181 nRet = InitialMenu ();
182-
182+
183183 return nRet;
184184}
185185
@@ -213,6 +213,9 @@ int COperateDesktop::InitialMenu()
213213 [&](){
214214 m_pScroll->slotSetAdaptWindows (
215215 CFrmViewer::ADAPT_WINDOWS::ZoomToWindow);
216+ if (GetParameter ())
217+ GetParameter ()->SetAdaptWindows (
218+ CFrmViewer::ADAPT_WINDOWS::ZoomToWindow);
216219 });
217220 Q_ASSERT (check);
218221 m_pZoomAspectRatio = pMenuZoom->addAction (
@@ -223,6 +226,9 @@ int COperateDesktop::InitialMenu()
223226 [&](){
224227 m_pScroll->slotSetAdaptWindows (
225228 CFrmViewer::ADAPT_WINDOWS::KeepAspectRationToWindow);
229+ if (GetParameter ())
230+ GetParameter ()->SetAdaptWindows (
231+ CFrmViewer::ADAPT_WINDOWS::KeepAspectRationToWindow);
226232 });
227233 Q_ASSERT (check);
228234 m_pZoomOriginal = pMenuZoom->addAction (
@@ -232,15 +238,26 @@ int COperateDesktop::InitialMenu()
232238 [&](){
233239 m_pScroll->slotSetAdaptWindows (
234240 CFrmViewer::ADAPT_WINDOWS::Original);
241+ if (GetParameter ())
242+ GetParameter ()->SetAdaptWindows (
243+ CFrmViewer::ADAPT_WINDOWS::Original);
235244 });
236245 Q_ASSERT (check);
237246 m_pZoomIn = pMenuZoom->addAction (QIcon::fromTheme (" zoom-in" ), tr (" Zoom in" ));
238247 m_pZoomIn->setCheckable (true );
239248 check = connect (
240249 m_pZoomIn, &QAction::toggled, this ,
241250 [&](){
242- if (m_psbZoomFactor)
243- m_psbZoomFactor->setValue ((m_pFrmViewer->GetZoomFactor () + 0.1 ) * 100 );
251+ double factor = 0 ;
252+ if (m_psbZoomFactor) {
253+ factor = (m_pFrmViewer->GetZoomFactor () + 0.1 ) * 100 ;
254+ m_psbZoomFactor->setValue (factor);
255+ }
256+ if (GetParameter ()) {
257+ GetParameter ()->SetAdaptWindows (
258+ CFrmViewer::ADAPT_WINDOWS::Zoom);
259+ GetParameter ()->SetZoomFactor (factor);
260+ }
244261 });
245262 Q_ASSERT (check);
246263 m_pZoomOut = pMenuZoom->addAction (
@@ -249,8 +266,16 @@ int COperateDesktop::InitialMenu()
249266 check = connect (
250267 m_pZoomOut, &QAction::toggled, this ,
251268 [&](){
252- if (m_psbZoomFactor)
253- m_psbZoomFactor->setValue ((m_pFrmViewer->GetZoomFactor () - 0.1 ) * 100 );
269+ double factor = 100 ;
270+ if (m_psbZoomFactor) {
271+ factor = (m_pFrmViewer->GetZoomFactor () - 0.1 ) * 100 ;
272+ m_psbZoomFactor->setValue (factor);
273+ }
274+ if (GetParameter ()) {
275+ GetParameter ()->SetAdaptWindows (
276+ CFrmViewer::ADAPT_WINDOWS::Zoom);
277+ GetParameter ()->SetZoomFactor (factor);
278+ }
254279 });
255280 Q_ASSERT (check);
256281 QActionGroup* pGBViewZoom = new QActionGroup (this );
@@ -363,6 +388,7 @@ int COperateDesktop::SetGlobalParameters(CParameterPlugin *pPara)
363388 this , SLOT (slotUpdateName ()));
364389 Q_ASSERT (check);
365390 }
391+ LoadAdaptWindows ();
366392 return 0 ;
367393 } else {
368394 QString szMsg = " There is not parameters! "
@@ -424,25 +450,8 @@ int COperateDesktop::SetParameter(CParameterBase *p)
424450 return 0 ;
425451}
426452
427- int COperateDesktop::Load (QSettings &set )
453+ int COperateDesktop::LoadAdaptWindows ( )
428454{
429- int nRet = 0 ;
430- Q_ASSERT (m_pFrmViewer);
431- nRet = COperate::Load (set);
432- if (m_pPara)
433- nRet = m_pPara->Load (set);
434- else {
435- QString szMsg = " There is not parameters! "
436- " please first create parameters, "
437- " then call SetParameter() in the " ;
438- szMsg += metaObject ()->className () + QString (" ::" )
439- + metaObject ()->className ();
440- szMsg += QString (" () or " ) + metaObject ()->className ()
441- + QString (" ::" ) + " Initial()" ;
442- szMsg += " to set the parameters pointer. " ;
443- qWarning (log) << szMsg.toStdString ().c_str ();
444- Q_ASSERT (false );// TODO: delete it
445- }
446455 if (m_pFrmViewer && GetParameter ())
447456 {
448457 m_pFrmViewer->slotSetZoomFactor (GetParameter ()->GetZoomFactor ());
@@ -463,6 +472,30 @@ int COperateDesktop::Load(QSettings &set)
463472 m_pZoomIn->setChecked (true );
464473 }
465474 }
475+ return 0 ;
476+ }
477+
478+ int COperateDesktop::Load (QSettings &set)
479+ {
480+ int nRet = 0 ;
481+ Q_ASSERT (m_pFrmViewer);
482+ nRet = COperate::Load (set);
483+ if (m_pPara)
484+ nRet = m_pPara->Load (set);
485+ else {
486+ QString szMsg = " There is not parameters! "
487+ " please first create parameters, "
488+ " then call SetParameter() in the " ;
489+ szMsg += metaObject ()->className () + QString (" ::" )
490+ + metaObject ()->className ();
491+ szMsg += QString (" () or " ) + metaObject ()->className ()
492+ + QString (" ::" ) + " Initial()" ;
493+ szMsg += " to set the parameters pointer. " ;
494+ qWarning (log) << szMsg.toStdString ().c_str ();
495+ Q_ASSERT (false );// TODO: delete it
496+ }
497+
498+ LoadAdaptWindows ();
466499 return nRet;
467500}
468501
0 commit comments