- Timestamp:
- Feb 11, 2020 8:29:39 PM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp
r83024 r83055 32 32 #include "UITabBar.h" 33 33 #include "UIToolBar.h" 34 #include "UIVirtualMachineItemCloud.h" 34 35 #include "UIVirtualMachineItemLocal.h" 35 36 #include "UITools.h" … … 731 732 if (pItem->itemType() == UIVirtualMachineItem::ItemType_Local) 732 733 m_pPaneToolsMachine->setMachine(pItem->toLocal()->machine()); 734 /* Update current cloud machine state: */ 735 if (pItem->itemType() == UIVirtualMachineItem::ItemType_CloudReal) 736 pItem->toCloud()->updateState(this); 733 737 } 734 738 else -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemCloud.cpp
r83050 r83055 21 21 #include "UIConverter.h" 22 22 #include "UIIconPool.h" 23 #include "UIMessageCenter.h" 23 24 #include "UIVirtualMachineItemCloud.h" 25 26 /* COM includes: */ 27 #include "CAppliance.h" 28 #include "CVirtualBox.h" 29 #include "CVirtualSystemDescription.h" 24 30 25 31 … … 45 51 } 46 52 53 void UIVirtualMachineItemCloud::updateState(QWidget *pParent) 54 { 55 /* Make sure item is of real cloud type: */ 56 AssertReturnVoid(itemType() == ItemType_CloudReal); 57 58 /* Update state: */ 59 const QString strState = acquireInstanceInfo(KVirtualSystemDescriptionType_CloudInstanceState, pParent); 60 QMap<QString, KMachineState> states; 61 states["RUNNING"] = KMachineState_Running; 62 states["STOPPED"] = KMachineState_Paused; 63 m_enmMachineState = states.value(strState, KMachineState_PoweredOff); 64 65 /* Recache finally: */ 66 recache(); 67 } 68 69 QString UIVirtualMachineItemCloud::acquireInstanceInfo(KVirtualSystemDescriptionType enmType, QWidget *pParent) 70 { 71 /* Make sure item is of real cloud type and is initialized: */ 72 AssertReturn(itemType() == ItemType_CloudReal, QString()); 73 AssertPtrReturn(m_pCloudMachine, QString()); 74 75 /* Get VirtualBox object: */ 76 CVirtualBox comVBox = uiCommon().virtualBox(); 77 78 /* Create appliance: */ 79 CAppliance comAppliance = comVBox.CreateAppliance(); 80 if (!comVBox.isOk()) 81 msgCenter().cannotCreateAppliance(comVBox); 82 else 83 { 84 /* Append it with one (1) description we need: */ 85 comAppliance.CreateVirtualSystemDescriptions(1); 86 if (!comAppliance.isOk()) 87 msgCenter().cannotCreateVirtualSystemDescription(comAppliance); 88 else 89 { 90 /* Get received description: */ 91 QVector<CVirtualSystemDescription> descriptions = comAppliance.GetVirtualSystemDescriptions(); 92 AssertReturn(!descriptions.isEmpty(), QString()); 93 CVirtualSystemDescription comDescription = descriptions.at(0); 94 95 /* Acquire cloud client: */ 96 CCloudClient comCloudClient = m_pCloudMachine->client(); 97 98 /* Now execute GetInstanceInfo async method: */ 99 CProgress comProgress = comCloudClient.GetInstanceInfo(m_strId, comDescription); 100 if (!comCloudClient.isOk()) 101 msgCenter().cannotAcquireCloudClientParameter(comCloudClient); 102 else 103 { 104 /* Show "Acquire instance info" progress: */ 105 msgCenter().showModalProgressDialog(comProgress, UICommon::tr("Acquire instance info ..."), 106 ":/progress_reading_appliance_90px.png", pParent, 0); 107 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 108 msgCenter().cannotAcquireCloudClientParameter(comProgress); 109 else 110 { 111 /* Now acquire description of certain type: */ 112 QVector<KVirtualSystemDescriptionType> types; 113 QVector<QString> refs, origValues, configValues, extraConfigValues; 114 comDescription.GetDescriptionByType(enmType, types, refs, origValues, configValues, extraConfigValues); 115 116 /* Return first config value if we have one: */ 117 AssertReturn(!configValues.isEmpty(), QString()); 118 return configValues.at(0); 119 } 120 } 121 } 122 } 123 124 /* Return null string by default: */ 125 return QString(); 126 } 47 127 void UIVirtualMachineItemCloud::recache() 48 128 { … … 66 146 67 147 /* Determine VM states: */ 68 m_enmMachineState = KMachineState_PoweredOff; 148 if ( itemType() == ItemType_CloudFake 149 || m_enmMachineState == KMachineState_Null) 150 m_enmMachineState = KMachineState_PoweredOff; 69 151 m_strMachineStateName = gpConverter->toString(m_enmMachineState); 70 152 if (itemType() == ItemType_CloudFake) -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemCloud.h
r83050 r83055 33 33 Q_OBJECT; 34 34 35 signals: 36 37 /** Notifies listeners about state change. */ 38 void sigStateChange(); 39 35 40 public: 36 41 … … 56 61 /** Returns fake cloud item state. */ 57 62 FakeCloudItemState fakeCloudItemState() const { return m_enmFakeCloudItemState; } 63 64 /** Updates cloud VM state. 65 * @param pWidget Brings parent widget to show messages according to. */ 66 void updateState(QWidget *pParent); 67 /** Acquires instance info of certain @a enmType. 68 * @param pWidget Brings parent widget to show messages according to. */ 69 QString acquireInstanceInfo(KVirtualSystemDescriptionType enmType, QWidget *pParent); 58 70 /** @} */ 59 71 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNodeMachine.cpp
r83050 r83055 41 41 , m_pCache(new UIVirtualMachineItemCloud(guiCloudMachine)) 42 42 { 43 /* Cloud VM item can notify machine node only directly (no console), we have to setup listener: */ 44 connect(static_cast<UIVirtualMachineItemCloud*>(m_pCache), &UIVirtualMachineItemCloud::sigStateChange, 45 this, &UIChooserNodeMachine::sltHandleStateChange); 43 46 if (parentNode()) 44 47 parentNode()->addNode(this, iPosition); … … 209 212 item()->updateItem(); 210 213 } 214 215 void UIChooserNodeMachine::sltHandleStateChange() 216 { 217 /* Update machine-item: */ 218 if (item()) 219 item()->updateItem(); 220 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNodeMachine.h
r83050 r83055 117 117 virtual void retranslateUi() /* override */; 118 118 119 private slots: 120 121 /** Handles machine state change. */ 122 void sltHandleStateChange(); 123 119 124 private: 120 125
Note:
See TracChangeset
for help on using the changeset viewer.