Changeset 83094 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Feb 17, 2020 10:12:35 AM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r83052 r83094 956 956 VirtualBox_QT_MOCSRCS = \ 957 957 src/hostnetwork/UIHostNetworkManager.cpp \ 958 src/manager/UIVirtualMachineItemCloud.cpp \ 958 959 src/manager/UIWelcomePane.cpp \ 959 960 src/snapshots/UISnapshotDetailsWidget.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UITask.h
r83008 r83094 47 47 Type_DetailsPopulation = 2, 48 48 Type_CloudAcquireInstances = 3, 49 Type_GetCloudInstanceState = 4, 49 50 }; 50 51 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp
r83064 r83094 284 284 } 285 285 286 void UIVirtualBoxManagerWidget::sltHandleCloudMachineStateChange(const QString &strId) 287 { 288 /* Acquire current item: */ 289 UIVirtualMachineItem *pItem = currentItem(); 290 291 /* repeat the task only if we are still on the same item: */ 292 if (pItem && pItem->id() == strId) 293 pItem->toCloud()->updateStateAsync(true /* delayed? */); 294 295 /* Pass the signal further: */ 296 emit sigCloudMachineStateChange(strId); 297 } 298 286 299 void UIVirtualBoxManagerWidget::sltHandleToolMenuRequested(UIToolClass enmClass, const QPoint &position) 287 300 { … … 373 386 /* Configure Chooser-pane: */ 374 387 connect(m_pPaneChooser, &UIChooser::sigCloudMachineStateChange, 375 this, &UIVirtualBoxManagerWidget::s igCloudMachineStateChange);388 this, &UIVirtualBoxManagerWidget::sltHandleCloudMachineStateChange); 376 389 /* Add into splitter: */ 377 390 m_pSplitter->addWidget(m_pPaneChooser); … … 757 770 /* Update current cloud machine state: */ 758 771 if (pItem->itemType() == UIVirtualMachineItem::ItemType_CloudReal) 759 pItem->toCloud()->updateState (this);772 pItem->toCloud()->updateStateAsync(false /* delayed? */); 760 773 } 761 774 else -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.h
r83064 r83094 157 157 * @param enmDirection Brings which direction was animation finished for. */ 158 158 void sltHandleSlidingAnimationComplete(SlidingDirection enmDirection); 159 160 /** Handles state change for cloud machine with specified @a strMachineId. */ 161 void sltHandleCloudMachineStateChange(const QString &strId); 159 162 /** @} */ 160 163 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemCloud.cpp
r83076 r83094 16 16 */ 17 17 18 /* Qt includes: */ 19 #include <QTimer> 20 18 21 /* GUI includes: */ 19 22 #include "UICloudMachine.h" … … 22 25 #include "UIIconPool.h" 23 26 #include "UIMessageCenter.h" 27 #include "UITask.h" 28 #include "UIThreadPool.h" 24 29 #include "UIVirtualMachineItemCloud.h" 25 30 … … 45 50 /* Using across module: */ 46 51 using namespace GetInstanceInfo; 52 53 54 /** UITask extension used to get cloud instance state async way. */ 55 class UITaskGetCloudInstanceState : public UITask 56 { 57 Q_OBJECT; 58 59 public: 60 61 /** Constructs task taking @a comCloudClient and @a strId as data. 62 * @param comCloudClient Brings the cloud client object. 63 * @param strId Brings the cloud VM id. */ 64 UITaskGetCloudInstanceState(const CCloudClient &comCloudClient, const QString &strId); 65 66 /** Returns the task result. */ 67 QString result() const; 68 69 protected: 70 71 /** Contains the task body. */ 72 virtual void run() /* override */; 73 74 private: 75 76 /** Holds the mutex to access result. */ 77 mutable QMutex m_mutex; 78 79 /** Holds the cloud client object. */ 80 CCloudClient m_comCloudClient; 81 /** Holds the cloud VM id. */ 82 QString m_strId; 83 84 /** Holds the error info object. */ 85 CVirtualBoxErrorInfo m_comErrorInfo; 86 87 /** Holds the task result. */ 88 QString m_strResult; 89 }; 47 90 48 91 … … 139 182 140 183 /********************************************************************************************************************************* 184 * Class UITaskGetCloudInstanceState implementation. * 185 *********************************************************************************************************************************/ 186 187 UITaskGetCloudInstanceState::UITaskGetCloudInstanceState(const CCloudClient &comCloudClient, const QString &strId) 188 : UITask(Type_GetCloudInstanceState) 189 , m_comCloudClient(comCloudClient) 190 , m_strId(strId) 191 { 192 } 193 194 QString UITaskGetCloudInstanceState::result() const 195 { 196 m_mutex.lock(); 197 const QString strResult = m_strResult; 198 m_mutex.unlock(); 199 return strResult; 200 } 201 202 void UITaskGetCloudInstanceState::run() 203 { 204 m_mutex.lock(); 205 m_strResult = getInstanceInfo(KVirtualSystemDescriptionType_CloudInstanceState, m_comCloudClient, m_strId); 206 m_mutex.unlock(); 207 } 208 209 210 /********************************************************************************************************************************* 141 211 * Class UIVirtualMachineItemCloud implementation. * 142 212 *********************************************************************************************************************************/ … … 177 247 /* Update state: */ 178 248 updateState(strState); 249 } 250 251 void UIVirtualMachineItemCloud::updateStateAsync(bool fDelayed) 252 { 253 QTimer::singleShot(fDelayed ? 10000 : 0, this, SLOT(sltCreateGetCloudInstanceStateTask())); 179 254 } 180 255 … … 397 472 } 398 473 474 void UIVirtualMachineItemCloud::sltCreateGetCloudInstanceStateTask() 475 { 476 /* Make sure item is of real cloud type and is initialized: */ 477 AssertReturnVoid(itemType() == ItemType_CloudReal); 478 AssertPtrReturnVoid(m_pCloudMachine); 479 480 /* Create and start task to acquire state async way: */ 481 UITask *pTask = new UITaskGetCloudInstanceState(m_pCloudMachine->client(), m_strId); 482 connect(pTask, &UITask::sigComplete, 483 this, &UIVirtualMachineItemCloud::sltHandleGetCloudInstanceStateDone); 484 uiCommon().threadPool()->enqueueTask(pTask); 485 } 486 487 void UIVirtualMachineItemCloud::sltHandleGetCloudInstanceStateDone(UITask *pTask) 488 { 489 /* Skip unrelated tasks: */ 490 if (!pTask || pTask->type() != UITask::Type_GetCloudInstanceState) 491 return; 492 493 /* Cast task to corresponding sub-class: */ 494 UITaskGetCloudInstanceState *pStateTask = static_cast<UITaskGetCloudInstanceState*>(pTask); 495 496 /* Update state: */ 497 updateState(pStateTask->result()); 498 } 499 399 500 void UIVirtualMachineItemCloud::updateState(const QString &strState) 400 501 { … … 415 516 emit sigStateChange(); 416 517 } 518 519 520 #include "UIVirtualMachineItemCloud.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemCloud.h
r83076 r83094 27 27 /* Forward declarations: */ 28 28 class UICloudMachine; 29 class UITask; 29 30 30 31 /** UIVirtualMachineItem sub-class used as cloud Virtual Machine item interface. */ … … 65 66 * @param pWidget Brings parent widget to show messages according to. */ 66 67 void updateState(QWidget *pParent); 68 69 /** Updates cloud VM state async way, @a fDelayed if requested or instant otherwise. */ 70 void updateStateAsync(bool fDelayed); 67 71 68 72 /** Puts cloud VM on pause. … … 114 118 /** @} */ 115 119 120 private slots: 121 122 /** Create cloud VM state acquire task. */ 123 void sltCreateGetCloudInstanceStateTask(); 124 /** Handles signal about cloud VM state acquire task is done. */ 125 void sltHandleGetCloudInstanceStateDone(UITask *pTask); 126 116 127 private: 117 128
Note:
See TracChangeset
for help on using the changeset viewer.