Changeset 69006 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Oct 6, 2017 3:08:33 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r68540 r69006 566 566 src/widgets/UIMiniToolBar.cpp \ 567 567 src/widgets/UIPortForwardingTable.cpp \ 568 src/widgets/UIProgressDialog.cpp \ 568 569 src/widgets/UITabBar.cpp \ 569 570 src/wizards/importappliance/UIWizardImportApp.cpp -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp
r68962 r69006 42 42 const char* UIExtraDataDefs::GUI_UpdateCheckCount = "GUI/UpdateCheckCount"; 43 43 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 44 45 /* Progress: */ 46 const char* UIExtraDataDefs::GUI_Progress_LegacyMode = "GUI/Progress/LegacyMode"; 44 47 45 48 /* Settings: */ -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h
r68962 r69006 59 59 /** @} */ 60 60 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 61 62 /** @name Progress 63 * @{ */ 64 /** Holds whether legacy progress handling method is requested. */ 65 extern const char* GUI_Progress_LegacyMode; 66 /** @} */ 61 67 62 68 /** @name Settings -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp
r68962 r69006 1940 1940 << GUI_PreventApplicationUpdate << GUI_UpdateDate << GUI_UpdateCheckCount 1941 1941 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 1942 << GUI_Progress_LegacyMode 1942 1943 << GUI_RestrictedGlobalSettingsPages << GUI_RestrictedMachineSettingsPages 1943 1944 << GUI_LanguageID … … 2291 2292 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 2292 2293 2294 bool UIExtraDataManager::legacyProgressHandlingRequested() 2295 { 2296 /* 'False' unless feature allowed: */ 2297 return isFeatureAllowed(GUI_Progress_LegacyMode); 2298 } 2299 2293 2300 bool UIExtraDataManager::guiFeatureEnabled(GUIFeatureType enmFeature) 2294 2301 { -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h
r68962 r69006 177 177 /** @} */ 178 178 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 179 180 /** @name Progress 181 * @{ */ 182 /** Returns whether legacy progress handling method is requested. */ 183 bool legacyProgressHandlingRequested(); 184 /** @} */ 179 185 180 186 /** @name Settings -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMainEventListener.cpp
r68508 r69006 58 58 # include "CCanShowWindowEvent.h" 59 59 # include "CShowWindowEvent.h" 60 # include "CProgressPercentageChangedEvent.h" 61 # include "CProgressTaskCompletedEvent.h" 60 62 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 61 63 … … 404 406 break; 405 407 } 408 case KVBoxEventType_OnProgressPercentageChanged: 409 { 410 CProgressPercentageChangedEvent es(pEvent); 411 emit sigProgressPercentageChange(es.GetProgressId(), (int)es.GetPercent()); 412 break; 413 } 414 case KVBoxEventType_OnProgressTaskCompleted: 415 { 416 CProgressTaskCompletedEvent es(pEvent); 417 emit sigProgressTaskComplete(es.GetProgressId()); 418 break; 419 } 406 420 407 421 default: break; -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMainEventListener.h
r68508 r69006 122 122 void sigAudioAdapterChange(); 123 123 124 /** Notifies about @a iPercent change for progress with @a strProgressId. */ 125 void sigProgressPercentageChange(QString strProgressId, int iPercent); 126 /** Notifies about task complete for progress with @a strProgressId. */ 127 void sigProgressTaskComplete(QString strProgressId); 128 124 129 public: 125 130 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIProgressDialog.cpp
r69005 r69006 32 32 # include "QILabel.h" 33 33 # include "UIErrorString.h" 34 # include "UIExtraDataManager.h" 35 # include "UIMainEventListener.h" 34 36 # include "UIModalWindowManager.h" 35 37 # include "UIProgressDialog.h" … … 41 43 42 44 /* COM includes: */ 45 # include "CEventListener.h" 46 # include "CEventSource.h" 43 47 # include "CProgress.h" 44 48 45 49 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 50 51 52 /** Private QObject extension 53 * providing UIExtraDataManager with the CVirtualBox event-source. */ 54 class UIProgressEventHandler : public QObject 55 { 56 Q_OBJECT; 57 58 signals: 59 60 /** Notifies about @a iPercent change for progress with @a strProgressId. */ 61 void sigProgressPercentageChange(QString strProgressId, int iPercent); 62 /** Notifies about task complete for progress with @a strProgressId. */ 63 void sigProgressTaskComplete(QString strProgressId); 64 65 public: 66 67 /** Constructs event proxy object on the basis of passed @a pParent. */ 68 UIProgressEventHandler(QObject *pParent, const CProgress &comProgress); 69 /** Destructs event proxy object. */ 70 ~UIProgressEventHandler(); 71 72 protected: 73 74 /** @name Prepare/Cleanup cascade. 75 * @{ */ 76 /** Prepares all. */ 77 void prepare(); 78 /** Prepares listener. */ 79 void prepareListener(); 80 /** Prepares connections. */ 81 void prepareConnections(); 82 83 /** Cleanups connections. */ 84 void cleanupConnections(); 85 /** Cleanups listener. */ 86 void cleanupListener(); 87 /** Cleanups all. */ 88 void cleanup(); 89 /** @} */ 90 91 private: 92 93 /** Holds the progress wrapper. */ 94 CProgress m_comProgress; 95 96 /** Holds the Qt event listener instance. */ 97 ComObjPtr<UIMainEventListenerImpl> m_pQtListener; 98 /** Holds the COM event listener instance. */ 99 CEventListener m_comEventListener; 100 }; 101 102 103 /********************************************************************************************************************************* 104 * Class UIProgressEventHandler implementation. * 105 *********************************************************************************************************************************/ 106 107 UIProgressEventHandler::UIProgressEventHandler(QObject *pParent, const CProgress &comProgress) 108 : QObject(pParent) 109 , m_comProgress(comProgress) 110 { 111 /* Prepare: */ 112 prepare(); 113 } 114 115 UIProgressEventHandler::~UIProgressEventHandler() 116 { 117 /* Cleanup: */ 118 cleanup(); 119 } 120 121 void UIProgressEventHandler::prepare() 122 { 123 /* Prepare: */ 124 prepareListener(); 125 prepareConnections(); 126 } 127 128 void UIProgressEventHandler::prepareListener() 129 { 130 /* Create event listener instance: */ 131 m_pQtListener.createObject(); 132 m_pQtListener->init(new UIMainEventListener, this); 133 m_comEventListener = CEventListener(m_pQtListener); 134 135 /* Get CProgress event source: */ 136 CEventSource comEventSourceProgress = m_comProgress.GetEventSource(); 137 AssertWrapperOk(comEventSourceProgress); 138 139 /* Enumerate all the required event-types: */ 140 QVector<KVBoxEventType> eventTypes; 141 eventTypes 142 << KVBoxEventType_OnProgressPercentageChanged 143 << KVBoxEventType_OnProgressTaskCompleted; 144 145 /* Register event listener for CProgress event source: */ 146 comEventSourceProgress.RegisterListener(m_comEventListener, eventTypes, 147 gEDataManager->eventHandlingType() == EventHandlingType_Active ? TRUE : FALSE); 148 AssertWrapperOk(comEventSourceProgress); 149 150 /* If event listener registered as passive one: */ 151 if (gEDataManager->eventHandlingType() == EventHandlingType_Passive) 152 { 153 /* Register event sources in their listeners as well: */ 154 m_pQtListener->getWrapped()->registerSource(comEventSourceProgress, m_comEventListener); 155 } 156 } 157 158 void UIProgressEventHandler::prepareConnections() 159 { 160 /* Create direct (sync) connections for signals of main listener: */ 161 connect(m_pQtListener->getWrapped(), &UIMainEventListener::sigProgressPercentageChange, 162 this, &UIProgressEventHandler::sigProgressPercentageChange, 163 Qt::DirectConnection); 164 connect(m_pQtListener->getWrapped(), &UIMainEventListener::sigProgressTaskComplete, 165 this, &UIProgressEventHandler::sigProgressTaskComplete, 166 Qt::DirectConnection); 167 } 168 169 void UIProgressEventHandler::cleanupConnections() 170 { 171 /* Nothing for now. */ 172 } 173 174 void UIProgressEventHandler::cleanupListener() 175 { 176 /* If event listener registered as passive one: */ 177 if (gEDataManager->eventHandlingType() == EventHandlingType_Passive) 178 { 179 /* Unregister everything: */ 180 m_pQtListener->getWrapped()->unregisterSources(); 181 } 182 183 /* Make sure VBoxSVC is available: */ 184 if (!vboxGlobal().isVBoxSVCAvailable()) 185 return; 186 187 /* Get CProgress event source: */ 188 CEventSource comEventSourceProgress = m_comProgress.GetEventSource(); 189 AssertWrapperOk(comEventSourceProgress); 190 191 /* Unregister event listener for CProgress event source: */ 192 comEventSourceProgress.UnregisterListener(m_comEventListener); 193 } 194 195 void UIProgressEventHandler::cleanup() 196 { 197 /* Cleanup: */ 198 cleanupConnections(); 199 cleanupListener(); 200 } 46 201 47 202 … … 62 217 , m_pImage(pImage) 63 218 , m_cMinDuration(cMinDuration) 219 , m_fLegacyHandling(gEDataManager->legacyProgressHandlingRequested()) 64 220 , m_pLabelImage(0) 65 221 , m_pLabelDescription(0) … … 71 227 , m_fCancelEnabled(false) 72 228 , m_fEnded(false) 229 , m_pEventHandler(0) 73 230 { 74 231 /* Prepare: */ … … 101 258 } 102 259 103 /* Start refresh timer: */ 104 int id = startTimer(cRefreshInterval); 260 /* Start refresh timer (if necessary): */ 261 int id = 0; 262 if (m_fLegacyHandling) 263 id = startTimer(cRefreshInterval); 105 264 106 265 /* Set busy cursor. … … 129 288 } 130 289 131 /* Kill refresh timer: */ 132 killTimer(id); 290 /* Kill refresh timer (if necessary): */ 291 if (m_fLegacyHandling) 292 killTimer(id); 133 293 134 294 #ifndef VBOX_WS_MAC … … 171 331 } 172 332 333 void UIProgressDialog::sltHandleProgressPercentageChange(QString /* strProgressId */, int iPercent) 334 { 335 /* New mode only: */ 336 AssertReturnVoid(!m_fLegacyHandling); 337 338 /* Update progress: */ 339 updateProgressState(); 340 updateProgressPercentage(iPercent); 341 } 342 343 void UIProgressDialog::sltHandleProgressTaskComplete(QString /* strProgressId */) 344 { 345 /* New mode only: */ 346 AssertReturnVoid(!m_fLegacyHandling); 347 348 /* If progress-dialog is not yet ended but progress is aborted or completed: */ 349 if (!m_fEnded && (!m_comProgress.isOk() || m_comProgress.GetCompleted())) 350 { 351 /* Set progress to 100%: */ 352 updateProgressPercentage(100); 353 354 /* Try to close the dialog: */ 355 closeProgressDialog(); 356 } 357 } 358 359 void UIProgressDialog::sltHandleWindowStackChange() 360 { 361 /* If progress-dialog is not yet ended but progress is aborted or completed: */ 362 if (!m_fEnded && (!m_comProgress.isOk() || m_comProgress.GetCompleted())) 363 { 364 /* Try to close the dialog: */ 365 closeProgressDialog(); 366 } 367 } 368 173 369 void UIProgressDialog::sltCancelOperation() 174 370 { … … 186 382 #endif 187 383 384 /* Make sure dialog is handling window stack changes: */ 385 connect(&windowManager(), &UIModalWindowManager::sigStackChanged, 386 this, &UIProgressDialog::sltHandleWindowStackChange); 387 188 388 /* Prepare: */ 389 prepareEventHandler(); 189 390 prepareWidgets(); 391 } 392 393 void UIProgressDialog::prepareEventHandler() 394 { 395 if (!m_fLegacyHandling) 396 { 397 /* Create CProgress event handler: */ 398 m_pEventHandler = new UIProgressEventHandler(this, m_comProgress); 399 connect(m_pEventHandler, &UIProgressEventHandler::sigProgressPercentageChange, 400 this, &UIProgressDialog::sltHandleProgressPercentageChange); 401 connect(m_pEventHandler, &UIProgressEventHandler::sigProgressTaskComplete, 402 this, &UIProgressDialog::sltHandleProgressTaskComplete); 403 } 190 404 } 191 405 … … 311 525 } 312 526 527 void UIProgressDialog::cleanupEventHandler() 528 { 529 if (!m_fLegacyHandling) 530 { 531 /* Destroy CProgress event handler: */ 532 delete m_pEventHandler; 533 m_pEventHandler = 0; 534 } 535 } 536 313 537 void UIProgressDialog::cleanup() 314 538 { … … 317 541 318 542 /* Call the timer event handling delegate: */ 319 handleTimerEvent(); 543 if (m_fLegacyHandling) 544 handleTimerEvent(); 320 545 321 546 /* Cleanup: */ 547 cleanupEventHandler(); 322 548 cleanupWidgets(); 323 549 } … … 430 656 void UIProgressDialog::handleTimerEvent() 431 657 { 658 /* Old mode only: */ 659 AssertReturnVoid(m_fLegacyHandling); 660 432 661 /* If progress-dialog is ended: */ 433 662 if (m_fEnded) … … 536 765 } 537 766 767 #include "UIProgressDialog.moc" 768 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIProgressDialog.h
r69004 r69006 28 28 class QILabel; 29 29 class UIMiniCancelButton; 30 class UIProgressEventHandler; 30 31 class CProgress; 31 32 … … 86 87 private slots: 87 88 89 /** Handles percentage changed event for progress with @a strProgressId to @a iPercent. */ 90 void sltHandleProgressPercentageChange(QString strProgressId, int iPercent); 91 /** Handles task completed event for progress with @a strProgressId. */ 92 void sltHandleProgressTaskComplete(QString strProgressId); 93 94 /** Handles window stack changed signal. */ 95 void sltHandleWindowStackChange(); 96 88 97 /** Handles request to cancel operation. */ 89 98 void sltCancelOperation(); … … 93 102 /** Prepares all. */ 94 103 void prepare(); 104 /** Prepares event handler. */ 105 void prepareEventHandler(); 95 106 /** Prepares widgets. */ 96 107 void prepareWidgets(); 97 108 /** Cleanups widgets. */ 98 109 void cleanupWidgets(); 110 /** Cleanups event handler. */ 111 void cleanupEventHandler(); 99 112 /** Cleanups all. */ 100 113 void cleanup(); … … 119 132 /** Holds the minimum duration before the progress-dialog is shown. */ 120 133 int m_cMinDuration; 134 135 /** Holds whether legacy handling is requested for this progress. */ 136 bool m_fLegacyHandling; 121 137 122 138 /** Holds the image label instance. */ … … 140 156 bool m_fEnded; 141 157 158 /** Holds the progress event handler instance. */ 159 UIProgressEventHandler *m_pEventHandler; 160 142 161 /** Holds the operation description template. */ 143 162 static const char *m_spcszOpDescTpl;
Note:
See TracChangeset
for help on using the changeset viewer.