@@ -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
@@ -209,7 +209,7 @@ int COperateDesktop::InitialMenu()
209209 m_pZoomToWindow = pMenuZoom->addAction (
210210 QIcon::fromTheme (" zoom-fit-best" ), tr (" Zoom to window" ));
211211 m_pZoomToWindow->setCheckable (true );
212- check = connect (m_pZoomToWindow, &QAction::toggled , this ,
212+ check = connect (m_pZoomToWindow, &QAction::triggered , this ,
213213 [&](){
214214 m_pScroll->slotSetAdaptWindows (
215215 CFrmViewer::ADAPT_WINDOWS ::ZoomToWindow);
@@ -219,7 +219,7 @@ int COperateDesktop::InitialMenu()
219219 QIcon::fromTheme (" zoom-aspect-ratio" ),
220220 tr (" Keep aspect ration to windows" ));
221221 m_pZoomAspectRatio->setCheckable (true );
222- check = connect (m_pZoomAspectRatio, &QAction::toggled , this ,
222+ check = connect (m_pZoomAspectRatio, &QAction::triggered , this ,
223223 [&](){
224224 m_pScroll->slotSetAdaptWindows (
225225 CFrmViewer::ADAPT_WINDOWS ::KeepAspectRationToWindow);
@@ -228,7 +228,7 @@ int COperateDesktop::InitialMenu()
228228 m_pZoomOriginal = pMenuZoom->addAction (
229229 QIcon::fromTheme (" zoom-original" ), tr (" Original" ));
230230 m_pZoomOriginal->setCheckable (true );
231- check = connect (m_pZoomOriginal, &QAction::toggled , this ,
231+ check = connect (m_pZoomOriginal, &QAction::triggered , this ,
232232 [&](){
233233 m_pScroll->slotSetAdaptWindows (
234234 CFrmViewer::ADAPT_WINDOWS ::Original);
@@ -237,20 +237,28 @@ int COperateDesktop::InitialMenu()
237237 m_pZoomIn = pMenuZoom->addAction (QIcon::fromTheme (" zoom-in" ), tr (" Zoom in" ));
238238 m_pZoomIn->setCheckable (true );
239239 check = connect (
240- m_pZoomIn, &QAction::toggled , this ,
240+ m_pZoomIn, &QAction::triggered , this ,
241241 [&](){
242- if (m_psbZoomFactor)
243- m_psbZoomFactor->setValue ((m_pFrmViewer->GetZoomFactor () + 0.1 ) * 100 );
242+ double factor = 0 ;
243+ if (m_psbZoomFactor) {
244+ factor = (m_pFrmViewer->GetZoomFactor () + 0.1 ) * 100 ;
245+ qDebug (log) << " Zoom in:" << factor;
246+ m_psbZoomFactor->setValue (factor);
247+ }
244248 });
245249 Q_ASSERT (check);
246250 m_pZoomOut = pMenuZoom->addAction (
247251 QIcon::fromTheme (" zoom-out" ), tr (" Zoom out" ));
248252 m_pZoomOut->setCheckable (true );
249253 check = connect (
250- m_pZoomOut, &QAction::toggled , this ,
254+ m_pZoomOut, &QAction::triggered , this ,
251255 [&](){
252- if (m_psbZoomFactor)
253- m_psbZoomFactor->setValue ((m_pFrmViewer->GetZoomFactor () - 0.1 ) * 100 );
256+ double factor = 100 ;
257+ if (m_psbZoomFactor) {
258+ factor = (m_pFrmViewer->GetZoomFactor () - 0.1 ) * 100 ;
259+ qDebug (log) << " Zoom out:" << factor;
260+ m_psbZoomFactor->setValue (factor);
261+ }
254262 });
255263 Q_ASSERT (check);
256264 QActionGroup* pGBViewZoom = new QActionGroup (this );
@@ -260,6 +268,14 @@ int COperateDesktop::InitialMenu()
260268 pGBViewZoom->addAction (m_pZoomOriginal);
261269 pGBViewZoom->addAction (m_pZoomIn);
262270 pGBViewZoom->addAction (m_pZoomOut);
271+ check = connect (pGBViewZoom, &QActionGroup::triggered,
272+ this , [&](QAction* a){
273+ if (a == m_pZoomIn || a == m_pZoomOut)
274+ m_psbZoomFactor->setEnabled (true );
275+ else {
276+ m_psbZoomFactor->setEnabled (false );
277+ }
278+ });
263279 }
264280 m_psbZoomFactor = new QSpinBox (pMenuZoom);
265281 m_psbZoomFactor->setRange (0 , 9999999 );
@@ -294,15 +310,15 @@ int COperateDesktop::InitialMenu()
294310 m_pRecord = new QAction (
295311 QIcon::fromTheme (" media-record" ), tr (" Start record" ), &m_Menu);
296312 m_pRecord->setCheckable (true );
297- check = connect (m_pRecord, SIGNAL (toggled (bool )),
313+ check = connect (m_pRecord, SIGNAL (triggered (bool )),
298314 this , SLOT (slotRecord (bool )));
299315 Q_ASSERT (check);
300316 m_Menu.addAction (m_pRecord);
301317 m_pRecordPause = new QAction (
302318 QIcon::fromTheme (" media-playback-pause" ), tr (" Record pause" ), &m_Menu);
303319 m_pRecordPause->setCheckable (true );
304320 m_pRecordPause->setEnabled (false );
305- check = connect (m_pRecordPause, SIGNAL (toggled (bool )),
321+ check = connect (m_pRecordPause, SIGNAL (triggered (bool )),
306322 this , SIGNAL (sigRecordPause (bool )));
307323 Q_ASSERT (check);
308324 m_Menu.addAction (m_pRecordPause);
@@ -363,6 +379,7 @@ int COperateDesktop::SetGlobalParameters(CParameterPlugin *pPara)
363379 this , SLOT (slotUpdateName ()));
364380 Q_ASSERT (check);
365381 }
382+ LoadAdaptWindows ();
366383 return 0 ;
367384 } else {
368385 QString szMsg = " There is not parameters! "
@@ -424,6 +441,35 @@ int COperateDesktop::SetParameter(CParameterBase *p)
424441 return 0 ;
425442}
426443
444+ int COperateDesktop::LoadAdaptWindows ()
445+ {
446+ if (m_pFrmViewer && GetParameter ())
447+ {
448+ m_pFrmViewer->slotSetZoomFactor (GetParameter ()->GetZoomFactor ());
449+ if (m_psbZoomFactor)
450+ m_psbZoomFactor->setValue (m_pFrmViewer->GetZoomFactor () * 100 );
451+ CFrmViewer::ADAPT_WINDOWS aw = GetParameter ()->GetAdaptWindows ();
452+ if (CFrmViewer::ADAPT_WINDOWS ::ZoomToWindow == aw) {
453+ if (m_pZoomToWindow) {
454+ m_pZoomToWindow->trigger ();
455+ }
456+ } else if (CFrmViewer::ADAPT_WINDOWS ::KeepAspectRationToWindow == aw) {
457+ if (m_pZoomAspectRatio) {
458+ m_pZoomAspectRatio->trigger ();
459+ }
460+ } else if (CFrmViewer::ADAPT_WINDOWS ::Original == aw) {
461+ if (m_pZoomOriginal) {
462+ m_pZoomOriginal->trigger ();
463+ }
464+ } else if (CFrmViewer::ADAPT_WINDOWS ::Zoom == aw) {
465+ if (m_pZoomIn) {
466+ m_pZoomIn->trigger ();
467+ }
468+ }
469+ }
470+ return 0 ;
471+ }
472+
427473int COperateDesktop::Load (QSettings &set)
428474{
429475 int nRet = 0 ;
@@ -443,26 +489,8 @@ int COperateDesktop::Load(QSettings &set)
443489 qWarning (log) << szMsg.toStdString ().c_str ();
444490 Q_ASSERT (false );// TODO: delete it
445491 }
446- if (m_pFrmViewer && GetParameter ())
447- {
448- m_pFrmViewer->slotSetZoomFactor (GetParameter ()->GetZoomFactor ());
449- if (m_psbZoomFactor)
450- m_psbZoomFactor->setValue (m_pFrmViewer->GetZoomFactor () * 100 );
451- CFrmViewer::ADAPT_WINDOWS aw = GetParameter ()->GetAdaptWindows ();
452- if (CFrmViewer::ADAPT_WINDOWS ::ZoomToWindow == aw) {
453- if (m_pZoomToWindow)
454- m_pZoomToWindow->setChecked (true );
455- } else if (CFrmViewer::ADAPT_WINDOWS ::KeepAspectRationToWindow == aw) {
456- if (m_pZoomAspectRatio)
457- m_pZoomAspectRatio->setChecked (true );
458- } else if (CFrmViewer::ADAPT_WINDOWS ::Original == aw) {
459- if (m_pZoomOriginal)
460- m_pZoomOriginal->setChecked (true );
461- } else if (CFrmViewer::ADAPT_WINDOWS ::Zoom == aw) {
462- if (m_pZoomIn)
463- m_pZoomIn->setChecked (true );
464- }
465- }
492+
493+ LoadAdaptWindows ();
466494 return nRet;
467495}
468496
@@ -514,6 +542,7 @@ void COperateDesktop::slotRecorderStateChanged(
514542
515543void COperateDesktop::slotValueChanged (int v)
516544{
545+ qDebug (log) << " zoom:" << v;
517546 if (!m_pScroll || !m_pFrmViewer) return ;
518547 m_pFrmViewer->slotSetZoomFactor (((double )v) / 100 );
519548 m_pScroll->slotSetAdaptWindows (CFrmViewer::ADAPT_WINDOWS ::Zoom);
0 commit comments