Changeset 83653 in vbox for trunk/src/VBox
- Timestamp:
- Apr 9, 2020 4:38:03 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 137119
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 8 deleted
- 5 edited
- 7 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r83350 r83653 318 318 ./src/widgets/graphics \ 319 319 ./src/wizards \ 320 ./src/wizards/addcloudvm \ 320 321 ./src/wizards/newcloudvm \ 321 322 ./src/wizards/newvm \ … … 683 684 src/widgets/graphics/UIGraphicsToolBar.h \ 684 685 src/widgets/graphics/UIGraphicsTextPane.h \ 686 src/wizards/addcloudvm/UIWizardAddCloudVM.h \ 687 src/wizards/addcloudvm/UIWizardAddCloudVMPageBasic1.h \ 688 src/wizards/addcloudvm/UIWizardAddCloudVMPageExpert.h \ 685 689 src/wizards/newcloudvm/UIWizardNewCloudVM.h \ 686 690 src/wizards/newcloudvm/UIWizardNewCloudVMPageBasic1.h \ … … 1131 1135 src/widgets/graphics/UIGraphicsToolBar.cpp \ 1132 1136 src/widgets/graphics/UIGraphicsTextPane.cpp \ 1137 src/wizards/addcloudvm/UIWizardAddCloudVM.cpp \ 1138 src/wizards/addcloudvm/UIWizardAddCloudVMPageBasic1.cpp \ 1139 src/wizards/addcloudvm/UIWizardAddCloudVMPageExpert.cpp \ 1133 1140 src/wizards/newcloudvm/UIWizardNewCloudVM.cpp \ 1134 1141 src/wizards/newcloudvm/UIWizardNewCloudVMPageBasic1.cpp \ … … 1947 1954 widgets/graphics \ 1948 1955 wizards \ 1956 wizards/addcloudvm \ 1949 1957 wizards/clonevd \ 1950 1958 wizards/clonevm \ -
trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp
r83494 r83653 1994 1994 case WizardType_ImportAppliance: strResult = "ImportAppliance"; break; 1995 1995 case WizardType_NewCloudVM: strResult = "NewCloudVM"; break; 1996 case WizardType_AddCloudVM: strResult = "AddCloudVM"; break; 1996 1997 case WizardType_FirstRun: strResult = "FirstRun"; break; 1997 1998 case WizardType_NewVD: strResult = "NewVD"; break; … … 2017 2018 keys << "ImportAppliance"; values << WizardType_ImportAppliance; 2018 2019 keys << "NewCloudVM"; values << WizardType_NewCloudVM; 2020 keys << "AddCloudVM"; values << WizardType_AddCloudVM; 2019 2021 keys << "FirstRun"; values << WizardType_FirstRun; 2020 2022 keys << "NewVD"; values << WizardType_NewVD; -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h
r83494 r83653 862 862 WizardType_ImportAppliance, 863 863 WizardType_NewCloudVM, 864 WizardType_AddCloudVM, 864 865 WizardType_FirstRun, 865 866 WizardType_NewVD, -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r83330 r83653 46 46 #include "UIVirtualBoxManagerWidget.h" 47 47 #include "UIVirtualMachineItemCloud.h" 48 #include "UIWizard NewCloudVM.h"48 #include "UIWizardAddCloudVM.h" 49 49 #include "UIWizardNewVM.h" 50 50 … … 920 920 /* Use the "safe way" to open stack of Mac OS X Sheets: */ 921 921 QWidget *pWizardParent = windowManager().realParentWindow(chooser()->managerWidget()); 922 UISafePointerWizard NewCloudVM pWizard = new UIWizardNewCloudVM(pWizardParent);922 UISafePointerWizardAddCloudVM pWizard = new UIWizardAddCloudVM(pWizardParent); 923 923 windowManager().registerNewParent(pWizard, pWizardParent); 924 924 pWizard->prepare(); -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/UIWizard.cpp
r82968 r83653 418 418 break; 419 419 case WizardType_NewCloudVM: 420 case WizardType_AddCloudVM: 420 421 dRatio += 0.7; 421 422 break; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVM.cpp
r83646 r83653 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIWizard NewCloudVM class implementation.3 * VBox Qt GUI - UIWizardAddCloudVM class implementation. 4 4 */ 5 5 … … 16 16 */ 17 17 18 /* Qt includes: */19 #include <QAbstractButton>20 21 18 /* GUI includes: */ 22 19 #include "UIMessageCenter.h" 23 #include "UIWizardNewCloudVM.h" 24 #include "UIWizardNewCloudVMPageBasic1.h" 25 #include "UIWizardNewCloudVMPageBasic2.h" 26 #include "UIWizardNewCloudVMPageExpert.h" 20 #include "UIWizardAddCloudVM.h" 21 #include "UIWizardAddCloudVMPageBasic1.h" 22 #include "UIWizardAddCloudVMPageExpert.h" 27 23 28 24 /* COM includes: */ … … 30 26 31 27 32 UIWizard NewCloudVM::UIWizardNewCloudVM(QWidget *pParent,28 UIWizardAddCloudVM::UIWizardAddCloudVM(QWidget *pParent, 33 29 const CCloudClient &comClient /* = CCloudClient() */, 34 const CVirtualSystemDescription &comDescription /* = CVirtualSystemDescription() */,35 30 WizardMode enmMode /* = WizardMode_Auto */) 36 : UIWizard(pParent, WizardType_ NewCloudVM, enmMode)31 : UIWizard(pParent, WizardType_AddCloudVM, enmMode) 37 32 , m_comClient(comClient) 38 , m_comVSD(comDescription)39 , m_fFullWizard(m_comClient.isNull() || m_comVSD.isNull())40 , m_fFinalStepPrevented(false)41 33 { 42 34 #ifndef VBOX_WS_MAC … … 49 41 } 50 42 51 void UIWizard NewCloudVM::prepare()43 void UIWizardAddCloudVM::prepare() 52 44 { 53 45 /* Create corresponding pages: */ … … 56 48 case WizardMode_Basic: 57 49 { 58 if (m_fFullWizard) 59 setPage(Page1, new UIWizardNewCloudVMPageBasic1); 60 setPage(Page2, new UIWizardNewCloudVMPageBasic2(m_fFullWizard)); 50 setPage(Page1, new UIWizardAddCloudVMPageBasic1); 61 51 break; 62 52 } 63 53 case WizardMode_Expert: 64 54 { 65 setPage(PageExpert, new UIWizard NewCloudVMPageExpert(m_fFullWizard));55 setPage(PageExpert, new UIWizardAddCloudVMPageExpert); 66 56 break; 67 57 } … … 76 66 } 77 67 78 bool UIWizard NewCloudVM::createVSDForm()68 bool UIWizardAddCloudVM::addCloudVMs() 79 69 { 80 /* Prepare result: */ 81 bool fResult = false; 70 /* Acquire prepared client and description: */ 71 CCloudClient comClient = client(); 72 AssertReturn(comClient.isNotNull(), false); 82 73 83 /* Main API request sequence, can be interrupted after any step: */84 do74 /* For each cloud instance name we have: */ 75 foreach (const QString &strInstanceName, field("instanceIds").toStringList()) 85 76 { 86 /* Acquire prepared client and description: */ 87 CCloudClient comClient = client(); 88 CVirtualSystemDescription comDescription = vsd(); 89 AssertReturn(comClient.isNotNull() && comDescription.isNotNull(), false); 90 91 /* Read Cloud Client description form: */ 92 CVirtualSystemDescriptionForm comForm; 93 CProgress comProgress = comClient.GetLaunchDescriptionForm(comDescription, comForm); 94 if (!comClient.isOk()) 95 { 96 msgCenter().cannotAcquireCloudClientParameter(comClient); 97 break; 98 } 99 100 /* Show "Acquire launch form" progress: */ 101 msgCenter().showModalProgressDialog(comProgress, tr("Acquire launch form ..."), 102 ":/progress_refresh_90px.png", this, 0); 103 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 104 { 105 msgCenter().cannotAcquireCloudClientParameter(comProgress); 106 break; 107 } 108 109 /* Remember Virtual System Description Form: */ 110 setVSDForm(comForm); 111 112 /* Finally, success: */ 113 fResult = true; 114 } 115 while (0); 116 117 /* Return result: */ 118 return fResult; 119 } 120 121 bool UIWizardNewCloudVM::createCloudVM() 122 { 123 /* Prepare result: */ 124 bool fResult = false; 125 126 /* Main API request sequence, can be interrupted after any step: */ 127 do 128 { 129 /* Do nothing if prevented: */ 130 if (m_fFinalStepPrevented) 131 { 132 fResult = true; 133 break; 134 } 135 136 /* Acquire prepared client and description: */ 137 CCloudClient comClient = client(); 138 CVirtualSystemDescription comDescription = vsd(); 139 AssertReturn(comClient.isNotNull() && comDescription.isNotNull(), false); 140 141 /* Initiate cloud VM creation procedure: */ 142 CProgress comProgress = comClient.LaunchVM(comDescription); 77 /* Initiate cloud VM add procedure: */ 78 CProgress comProgress = comClient.AddCloudMachine(strInstanceName); 143 79 if (!comClient.isOk()) 144 80 { 145 81 msgCenter().cannotCreateCloudMachine(comClient, this); 146 break;82 return false; 147 83 } 148 84 149 /* Show " Create Cloud Machine" progress: */150 msgCenter().showModalProgressDialog(comProgress, tr(" Create Cloud Machine ..."),85 /* Show "Add cloud machine" progress: */ 86 msgCenter().showModalProgressDialog(comProgress, tr("Add cloud machine ..."), 151 87 ":/progress_new_cloud_vm_90px.png", this, 0); 152 88 if (comProgress.GetCanceled()) 153 break;89 return false; 154 90 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 155 91 { 156 92 msgCenter().cannotCreateCloudMachine(comProgress, this); 157 break;93 return false; 158 94 } 95 } 159 96 160 /* Finally, success: */ 161 fResult = true; 162 } 163 while (0); 164 165 /* Return result: */ 166 return fResult; 97 /* Success by default: */ 98 return true; 167 99 } 168 100 169 void UIWizardNewCloudVM::scheduleAutoFinish() 170 { 171 QMetaObject::invokeMethod(this, "sltTriggerFinishButton", Qt::QueuedConnection); 172 } 173 174 void UIWizardNewCloudVM::retranslateUi() 101 void UIWizardAddCloudVM::retranslateUi() 175 102 { 176 103 /* Call to base-class: */ … … 178 105 179 106 /* Translate wizard: */ 180 setWindowTitle(tr(" CreateCloud Virtual Machine"));181 setButtonText(QWizard::FinishButton, tr(" Create"));107 setWindowTitle(tr("Add Cloud Virtual Machine")); 108 setButtonText(QWizard::FinishButton, tr("Add")); 182 109 } 183 184 void UIWizardNewCloudVM::sltTriggerFinishButton()185 {186 button(QWizard::FinishButton)->click();187 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVM.h
r83646 r83653 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIWizard NewCloudVM class declaration.3 * VBox Qt GUI - UIWizardAddCloudVM class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef FEQT_INCLUDED_SRC_wizards_ newcloudvm_UIWizardNewCloudVM_h19 #define FEQT_INCLUDED_SRC_wizards_ newcloudvm_UIWizardNewCloudVM_h18 #ifndef FEQT_INCLUDED_SRC_wizards_addcloudvm_UIWizardAddCloudVM_h 19 #define FEQT_INCLUDED_SRC_wizards_addcloudvm_UIWizardAddCloudVM_h 20 20 #ifndef RT_WITHOUT_PRAGMA_ONCE 21 21 # pragma once … … 28 28 #include "COMEnums.h" 29 29 #include "CCloudClient.h" 30 #include "CVirtualSystemDescription.h"31 #include "CVirtualSystemDescriptionForm.h"32 30 33 /** NewCloud VM wizard. */34 class UIWizard NewCloudVM : public UIWizard31 /** Add Cloud VM wizard. */ 32 class UIWizardAddCloudVM : public UIWizard 35 33 { 36 34 Q_OBJECT; … … 41 39 enum 42 40 { 43 Page1, 44 Page2 41 Page1 45 42 }; 46 43 … … 51 48 }; 52 49 53 /** Constructs New Cloud VM wizard passing @a pParent to the base-class. 54 * @param comClient Brings the Cloud Client object to work with. 55 * @param comDescription Brings the Virtual System Description object to use. */ 56 UIWizardNewCloudVM(QWidget *pParent, 50 /** Constructs Add Cloud VM wizard passing @a pParent & @a enmMode to the base-class. 51 * @param comClient Brings the Cloud Client object wrapper to work with. */ 52 UIWizardAddCloudVM(QWidget *pParent, 57 53 const CCloudClient &comClient = CCloudClient(), 58 const CVirtualSystemDescription &comDescription = CVirtualSystemDescription(),59 54 WizardMode enmMode = WizardMode_Auto); 60 55 61 56 /** Prepares all. */ 62 57 virtual void prepare() /* override */; 63 64 /** Sets whether the final step is @a fPrevented. */65 void setFinalStepPrevented(bool fPrevented) { m_fFinalStepPrevented = fPrevented; }66 58 67 59 /** Defines Cloud @a comClient object. */ … … 70 62 CCloudClient client() const { return m_comClient; } 71 63 72 /** Defines Virtual System @a comDescription object. */ 73 void setVSD(const CVirtualSystemDescription &comDescription) { m_comVSD = comDescription; } 74 /** Returns Virtual System Description object. */ 75 CVirtualSystemDescription vsd() const { return m_comVSD; } 76 77 /** Defines Virtual System Description @a comForm object. */ 78 void setVSDForm(const CVirtualSystemDescriptionForm &comForm) { m_comVSDForm = comForm; } 79 /** Returns Virtual System Description Form object. */ 80 CVirtualSystemDescriptionForm vsdForm() const { return m_comVSDForm; } 81 82 /** Creates VSD Form. */ 83 bool createVSDForm(); 84 85 /** Creates New Cloud VM. */ 86 bool createCloudVM(); 87 88 /** Schedules Finish button trigger for 89 * the next event-loop cicle. */ 90 void scheduleAutoFinish(); 64 /** Adds cloud VMs. */ 65 bool addCloudVMs(); 91 66 92 67 protected: … … 95 70 virtual void retranslateUi() /* override */; 96 71 97 private slots:98 99 /** Triggers Finish button. */100 void sltTriggerFinishButton();101 102 72 private: 103 73 104 /** Holds the Cloud Client object reference. */ 105 CCloudClient m_comClient; 106 /** Holds the Virtual System Description object reference. */ 107 CVirtualSystemDescription m_comVSD; 108 /** Holds the Virtual System Description Form object reference. */ 109 CVirtualSystemDescriptionForm m_comVSDForm; 110 111 /** Holds whether we want full wizard form or short one. */ 112 bool m_fFullWizard; 113 /** Holds whether the final step is prevented. */ 114 bool m_fFinalStepPrevented; 74 /** Holds the Cloud Client object wrapper. */ 75 CCloudClient m_comClient; 115 76 }; 116 77 117 /** Safe pointer to newcloud vm wizard. */118 typedef QPointer<UIWizard NewCloudVM> UISafePointerWizardNewCloudVM;78 /** Safe pointer to add cloud vm wizard. */ 79 typedef QPointer<UIWizardAddCloudVM> UISafePointerWizardAddCloudVM; 119 80 120 #endif /* !FEQT_INCLUDED_SRC_wizards_ newcloudvm_UIWizardNewCloudVM_h */81 #endif /* !FEQT_INCLUDED_SRC_wizards_addcloudvm_UIWizardAddCloudVM_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVMPageBasic1.cpp
r83646 r83653 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIWizard NewCloudVMPageBasic1 class implementation.3 * VBox Qt GUI - UIWizardAddCloudVMPageBasic1 class implementation. 4 4 */ 5 5 … … 31 31 #include "UIMessageCenter.h" 32 32 #include "UIVirtualBoxManager.h" 33 #include "UIWizard NewCloudVM.h"34 #include "UIWizard NewCloudVMPageBasic1.h"33 #include "UIWizardAddCloudVM.h" 34 #include "UIWizardAddCloudVMPageBasic1.h" 35 35 36 36 /* COM includes: */ 37 #include "CAppliance.h"38 37 #include "CStringArray.h" 39 38 40 39 41 40 /********************************************************************************************************************************* 42 * Class UIWizard NewCloudVMPage1 implementation. *41 * Class UIWizardAddCloudVMPage1 implementation. * 43 42 *********************************************************************************************************************************/ 44 43 45 UIWizard NewCloudVMPage1::UIWizardNewCloudVMPage1()44 UIWizardAddCloudVMPage1::UIWizardAddCloudVMPage1() 46 45 : m_fPolished(false) 47 , m_p DestinationLayout(0)48 , m_p DestinationLabel(0)49 , m_p DestinationComboBox(0)46 , m_pSourceLayout(0) 47 , m_pSourceLabel(0) 48 , m_pSourceComboBox(0) 50 49 , m_pCloudContainerLayout(0) 51 50 , m_pAccountLabel(0) … … 53 52 , m_pAccountToolButton(0) 54 53 , m_pAccountPropertyTable(0) 55 , m_pAccountI mageLabel(0)56 , m_pAccountI mageList(0)57 { 58 } 59 60 void UIWizard NewCloudVMPage1::populateDestinations()54 , m_pAccountInstanceLabel(0) 55 , m_pAccountInstanceList(0) 56 { 57 } 58 59 void UIWizardAddCloudVMPage1::populateSources() 61 60 { 62 61 /* To be executed just once, so combo should be empty: */ 63 AssertReturnVoid(m_p DestinationComboBox->count() == 0);64 65 /* Do we have OCI destination? */62 AssertReturnVoid(m_pSourceComboBox->count() == 0); 63 64 /* Do we have OCI source? */ 66 65 bool fOCIPresent = false; 67 66 … … 94 93 95 94 /* Compose empty item, fill it's data: */ 96 m_p DestinationComboBox->addItem(QString());97 m_p DestinationComboBox->setItemData(m_pDestinationComboBox->count() - 1, comProvider.GetId(), DestinationData_ID);98 m_p DestinationComboBox->setItemData(m_pDestinationComboBox->count() - 1, comProvider.GetName(), DestinationData_Name);99 m_p DestinationComboBox->setItemData(m_pDestinationComboBox->count() - 1, comProvider.GetShortName(), DestinationData_ShortName);100 if (m_p DestinationComboBox->itemData(m_pDestinationComboBox->count() - 1, DestinationData_ShortName).toString() == "OCI")95 m_pSourceComboBox->addItem(QString()); 96 m_pSourceComboBox->setItemData(m_pSourceComboBox->count() - 1, comProvider.GetId(), SourceData_ID); 97 m_pSourceComboBox->setItemData(m_pSourceComboBox->count() - 1, comProvider.GetName(), SourceData_Name); 98 m_pSourceComboBox->setItemData(m_pSourceComboBox->count() - 1, comProvider.GetShortName(), SourceData_ShortName); 99 if (m_pSourceComboBox->itemData(m_pSourceComboBox->count() - 1, SourceData_ShortName).toString() == "OCI") 101 100 fOCIPresent = true; 102 101 } … … 106 105 /* Set default: */ 107 106 if (fOCIPresent) 108 set Destination("OCI");109 } 110 111 void UIWizard NewCloudVMPage1::populateAccounts()107 setSource("OCI"); 108 } 109 110 void UIWizardAddCloudVMPage1::populateAccounts() 112 111 { 113 112 /* Block signals while updating: */ … … 125 124 126 125 /* If provider chosen: */ 127 if (! destinationId().isNull())126 if (!sourceId().isNull()) 128 127 { 129 128 /* Main API request sequence, can be interrupted after any step: */ … … 131 130 { 132 131 /* (Re)initialize Cloud Provider: */ 133 m_comCloudProvider = m_comCloudProviderManager.GetProviderById( destinationId());132 m_comCloudProvider = m_comCloudProviderManager.GetProviderById(sourceId()); 134 133 if (!m_comCloudProviderManager.isOk()) 135 134 { 136 msgCenter().cannotFindCloudProvider(m_comCloudProviderManager, destinationId());135 msgCenter().cannotFindCloudProvider(m_comCloudProviderManager, sourceId()); 137 136 break; 138 137 } … … 176 175 } 177 176 178 void UIWizard NewCloudVMPage1::populateAccountProperties()177 void UIWizardAddCloudVMPage1::populateAccountProperties() 179 178 { 180 179 /* Block signals while updating: */ … … 269 268 } 270 269 271 void UIWizard NewCloudVMPage1::populateAccountImages()270 void UIWizardAddCloudVMPage1::populateAccountInstances() 272 271 { 273 272 /* Block signals while updating: */ 274 m_pAccountI mageList->blockSignals(true);273 m_pAccountInstanceList->blockSignals(true); 275 274 276 275 /* Clear list initially: */ 277 m_pAccountI mageList->clear();276 m_pAccountInstanceList->clear(); 278 277 /* Clear Cloud Client: */ 279 278 setClient(CCloudClient()); … … 296 295 setClient(comCloudClient); 297 296 298 /* Gather i mage names, ids and states.299 * Currently we are interested in Available images only. */297 /* Gather instance names, ids and states. 298 * Currently we are interested in Running and Stopped instances only. */ 300 299 CStringArray comNames; 301 300 CStringArray comIDs; 302 const QVector<KCloudImageState> cloudImageStates = QVector<KCloudImageState>() 303 << KCloudImageState_Available; 304 305 /* Ask for cloud custom images: */ 306 CProgress comProgress = comCloudClient.ListImages(cloudImageStates, comNames, comIDs); 301 const QVector<KCloudMachineState> cloudMachineStates = QVector<KCloudMachineState>() 302 << KCloudMachineState_Running 303 << KCloudMachineState_Stopped; 304 305 /* Ask for cloud instances: */ 306 CProgress comProgress = comCloudClient.ListInstances(cloudMachineStates, comNames, comIDs); 307 307 if (!comCloudClient.isOk()) 308 308 { … … 311 311 } 312 312 313 /* Show "Acquire cloud i mages" progress: */314 msgCenter().showModalProgressDialog(comProgress, UIWizard NewCloudVM::tr("Acquire cloud images ..."),313 /* Show "Acquire cloud instances" progress: */ 314 msgCenter().showModalProgressDialog(comProgress, UIWizardAddCloudVM::tr("Acquire cloud instances ..."), 315 315 ":/progress_reading_appliance_90px.png", 0, 0); 316 316 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) … … 326 326 { 327 327 /* Create list item: */ 328 QListWidgetItem *pItem = new QListWidgetItem(names.at(i), m_pAccountI mageList);328 QListWidgetItem *pItem = new QListWidgetItem(names.at(i), m_pAccountInstanceList); 329 329 if (pItem) 330 330 { … … 335 335 336 336 /* Choose the 1st one by default if possible: */ 337 if (m_pAccountI mageList->count())338 m_pAccountI mageList->setCurrentRow(0);337 if (m_pAccountInstanceList->count()) 338 m_pAccountInstanceList->setCurrentRow(0); 339 339 } 340 340 while (0); … … 342 342 343 343 /* Unblock signals after update: */ 344 m_pAccountImageList->blockSignals(false); 345 } 346 347 void UIWizardNewCloudVMPage1::populateFormProperties() 348 { 349 /* Clear description & form properties: */ 350 setVSD(CVirtualSystemDescription()); 351 setVSDForm(CVirtualSystemDescriptionForm()); 352 353 /* If client created: */ 354 CCloudClient comCloudClient = client(); 355 if (comCloudClient.isNotNull()) 356 { 357 /* Main API request sequence, can be interrupted after any step: */ 358 do 359 { 360 /* Create appliance: */ 361 CVirtualBox comVBox = uiCommon().virtualBox(); 362 CAppliance comAppliance = comVBox.CreateAppliance(); 363 if (!comVBox.isOk()) 364 { 365 msgCenter().cannotCreateAppliance(comVBox); 366 break; 367 } 368 369 /* Create virtual system description: */ 370 comAppliance.CreateVirtualSystemDescriptions(1); 371 if (!comAppliance.isOk()) 372 { 373 msgCenter().cannotCreateVirtualSystemDescription(comAppliance); 374 break; 375 } 376 377 /* Acquire virtual system description: */ 378 QVector<CVirtualSystemDescription> descriptions = comAppliance.GetVirtualSystemDescriptions(); 379 if (!comAppliance.isOk()) 380 { 381 msgCenter().cannotAcquireVirtualSystemDescription(comAppliance); 382 break; 383 } 384 385 /* Make sure there is at least one virtual system description created: */ 386 AssertReturnVoid(!descriptions.isEmpty()); 387 CVirtualSystemDescription comVSD = descriptions.at(0); 388 389 /* Remember Virtual System Description: */ 390 setVSD(comVSD); 391 392 /* Add image id to virtual system description: */ 393 comVSD.AddDescription(KVirtualSystemDescriptionType_CloudImageId, imageId(), QString()); 394 if (!comVSD.isOk()) 395 { 396 msgCenter().cannotAddVirtualSystemDescriptionValue(comVSD); 397 break; 398 } 399 400 /* Create Virtual System Description Form: */ 401 qobject_cast<UIWizardNewCloudVM*>(wizardImp())->createVSDForm(); 402 } 403 while (0); 404 } 405 } 406 407 void UIWizardNewCloudVMPage1::updateDestinationComboToolTip() 408 { 409 const int iCurrentIndex = m_pDestinationComboBox->currentIndex(); 344 m_pAccountInstanceList->blockSignals(false); 345 } 346 347 void UIWizardAddCloudVMPage1::updateSourceComboToolTip() 348 { 349 const int iCurrentIndex = m_pSourceComboBox->currentIndex(); 410 350 if (iCurrentIndex != -1) 411 351 { 412 const QString strCurrentToolTip = m_p DestinationComboBox->itemData(iCurrentIndex, Qt::ToolTipRole).toString();352 const QString strCurrentToolTip = m_pSourceComboBox->itemData(iCurrentIndex, Qt::ToolTipRole).toString(); 413 353 AssertMsg(!strCurrentToolTip.isEmpty(), ("Data not found!")); 414 m_p DestinationComboBox->setToolTip(strCurrentToolTip);415 } 416 } 417 418 void UIWizard NewCloudVMPage1::updateAccountPropertyTableToolTips()354 m_pSourceComboBox->setToolTip(strCurrentToolTip); 355 } 356 } 357 358 void UIWizardAddCloudVMPage1::updateAccountPropertyTableToolTips() 419 359 { 420 360 /* Iterate through all the key items: */ … … 426 366 { 427 367 const QString strToolTip = pItemK->data(Qt::UserRole).toString(); 428 pItemK->setToolTip(QApplication::translate("UIWizard NewCloudVMPageBasic1", strToolTip.toUtf8().constData()));429 } 430 } 431 } 432 433 void UIWizard NewCloudVMPage1::adjustAccountPropertyTable()368 pItemK->setToolTip(QApplication::translate("UIWizardAddCloudVMPageBasic1", strToolTip.toUtf8().constData())); 369 } 370 } 371 } 372 373 void UIWizardAddCloudVMPage1::adjustAccountPropertyTable() 434 374 { 435 375 /* Disable last column stretching temporary: */ … … 448 388 } 449 389 450 void UIWizard NewCloudVMPage1::setDestination(const QString &strDestination)451 { 452 const int iIndex = m_p DestinationComboBox->findData(strDestination, DestinationData_ShortName);390 void UIWizardAddCloudVMPage1::setSource(const QString &strSource) 391 { 392 const int iIndex = m_pSourceComboBox->findData(strSource, SourceData_ShortName); 453 393 AssertMsg(iIndex != -1, ("Data not found!")); 454 m_p DestinationComboBox->setCurrentIndex(iIndex);455 } 456 457 QString UIWizard NewCloudVMPage1::destination() const458 { 459 const int iIndex = m_p DestinationComboBox->currentIndex();460 return m_p DestinationComboBox->itemData(iIndex, DestinationData_ShortName).toString();461 } 462 463 QUuid UIWizard NewCloudVMPage1::destinationId() const464 { 465 const int iIndex = m_p DestinationComboBox->currentIndex();466 return m_p DestinationComboBox->itemData(iIndex, DestinationData_ID).toUuid();467 } 468 469 QString UIWizard NewCloudVMPage1::profileName() const394 m_pSourceComboBox->setCurrentIndex(iIndex); 395 } 396 397 QString UIWizardAddCloudVMPage1::source() const 398 { 399 const int iIndex = m_pSourceComboBox->currentIndex(); 400 return m_pSourceComboBox->itemData(iIndex, SourceData_ShortName).toString(); 401 } 402 403 QUuid UIWizardAddCloudVMPage1::sourceId() const 404 { 405 const int iIndex = m_pSourceComboBox->currentIndex(); 406 return m_pSourceComboBox->itemData(iIndex, SourceData_ID).toUuid(); 407 } 408 409 QString UIWizardAddCloudVMPage1::profileName() const 470 410 { 471 411 const int iIndex = m_pAccountComboBox->currentIndex(); … … 473 413 } 474 414 475 QString UIWizardNewCloudVMPage1::imageId() const 476 { 477 QListWidgetItem *pItem = m_pAccountImageList->currentItem(); 478 return pItem ? pItem->data(Qt::UserRole).toString() : QString(); 479 } 480 481 void UIWizardNewCloudVMPage1::setClient(const CCloudClient &comClient) 482 { 483 qobject_cast<UIWizardNewCloudVM*>(wizardImp())->setClient(comClient); 484 } 485 486 CCloudClient UIWizardNewCloudVMPage1::client() const 487 { 488 return qobject_cast<UIWizardNewCloudVM*>(wizardImp())->client(); 489 } 490 491 void UIWizardNewCloudVMPage1::setVSD(const CVirtualSystemDescription &comDescription) 492 { 493 qobject_cast<UIWizardNewCloudVM*>(wizardImp())->setVSD(comDescription); 494 } 495 496 CVirtualSystemDescription UIWizardNewCloudVMPage1::vsd() const 497 { 498 return qobject_cast<UIWizardNewCloudVM*>(wizardImp())->vsd(); 499 } 500 501 void UIWizardNewCloudVMPage1::setVSDForm(const CVirtualSystemDescriptionForm &comForm) 502 { 503 qobject_cast<UIWizardNewCloudVM*>(wizardImp())->setVSDForm(comForm); 504 } 505 506 CVirtualSystemDescriptionForm UIWizardNewCloudVMPage1::vsdForm() const 507 { 508 return qobject_cast<UIWizardNewCloudVM*>(wizardImp())->vsdForm(); 415 QStringList UIWizardAddCloudVMPage1::instanceIds() const 416 { 417 QStringList result; 418 foreach (QListWidgetItem *pItem, m_pAccountInstanceList->selectedItems()) 419 result << pItem->data(Qt::UserRole).toString(); 420 return result; 421 } 422 423 void UIWizardAddCloudVMPage1::setClient(const CCloudClient &comClient) 424 { 425 qobject_cast<UIWizardAddCloudVM*>(wizardImp())->setClient(comClient); 426 } 427 428 CCloudClient UIWizardAddCloudVMPage1::client() const 429 { 430 return qobject_cast<UIWizardAddCloudVM*>(wizardImp())->client(); 509 431 } 510 432 511 433 512 434 /********************************************************************************************************************************* 513 * Class UIWizard NewCloudVMPageBasic1 implementation. *435 * Class UIWizardAddCloudVMPageBasic1 implementation. * 514 436 *********************************************************************************************************************************/ 515 437 516 UIWizard NewCloudVMPageBasic1::UIWizardNewCloudVMPageBasic1()438 UIWizardAddCloudVMPageBasic1::UIWizardAddCloudVMPageBasic1() 517 439 : m_pLabelMain(0) 518 440 , m_pLabelDescription(0) … … 530 452 } 531 453 532 /* Create destinationlayout: */533 m_p DestinationLayout = new QGridLayout;534 if (m_p DestinationLayout)535 { 536 m_p DestinationLayout->setColumnStretch(0, 0);537 m_p DestinationLayout->setColumnStretch(1, 1);538 539 /* Create destinationlabel: */540 m_p DestinationLabel = new QLabel(this);541 if (m_p DestinationLabel)454 /* Create source layout: */ 455 m_pSourceLayout = new QGridLayout; 456 if (m_pSourceLayout) 457 { 458 m_pSourceLayout->setColumnStretch(0, 0); 459 m_pSourceLayout->setColumnStretch(1, 1); 460 461 /* Create source label: */ 462 m_pSourceLabel = new QLabel(this); 463 if (m_pSourceLabel) 542 464 { 543 465 /* Add into layout: */ 544 m_p DestinationLayout->addWidget(m_pDestinationLabel, 0, 0, Qt::AlignRight);545 } 546 /* Create destinationselector: */547 m_p DestinationComboBox = new QIComboBox(this);548 if (m_p DestinationComboBox)549 { 550 m_p DestinationLabel->setBuddy(m_pDestinationComboBox);466 m_pSourceLayout->addWidget(m_pSourceLabel, 0, 0, Qt::AlignRight); 467 } 468 /* Create source selector: */ 469 m_pSourceComboBox = new QIComboBox(this); 470 if (m_pSourceComboBox) 471 { 472 m_pSourceLabel->setBuddy(m_pSourceComboBox); 551 473 552 474 /* Add into layout: */ 553 m_p DestinationLayout->addWidget(m_pDestinationComboBox, 0, 1);475 m_pSourceLayout->addWidget(m_pSourceComboBox, 0, 1); 554 476 } 555 477 … … 559 481 { 560 482 /* Add into layout: */ 561 m_p DestinationLayout->addWidget(m_pLabelDescription, 1, 0, 1, 2);483 m_pSourceLayout->addWidget(m_pLabelDescription, 1, 0, 1, 2); 562 484 } 563 485 564 486 /* Add into layout: */ 565 pMainLayout->addLayout(m_p DestinationLayout);487 pMainLayout->addLayout(m_pSourceLayout); 566 488 } 567 489 … … 635 557 636 558 /* Create account instance label: */ 637 m_pAccountI mageLabel = new QLabel(this);638 if (m_pAccountI mageLabel)559 m_pAccountInstanceLabel = new QLabel(this); 560 if (m_pAccountInstanceLabel) 639 561 { 640 562 /* Add into layout: */ 641 m_pCloudContainerLayout->addWidget(m_pAccountI mageLabel, 2, 0, Qt::AlignRight);563 m_pCloudContainerLayout->addWidget(m_pAccountInstanceLabel, 2, 0, Qt::AlignRight); 642 564 } 643 565 /* Create profile instances table: */ 644 m_pAccountI mageList = new QListWidget(this);645 if (m_pAccountI mageList)646 { 647 m_pAccountI mageLabel->setBuddy(m_pAccountImageLabel);648 const QFontMetrics fm(m_pAccountI mageList->font());566 m_pAccountInstanceList = new QListWidget(this); 567 if (m_pAccountInstanceList) 568 { 569 m_pAccountInstanceLabel->setBuddy(m_pAccountInstanceLabel); 570 const QFontMetrics fm(m_pAccountInstanceList->font()); 649 571 const int iFontWidth = fm.width('x'); 650 572 const int iTotalWidth = 50 * iFontWidth; 651 573 const int iFontHeight = fm.height(); 652 574 const int iTotalHeight = 4 * iFontHeight; 653 m_pAccountImageList->setMinimumSize(QSize(iTotalWidth, iTotalHeight)); 654 //m_pAccountImageList->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); 655 m_pAccountImageList->setAlternatingRowColors(true); 575 m_pAccountInstanceList->setMinimumSize(QSize(iTotalWidth, iTotalHeight)); 576 //m_pAccountInstanceList->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); 577 m_pAccountInstanceList->setAlternatingRowColors(true); 578 m_pAccountInstanceList->setSelectionMode(QAbstractItemView::ExtendedSelection); 656 579 657 580 /* Add into layout: */ 658 m_pCloudContainerLayout->addWidget(m_pAccountI mageList, 2, 1, 2, 1);581 m_pCloudContainerLayout->addWidget(m_pAccountInstanceList, 2, 1, 2, 1); 659 582 } 660 583 … … 667 590 if (gpManager) 668 591 connect(gpManager, &UIVirtualBoxManager::sigCloudProfileManagerChange, 669 this, &UIWizard NewCloudVMPageBasic1::sltHandleDestinationChange);670 connect(m_p DestinationComboBox, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::activated),671 this, &UIWizard NewCloudVMPageBasic1::sltHandleDestinationChange);592 this, &UIWizardAddCloudVMPageBasic1::sltHandleSourceChange); 593 connect(m_pSourceComboBox, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::activated), 594 this, &UIWizardAddCloudVMPageBasic1::sltHandleSourceChange); 672 595 connect(m_pAccountComboBox, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::currentIndexChanged), 673 this, &UIWizard NewCloudVMPageBasic1::sltHandleAccountComboChange);596 this, &UIWizardAddCloudVMPageBasic1::sltHandleAccountComboChange); 674 597 connect(m_pAccountToolButton, &QIToolButton::clicked, 675 this, &UIWizardNewCloudVMPageBasic1::sltHandleAccountButtonClick); 676 connect(m_pAccountImageList, &QListWidget::currentRowChanged, 677 this, &UIWizardNewCloudVMPageBasic1::completeChanged); 678 } 679 680 bool UIWizardNewCloudVMPageBasic1::event(QEvent *pEvent) 598 this, &UIWizardAddCloudVMPageBasic1::sltHandleAccountButtonClick); 599 connect(m_pAccountInstanceList, &QListWidget::currentRowChanged, 600 this, &UIWizardAddCloudVMPageBasic1::completeChanged); 601 602 /* Register fields: */ 603 registerField("instanceIds", this, "instanceIds"); 604 } 605 606 bool UIWizardAddCloudVMPageBasic1::event(QEvent *pEvent) 681 607 { 682 608 /* Handle known event types: */ … … 698 624 } 699 625 700 void UIWizard NewCloudVMPageBasic1::retranslateUi()626 void UIWizardAddCloudVMPageBasic1::retranslateUi() 701 627 { 702 628 /* Translate page: */ 703 setTitle(UIWizard NewCloudVM::tr("Destination to create"));629 setTitle(UIWizardAddCloudVM::tr("Source to add from")); 704 630 705 631 /* Translate main label: */ 706 m_pLabelMain->setText(UIWizard NewCloudVM::tr("Please choose the destination to create cloud virtual machine in. This can "632 m_pLabelMain->setText(UIWizardAddCloudVM::tr("Please choose the source to add cloud virtual machine from. This can " 707 633 "be one of known cloud service providers below.")); 708 634 709 /* Translate destinationlabel: */710 m_p DestinationLabel->setText(UIWizardNewCloudVM::tr("&Destination:"));711 /* Translate received values of Destinationcombo-box.635 /* Translate source label: */ 636 m_pSourceLabel->setText(UIWizardAddCloudVM::tr("&Source:")); 637 /* Translate received values of Source combo-box. 712 638 * We are enumerating starting from 0 for simplicity: */ 713 for (int i = 0; i < m_p DestinationComboBox->count(); ++i)714 { 715 m_p DestinationComboBox->setItemText(i, m_pDestinationComboBox->itemData(i, DestinationData_Name).toString());716 m_p DestinationComboBox->setItemData(i, UIWizardNewCloudVM::tr("Create VM forcloud service provider."), Qt::ToolTipRole);639 for (int i = 0; i < m_pSourceComboBox->count(); ++i) 640 { 641 m_pSourceComboBox->setItemText(i, m_pSourceComboBox->itemData(i, SourceData_Name).toString()); 642 m_pSourceComboBox->setItemData(i, UIWizardAddCloudVM::tr("Add VM from cloud service provider."), Qt::ToolTipRole); 717 643 } 718 644 719 645 /* Translate description label: */ 720 m_pLabelDescription->setText(UIWizard NewCloudVM::tr("<p>Please choose one of cloud service accounts you have registered to "721 " create virtual machine for. Existing custom imageslist will be "722 "updated. To continue, select one of custom images to createvirtual "646 m_pLabelDescription->setText(UIWizardAddCloudVM::tr("<p>Please choose one of cloud service accounts you have registered to " 647 "add virtual machine from. Existing instance list will be " 648 "updated. To continue, select at least one instance to add virtual " 723 649 "machine on the basis of it.</p>")); 724 650 725 651 /* Translate cloud stuff: */ 726 m_pAccountLabel->setText(UIWizard NewCloudVM::tr("&Account:"));727 m_pAccountI mageLabel->setText(UIWizardNewCloudVM::tr("&Images:"));652 m_pAccountLabel->setText(UIWizardAddCloudVM::tr("&Account:")); 653 m_pAccountInstanceLabel->setText(UIWizardAddCloudVM::tr("&Instances:")); 728 654 729 655 /* Adjust label widths: */ 730 656 QList<QWidget*> labels; 731 labels << m_p DestinationLabel;657 labels << m_pSourceLabel; 732 658 labels << m_pAccountLabel; 733 labels << m_pAccountI mageLabel;659 labels << m_pAccountInstanceLabel; 734 660 int iMaxWidth = 0; 735 661 foreach (QWidget *pLabel, labels) 736 662 iMaxWidth = qMax(iMaxWidth, pLabel->minimumSizeHint().width()); 737 m_p DestinationLayout->setColumnMinimumWidth(0, iMaxWidth);663 m_pSourceLayout->setColumnMinimumWidth(0, iMaxWidth); 738 664 m_pCloudContainerLayout->setColumnMinimumWidth(0, iMaxWidth); 739 665 740 666 /* Update tool-tips: */ 741 update DestinationComboToolTip();667 updateSourceComboToolTip(); 742 668 updateAccountPropertyTableToolTips(); 743 669 } 744 670 745 void UIWizard NewCloudVMPageBasic1::initializePage()671 void UIWizardAddCloudVMPageBasic1::initializePage() 746 672 { 747 673 /* If wasn't polished yet: */ 748 674 if (!m_fPolished) 749 675 { 750 /* Populate destinations: */751 populate Destinations();676 /* Populate sources: */ 677 populateSources(); 752 678 /* Choose one of them, asynchronously: */ 753 QMetaObject::invokeMethod(this, "sltHandle DestinationChange", Qt::QueuedConnection);679 QMetaObject::invokeMethod(this, "sltHandleSourceChange", Qt::QueuedConnection); 754 680 m_fPolished = true; 755 681 } … … 759 685 } 760 686 761 bool UIWizard NewCloudVMPageBasic1::isComplete() const687 bool UIWizardAddCloudVMPageBasic1::isComplete() const 762 688 { 763 689 /* Initial result: */ 764 690 bool fResult = true; 765 691 766 /* Check cloud settings: */ 692 /* Make sure client is not NULL and 693 * at least one instance is selected: */ 767 694 fResult = client().isNotNull() 768 && !i mageId().isNull();695 && !instanceIds().isEmpty(); 769 696 770 697 /* Return result: */ … … 772 699 } 773 700 774 bool UIWizard NewCloudVMPageBasic1::validatePage()701 bool UIWizardAddCloudVMPageBasic1::validatePage() 775 702 { 776 703 /* Initial result: */ 777 704 bool fResult = true; 778 705 779 /* Populate vsd and form properties: */ 780 populateFormProperties(); 781 /* And make sure they are not NULL: */ 782 fResult = vsd().isNotNull() 783 && vsdForm().isNotNull(); 706 /* Lock finish button: */ 707 startProcessing(); 708 709 /* Try to add cloud VMs: */ 710 fResult = qobject_cast<UIWizardAddCloudVM*>(wizard())->addCloudVMs(); 711 712 /* Unlock finish button: */ 713 endProcessing(); 784 714 785 715 /* Return result: */ … … 787 717 } 788 718 789 void UIWizard NewCloudVMPageBasic1::sltHandleDestinationChange()719 void UIWizardAddCloudVMPageBasic1::sltHandleSourceChange() 790 720 { 791 721 /* Update tool-tip: */ 792 update DestinationComboToolTip();793 794 /* Make i mage list focused by default: */795 m_pAccountI mageList->setFocus();722 updateSourceComboToolTip(); 723 724 /* Make instance list focused by default: */ 725 m_pAccountInstanceList->setFocus(); 796 726 797 727 /* Refresh required settings: */ 798 728 populateAccounts(); 799 729 populateAccountProperties(); 800 populateAccountI mages();730 populateAccountInstances(); 801 731 emit completeChanged(); 802 732 } 803 733 804 void UIWizard NewCloudVMPageBasic1::sltHandleAccountComboChange()734 void UIWizardAddCloudVMPageBasic1::sltHandleAccountComboChange() 805 735 { 806 736 /* Refresh required settings: */ 807 737 populateAccountProperties(); 808 populateAccountI mages();738 populateAccountInstances(); 809 739 emit completeChanged(); 810 740 } 811 741 812 void UIWizard NewCloudVMPageBasic1::sltHandleAccountButtonClick()742 void UIWizardAddCloudVMPageBasic1::sltHandleAccountButtonClick() 813 743 { 814 744 /* Open Cloud Profile Manager: */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVMPageBasic1.h
r83646 r83653 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIWizard NewCloudVMPageBasic1 class declaration.3 * VBox Qt GUI - UIWizardAddCloudVMPageBasic1 class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef FEQT_INCLUDED_SRC_wizards_ newcloudvm_UIWizardNewCloudVMPageBasic1_h19 #define FEQT_INCLUDED_SRC_wizards_ newcloudvm_UIWizardNewCloudVMPageBasic1_h18 #ifndef FEQT_INCLUDED_SRC_wizards_addcloudvm_UIWizardAddCloudVMPageBasic1_h 19 #define FEQT_INCLUDED_SRC_wizards_addcloudvm_UIWizardAddCloudVMPageBasic1_h 20 20 #ifndef RT_WITHOUT_PRAGMA_ONCE 21 21 # pragma once … … 31 31 #include "CCloudProvider.h" 32 32 #include "CCloudProviderManager.h" 33 #include "CVirtualSystemDescription.h"34 #include "CVirtualSystemDescriptionForm.h"35 33 36 34 /* Forward declarations: */ … … 43 41 class QIToolButton; 44 42 45 /** Destinationcombo data fields. */43 /** Source combo data fields. */ 46 44 enum 47 45 { 48 DestinationData_ID= Qt::UserRole + 1,49 DestinationData_Name= Qt::UserRole + 2,50 DestinationData_ShortName= Qt::UserRole + 346 SourceData_ID = Qt::UserRole + 1, 47 SourceData_Name = Qt::UserRole + 2, 48 SourceData_ShortName = Qt::UserRole + 3 51 49 }; 52 50 … … 57 55 }; 58 56 59 /** UIWizardPageBase extension for 1st page of the NewCloud VM wizard. */60 class UIWizard NewCloudVMPage1 : public UIWizardPageBase57 /** UIWizardPageBase extension for 1st page of the Add Cloud VM wizard. */ 58 class UIWizardAddCloudVMPage1 : public UIWizardPageBase 61 59 { 62 60 protected: 63 61 64 62 /** Constructs 1st page base. */ 65 UIWizard NewCloudVMPage1();63 UIWizardAddCloudVMPage1(); 66 64 67 /** Populates destinations. */68 void populate Destinations();65 /** Populates sources. */ 66 void populateSources(); 69 67 /** Populates accounts. */ 70 68 void populateAccounts(); 71 69 /** Populates account properties. */ 72 70 void populateAccountProperties(); 73 /** Populates account images. */ 74 void populateAccountImages(); 75 /** Populates form properties. */ 76 void populateFormProperties(); 71 /** Populates account instances. */ 72 void populateAccountInstances(); 77 73 78 /** Updates destinationcombo tool-tips. */79 void update DestinationComboToolTip();74 /** Updates source combo tool-tips. */ 75 void updateSourceComboToolTip(); 80 76 /** Updates account property table tool-tips. */ 81 77 void updateAccountPropertyTableToolTips(); … … 83 79 void adjustAccountPropertyTable(); 84 80 85 /** Defines @a str Destination. */86 void set Destination(const QString &strDestination);87 /** Returns destination. */88 QString destination() const;89 /** Returns destinationID. */90 QUuid destinationId() const;81 /** Defines @a strSource. */ 82 void setSource(const QString &strSource); 83 /** Returns source. */ 84 QString source() const; 85 /** Returns source ID. */ 86 QUuid sourceId() const; 91 87 92 88 /** Returns profile name. */ 93 89 QString profileName() const; 94 /** Returns i mage ID. */95 QString imageId() const;90 /** Returns instance IDs. */ 91 QStringList instanceIds() const; 96 92 97 93 /** Defines Cloud @a comClient object. */ … … 99 95 /** Returns Cloud Client object. */ 100 96 CCloudClient client() const; 101 102 /** Defines Virtual System @a comDescription object. */103 void setVSD(const CVirtualSystemDescription &comDescription);104 /** Returns Virtual System Description object. */105 CVirtualSystemDescription vsd() const;106 107 /** Defines Virtual System Description @a comForm object. */108 void setVSDForm(const CVirtualSystemDescriptionForm &comForm);109 /** Returns Virtual System Description Form object. */110 CVirtualSystemDescriptionForm vsdForm() const;111 97 112 98 /** Holds whether starting page was polished. */ … … 120 106 CCloudProfile m_comCloudProfile; 121 107 122 /** Holds the destinationlayout instance. */123 QGridLayout *m_p DestinationLayout;124 /** Holds the destinationtype label instance. */125 QLabel *m_p DestinationLabel;126 /** Holds the destinationtype combo-box instance. */127 QIComboBox *m_p DestinationComboBox;108 /** Holds the source layout instance. */ 109 QGridLayout *m_pSourceLayout; 110 /** Holds the source type label instance. */ 111 QLabel *m_pSourceLabel; 112 /** Holds the source type combo-box instance. */ 113 QIComboBox *m_pSourceComboBox; 128 114 129 115 /** Holds the cloud container layout instance. */ … … 137 123 /** Holds the account property table instance. */ 138 124 QTableWidget *m_pAccountPropertyTable; 139 /** Holds the account i mage label instance. */140 QLabel *m_pAccountI mageLabel;141 /** Holds the account i mage list instance. */142 QListWidget *m_pAccountI mageList;125 /** Holds the account instance label instance. */ 126 QLabel *m_pAccountInstanceLabel; 127 /** Holds the account instance list instance. */ 128 QListWidget *m_pAccountInstanceList; 143 129 }; 144 130 145 /** UIWizardPage extension for 1st page of the New Cloud VM wizard, extends UIWizardNewCloudVMPage1 as well. */146 class UIWizard NewCloudVMPageBasic1 : public UIWizardPage, public UIWizardNewCloudVMPage1131 /** UIWizardPage extension for 1st page of the Add Cloud VM wizard, extends UIWizardAddCloudVMPage1 as well. */ 132 class UIWizardAddCloudVMPageBasic1 : public UIWizardPage, public UIWizardAddCloudVMPage1 147 133 { 148 134 Q_OBJECT; 135 Q_PROPERTY(QStringList instanceIds READ instanceIds); 149 136 150 137 public: 151 138 152 139 /** Constructs 1st basic page. */ 153 UIWizard NewCloudVMPageBasic1();140 UIWizardAddCloudVMPageBasic1(); 154 141 155 142 protected: … … 175 162 private slots: 176 163 177 /** Handles change in destinationcombo-box. */178 void sltHandle DestinationChange();164 /** Handles change in source combo-box. */ 165 void sltHandleSourceChange(); 179 166 180 167 /** Handles change in account combo-box. */ … … 192 179 }; 193 180 194 #endif /* !FEQT_INCLUDED_SRC_wizards_ newcloudvm_UIWizardNewCloudVMPageBasic1_h */181 #endif /* !FEQT_INCLUDED_SRC_wizards_addcloudvm_UIWizardAddCloudVMPageBasic1_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVMPageExpert.cpp
r83646 r83653 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIWizard NewCloudVMPageExpert class implementation.3 * VBox Qt GUI - UIWizardAddCloudVMPageExpert class implementation. 4 4 */ 5 5 … … 18 18 /* Qt includes: */ 19 19 #include <QGroupBox> 20 #include <QHBoxLayout> 20 21 #include <QHeaderView> 21 22 #include <QListWidget> 22 23 #include <QTableWidget> 23 #include <QVBoxLayout>24 24 25 25 /* GUI includes: */ … … 29 29 #include "UIMessageCenter.h" 30 30 #include "UIVirtualBoxManager.h" 31 #include "UIWizardNewCloudVM.h" 32 #include "UIWizardNewCloudVMPageExpert.h" 33 34 35 UIWizardNewCloudVMPageExpert::UIWizardNewCloudVMPageExpert(bool fFullWizard) 36 : UIWizardNewCloudVMPage2(fFullWizard) 37 , m_pCntDestination(0) 38 , m_pSettingsCnt(0) 31 #include "UIWizardAddCloudVM.h" 32 #include "UIWizardAddCloudVMPageExpert.h" 33 34 35 UIWizardAddCloudVMPageExpert::UIWizardAddCloudVMPageExpert() 36 : m_pCntSource(0) 39 37 { 40 38 /* Create main layout: */ … … 42 40 if (pMainLayout) 43 41 { 44 /* Create destinationcontainer: */45 m_pCnt Destination= new QGroupBox(this);46 if (m_pCnt Destination)42 /* Create source container: */ 43 m_pCntSource = new QGroupBox(this); 44 if (m_pCntSource) 47 45 { 48 /* There is no destination table in short wizard form: */ 49 if (!m_fFullWizard) 50 m_pCntDestination->setVisible(false); 51 52 /* Create destination layout: */ 53 m_pDestinationLayout = new QGridLayout(m_pCntDestination); 54 if (m_pDestinationLayout) 46 /* Create source layout: */ 47 m_pSourceLayout = new QGridLayout(m_pCntSource); 48 if (m_pSourceLayout) 55 49 { 56 /* Create destinationselector: */57 m_p DestinationComboBox = new QIComboBox(m_pCntDestination);58 if (m_p DestinationComboBox)50 /* Create source selector: */ 51 m_pSourceComboBox = new QIComboBox(m_pCntSource); 52 if (m_pSourceComboBox) 59 53 { 60 54 /* Add into layout: */ 61 m_p DestinationLayout->addWidget(m_pDestinationComboBox, 0, 0);55 m_pSourceLayout->addWidget(m_pSourceComboBox, 0, 0); 62 56 } 63 57 … … 77 71 78 72 /* Create account combo-box: */ 79 m_pAccountComboBox = new QIComboBox(m_pCnt Destination);73 m_pAccountComboBox = new QIComboBox(m_pCntSource); 80 74 if (m_pAccountComboBox) 81 75 { … … 84 78 } 85 79 /* Create account tool-button: */ 86 m_pAccountToolButton = new QIToolButton(m_pCnt Destination);80 m_pAccountToolButton = new QIToolButton(m_pCntSource); 87 81 if (m_pAccountToolButton) 88 82 { … … 99 93 100 94 /* Create profile property table: */ 101 m_pAccountPropertyTable = new QTableWidget(m_pCnt Destination);95 m_pAccountPropertyTable = new QTableWidget(m_pCntSource); 102 96 if (m_pAccountPropertyTable) 103 97 { … … 119 113 120 114 /* Create profile instances table: */ 121 m_pAccountI mageList = new QListWidget(m_pCntDestination);122 if (m_pAccountI mageList)115 m_pAccountInstanceList = new QListWidget(m_pCntSource); 116 if (m_pAccountInstanceList) 123 117 { 124 const QFontMetrics fm(m_pAccountI mageList->font());118 const QFontMetrics fm(m_pAccountInstanceList->font()); 125 119 const int iFontWidth = fm.width('x'); 126 120 const int iTotalWidth = 50 * iFontWidth; 127 121 const int iFontHeight = fm.height(); 128 122 const int iTotalHeight = 4 * iFontHeight; 129 m_pAccountImageList->setMinimumSize(QSize(iTotalWidth, iTotalHeight)); 130 //m_pAccountImageList->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); 131 m_pAccountImageList->setAlternatingRowColors(true); 123 m_pAccountInstanceList->setMinimumSize(QSize(iTotalWidth, iTotalHeight)); 124 //m_pAccountInstanceList->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); 125 m_pAccountInstanceList->setAlternatingRowColors(true); 126 m_pAccountInstanceList->setSelectionMode(QAbstractItemView::ExtendedSelection); 132 127 133 128 /* Add into layout: */ 134 m_pCloudContainerLayout->addWidget(m_pAccountI mageList, 2, 0);129 m_pCloudContainerLayout->addWidget(m_pAccountInstanceList, 2, 0); 135 130 } 136 131 137 132 /* Add into layout: */ 138 m_p DestinationLayout->addLayout(m_pCloudContainerLayout, 1, 0);133 m_pSourceLayout->addLayout(m_pCloudContainerLayout, 1, 0); 139 134 } 140 135 } 141 136 142 137 /* Add into layout: */ 143 pMainLayout->addWidget(m_pCntDestination); 144 } 145 146 /* Create settings container: */ 147 m_pSettingsCnt = new QGroupBox(this); 148 if (m_pSettingsCnt) 149 { 150 /* Create form editor layout: */ 151 QVBoxLayout *pFormEditorLayout = new QVBoxLayout(m_pSettingsCnt); 152 if (pFormEditorLayout) 153 { 154 /* Create form editor widget: */ 155 m_pFormEditor = new UIFormEditorWidget(m_pSettingsCnt); 156 if (m_pFormEditor) 157 { 158 /* Make form-editor fit 8 sections in height by default: */ 159 const int iDefaultSectionHeight = m_pFormEditor->verticalHeader() 160 ? m_pFormEditor->verticalHeader()->defaultSectionSize() 161 : 0; 162 if (iDefaultSectionHeight > 0) 163 m_pFormEditor->setMinimumHeight(8 * iDefaultSectionHeight); 164 165 /* Add into layout: */ 166 pFormEditorLayout->addWidget(m_pFormEditor); 167 } 168 } 169 170 /* Add into layout: */ 171 pMainLayout->addWidget(m_pSettingsCnt); 138 pMainLayout->addWidget(m_pCntSource); 172 139 } 173 140 } … … 176 143 if (gpManager) 177 144 connect(gpManager, &UIVirtualBoxManager::sigCloudProfileManagerChange, 178 this, &UIWizard NewCloudVMPageExpert::sltHandleDestinationChange);179 connect(m_p DestinationComboBox, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::activated),180 this, &UIWizard NewCloudVMPageExpert::sltHandleDestinationChange);145 this, &UIWizardAddCloudVMPageExpert::sltHandleSourceChange); 146 connect(m_pSourceComboBox, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::activated), 147 this, &UIWizardAddCloudVMPageExpert::sltHandleSourceChange); 181 148 connect(m_pAccountComboBox, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::currentIndexChanged), 182 this, &UIWizard NewCloudVMPageExpert::sltHandleAccountComboChange);149 this, &UIWizardAddCloudVMPageExpert::sltHandleAccountComboChange); 183 150 connect(m_pAccountToolButton, &QIToolButton::clicked, 184 this, &UIWizardNewCloudVMPageExpert::sltHandleAccountButtonClick); 185 connect(m_pAccountImageList, &QListWidget::currentRowChanged, 186 this, &UIWizardNewCloudVMPageExpert::sltHandleInstanceListChange); 187 } 188 189 bool UIWizardNewCloudVMPageExpert::event(QEvent *pEvent) 151 this, &UIWizardAddCloudVMPageExpert::sltHandleAccountButtonClick); 152 connect(m_pAccountInstanceList, &QListWidget::currentRowChanged, 153 this, &UIWizardAddCloudVMPageExpert::completeChanged); 154 155 /* Register fields: */ 156 registerField("instanceIds", this, "instanceIds"); 157 } 158 159 bool UIWizardAddCloudVMPageExpert::event(QEvent *pEvent) 190 160 { 191 161 /* Handle known event types: */ … … 207 177 } 208 178 209 void UIWizard NewCloudVMPageExpert::retranslateUi()210 { 211 /* Translate destinationcontainer: */212 m_pCnt Destination->setTitle(UIWizardNewCloudVM::tr("Destination"));213 214 /* Translate received values of Destinationcombo-box.179 void UIWizardAddCloudVMPageExpert::retranslateUi() 180 { 181 /* Translate source container: */ 182 m_pCntSource->setTitle(UIWizardAddCloudVM::tr("Source")); 183 184 /* Translate received values of Source combo-box. 215 185 * We are enumerating starting from 0 for simplicity: */ 216 for (int i = 0; i < m_pDestinationComboBox->count(); ++i) 217 { 218 m_pDestinationComboBox->setItemText(i, m_pDestinationComboBox->itemData(i, DestinationData_Name).toString()); 219 m_pDestinationComboBox->setItemData(i, UIWizardNewCloudVM::tr("Create VM for cloud service provider."), Qt::ToolTipRole); 220 } 221 222 /* Translate settings container: */ 223 m_pSettingsCnt->setTitle(UIWizardNewCloudVM::tr("Settings")); 186 for (int i = 0; i < m_pSourceComboBox->count(); ++i) 187 { 188 m_pSourceComboBox->setItemText(i, m_pSourceComboBox->itemData(i, SourceData_Name).toString()); 189 m_pSourceComboBox->setItemData(i, UIWizardAddCloudVM::tr("Add VM from cloud service provider."), Qt::ToolTipRole); 190 } 224 191 225 192 /* Update tool-tips: */ 226 update DestinationComboToolTip();193 updateSourceComboToolTip(); 227 194 updateAccountPropertyTableToolTips(); 228 195 } 229 196 230 void UIWizard NewCloudVMPageExpert::initializePage()197 void UIWizardAddCloudVMPageExpert::initializePage() 231 198 { 232 199 /* If wasn't polished yet: */ 233 if (!UIWizardNewCloudVMPage1::m_fPolished || !UIWizardNewCloudVMPage2::m_fPolished) 234 { 235 if (m_fFullWizard) 236 { 237 /* Populate destinations: */ 238 populateDestinations(); 239 /* Choose one of them, asynchronously: */ 240 QMetaObject::invokeMethod(this, "sltHandleDestinationChange", Qt::QueuedConnection); 241 } 242 else 243 { 244 /* Generate VSD form, asynchronously: */ 245 QMetaObject::invokeMethod(this, "sltInitShortWizardForm", Qt::QueuedConnection); 246 } 247 UIWizardNewCloudVMPage1::m_fPolished = true; 248 UIWizardNewCloudVMPage2::m_fPolished = true; 200 if (!UIWizardAddCloudVMPage1::m_fPolished) 201 { 202 /* Populate sources: */ 203 populateSources(); 204 /* Choose one of them, asynchronously: */ 205 QMetaObject::invokeMethod(this, "sltHandleSourceChange", Qt::QueuedConnection); 206 UIWizardAddCloudVMPage1::m_fPolished = true; 249 207 } 250 208 … … 253 211 } 254 212 255 bool UIWizard NewCloudVMPageExpert::isComplete() const213 bool UIWizardAddCloudVMPageExpert::isComplete() const 256 214 { 257 215 /* Initial result: */ 258 216 bool fResult = true; 259 217 260 /* Check cloud settings: */ 261 fResult = UIWizardNewCloudVMPage1::client().isNotNull() 262 && UIWizardNewCloudVMPage1::vsd().isNotNull(); 218 /* Make sure client is not NULL and 219 * at least one instance is selected: */ 220 fResult = UIWizardAddCloudVMPage1::client().isNotNull() 221 && !UIWizardAddCloudVMPage1::instanceIds().isEmpty(); 263 222 264 223 /* Return result: */ … … 266 225 } 267 226 268 bool UIWizard NewCloudVMPageExpert::validatePage()227 bool UIWizardAddCloudVMPageExpert::validatePage() 269 228 { 270 229 /* Initial result: */ … … 274 233 startProcessing(); 275 234 276 /* Make sure table has own data committed: */ 277 m_pFormEditor->makeSureEditorDataCommitted(); 278 279 /* Check whether we have proper VSD form: */ 280 CVirtualSystemDescriptionForm comForm = UIWizardNewCloudVMPage1::vsdForm(); 281 /* Give changed VSD back: */ 282 if (comForm.isNotNull()) 283 { 284 comForm.GetVirtualSystemDescription(); 285 fResult = comForm.isOk(); 286 if (!fResult) 287 msgCenter().cannotAcquireVirtualSystemDescriptionFormProperty(comForm); 288 } 289 290 /* Try to create cloud VM: */ 291 if (fResult) 292 { 293 fResult = qobject_cast<UIWizardNewCloudVM*>(wizard())->createCloudVM(); 294 295 /* If the final step failed we could try 296 * sugest user more valid form this time: */ 297 if (!fResult) 298 sltInitShortWizardForm(); 299 } 235 /* Try to add cloud VMs: */ 236 fResult = qobject_cast<UIWizardAddCloudVM*>(wizard())->addCloudVMs(); 300 237 301 238 /* Unlock finish button: */ … … 306 243 } 307 244 308 void UIWizard NewCloudVMPageExpert::sltHandleDestinationChange()245 void UIWizardAddCloudVMPageExpert::sltHandleSourceChange() 309 246 { 310 247 /* Update tool-tip: */ 311 update DestinationComboToolTip();312 313 /* Make i mage list focused by default: */314 m_pAccountI mageList->setFocus();248 updateSourceComboToolTip(); 249 250 /* Make instance list focused by default: */ 251 m_pAccountInstanceList->setFocus(); 315 252 316 253 /* Refresh required settings: */ 317 254 populateAccounts(); 318 255 populateAccountProperties(); 319 populateAccountImages(); 320 populateFormProperties(); 321 refreshFormPropertiesTable(); 256 populateAccountInstances(); 322 257 emit completeChanged(); 323 258 } 324 259 325 void UIWizard NewCloudVMPageExpert::sltHandleAccountComboChange()260 void UIWizardAddCloudVMPageExpert::sltHandleAccountComboChange() 326 261 { 327 262 /* Refresh required settings: */ 328 263 populateAccountProperties(); 329 populateAccountImages(); 330 populateFormProperties(); 331 refreshFormPropertiesTable(); 264 populateAccountInstances(); 332 265 emit completeChanged(); 333 266 } 334 267 335 void UIWizard NewCloudVMPageExpert::sltHandleAccountButtonClick()268 void UIWizardAddCloudVMPageExpert::sltHandleAccountButtonClick() 336 269 { 337 270 /* Open Cloud Profile Manager: */ … … 339 272 gpManager->openCloudProfileManager(); 340 273 } 341 342 void UIWizardNewCloudVMPageExpert::sltHandleInstanceListChange()343 {344 /* Refresh required settings: */345 populateFormProperties();346 refreshFormPropertiesTable();347 emit completeChanged();348 }349 350 void UIWizardNewCloudVMPageExpert::sltInitShortWizardForm()351 {352 /* Create Virtual System Description Form: */353 qobject_cast<UIWizardNewCloudVM*>(wizardImp())->createVSDForm();354 355 /* Refresh form properties table: */356 refreshFormPropertiesTable();357 emit completeChanged();358 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVMPageExpert.h
r83646 r83653 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIWizard NewCloudVMPageExpert class declaration.3 * VBox Qt GUI - UIWizardAddCloudVMPageExpert class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef FEQT_INCLUDED_SRC_wizards_ newcloudvm_UIWizardNewCloudVMPageExpert_h19 #define FEQT_INCLUDED_SRC_wizards_ newcloudvm_UIWizardNewCloudVMPageExpert_h18 #ifndef FEQT_INCLUDED_SRC_wizards_addcloudvm_UIWizardAddCloudVMPageExpert_h 19 #define FEQT_INCLUDED_SRC_wizards_addcloudvm_UIWizardAddCloudVMPageExpert_h 20 20 #ifndef RT_WITHOUT_PRAGMA_ONCE 21 21 # pragma once … … 23 23 24 24 /* GUI includes: */ 25 #include "UIWizardNewCloudVMPageBasic1.h" 26 #include "UIWizardNewCloudVMPageBasic2.h" 25 #include "UIWizardAddCloudVMPageBasic1.h" 27 26 28 27 /* Forward declarations: */ 29 28 class QGroupBox; 30 29 31 /** UIWizardPage extension for UIWizardNewCloudVMPage1 and UIWizardNewCloudVMPage2. */ 32 class UIWizardNewCloudVMPageExpert : public UIWizardPage, 33 public UIWizardNewCloudVMPage1, 34 public UIWizardNewCloudVMPage2 30 /** UIWizardPage extension for UIWizardAddCloudVMPage1. */ 31 class UIWizardAddCloudVMPageExpert : public UIWizardPage, 32 public UIWizardAddCloudVMPage1 35 33 { 36 34 Q_OBJECT; 35 Q_PROPERTY(QStringList instanceIds READ instanceIds); 37 36 38 37 public: 39 38 40 39 /** Constructs expert page. */ 41 UIWizard NewCloudVMPageExpert(bool fFullWizard);40 UIWizardAddCloudVMPageExpert(); 42 41 43 42 protected: … … 63 62 private slots: 64 63 65 /** Handles change in destinationcombo-box. */66 void sltHandle DestinationChange();64 /** Handles change in source combo-box. */ 65 void sltHandleSourceChange(); 67 66 68 67 /** Handles change in account combo-box. */ 69 68 void sltHandleAccountComboChange(); 69 70 70 /** Handles account tool-button click. */ 71 71 void sltHandleAccountButtonClick(); 72 72 73 /** Handles change in instance list. */74 void sltHandleInstanceListChange();75 76 /** Initializes short wizard form. */77 void sltInitShortWizardForm();78 79 73 private: 80 74 81 /** Holds the destination container instance. */ 82 QGroupBox *m_pCntDestination; 83 /** Holds the settings container instance. */ 84 QGroupBox *m_pSettingsCnt; 75 /** Holds the source container instance. */ 76 QGroupBox *m_pCntSource; 85 77 }; 86 78 87 #endif /* !FEQT_INCLUDED_SRC_wizards_ newcloudvm_UIWizardNewCloudVMPageExpert_h */79 #endif /* !FEQT_INCLUDED_SRC_wizards_addcloudvm_UIWizardAddCloudVMPageExpert_h */
Note:
See TracChangeset
for help on using the changeset viewer.