Changeset 91368 in vbox
- Timestamp:
- Sep 24, 2021 4:31:13 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 147042
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r91363 r91368 911 911 /* Use the "safe way" to open stack of Mac OS X Sheets: */ 912 912 QWidget *pWizardParent = windowManager().realParentWindow(this); 913 UISafePointerWizard pWizard = new UIWizardExportApp(pWizardParent, names, 914 pAction && 915 pAction == actionPool()->action(UIActionIndexMN_M_Machine_S_ExportToOCI)); 913 UINativeWizardPointer pWizard = new UIWizardExportApp(pWizardParent, 914 names, 915 pAction && 916 pAction == actionPool()->action(UIActionIndexMN_M_Machine_S_ExportToOCI)); 916 917 windowManager().registerNewParent(pWizard, pWizardParent); 917 pWizard->prepare();918 918 pWizard->exec(); 919 919 delete pWizard; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportApp.cpp
r91285 r91368 17 17 18 18 /* Qt includes: */ 19 #include <QAbstractButton>20 19 #include <QFileInfo> 20 #include <QPushButton> 21 21 #include <QVariant> 22 22 … … 35 35 /* COM includes: */ 36 36 #include "CAppliance.h" 37 38 /* COM includes: */39 37 #include "CVFSExplorer.h" 40 38 41 39 42 40 UIWizardExportApp::UIWizardExportApp(QWidget *pParent, 43 const QStringList & selectedVMNames /* = QStringList() */,41 const QStringList &predefinedMachineNames /* = QStringList() */, 44 42 bool fFastTraverToExportOCI /* = false */) 45 : UIWizard(pParent, WizardType_ExportAppliance) 46 , m_selectedVMNames(selectedVMNames) 43 : UINativeWizard(pParent, WizardType_ExportAppliance, WizardMode_Auto, 44 fFastTraverToExportOCI ? "cloud-export-oci" : "ovf") 45 , m_predefinedMachineNames(predefinedMachineNames) 47 46 , m_fFastTraverToExportOCI(fFastTraverToExportOCI) 47 , m_fFormatCloudOne(false) 48 48 { 49 49 #ifndef VBOX_WS_MAC 50 50 /* Assign watermark: */ 51 assignWatermark(":/wizard_ovf_export.png");51 setPixmapName(":/wizard_ovf_export.png"); 52 52 #else 53 53 /* Assign background image: */ 54 assignBackground(":/wizard_ovf_export_bg.png");54 setPixmapName(":/wizard_ovf_export_bg.png"); 55 55 #endif 56 56 } 57 57 58 QStringList UIWizardExportApp::machineNames() const 59 { 60 return m_machineNames; 61 } 62 63 void UIWizardExportApp::setMachineNames(const QStringList &names) 64 { 65 m_machineNames = names; 66 } 67 68 QList<QUuid> UIWizardExportApp::machineIDs() const 69 { 70 return m_machineIDs; 71 } 72 73 void UIWizardExportApp::setMachineIDs(const QList<QUuid> &ids) 74 { 75 m_machineIDs = ids; 76 } 77 78 QString UIWizardExportApp::format() const 79 { 80 return m_strFormat; 81 } 82 83 void UIWizardExportApp::setFormat(const QString &strFormat) 84 { 85 m_strFormat = strFormat; 86 } 87 88 bool UIWizardExportApp::isFormatCloudOne() const 89 { 90 return m_fFormatCloudOne; 91 } 92 93 void UIWizardExportApp::setFormatCloudOne(bool fCloudOne) 94 { 95 m_fFormatCloudOne = fCloudOne; 96 } 97 98 QString UIWizardExportApp::path() const 99 { 100 return m_strPath; 101 } 102 103 void UIWizardExportApp::setPath(const QString &strPath) 104 { 105 m_strPath = strPath; 106 } 107 108 MACAddressExportPolicy UIWizardExportApp::macAddressExportPolicy() const 109 { 110 return m_enmMACAddressExportPolicy; 111 } 112 113 void UIWizardExportApp::setMACAddressExportPolicy(MACAddressExportPolicy enmPolicy) 114 { 115 m_enmMACAddressExportPolicy = enmPolicy; 116 } 117 118 bool UIWizardExportApp::isManifestSelected() const 119 { 120 return m_fManifestSelected; 121 } 122 123 void UIWizardExportApp::setManifestSelected(bool fSelected) 124 { 125 m_fManifestSelected = fSelected; 126 } 127 128 bool UIWizardExportApp::isIncludeISOsSelected() const 129 { 130 return m_fIncludeISOsSelected; 131 } 132 133 void UIWizardExportApp::setIncludeISOsSelected(bool fSelected) 134 { 135 m_fIncludeISOsSelected = fSelected; 136 } 137 138 CAppliance UIWizardExportApp::localAppliance() 139 { 140 return m_comLocalAppliance; 141 } 142 143 void UIWizardExportApp::setLocalAppliance(const CAppliance &comAppliance) 144 { 145 m_comLocalAppliance = comAppliance; 146 } 147 148 QString UIWizardExportApp::profileName() const 149 { 150 return m_strProfileName; 151 } 152 153 void UIWizardExportApp::setProfileName(const QString &strName) 154 { 155 m_strProfileName = strName; 156 } 157 158 CAppliance UIWizardExportApp::cloudAppliance() 159 { 160 return m_comCloudAppliance; 161 } 162 163 void UIWizardExportApp::setCloudAppliance(const CAppliance &comAppliance) 164 { 165 m_comCloudAppliance = comAppliance; 166 } 167 168 CCloudClient UIWizardExportApp::cloudClient() 169 { 170 return m_comCloudClient; 171 } 172 173 void UIWizardExportApp::setCloudClient(const CCloudClient &comClient) 174 { 175 m_comCloudClient = comClient; 176 } 177 178 CVirtualSystemDescription UIWizardExportApp::vsd() 179 { 180 return m_comVsd; 181 } 182 183 void UIWizardExportApp::setVsd(const CVirtualSystemDescription &comDescription) 184 { 185 m_comVsd = comDescription; 186 } 187 188 CVirtualSystemDescriptionForm UIWizardExportApp::vsdExportForm() 189 { 190 return m_comVsdExportForm; 191 } 192 193 void UIWizardExportApp::setVsdExportForm(const CVirtualSystemDescriptionForm &comForm) 194 { 195 m_comVsdExportForm = comForm; 196 } 197 198 CloudExportMode UIWizardExportApp::cloudExportMode() const 199 { 200 return m_enmCloudExportMode; 201 } 202 203 void UIWizardExportApp::setCloudExportMode(const CloudExportMode &enmMode) 204 { 205 m_enmCloudExportMode = enmMode; 206 } 207 208 void UIWizardExportApp::goForward() 209 { 210 wizardButton(WizardButtonType_Next)->click(); 211 } 212 58 213 QString UIWizardExportApp::uri(bool fWithFile) const 59 214 { 60 215 /* For Cloud formats: */ 61 if ( field("isFormatCloudOne").toBool())62 return QString("%1://").arg(f ield("providerShortName").toString());216 if (isFormatCloudOne()) 217 return QString("%1://").arg(format()); 63 218 else 64 219 { 65 220 /* Prepare storage path: */ 66 QString strPath = field("path").toString();221 QString strPath = path(); 67 222 /* Append file name if requested: */ 68 223 if (!fWithFile) … … 80 235 { 81 236 /* Check whether there was cloud target selected: */ 82 const bool fIsFormatCloudOne = field("isFormatCloudOne").toBool(); 83 if (fIsFormatCloudOne) 237 if (isFormatCloudOne()) 84 238 { 85 239 /* Get appliance: */ 86 CAppliance comAppliance = field("cloudAppliance").value<CAppliance>();240 CAppliance comAppliance = cloudAppliance(); 87 241 AssertReturn(comAppliance.isNotNull(), false); 88 242 … … 93 247 { 94 248 /* Get appliance: */ 95 CAppliance comAppliance = field("localAppliance").value<CAppliance>();249 CAppliance comAppliance = localAppliance(); 96 250 AssertReturn(comAppliance.isNotNull(), false); 97 251 … … 101 255 102 256 /* Compose a list of all required files: */ 103 QFileInfo fi( field("path").toString());257 QFileInfo fi(path()); 104 258 QVector<QString> files; 105 259 … … 111 265 { 112 266 /* Add manifest file if requested: */ 113 if ( field("manifestSelected").toBool())267 if (isManifestSelected()) 114 268 files << fi.baseName() + ".mf"; 115 269 … … 174 328 } 175 329 176 void UIWizardExportApp::sltCurrentIdChanged(int iId) 177 { 178 /* Call to base-class: */ 179 UIWizard::sltCurrentIdChanged(iId); 180 181 /* Enable 2nd button (Reset to Defaults) for 3rd and Expert pages only! */ 182 setOption(QWizard::HaveCustomButton2, (mode() == WizardMode_Basic && iId == Page3) 183 || (mode() == WizardMode_Expert && iId == PageExpert)); 184 } 185 186 void UIWizardExportApp::retranslateUi() 187 { 188 /* Call to base-class: */ 189 UIWizard::retranslateUi(); 190 191 /* Translate wizard: */ 192 setWindowTitle(tr("Export Virtual Appliance")); 193 setButtonText(QWizard::CustomButton2, tr("Restore Defaults")); 194 setButtonText(QWizard::FinishButton, tr("Export")); 195 } 196 197 void UIWizardExportApp::prepare() 330 void UIWizardExportApp::populatePages() 198 331 { 199 332 /* Create corresponding pages: */ … … 202 335 case WizardMode_Basic: 203 336 { 204 setPage(Page1, new UIWizardExportAppPageBasic1(m_selectedVMNames));205 setPage(Page2,new UIWizardExportAppPageBasic2(m_fFastTraverToExportOCI));206 setPage(Page3,new UIWizardExportAppPageBasic3);337 addPage(new UIWizardExportAppPageBasic1(m_predefinedMachineNames, m_fFastTraverToExportOCI)); 338 addPage(new UIWizardExportAppPageBasic2(m_fFastTraverToExportOCI)); 339 addPage(new UIWizardExportAppPageBasic3); 207 340 break; 208 341 } 209 342 case WizardMode_Expert: 210 343 { 211 setPage(PageExpert, new UIWizardExportAppPageExpert(m_selectedVMNames, m_fFastTraverToExportOCI));344 addPage(new UIWizardExportAppPageExpert(m_predefinedMachineNames, m_fFastTraverToExportOCI)); 212 345 break; 213 346 } … … 218 351 } 219 352 } 220 221 if (!m_fFastTraverToExportOCI) 222 enableHelpButton("ovf"); 223 else 224 enableHelpButton("cloud-export-oci"); 225 353 } 354 355 void UIWizardExportApp::retranslateUi() 356 { 226 357 /* Call to base-class: */ 227 UIWizard::prepare(); 228 229 /* Now, when we are ready, we can 230 * fast traver to page 2 if requested: */ 231 if ( mode() == WizardMode_Basic 232 && m_fFastTraverToExportOCI) 233 button(QWizard::NextButton)->click(); 358 UINativeWizard::retranslateUi(); 359 360 /* Translate wizard: */ 361 setWindowTitle(tr("Export Virtual Appliance")); 362 /// @todo implement this? 363 //setButtonText(QWizard::FinishButton, tr("Export")); 234 364 } 235 365 … … 290 420 /* Prepare export options: */ 291 421 QVector<KExportOptions> options; 292 switch ( field("macAddressExportPolicy").value<MACAddressExportPolicy>())422 switch (macAddressExportPolicy()) 293 423 { 294 424 case MACAddressExportPolicy_StripAllNonNATMACs: options.append(KExportOptions_StripAllNonNATMACs); break; … … 296 426 default: break; 297 427 } 298 if ( field("manifestSelected").toBool())428 if (isManifestSelected()) 299 429 options.append(KExportOptions_CreateManifest); 300 if ( field("includeISOsSelected").toBool())430 if (isIncludeISOsSelected()) 301 431 options.append(KExportOptions_ExportDVDImages); 302 432 303 433 /* Is this VM being exported to cloud? */ 304 if ( field("isFormatCloudOne").toBool())434 if (isFormatCloudOne()) 305 435 { 306 436 /* We can have wizard and it's result … … 308 438 int iWizardResult = -1; 309 439 310 switch ( field("cloudExportMode").value<CloudExportMode>())440 switch (cloudExportMode()) 311 441 { 312 442 case CloudExportMode_AskThenExport: 313 443 { 314 444 /* Get the required parameters to init short wizard mode: */ 315 CCloudClient comClient = field("client").value<CCloudClient>();316 CVirtualSystemDescription comDescription = field("vsd").value<CVirtualSystemDescription>();445 CCloudClient comClient = cloudClient(); 446 CVirtualSystemDescription comDescription = vsd(); 317 447 /* Create and run wizard as modal dialog, but prevent final step: */ 318 pNewCloudVMWizard = new UIWizardNewCloudVM(this, QString() /** @todo pass proper full group name! */, comClient, comDescription, mode()); 448 QWidget *pWizardParent = windowManager().realParentWindow(this); 449 const QString strGroupName = QString("/%1/%2").arg(format(), profileName()); 450 pNewCloudVMWizard = new UIWizardNewCloudVM(pWizardParent, strGroupName, comClient, comDescription, mode()); 451 windowManager().registerNewParent(pNewCloudVMWizard, pWizardParent); 319 452 pNewCloudVMWizard->setFinalStepPrevented(true); 320 453 iWizardResult = pNewCloudVMWizard->exec(); … … 331 464 332 465 /* Prepare Export VM progress: */ 333 CProgress comProgress = comAppliance.Write(f ield("format").toString(), options, uri());466 CProgress comProgress = comAppliance.Write(format(), options, uri()); 334 467 if (!comAppliance.isOk()) 335 468 { … … 353 486 iWizardResult = -1; 354 487 355 switch ( field("cloudExportMode").value<CloudExportMode>())488 switch (cloudExportMode()) 356 489 { 357 490 case CloudExportMode_AskThenExport: … … 368 501 { 369 502 /* Get the required parameters to init short wizard mode: */ 370 CCloudClient comClient = field("client").value<CCloudClient>();371 CVirtualSystemDescription comDescription = field("vsd").value<CVirtualSystemDescription>();503 CCloudClient comClient = cloudClient(); 504 CVirtualSystemDescription comDescription = vsd(); 372 505 /* Create and run short wizard mode as modal dialog: */ 373 506 QWidget *pWizardParent = windowManager().realParentWindow(this); 374 pNewCloudVMWizard = new UIWizardNewCloudVM(pWizardParent, QString() /** @todo pass proper full group name! */, comClient, comDescription, mode()); 507 const QString strGroupName = QString("/%1/%2").arg(format(), profileName()); 508 pNewCloudVMWizard = new UIWizardNewCloudVM(pWizardParent, strGroupName, comClient, comDescription, mode()); 375 509 windowManager().registerNewParent(pNewCloudVMWizard, pWizardParent); 376 510 iWizardResult = pNewCloudVMWizard->exec(); … … 391 525 /* Export appliance: */ 392 526 UINotificationProgressApplianceExport *pNotification = new UINotificationProgressApplianceExport(comAppliance, 393 f ield("format").toString(),527 format(), 394 528 options, 395 529 uri()); -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportApp.h
r91285 r91368 23 23 24 24 /* GUI includes: */ 25 #include "UIWizard.h" 26 27 /* Forward declarations: */ 28 class CAppliance; 25 #include "UINativeWizard.h" 26 27 /* COM includes: */ 28 #include "COMEnums.h" 29 #include "CAppliance.h" 30 #include "CCloudClient.h" 31 #include "CVirtualSystemDescription.h" 32 #include "CVirtualSystemDescriptionForm.h" 33 34 /** MAC address export policies. */ 35 enum MACAddressExportPolicy 36 { 37 MACAddressExportPolicy_KeepAllMACs, 38 MACAddressExportPolicy_StripAllNonNATMACs, 39 MACAddressExportPolicy_StripAllMACs, 40 MACAddressExportPolicy_MAX 41 }; 42 Q_DECLARE_METATYPE(MACAddressExportPolicy); 43 44 /** Cloud export option modes. */ 45 enum CloudExportMode 46 { 47 CloudExportMode_Invalid, 48 CloudExportMode_AskThenExport, 49 CloudExportMode_ExportThenAsk, 50 CloudExportMode_DoNotAsk 51 }; 52 Q_DECLARE_METATYPE(CloudExportMode); 29 53 30 54 /** Export Appliance wizard. */ 31 class UIWizardExportApp : public UI Wizard55 class UIWizardExportApp : public UINativeWizard 32 56 { 33 57 Q_OBJECT; … … 35 59 public: 36 60 37 /** Basic page IDs. */ 38 enum 39 { 40 Page1, 41 Page2, 42 Page3 43 }; 44 45 /** Expert page IDs. */ 46 enum 47 { 48 PageExpert 49 }; 50 51 /** Constructs export appliance wizard passing @a pParent to the base-class. 52 * @param selectedVMNames Brings the names of VMs to be exported. */ 61 /** Constructs Export Appliance wizard passing @a pParent to the base-class. 62 * @param predefinedMachineNames Brings the predefined list of machine names. 63 * @param fFastTraverToExportOCI Brings whether wizard should start with OCI target. */ 53 64 UIWizardExportApp(QWidget *pParent, 54 const QStringList & selectedVMNames = QStringList(),65 const QStringList &predefinedMachineNames = QStringList(), 55 66 bool fFastTraverToExportOCI = false); 56 67 57 /** Composes universal resource identifier. 58 * @param fWithFile Brings whether uri should include file name as well. */ 59 QString uri(bool fWithFile = true) const; 60 61 /** Exports Appliance. */ 62 bool exportAppliance(); 63 64 protected slots: 65 66 /** Handles page change to @a iId. */ 67 virtual void sltCurrentIdChanged(int iId) /* override final */; 68 /** @name Common fields. 69 * @{ */ 70 /** Returns a list of machine names. */ 71 QStringList machineNames() const; 72 /** Defines a list of machine @a names. */ 73 void setMachineNames(const QStringList &names); 74 /** Returns a list of machine IDs. */ 75 QList<QUuid> machineIDs() const; 76 /** Defines a list of machine @a ids. */ 77 void setMachineIDs(const QList<QUuid> &ids); 78 79 /** Returns format. */ 80 QString format() const; 81 /** Defines @a strFormat. */ 82 void setFormat(const QString &strFormat); 83 84 /** Returns whether format is cloud one. */ 85 bool isFormatCloudOne() const; 86 /** Defines whether format is @a fCloudOne. */ 87 void setFormatCloudOne(bool fCloudOne); 88 /** @} */ 89 90 /** @name Local export fields. 91 * @{ */ 92 /** Returns path. */ 93 QString path() const; 94 /** Defines @a strPath. */ 95 void setPath(const QString &strPath); 96 97 /** Returns MAC address export policy. */ 98 MACAddressExportPolicy macAddressExportPolicy() const; 99 /** Defines MAC address export @a enmPolicy. */ 100 void setMACAddressExportPolicy(MACAddressExportPolicy enmPolicy); 101 102 /** Returns whether manifest is selected. */ 103 bool isManifestSelected() const; 104 /** Defines whether manifest is @a fSelected. */ 105 void setManifestSelected(bool fSelected); 106 107 /** Returns whether include ISOs is selected. */ 108 bool isIncludeISOsSelected() const; 109 /** Defines whether include ISOs is @a fSelected. */ 110 void setIncludeISOsSelected(bool fSelected); 111 112 /** Returns local appliance object. */ 113 CAppliance localAppliance(); 114 /** Defines local @a comAppliance object. */ 115 void setLocalAppliance(const CAppliance &comAppliance); 116 /** @} */ 117 118 /** @name Cloud export fields. 119 * @{ */ 120 /** Returns profile name. */ 121 QString profileName() const; 122 /** Defines profile @a strName. */ 123 void setProfileName(const QString &strName); 124 125 /** Returns cloud appliance object. */ 126 CAppliance cloudAppliance(); 127 /** Defines cloud @a comAppliance object. */ 128 void setCloudAppliance(const CAppliance &comAppliance); 129 130 /** Returns cloud client object. */ 131 CCloudClient cloudClient(); 132 /** Defines cloud @a comClient object. */ 133 void setCloudClient(const CCloudClient &comClient); 134 135 /** Returns virtual system description object. */ 136 CVirtualSystemDescription vsd(); 137 /** Defines virtual system @a comDescription object. */ 138 void setVsd(const CVirtualSystemDescription &comDescription); 139 140 /** Returns virtual system description export form object. */ 141 CVirtualSystemDescriptionForm vsdExportForm(); 142 /** Defines virtual system description export @a comForm object. */ 143 void setVsdExportForm(const CVirtualSystemDescriptionForm &comForm); 144 145 /** Returns cloud export mode. */ 146 CloudExportMode cloudExportMode() const; 147 /** Defines cloud export @a enmMode. */ 148 void setCloudExportMode(const CloudExportMode &enmMode); 149 /** @} */ 150 151 /** @name Auxiliary stuff. 152 * @{ */ 153 /** Goes forward. Required for fast travel to next page. */ 154 void goForward(); 155 156 /** Composes universal resource identifier. 157 * @param fWithFile Brings whether uri should include file name as well. */ 158 QString uri(bool fWithFile = true) const; 159 160 /** Exports Appliance. */ 161 bool exportAppliance(); 162 /** @} */ 68 163 69 164 protected: 70 165 71 /** Handles translation event. */ 72 virtual void retranslateUi() /* override final */; 73 74 /** Prepares all. */ 75 virtual void prepare() /* override final */; 166 /** @name Virtual stuff. 167 * @{ */ 168 /** Populates pages. */ 169 virtual void populatePages() /* override final */; 170 171 /** Handles translation event. */ 172 virtual void retranslateUi() /* override final */; 173 /** @} */ 76 174 77 175 private: 78 176 79 /** Exports VMs enumerated in @a comAppliance. */ 80 bool exportVMs(CAppliance &comAppliance); 81 82 /** Holds the names of VMs to be exported. */ 83 QStringList m_selectedVMNames; 84 /** Holds whether we should fast travel to page 2. */ 85 bool m_fFastTraverToExportOCI; 177 /** @name Auxiliary stuff. 178 * @{ */ 179 /** Exports VMs enumerated in @a comAppliance. */ 180 bool exportVMs(CAppliance &comAppliance); 181 /** @} */ 182 183 /** @name Arguments. 184 * @{ */ 185 /** Holds the predefined list of machine names. */ 186 QStringList m_predefinedMachineNames; 187 /** Holds whether we should fast travel to page 2. */ 188 bool m_fFastTraverToExportOCI; 189 /** @} */ 190 191 /** @name Common fields. 192 * @{ */ 193 /** Holds the list of machine names. */ 194 QStringList m_machineNames; 195 /** Holds the list of machine IDs. */ 196 QList<QUuid> m_machineIDs; 197 198 /** Holds the format. */ 199 QString m_strFormat; 200 /** Holds whether format is cloud one. */ 201 bool m_fFormatCloudOne; 202 /** @} */ 203 204 /** @name Local export fields. 205 * @{ */ 206 /** Holds the path. */ 207 QString m_strPath; 208 /** Holds the MAC address export policy. */ 209 MACAddressExportPolicy m_enmMACAddressExportPolicy; 210 /** Holds whether manifest is selected. */ 211 bool m_fManifestSelected; 212 /** Holds whether ISOs are included. */ 213 bool m_fIncludeISOsSelected; 214 /** Holds local appliance object. */ 215 CAppliance m_comLocalAppliance; 216 /** @} */ 217 218 /** @name Cloud export fields. 219 * @{ */ 220 /** Holds profile name. */ 221 QString m_strProfileName; 222 /** Holds cloud appliance object. */ 223 CAppliance m_comCloudAppliance; 224 /** Returns cloud client object. */ 225 CCloudClient m_comCloudClient; 226 /** Returns virtual system description object. */ 227 CVirtualSystemDescription m_comVsd; 228 /** Returns virtual system description export form object. */ 229 CVirtualSystemDescriptionForm m_comVsdExportForm; 230 /** Returns cloud export mode. */ 231 CloudExportMode m_enmCloudExportMode; 232 /** @} */ 86 233 }; 87 234 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic1.cpp
r91363 r91368 21 21 22 22 /* GUI includes: */ 23 #include "QILabelSeparator.h"24 23 #include "QIRichTextLabel.h" 25 24 #include "UICommon.h" … … 32 31 #include "CMachine.h" 33 32 33 /* Namespaces: */ 34 using namespace UIWizardExportAppPage1; 35 34 36 35 37 /** QListWidgetItem subclass for Export Appliance wizard VM list. */ … … 41 43 * @param strUuid Brings the machine ID. 42 44 * @param fInSaveState Brings whether machine is in Saved state. */ 43 UIVMListWidgetItem(QPixmap &pixIcon, QString &strText, QUuid aUuid, bool fInSaveState, QListWidget *pParent)45 UIVMListWidgetItem(QPixmap &pixIcon, QString &strText, QUuid uUuid, bool fInSaveState, QListWidget *pParent) 44 46 : QListWidgetItem(pixIcon, strText, pParent) 45 , m_uUuid( aUuid)47 , m_uUuid(uUuid) 46 48 , m_fInSaveState(fInSaveState) 47 49 {} … … 61 63 62 64 /** Holds the machine ID. */ 63 QUuid 65 QUuid m_uUuid; 64 66 /** Holds whether machine is in Saved state. */ 65 bool 67 bool m_fInSaveState; 66 68 }; 67 69 … … 71 73 *********************************************************************************************************************************/ 72 74 73 UIWizardExportAppPage1::UIWizardExportAppPage1() 74 { 75 } 76 77 void UIWizardExportAppPage1::populateVMSelectorItems(const QStringList &selectedVMNames) 75 void UIWizardExportAppPage1::populateVMItems(QListWidget *pVMSelector, const QStringList &selectedVMNames) 78 76 { 79 77 /* Add all VM items into VM selector: */ 80 foreach (const CMachine & machine, uiCommon().virtualBox().GetMachines())78 foreach (const CMachine &comMachine, uiCommon().virtualBox().GetMachines()) 81 79 { 82 80 QPixmap pixIcon; … … 85 83 bool fInSaveState = false; 86 84 bool fEnabled = false; 87 const QStyle *pStyle = QApplication::style(); 88 const int iIconMetric = pStyle->pixelMetric(QStyle::PM_SmallIconSize); 89 if (machine.GetAccessible()) 90 { 91 pixIcon = generalIconPool().userMachinePixmapDefault(machine); 85 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize); 86 if (comMachine.GetAccessible()) 87 { 88 pixIcon = generalIconPool().userMachinePixmapDefault(comMachine); 92 89 if (pixIcon.isNull()) 93 pixIcon = generalIconPool().guestOSTypePixmapDefault( machine.GetOSTypeId());94 strName = machine.GetName();95 uUuid = machine.GetId();96 fEnabled = machine.GetSessionState() == KSessionState_Unlocked;97 fInSaveState = machine.GetState() == KMachineState_Saved || machine.GetState() == KMachineState_AbortedSaved;90 pixIcon = generalIconPool().guestOSTypePixmapDefault(comMachine.GetOSTypeId()); 91 strName = comMachine.GetName(); 92 uUuid = comMachine.GetId(); 93 fEnabled = comMachine.GetSessionState() == KSessionState_Unlocked; 94 fInSaveState = comMachine.GetState() == KMachineState_Saved || comMachine.GetState() == KMachineState_AbortedSaved; 98 95 } 99 96 else 100 97 { 101 QString settingsFile = machine.GetSettingsFilePath(); 102 QFileInfo fi(settingsFile); 98 QFileInfo fi(comMachine.GetSettingsFilePath()); 103 99 strName = UICommon::hasAllowedExtension(fi.completeSuffix(), VBoxFileExts) ? fi.completeBaseName() : fi.fileName(); 104 100 pixIcon = QPixmap(":/os_other.png").scaled(iIconMetric, iIconMetric, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 105 101 } 106 QListWidgetItem *pItem = new UIVMListWidgetItem(pixIcon, strName, uUuid, fInSaveState, m_pVMSelector);102 QListWidgetItem *pItem = new UIVMListWidgetItem(pixIcon, strName, uUuid, fInSaveState, pVMSelector); 107 103 if (!fEnabled) 108 104 pItem->setFlags(Qt::ItemFlags()); 109 m_pVMSelector->addItem(pItem);110 } 111 m_pVMSelector->sortItems();105 pVMSelector->addItem(pItem); 106 } 107 pVMSelector->sortItems(); 112 108 113 109 /* Choose initially selected items (if passed): */ 114 for (int i = 0; i < selectedVMNames.size(); ++i)115 { 116 QList<QListWidgetItem*> list = m_pVMSelector->findItems(selectedVMNames[i], Qt::MatchExactly);110 foreach (const QString &strSelectedVMName, selectedVMNames) 111 { 112 const QList<QListWidgetItem*> list = pVMSelector->findItems(strSelectedVMName, Qt::MatchExactly); 117 113 if (list.size() > 0) 118 114 { 119 if ( m_pVMSelector->selectedItems().isEmpty())120 m_pVMSelector->setCurrentItem(list.first());115 if (pVMSelector->selectedItems().isEmpty()) 116 pVMSelector->setCurrentItem(list.first()); 121 117 else 122 118 list.first()->setSelected(true); … … 125 121 } 126 122 127 QStringList UIWizardExportAppPage1::machineNames() const 123 void UIWizardExportAppPage1::refreshSavedMachines(QStringList &savedMachines, QListWidget *pVMSelector) 124 { 125 savedMachines.clear(); 126 foreach (QListWidgetItem *pItem, pVMSelector->selectedItems()) 127 if (static_cast<UIVMListWidgetItem*>(pItem)->isInSaveState()) 128 savedMachines << pItem->text(); 129 } 130 131 QStringList UIWizardExportAppPage1::machineNames(QListWidget *pVMSelector) 128 132 { 129 133 /* Prepare list: */ 130 QStringList machineNames;134 QStringList names; 131 135 /* Iterate over all the selected items: */ 132 foreach (QListWidgetItem *pItem, m_pVMSelector->selectedItems())133 machineNames << pItem->text();136 foreach (QListWidgetItem *pItem, pVMSelector->selectedItems()) 137 names << pItem->text(); 134 138 /* Return result list: */ 135 return machineNames;136 } 137 138 QList<QUuid> UIWizardExportAppPage1::machineIDs( ) const139 return names; 140 } 141 142 QList<QUuid> UIWizardExportAppPage1::machineIDs(QListWidget *pVMSelector) 139 143 { 140 144 /* Prepare list: */ 141 QList<QUuid> machineIDs;145 QList<QUuid> ids; 142 146 /* Iterate over all the selected items: */ 143 foreach (QListWidgetItem *pItem, m_pVMSelector->selectedItems())144 machineIDs.append(static_cast<UIVMListWidgetItem*>(pItem)->uuid());147 foreach (QListWidgetItem *pItem, pVMSelector->selectedItems()) 148 ids.append(static_cast<UIVMListWidgetItem*>(pItem)->uuid()); 145 149 /* Return result list: */ 146 return machineIDs;150 return ids; 147 151 } 148 152 … … 152 156 *********************************************************************************************************************************/ 153 157 154 UIWizardExportAppPageBasic1::UIWizardExportAppPageBasic1(const QStringList &selectedVMNames) 155 { 156 /* Create main layout: */ 157 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 158 if (pMainLayout) 159 { 160 /* Create label: */ 161 m_pLabel = new QIRichTextLabel; 162 if (m_pLabel) 163 { 164 /* Add into layout: */ 165 pMainLayout->addWidget(m_pLabel); 166 } 167 168 /* Create VM selector: */ 169 m_pVMSelector = new QListWidget; 158 UIWizardExportAppPageBasic1::UIWizardExportAppPageBasic1(const QStringList &selectedVMNames, bool fFastTravelToNextPage) 159 : m_selectedVMNames(selectedVMNames) 160 , m_fFastTravelToNextPage(fFastTravelToNextPage) 161 , m_pLabelMain(0) 162 , m_pVMSelector(0) 163 { 164 /* Prepare main layout: */ 165 QVBoxLayout *pLayoutMain = new QVBoxLayout(this); 166 if (pLayoutMain) 167 { 168 /* Prepare main label: */ 169 m_pLabelMain = new QIRichTextLabel(this); 170 if (m_pLabelMain) 171 pLayoutMain->addWidget(m_pLabelMain); 172 173 /* Prepare VM selector: */ 174 m_pVMSelector = new QListWidget(this); 170 175 if (m_pVMSelector) 171 176 { 172 177 m_pVMSelector->setAlternatingRowColors(true); 173 178 m_pVMSelector->setSelectionMode(QAbstractItemView::ExtendedSelection); 174 175 /* Add into layout: */ 176 pMainLayout->addWidget(m_pVMSelector); 177 } 178 } 179 180 /* Populate VM selector items: */ 181 populateVMSelectorItems(selectedVMNames); 179 pLayoutMain->addWidget(m_pVMSelector); 180 } 181 } 182 182 183 183 /* Setup connections: */ 184 connect(m_pVMSelector, &QListWidget::itemSelectionChanged, this, &UIWizardExportAppPageBasic1::completeChanged); 185 186 /* Register fields: */ 187 registerField("machineNames", this, "machineNames"); 188 registerField("machineIDs", this, "machineIDs"); 184 connect(m_pVMSelector, &QListWidget::itemSelectionChanged, 185 this, &UIWizardExportAppPageBasic1::sltHandleVMItemSelectionChanged); 186 } 187 188 UIWizardExportApp *UIWizardExportAppPageBasic1::wizard() const 189 { 190 return qobject_cast<UIWizardExportApp*>(UINativeWizardPage::wizard()); 189 191 } 190 192 … … 195 197 196 198 /* Translate widgets: */ 197 m_pLabel ->setText(UIWizardExportApp::tr("<p>Please select the virtual machines that should be added to the appliance. "198 "You can select more than one. Please note that these machines have to be "199 "turned off before they can be exported.</p>"));199 m_pLabelMain->setText(UIWizardExportApp::tr("<p>Please select the virtual machines that should be added to the appliance. " 200 "You can select more than one. Please note that these machines have to be " 201 "turned off before they can be exported.</p>")); 200 202 } 201 203 202 204 void UIWizardExportAppPageBasic1::initializePage() 203 205 { 206 /* Populate VM items: */ 207 populateVMItems(m_pVMSelector, m_selectedVMNames); 204 208 /* Translate page: */ 205 209 retranslateUi(); 210 211 /* Now, when we are ready, we can 212 * fast traver to page 2 if requested: */ 213 if (m_fFastTravelToNextPage) 214 wizard()->goForward(); 206 215 } 207 216 208 217 bool UIWizardExportAppPageBasic1::isComplete() const 209 {210 /* There should be at least one VM selected: */211 return m_pVMSelector->selectedItems().size() > 0;212 }213 214 bool UIWizardExportAppPageBasic1::validatePage()215 218 { 216 219 /* Initial result: */ 217 220 bool fResult = true; 218 221 222 /* There should be at least one VM selected: */ 223 fResult = wizard()->machineNames().size() > 0; 224 225 /* Return result: */ 226 return fResult; 227 } 228 229 bool UIWizardExportAppPageBasic1::validatePage() 230 { 231 /* Initial result: */ 232 bool fResult = true; 233 219 234 /* Ask user about machines which are in Saved state currently: */ 220 235 QStringList savedMachines; 221 QList<QListWidgetItem*> items = m_pVMSelector->selectedItems(); 222 for (int i=0; i < items.size(); ++i) 223 { 224 if (static_cast<UIVMListWidgetItem*>(items.at(i))->isInSaveState()) 225 savedMachines << items.at(i)->text(); 226 } 236 refreshSavedMachines(savedMachines, m_pVMSelector); 227 237 if (!savedMachines.isEmpty()) 228 238 fResult = msgCenter().confirmExportMachinesInSaveState(savedMachines, this); … … 231 241 return fResult; 232 242 } 243 244 void UIWizardExportAppPageBasic1::sltHandleVMItemSelectionChanged() 245 { 246 updateMachines(); 247 emit completeChanged(); 248 } 249 250 void UIWizardExportAppPageBasic1::updateMachines() 251 { 252 /* Update wizard fields: */ 253 wizard()->setMachineNames(machineNames(m_pVMSelector)); 254 wizard()->setMachineIDs(machineIDs(m_pVMSelector)); 255 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic1.h
r82968 r91368 5 5 6 6 /* 7 * Copyright (C) 2009-202 0Oracle Corporation7 * Copyright (C) 2009-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 26 26 27 27 /* GUI includes: */ 28 #include "UI WizardPage.h"28 #include "UINativeWizardPage.h" 29 29 30 30 /* Forward declarations: */ 31 31 class QListWidget; 32 32 class QIRichTextLabel; 33 class UIWizardExportApp; 33 34 35 /** Namespace for 1st basic page of the Export Appliance wizard. */ 36 namespace UIWizardExportAppPage1 37 { 38 /** Populates @a pVMSelector with items on the basis of passed @a selectedVMNames. */ 39 void populateVMItems(QListWidget *pVMSelector, const QStringList &selectedVMNames); 34 40 35 /** UIWizardPageBase extension for 1st page of the Export Appliance wizard. */ 36 class UIWizardExportAppPage1 : public UIWizardPageBase 37 { 38 protected: 41 /** Refresh a list of saved machines selected in @a pVMSelector. */ 42 void refreshSavedMachines(QStringList &savedMachines, QListWidget *pVMSelector); 39 43 40 /** Constructs 1st page base. */ 41 UIWizardExportAppPage1(); 44 /** Returns a list of machine names selected in @a pVMSelector. */ 45 QStringList machineNames(QListWidget *pVMSelector); 46 /** Returns a list of machine IDs selected in @a pVMSelector. */ 47 QList<QUuid> machineIDs(QListWidget *pVMSelector); 48 } 42 49 43 /** Populates VM selector items on the basis of passed @a selectedVMNames. */ 44 void populateVMSelectorItems(const QStringList &selectedVMNames); 45 46 /** Returns a list of selected machine names. */ 47 QStringList machineNames() const; 48 /** Returns a list of selected machine IDs. */ 49 QList<QUuid> machineIDs() const; 50 51 /** Holds the VM selector instance. */ 52 QListWidget *m_pVMSelector; 53 }; 54 55 56 /** UIWizardPage extension for 1st page of the Export Appliance wizard, extends UIWizardExportAppPage1 as well. */ 57 class UIWizardExportAppPageBasic1 : public UIWizardPage, public UIWizardExportAppPage1 50 /** UINativeWizardPage extension for 1st basic page of the Export Appliance wizard, 51 * based on UIWizardAddCloudVMPage1 namespace functions. */ 52 class UIWizardExportAppPageBasic1 : public UINativeWizardPage 58 53 { 59 54 Q_OBJECT; 60 Q_PROPERTY(QStringList machineNames READ machineNames);61 Q_PROPERTY(QList<QUuid> machineIDs READ machineIDs);62 55 63 56 public: 64 57 65 58 /** Constructs 1st basic page. 66 * @param selectedVMNames Brings the list of selected VM names. */ 67 UIWizardExportAppPageBasic1(const QStringList &selectedVMNames); 59 * @param selectedVMNames Brings the list of selected VM names. 60 * @param fFastTravelToNextPage Brings whether we should fast-travel to next page. */ 61 UIWizardExportAppPageBasic1(const QStringList &selectedVMNames, bool fFastTravelToNextPage); 68 62 69 private: 63 protected: 64 65 /** Returns wizard this page belongs to. */ 66 UIWizardExportApp *wizard() const; 70 67 71 68 /** Handles translation event. */ … … 81 78 virtual bool validatePage() /* override */; 82 79 80 private slots: 81 82 /** Handles VM item selection change. */ 83 void sltHandleVMItemSelectionChanged(); 84 83 85 private: 84 86 85 /** Holds the label instance. */ 86 QIRichTextLabel *m_pLabel; 87 /** Updates machines. */ 88 void updateMachines(); 89 90 /** Holds the list of selected VM names. */ 91 const QStringList m_selectedVMNames; 92 /** Holds whether we should fast travel to next page. */ 93 bool m_fFastTravelToNextPage; 94 95 /** Holds the main label instance. */ 96 QIRichTextLabel *m_pLabelMain; 97 /** Holds the VM selector instance. */ 98 QListWidget *m_pVMSelector; 87 99 }; 88 100 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic2.cpp
r91262 r91368 5 5 6 6 /* 7 * Copyright (C) 2009-202 0Oracle Corporation7 * Copyright (C) 2009-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 17 18 18 /* Qt includes: */ 19 #include <QButtonGroup> 19 20 #include <QCheckBox> 20 #include <QComboBox>21 21 #include <QDir> 22 22 #include <QGridLayout> 23 #include <QHeaderView>24 23 #include <QLabel> 25 24 #include <QRadioButton> 26 25 #include <QStackedWidget> 27 #include <QTableWidget>28 26 #include <QVBoxLayout> 29 27 30 28 /* GUI includes: */ 29 #include "QIComboBox.h" 31 30 #include "QIRichTextLabel.h" 32 31 #include "QIToolButton.h" 33 32 #include "UICloudNetworkingStuff.h" 34 33 #include "UICommon.h" 35 #include "UIConverter.h"36 34 #include "UIEmptyFilePathSelector.h" 37 35 #include "UIIconPool.h" … … 46 44 #include "CSystemProperties.h" 47 45 46 /* Namespaces: */ 47 using namespace UIWizardExportAppPage2; 48 48 49 49 50 /********************************************************************************************************************************* … … 51 52 *********************************************************************************************************************************/ 52 53 53 UIWizardExportAppPage2::UIWizardExportAppPage2(bool fExportToOCIByDefault) 54 void UIWizardExportAppPage2::populateFormats(QIComboBox *pCombo, bool fExportToOCIByDefault) 55 { 56 /* Sanity check: */ 57 AssertPtrReturnVoid(pCombo); 58 /* We need top-level parent as well: */ 59 QWidget *pParent = pCombo->window(); 60 AssertPtrReturnVoid(pParent); 61 62 /* Remember current item data to be able to restore it: */ 63 QString strOldData; 64 if (pCombo->currentIndex() != -1) 65 strOldData = pCombo->currentData(FormatData_ShortName).toString(); 66 else 67 { 68 /* Otherwise "OCI" or "ovf-1.0" should be the default one: */ 69 if (fExportToOCIByDefault) 70 strOldData = "OCI"; 71 else 72 strOldData = "ovf-1.0"; 73 } 74 75 /* Block signals while updating: */ 76 pCombo->blockSignals(true); 77 78 /* Clear combo initially: */ 79 pCombo->clear(); 80 81 /* Compose hardcoded format list: */ 82 QStringList formats; 83 formats << "ovf-0.9"; 84 formats << "ovf-1.0"; 85 formats << "ovf-2.0"; 86 /* Add that list to combo: */ 87 foreach (const QString &strShortName, formats) 88 { 89 /* Compose empty item, fill it's data: */ 90 pCombo->addItem(QString()); 91 pCombo->setItemData(pCombo->count() - 1, strShortName, FormatData_ShortName); 92 } 93 94 /* Iterate through existing providers: */ 95 foreach (const CCloudProvider &comProvider, listCloudProviders(pParent)) 96 { 97 /* Skip if we have nothing to populate (file missing?): */ 98 if (comProvider.isNull()) 99 continue; 100 /* Acquire provider name: */ 101 QString strProviderName; 102 if (!cloudProviderName(comProvider, strProviderName, pParent)) 103 continue; 104 /* Acquire provider short name: */ 105 QString strProviderShortName; 106 if (!cloudProviderShortName(comProvider, strProviderShortName, pParent)) 107 continue; 108 109 /* Compose empty item, fill it's data: */ 110 pCombo->addItem(QString()); 111 pCombo->setItemData(pCombo->count() - 1, strProviderName, FormatData_Name); 112 pCombo->setItemData(pCombo->count() - 1, strProviderShortName, FormatData_ShortName); 113 pCombo->setItemData(pCombo->count() - 1, true, FormatData_IsItCloudFormat); 114 } 115 116 /* Set previous/default item if possible: */ 117 int iNewIndex = -1; 118 if ( iNewIndex == -1 119 && !strOldData.isNull()) 120 iNewIndex = pCombo->findData(strOldData, FormatData_ShortName); 121 if ( iNewIndex == -1 122 && pCombo->count() > 0) 123 iNewIndex = 0; 124 if (iNewIndex != -1) 125 pCombo->setCurrentIndex(iNewIndex); 126 127 /* Unblock signals after update: */ 128 pCombo->blockSignals(false); 129 } 130 131 void UIWizardExportAppPage2::populateMACAddressPolicies(QIComboBox *pCombo) 132 { 133 /* Sanity check: */ 134 AssertPtrReturnVoid(pCombo); 135 /* We need top-level parent as well: */ 136 QWidget *pParent = pCombo->window(); 137 AssertPtrReturnVoid(pParent); 138 139 /* Map known export options to known MAC address export policies: */ 140 QMap<KExportOptions, MACAddressExportPolicy> knownOptions; 141 knownOptions[KExportOptions_StripAllMACs] = MACAddressExportPolicy_StripAllMACs; 142 knownOptions[KExportOptions_StripAllNonNATMACs] = MACAddressExportPolicy_StripAllNonNATMACs; 143 /* Load currently supported export options: */ 144 const QVector<KExportOptions> supportedOptions = 145 uiCommon().virtualBox().GetSystemProperties().GetSupportedExportOptions(); 146 /* Check which of supported options/policies are known: */ 147 QList<MACAddressExportPolicy> supportedPolicies; 148 foreach (const KExportOptions &enmOption, supportedOptions) 149 if (knownOptions.contains(enmOption)) 150 supportedPolicies << knownOptions.value(enmOption); 151 152 /* Remember current item data to be able to restore it: */ 153 MACAddressExportPolicy enmOldData = MACAddressExportPolicy_MAX; 154 if (pCombo->currentIndex() != -1) 155 enmOldData = pCombo->currentData().value<MACAddressExportPolicy>(); 156 else 157 { 158 if (supportedPolicies.contains(MACAddressExportPolicy_StripAllNonNATMACs)) 159 enmOldData = MACAddressExportPolicy_StripAllNonNATMACs; 160 else 161 enmOldData = MACAddressExportPolicy_KeepAllMACs; 162 } 163 164 /* Block signals while updating: */ 165 pCombo->blockSignals(true); 166 167 /* Clear combo initially: */ 168 pCombo->clear(); 169 170 /* Add supported policies first: */ 171 foreach (const MACAddressExportPolicy &enmPolicy, supportedPolicies) 172 pCombo->addItem(QString(), QVariant::fromValue(enmPolicy)); 173 174 /* Add hardcoded policy finally: */ 175 pCombo->addItem(QString(), QVariant::fromValue(MACAddressExportPolicy_KeepAllMACs)); 176 177 /* Set previous/default item if possible: */ 178 int iNewIndex = -1; 179 if ( iNewIndex == -1 180 && enmOldData != MACAddressExportPolicy_MAX) 181 iNewIndex = pCombo->findData(QVariant::fromValue(enmOldData)); 182 if ( iNewIndex == -1 183 && pCombo->count() > 0) 184 iNewIndex = 0; 185 if (iNewIndex != -1) 186 pCombo->setCurrentIndex(iNewIndex); 187 188 /* Unblock signals after update: */ 189 pCombo->blockSignals(false); 190 } 191 192 QString UIWizardExportAppPage2::format(QIComboBox *pCombo) 193 { 194 return pCombo->currentData(FormatData_ShortName).toString(); 195 } 196 197 bool UIWizardExportAppPage2::isFormatCloudOne(QIComboBox *pCombo, int iIndex /* = -1 */) 198 { 199 /* Sanity check: */ 200 AssertPtrReturn(pCombo, false); 201 202 /* Handle special case, -1 means "current one": */ 203 if (iIndex == -1) 204 iIndex = pCombo->currentIndex(); 205 206 /* Give the actual result: */ 207 return pCombo->itemData(iIndex, FormatData_IsItCloudFormat).toBool(); 208 } 209 210 void UIWizardExportAppPage2::refreshStackedWidget(QStackedWidget *pStackedWidget, bool fIsFormatCloudOne) 211 { 212 /* Update stack appearance according to chosen format: */ 213 pStackedWidget->setCurrentIndex((int)fIsFormatCloudOne); 214 } 215 216 void UIWizardExportAppPage2::refreshFileSelectorName(QString &strFileSelectorName, 217 const QStringList &machineNames, 218 const QString &strDefaultApplianceName, 219 bool fIsFormatCloudOne) 220 { 221 /* If format is cloud one: */ 222 if (fIsFormatCloudOne) 223 { 224 /* We use no name: */ 225 strFileSelectorName.clear(); 226 } 227 /* If format is local one: */ 228 else 229 { 230 /* If it's one VM only, we use the VM name as file-name: */ 231 if (machineNames.size() == 1) 232 strFileSelectorName = machineNames.first(); 233 /* Otherwise => we use the default file-name: */ 234 else 235 strFileSelectorName = strDefaultApplianceName; 236 } 237 } 238 239 void UIWizardExportAppPage2::refreshFileSelectorExtension(QString &strFileSelectorExt, 240 UIEmptyFilePathSelector *pFileSelector, 241 bool fIsFormatCloudOne) 242 { 243 /* If format is cloud one: */ 244 if (fIsFormatCloudOne) 245 { 246 /* We use no extension: */ 247 strFileSelectorExt.clear(); 248 249 /* Update file chooser accordingly: */ 250 pFileSelector->setFileFilters(QString()); 251 } 252 /* If format is local one: */ 253 else 254 { 255 /* We use the default (.ova) extension: */ 256 strFileSelectorExt = ".ova"; 257 258 /* Update file chooser accordingly: */ 259 pFileSelector->setFileFilters(UIWizardExportApp::tr("Open Virtualization Format Archive (%1)").arg("*.ova") + ";;" + 260 UIWizardExportApp::tr("Open Virtualization Format (%1)").arg("*.ovf")); 261 } 262 } 263 264 void UIWizardExportAppPage2::refreshFileSelectorPath(UIEmptyFilePathSelector *pFileSelector, 265 const QString &strFileSelectorName, 266 const QString &strFileSelectorExt, 267 bool fIsFormatCloudOne) 268 { 269 /* If format is cloud one: */ 270 if (fIsFormatCloudOne) 271 { 272 /* Clear file selector path: */ 273 pFileSelector->setPath(QString()); 274 } 275 /* If format is local one: */ 276 else 277 { 278 /* Compose file selector path: */ 279 const QString strPath = QDir::toNativeSeparators(QString("%1/%2") 280 .arg(uiCommon().documentsPath()) 281 .arg(strFileSelectorName + strFileSelectorExt)); 282 pFileSelector->setPath(strPath); 283 } 284 } 285 286 void UIWizardExportAppPage2::refreshManifestCheckBoxAccess(QCheckBox *pCheckBox, 287 bool fIsFormatCloudOne) 288 { 289 /* If format is cloud one: */ 290 if (fIsFormatCloudOne) 291 { 292 /* Disable manifest check-box: */ 293 pCheckBox->setChecked(false); 294 pCheckBox->setEnabled(false); 295 } 296 /* If format is local one: */ 297 else 298 { 299 /* Enable and select manifest check-box: */ 300 pCheckBox->setChecked(true); 301 pCheckBox->setEnabled(true); 302 } 303 } 304 305 void UIWizardExportAppPage2::refreshIncludeISOsCheckBoxAccess(QCheckBox *pCheckBox, 306 bool fIsFormatCloudOne) 307 { 308 /* If format is cloud one: */ 309 if (fIsFormatCloudOne) 310 { 311 /* Disable include ISO check-box: */ 312 pCheckBox->setChecked(false); 313 pCheckBox->setEnabled(false); 314 } 315 /* If format is local one: */ 316 else 317 { 318 /* Enable include ISO check-box: */ 319 pCheckBox->setEnabled(true); 320 } 321 } 322 323 void UIWizardExportAppPage2::refreshProfileCombo(QIComboBox *pCombo, 324 const QString &strFormat, 325 bool fIsFormatCloudOne) 326 { 327 /* Sanity check: */ 328 AssertPtrReturnVoid(pCombo); 329 330 /* If format is cloud one: */ 331 if (fIsFormatCloudOne) 332 { 333 /* We need top-level parent as well: */ 334 QWidget *pParent = pCombo->window(); 335 AssertPtrReturnVoid(pParent); 336 /* Acquire provider: */ 337 CCloudProvider comProvider = cloudProviderByShortName(strFormat, pParent); 338 AssertReturnVoid(comProvider.isNotNull()); 339 340 /* Remember current item data to be able to restore it: */ 341 QString strOldData; 342 if (pCombo->currentIndex() != -1) 343 strOldData = pCombo->currentData(ProfileData_Name).toString(); 344 345 /* Block signals while updating: */ 346 pCombo->blockSignals(true); 347 348 /* Clear combo initially: */ 349 pCombo->clear(); 350 351 /* Iterate through existing profile names: */ 352 foreach (const CCloudProfile &comProfile, listCloudProfiles(comProvider, pParent)) 353 { 354 /* Skip if we have nothing to populate (wtf happened?): */ 355 if (comProfile.isNull()) 356 continue; 357 /* Acquire profile name: */ 358 QString strProfileName; 359 if (!cloudProfileName(comProfile, strProfileName, pParent)) 360 continue; 361 362 /* Compose item, fill it's data: */ 363 pCombo->addItem(strProfileName); 364 pCombo->setItemData(pCombo->count() - 1, strProfileName, ProfileData_Name); 365 } 366 367 /* Set previous/default item if possible: */ 368 int iNewIndex = -1; 369 if ( iNewIndex == -1 370 && !strOldData.isNull()) 371 iNewIndex = pCombo->findData(strOldData, ProfileData_Name); 372 if ( iNewIndex == -1 373 && pCombo->count() > 0) 374 iNewIndex = 0; 375 if (iNewIndex != -1) 376 pCombo->setCurrentIndex(iNewIndex); 377 378 /* Unblock signals after update: */ 379 pCombo->blockSignals(false); 380 } 381 /* If format is local one: */ 382 else 383 { 384 /* Block signals while updating: */ 385 pCombo->blockSignals(true); 386 387 /* Clear combo initially: */ 388 pCombo->clear(); 389 390 /* Unblock signals after update: */ 391 pCombo->blockSignals(false); 392 } 393 } 394 395 void UIWizardExportAppPage2::refreshCloudProfile(CCloudProfile &comCloudProfile, 396 const QString &strShortProviderName, 397 const QString &strProfileName, 398 bool fIsFormatCloudOne) 399 { 400 /* If format is cloud one: */ 401 if (fIsFormatCloudOne) 402 comCloudProfile = cloudProfileByName(strShortProviderName, strProfileName); 403 /* If format is local one: */ 404 else 405 comCloudProfile = CCloudProfile(); 406 } 407 408 void UIWizardExportAppPage2::refreshCloudExportMode(const QMap<CloudExportMode, QAbstractButton*> &radios, 409 bool fIsFormatCloudOne) 410 { 411 /* If format is cloud one: */ 412 if (fIsFormatCloudOne) 413 { 414 /* Check if something already chosen: */ 415 bool fSomethingChosen = false; 416 foreach (QAbstractButton *pButton, radios.values()) 417 if (pButton->isChecked()) 418 fSomethingChosen = true; 419 /* Choose default cloud export option: */ 420 if (!fSomethingChosen) 421 radios.value(CloudExportMode_ExportThenAsk)->setChecked(true); 422 } 423 /* If format is local one: */ 424 else 425 { 426 /* Make sure nothing chosen: */ 427 foreach (QAbstractButton *pButton, radios.values()) 428 pButton->setChecked(false); 429 } 430 } 431 432 void UIWizardExportAppPage2::refreshCloudStuff(CAppliance &comCloudAppliance, 433 CCloudClient &comCloudClient, 434 CVirtualSystemDescription &comCloudVsd, 435 CVirtualSystemDescriptionForm &comCloudVsdExportForm, 436 const CCloudProfile &comCloudProfile, 437 const QList<QUuid> &machineIDs, 438 const QString &strUri, 439 const CloudExportMode enmCloudExportMode) 440 { 441 /* Clear stuff: */ 442 comCloudAppliance = CAppliance(); 443 comCloudClient = CCloudClient(); 444 comCloudVsd = CVirtualSystemDescription(); 445 comCloudVsdExportForm = CVirtualSystemDescriptionForm(); 446 447 /* Sanity check: */ 448 if (comCloudProfile.isNull()) 449 return; 450 if (machineIDs.isEmpty()) 451 return; 452 453 /* Perform cloud export procedure for first uuid only: */ 454 const QUuid uMachineId = machineIDs.first(); 455 456 /* Get the machine with the uMachineId: */ 457 CVirtualBox comVBox = uiCommon().virtualBox(); 458 CMachine comMachine = comVBox.FindMachine(uMachineId.toString()); 459 if (!comVBox.isOk()) 460 { 461 msgCenter().cannotFindMachineById(comVBox, uMachineId); 462 return; 463 } 464 465 /* Create appliance: */ 466 CAppliance comAppliance = comVBox.CreateAppliance(); 467 if (!comVBox.isOk()) 468 { 469 msgCenter().cannotCreateAppliance(comVBox); 470 return; 471 } 472 473 /* Remember appliance: */ 474 comCloudAppliance = comAppliance; 475 476 /* Add the export virtual system description to our appliance object: */ 477 CVirtualSystemDescription comVsd = comMachine.ExportTo(comCloudAppliance, strUri); 478 if (!comMachine.isOk()) 479 { 480 msgCenter().cannotExportAppliance(comMachine, comCloudAppliance.GetPath()); 481 return; 482 } 483 484 /* Remember description: */ 485 comCloudVsd = comVsd; 486 487 /* Add Launch Instance flag to virtual system description: */ 488 switch (enmCloudExportMode) 489 { 490 case CloudExportMode_AskThenExport: 491 case CloudExportMode_ExportThenAsk: 492 comCloudVsd.AddDescription(KVirtualSystemDescriptionType_CloudLaunchInstance, "true", QString()); 493 break; 494 default: 495 comCloudVsd.AddDescription(KVirtualSystemDescriptionType_CloudLaunchInstance, "false", QString()); 496 break; 497 } 498 if (!comCloudVsd.isOk()) 499 { 500 msgCenter().cannotAddVirtualSystemDescriptionValue(comCloudVsd); 501 return; 502 } 503 504 /* Create Cloud Client: */ 505 CCloudClient comClient = cloudClient(comCloudProfile); 506 if (comClient.isNull()) 507 return; 508 509 /* Remember client: */ 510 comCloudClient = comClient; 511 512 /* Read Cloud Client Export description form: */ 513 CVirtualSystemDescriptionForm comVsdExportForm; 514 bool fResult = exportDescriptionForm(comCloudClient, comCloudVsd, comVsdExportForm); 515 if (!fResult) 516 return; 517 518 /* Remember export description form: */ 519 comCloudVsdExportForm = comVsdExportForm; 520 } 521 522 QString UIWizardExportAppPage2::profileName(QIComboBox *pCombo) 523 { 524 return pCombo->currentData(ProfileData_Name).toString(); 525 } 526 527 void UIWizardExportAppPage2::updateFormatComboToolTip(QIComboBox *pCombo) 528 { 529 AssertPtrReturnVoid(pCombo); 530 QString strCurrentToolTip; 531 if (pCombo->count() != 0) 532 { 533 strCurrentToolTip = pCombo->currentData(Qt::ToolTipRole).toString(); 534 AssertMsg(!strCurrentToolTip.isEmpty(), ("Data not found!")); 535 } 536 pCombo->setToolTip(strCurrentToolTip); 537 } 538 539 void UIWizardExportAppPage2::updateMACAddressExportPolicyComboToolTip(QIComboBox *pCombo) 540 { 541 AssertPtrReturnVoid(pCombo); 542 QString strCurrentToolTip; 543 if (pCombo->count() != 0) 544 { 545 strCurrentToolTip = pCombo->currentData(Qt::ToolTipRole).toString(); 546 AssertMsg(!strCurrentToolTip.isEmpty(), ("Data not found!")); 547 } 548 pCombo->setToolTip(strCurrentToolTip); 549 } 550 551 552 /********************************************************************************************************************************* 553 * Class UIWizardExportAppPageBasic2 implementation. * 554 *********************************************************************************************************************************/ 555 556 UIWizardExportAppPageBasic2::UIWizardExportAppPageBasic2(bool fExportToOCIByDefault) 54 557 : m_fExportToOCIByDefault(fExportToOCIByDefault) 558 , m_pLabelFormat(0) 559 , m_pLabelSettings(0) 55 560 , m_pFormatLayout(0) 56 , m_pSettingsLayout1(0)57 , m_pSettingsLayout2(0)58 561 , m_pFormatComboBoxLabel(0) 59 562 , m_pFormatComboBox(0) 60 563 , m_pSettingsWidget(0) 564 , m_pSettingsLayout1(0) 61 565 , m_pFileSelectorLabel(0) 62 566 , m_pFileSelector(0) … … 66 570 , m_pManifestCheckbox(0) 67 571 , m_pIncludeISOsCheckbox(0) 572 , m_pSettingsLayout2(0) 68 573 , m_pProfileLabel(0) 69 574 , m_pProfileComboBox(0) 70 575 , m_pProfileToolButton(0) 71 , m_pMachineLabel(0) 72 , m_pRadioDoNotAsk(0) 73 , m_pRadioAskThenExport(0) 74 , m_pRadioExportThenAsk(0) 75 { 76 } 77 78 void UIWizardExportAppPage2::populateFormats() 79 { 80 AssertReturnVoid(m_pFormatComboBox->count() == 0); 81 82 /* Compose hardcoded format list: */ 83 QStringList formats; 84 formats << "ovf-0.9"; 85 formats << "ovf-1.0"; 86 formats << "ovf-2.0"; 87 /* Add that list to combo: */ 88 foreach (const QString &strShortName, formats) 89 { 90 /* Compose empty item, fill it's data: */ 91 m_pFormatComboBox->addItem(QString()); 92 m_pFormatComboBox->setItemData(m_pFormatComboBox->count() - 1, strShortName, FormatData_ShortName); 93 } 94 95 /* Initialize Cloud Provider Manager: */ 96 bool fOCIPresent = false; 97 m_comCloudProviderManager = cloudProviderManager(wizardImp()); 98 if (m_comCloudProviderManager.isNotNull()) 99 { 100 /* Iterate through existing providers: */ 101 foreach (const CCloudProvider &comProvider, listCloudProviders(wizardImp())) 102 { 103 /* Skip if we have nothing to populate (file missing?): */ 104 if (comProvider.isNull()) 105 continue; 106 107 /* Compose empty item, fill it's data: */ 108 m_pFormatComboBox->addItem(QString()); 109 m_pFormatComboBox->setItemData(m_pFormatComboBox->count() - 1, comProvider.GetId(), FormatData_ID); 110 m_pFormatComboBox->setItemData(m_pFormatComboBox->count() - 1, comProvider.GetName(), FormatData_Name); 111 m_pFormatComboBox->setItemData(m_pFormatComboBox->count() - 1, comProvider.GetShortName(), FormatData_ShortName); 112 m_pFormatComboBox->setItemData(m_pFormatComboBox->count() - 1, true, FormatData_IsItCloudFormat); 113 if (m_pFormatComboBox->itemData(m_pFormatComboBox->count() - 1, FormatData_ShortName).toString() == "OCI") 114 fOCIPresent = true; 115 } 116 } 117 118 /* Set default: */ 119 if (m_fExportToOCIByDefault && fOCIPresent) 120 setFormat("OCI"); 121 else 122 setFormat("ovf-1.0"); 123 } 124 125 void UIWizardExportAppPage2::populateMACAddressPolicies() 126 { 127 AssertReturnVoid(m_pMACComboBox->count() == 0); 128 129 /* Map known export options to known MAC address export policies: */ 130 QMap<KExportOptions, MACAddressExportPolicy> knownOptions; 131 knownOptions[KExportOptions_StripAllMACs] = MACAddressExportPolicy_StripAllMACs; 132 knownOptions[KExportOptions_StripAllNonNATMACs] = MACAddressExportPolicy_StripAllNonNATMACs; 133 134 /* Load currently supported export options: */ 135 CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties(); 136 const QVector<KExportOptions> supportedOptions = comProperties.GetSupportedExportOptions(); 137 138 /* Check which of supported options/policies are known: */ 139 QList<MACAddressExportPolicy> supportedPolicies; 140 foreach (const KExportOptions &enmOption, supportedOptions) 141 if (knownOptions.contains(enmOption)) 142 supportedPolicies << knownOptions.value(enmOption); 143 144 /* Add supported policies first: */ 145 foreach (const MACAddressExportPolicy &enmPolicy, supportedPolicies) 146 m_pMACComboBox->addItem(QString(), QVariant::fromValue(enmPolicy)); 147 148 /* Add hardcoded policy finally: */ 149 m_pMACComboBox->addItem(QString(), QVariant::fromValue(MACAddressExportPolicy_KeepAllMACs)); 150 151 /* Set default: */ 152 if (supportedPolicies.contains(MACAddressExportPolicy_StripAllNonNATMACs)) 153 setMACAddressExportPolicy(MACAddressExportPolicy_StripAllNonNATMACs); 154 else 155 setMACAddressExportPolicy(MACAddressExportPolicy_KeepAllMACs); 156 } 157 158 void UIWizardExportAppPage2::populateProfiles() 159 { 160 /* Block signals while updating: */ 161 m_pProfileComboBox->blockSignals(true); 162 163 /* Remember current item data to be able to restore it: */ 164 QString strOldData; 165 if (m_pProfileComboBox->currentIndex() != -1) 166 strOldData = m_pProfileComboBox->itemData(m_pProfileComboBox->currentIndex(), ProfileData_Name).toString(); 167 168 /* Clear combo initially: */ 169 m_pProfileComboBox->clear(); 170 /* Clear Cloud Provider: */ 171 m_comCloudProvider = CCloudProvider(); 172 173 /* If provider chosen: */ 174 if (!providerId().isNull()) 175 { 176 /* (Re)initialize Cloud Provider: */ 177 m_comCloudProvider = cloudProviderById(providerId(), wizardImp()); 178 if (m_comCloudProvider.isNotNull()) 179 { 180 /* Iterate through existing profile names: */ 181 foreach (const CCloudProfile &comProfile, listCloudProfiles(m_comCloudProvider, wizardImp())) 182 { 183 /* Acquire profile name: */ 184 QString strProfileName; 185 if (cloudProfileName(comProfile, strProfileName, wizardImp())) 186 { 187 /* Compose item, fill it's data: */ 188 m_pProfileComboBox->addItem(strProfileName); 189 m_pProfileComboBox->setItemData(m_pProfileComboBox->count() - 1, strProfileName, ProfileData_Name); 190 } 191 } 192 } 193 194 /* Set previous/default item if possible: */ 195 int iNewIndex = -1; 196 if ( iNewIndex == -1 197 && !strOldData.isNull()) 198 iNewIndex = m_pProfileComboBox->findData(strOldData, ProfileData_Name); 199 if ( iNewIndex == -1 200 && m_pProfileComboBox->count() > 0) 201 iNewIndex = 0; 202 if (iNewIndex != -1) 203 m_pProfileComboBox->setCurrentIndex(iNewIndex); 204 } 205 206 /* Unblock signals after update: */ 207 m_pProfileComboBox->blockSignals(false); 208 } 209 210 void UIWizardExportAppPage2::populateProfile() 211 { 212 /* Clear Cloud Profile: */ 213 m_comCloudProfile = CCloudProfile(); 214 215 /* If both provider and profile chosen: */ 216 if (!providerShortName().isNull() && !profileName().isNull()) 217 { 218 /* Acquire Cloud Profile: */ 219 m_comCloudProfile = cloudProfileByName(providerShortName(), profileName(), wizardImp()); 220 } 221 } 222 223 void UIWizardExportAppPage2::populateFormProperties() 224 { 225 /* Clear appliance: */ 226 m_comAppliance = CAppliance(); 227 /* Clear cloud client: */ 228 m_comClient = CCloudClient(); 229 /* Clear description: */ 230 m_comVSD = CVirtualSystemDescription(); 231 /* Clear description form: */ 232 m_comVSDExportForm = CVirtualSystemDescriptionForm(); 233 234 /* If profile chosen: */ 235 if (m_comCloudProfile.isNotNull()) 236 { 237 /* Main API request sequence, can be interrupted after any step: */ 238 do 239 { 240 /* Perform cloud export procedure for first uuid only: */ 241 const QList<QUuid> uuids = fieldImp("machineIDs").value<QList<QUuid> >(); 242 AssertReturnVoid(!uuids.isEmpty()); 243 const QUuid uMachineId = uuids.first(); 244 245 /* Get the machine with the uMachineId: */ 246 CVirtualBox comVBox = uiCommon().virtualBox(); 247 CMachine comMachine = comVBox.FindMachine(uMachineId.toString()); 248 if (!comVBox.isOk()) 249 { 250 msgCenter().cannotFindMachineById(comVBox, uMachineId); 251 break; 252 } 253 254 /* Create appliance: */ 255 CAppliance comAppliance = comVBox.CreateAppliance(); 256 if (!comVBox.isOk()) 257 { 258 msgCenter().cannotCreateAppliance(comVBox); 259 break; 260 } 261 262 /* Remember appliance: */ 263 m_comAppliance = comAppliance; 264 265 /* Add the export virtual system description to our appliance object: */ 266 CVirtualSystemDescription comVSD = comMachine.ExportTo(m_comAppliance, qobject_cast<UIWizardExportApp*>(wizardImp())->uri()); 267 if (!comMachine.isOk()) 268 { 269 msgCenter().cannotExportAppliance(comMachine, m_comAppliance.GetPath(), thisImp()); 270 break; 271 } 272 273 /* Remember description: */ 274 m_comVSD = comVSD; 275 276 /* Add Launch Instance flag to virtual system description: */ 277 switch (cloudExportMode()) 278 { 279 case CloudExportMode_AskThenExport: 280 case CloudExportMode_ExportThenAsk: 281 m_comVSD.AddDescription(KVirtualSystemDescriptionType_CloudLaunchInstance, "true", QString()); 282 break; 283 default: 284 m_comVSD.AddDescription(KVirtualSystemDescriptionType_CloudLaunchInstance, "false", QString()); 285 break; 286 } 287 if (!m_comVSD.isOk()) 288 { 289 msgCenter().cannotAddVirtualSystemDescriptionValue(m_comVSD); 290 break; 291 } 292 293 /* Create Cloud Client: */ 294 CCloudClient comClient = cloudClient(m_comCloudProfile); 295 if (comClient.isNull()) 296 break; 297 298 /* Remember client: */ 299 m_comClient = comClient; 300 301 /* Read Cloud Client Export description form: */ 302 CVirtualSystemDescriptionForm comExportForm; 303 bool fResult = exportDescriptionForm(m_comClient, m_comVSD, comExportForm, wizardImp()); 304 if (!fResult) 305 break; 306 307 /* Remember description form: */ 308 m_comVSDExportForm = comExportForm; 309 } 310 while (0); 311 } 312 } 313 314 void UIWizardExportAppPage2::updatePageAppearance() 315 { 316 /* Update page appearance according to chosen format: */ 317 m_pSettingsWidget->setCurrentIndex((int)isFormatCloudOne()); 318 } 319 320 void UIWizardExportAppPage2::refreshFileSelectorName() 321 { 322 /* If it's one VM only, we use the VM name as file-name: */ 323 if (fieldImp("machineNames").toStringList().size() == 1) 324 m_strFileSelectorName = fieldImp("machineNames").toStringList()[0]; 325 /* Otherwise => we use the default file-name: */ 326 else 327 m_strFileSelectorName = m_strDefaultApplianceName; 328 329 /* Cascade update for file selector path: */ 330 refreshFileSelectorPath(); 331 } 332 333 void UIWizardExportAppPage2::refreshFileSelectorExtension() 334 { 335 /* Save old extension to compare afterwards: */ 336 const QString strOldExtension = m_strFileSelectorExt; 337 338 /* If format is cloud one: */ 339 if (isFormatCloudOne()) 340 { 341 /* We use no extension: */ 342 m_strFileSelectorExt.clear(); 343 344 /* Update file chooser accordingly: */ 345 m_pFileSelector->setFileFilters(QString()); 346 } 347 /* Otherwise: */ 348 else 349 { 350 /* We use the default (.ova) extension: */ 351 m_strFileSelectorExt = ".ova"; 352 353 /* Update file chooser accordingly: */ 354 m_pFileSelector->setFileFilters(UIWizardExportApp::tr("Open Virtualization Format Archive (%1)").arg("*.ova") + ";;" + 355 UIWizardExportApp::tr("Open Virtualization Format (%1)").arg("*.ovf")); 356 } 357 358 /* Cascade update for file selector path if necessary: */ 359 if (m_strFileSelectorExt != strOldExtension) 360 refreshFileSelectorPath(); 361 } 362 363 void UIWizardExportAppPage2::refreshFileSelectorPath() 364 { 365 /* If format is cloud one: */ 366 if (isFormatCloudOne()) 367 { 368 /* Clear file selector path: */ 369 m_pFileSelector->setPath(QString()); 370 } 371 else 372 { 373 /* Compose file selector path: */ 374 const QString strPath = QDir::toNativeSeparators(QString("%1/%2") 375 .arg(uiCommon().documentsPath()) 376 .arg(m_strFileSelectorName + m_strFileSelectorExt)); 377 m_pFileSelector->setPath(strPath); 378 } 379 } 380 381 void UIWizardExportAppPage2::refreshManifestCheckBoxAccess() 382 { 383 /* If format is cloud one: */ 384 if (isFormatCloudOne()) 385 { 386 /* Disable manifest check-box: */ 387 m_pManifestCheckbox->setChecked(false); 388 m_pManifestCheckbox->setEnabled(false); 389 } 390 /* Otherwise: */ 391 else 392 { 393 /* Enable manifest check-box: */ 394 m_pManifestCheckbox->setChecked(true); 395 m_pManifestCheckbox->setEnabled(true); 396 } 397 } 398 399 void UIWizardExportAppPage2::refreshIncludeISOsCheckBoxAccess() 400 { 401 /* If format is cloud one: */ 402 if (isFormatCloudOne()) 403 { 404 /* Disable include ISO check-box: */ 405 m_pIncludeISOsCheckbox->setChecked(false); 406 m_pIncludeISOsCheckbox->setEnabled(false); 407 } 408 /* Otherwise: */ 409 else 410 { 411 /* Enable include ISO check-box: */ 412 m_pIncludeISOsCheckbox->setEnabled(true); 413 } 414 } 415 416 void UIWizardExportAppPage2::updateFormatComboToolTip() 417 { 418 const int iCurrentIndex = m_pFormatComboBox->currentIndex(); 419 const QString strCurrentToolTip = m_pFormatComboBox->itemData(iCurrentIndex, Qt::ToolTipRole).toString(); 420 AssertMsg(!strCurrentToolTip.isEmpty(), ("Data not found!")); 421 m_pFormatComboBox->setToolTip(strCurrentToolTip); 422 } 423 424 void UIWizardExportAppPage2::updateMACAddressExportPolicyComboToolTip() 425 { 426 const QString strCurrentToolTip = m_pMACComboBox->currentData(Qt::ToolTipRole).toString(); 427 AssertMsg(!strCurrentToolTip.isEmpty(), ("Data not found!")); 428 m_pMACComboBox->setToolTip(strCurrentToolTip); 429 } 430 431 void UIWizardExportAppPage2::setFormat(const QString &strFormat) 432 { 433 const int iIndex = m_pFormatComboBox->findData(strFormat, FormatData_ShortName); 434 AssertMsg(iIndex != -1, ("Data not found!")); 435 m_pFormatComboBox->setCurrentIndex(iIndex); 436 } 437 438 QString UIWizardExportAppPage2::format() const 439 { 440 const int iIndex = m_pFormatComboBox->currentIndex(); 441 return m_pFormatComboBox->itemData(iIndex, FormatData_ShortName).toString(); 442 } 443 444 bool UIWizardExportAppPage2::isFormatCloudOne(int iIndex /* = -1 */) const 445 { 446 if (iIndex == -1) 447 iIndex = m_pFormatComboBox->currentIndex(); 448 return m_pFormatComboBox->itemData(iIndex, FormatData_IsItCloudFormat).toBool(); 449 } 450 451 void UIWizardExportAppPage2::setPath(const QString &strPath) 452 { 453 m_pFileSelector->setPath(strPath); 454 } 455 456 QString UIWizardExportAppPage2::path() const 457 { 458 return m_pFileSelector->path(); 459 } 460 461 void UIWizardExportAppPage2::setMACAddressExportPolicy(MACAddressExportPolicy enmMACAddressExportPolicy) 462 { 463 const int iIndex = m_pMACComboBox->findData(enmMACAddressExportPolicy); 464 AssertMsg(iIndex != -1, ("Data not found!")); 465 m_pMACComboBox->setCurrentIndex(iIndex); 466 } 467 468 MACAddressExportPolicy UIWizardExportAppPage2::macAddressExportPolicy() const 469 { 470 return m_pMACComboBox->currentData().value<MACAddressExportPolicy>(); 471 } 472 473 void UIWizardExportAppPage2::setManifestSelected(bool fChecked) 474 { 475 m_pManifestCheckbox->setChecked(fChecked); 476 } 477 478 bool UIWizardExportAppPage2::isManifestSelected() const 479 { 480 return m_pManifestCheckbox->isChecked(); 481 } 482 483 void UIWizardExportAppPage2::setIncludeISOsSelected(bool fChecked) 484 { 485 m_pIncludeISOsCheckbox->setChecked(fChecked); 486 } 487 488 bool UIWizardExportAppPage2::isIncludeISOsSelected() const 489 { 490 return m_pIncludeISOsCheckbox->isChecked(); 491 } 492 493 void UIWizardExportAppPage2::setProviderById(const QUuid &uId) 494 { 495 const int iIndex = m_pFormatComboBox->findData(uId, FormatData_ID); 496 AssertMsg(iIndex != -1, ("Data not found!")); 497 m_pFormatComboBox->setCurrentIndex(iIndex); 498 } 499 500 QUuid UIWizardExportAppPage2::providerId() const 501 { 502 const int iIndex = m_pFormatComboBox->currentIndex(); 503 return m_pFormatComboBox->itemData(iIndex, FormatData_ID).toUuid(); 504 } 505 506 QString UIWizardExportAppPage2::providerShortName() const 507 { 508 const int iIndex = m_pFormatComboBox->currentIndex(); 509 return m_pFormatComboBox->itemData(iIndex, FormatData_ShortName).toString(); 510 } 511 512 QString UIWizardExportAppPage2::profileName() const 513 { 514 const int iIndex = m_pProfileComboBox->currentIndex(); 515 return m_pProfileComboBox->itemData(iIndex, ProfileData_Name).toString(); 516 } 517 518 CAppliance UIWizardExportAppPage2::cloudAppliance() const 519 { 520 return m_comAppliance; 521 } 522 523 CCloudClient UIWizardExportAppPage2::client() const 524 { 525 return m_comClient; 526 } 527 528 CVirtualSystemDescription UIWizardExportAppPage2::vsd() const 529 { 530 return m_comVSD; 531 } 532 533 CVirtualSystemDescriptionForm UIWizardExportAppPage2::vsdExportForm() const 534 { 535 return m_comVSDExportForm; 536 } 537 538 CloudExportMode UIWizardExportAppPage2::cloudExportMode() const 539 { 540 if (m_pRadioAskThenExport->isChecked()) 541 return CloudExportMode_AskThenExport; 542 else if (m_pRadioExportThenAsk->isChecked()) 543 return CloudExportMode_ExportThenAsk; 544 return CloudExportMode_DoNotAsk; 545 } 546 547 548 /********************************************************************************************************************************* 549 * Class UIWizardExportAppPageBasic2 implementation. * 550 *********************************************************************************************************************************/ 551 552 UIWizardExportAppPageBasic2::UIWizardExportAppPageBasic2(bool fExportToOCIByDefault) 553 : UIWizardExportAppPage2(fExportToOCIByDefault) 554 , m_pLabelFormat(0) 555 , m_pLabelSettings(0) 576 , m_pExportModeLabel(0) 577 , m_pExportModeButtonGroup(0) 556 578 { 557 579 /* Create main layout: */ … … 560 582 { 561 583 /* Create format label: */ 562 m_pLabelFormat = new QIRichTextLabel ;584 m_pLabelFormat = new QIRichTextLabel(this); 563 585 if (m_pLabelFormat) 564 {565 /* Add into layout: */566 586 pMainLayout->addWidget(m_pLabelFormat); 567 }568 587 569 588 /* Create format layout: */ … … 581 600 m_pFormatLayout->setColumnStretch(1, 1); 582 601 583 /* Create format combo-box: */584 m_pFormatComboBox = new QComboBox;585 if (m_pFormatComboBox)586 {587 /* Add into layout: */588 m_pFormatLayout->addWidget(m_pFormatComboBox, 0, 1);589 }590 602 /* Create format combo-box label: */ 591 m_pFormatComboBoxLabel = new QLabel ;603 m_pFormatComboBoxLabel = new QLabel(this); 592 604 if (m_pFormatComboBoxLabel) 593 605 { 594 606 m_pFormatComboBoxLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); 607 m_pFormatLayout->addWidget(m_pFormatComboBoxLabel, 0, 0); 608 } 609 /* Create format combo-box: */ 610 m_pFormatComboBox = new QIComboBox(this); 611 if (m_pFormatComboBox) 612 { 595 613 m_pFormatComboBoxLabel->setBuddy(m_pFormatComboBox); 596 597 /* Add into layout: */ 598 m_pFormatLayout->addWidget(m_pFormatComboBoxLabel, 0, 0); 614 m_pFormatLayout->addWidget(m_pFormatComboBox, 0, 1); 599 615 } 600 616 … … 604 620 605 621 /* Create settings label: */ 606 m_pLabelSettings = new QIRichTextLabel ;622 m_pLabelSettings = new QIRichTextLabel(this); 607 623 if (m_pLabelSettings) 608 {609 /* Add into layout: */610 624 pMainLayout->addWidget(m_pLabelSettings); 611 }612 625 613 626 /* Create settings layout: */ 614 m_pSettingsWidget = new QStackedWidget ;627 m_pSettingsWidget = new QStackedWidget(this); 615 628 if (m_pSettingsWidget) 616 629 { 617 630 /* Create settings pane 1: */ 618 QWidget *pSettingsPane1 = new QWidget ;631 QWidget *pSettingsPane1 = new QWidget(m_pSettingsWidget); 619 632 if (pSettingsPane1) 620 633 { … … 634 647 635 648 /* Create file selector: */ 636 m_pFileSelector = new UIEmptyFilePathSelector ;649 m_pFileSelector = new UIEmptyFilePathSelector(pSettingsPane1); 637 650 if (m_pFileSelector) 638 651 { … … 641 654 m_pFileSelector->setButtonPosition(UIEmptyFilePathSelector::RightPosition); 642 655 m_pFileSelector->setDefaultSaveExt("ova"); 643 644 /* Add into layout: */645 656 m_pSettingsLayout1->addWidget(m_pFileSelector, 0, 1, 1, 2); 646 657 } 647 658 /* Create file selector label: */ 648 m_pFileSelectorLabel = new QLabel ;659 m_pFileSelectorLabel = new QLabel(pSettingsPane1); 649 660 if (m_pFileSelectorLabel) 650 661 { 651 662 m_pFileSelectorLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); 652 663 m_pFileSelectorLabel->setBuddy(m_pFileSelector); 653 654 /* Add into layout: */655 664 m_pSettingsLayout1->addWidget(m_pFileSelectorLabel, 0, 0); 656 665 } 657 666 658 667 /* Create MAC policy combo-box: */ 659 m_pMACComboBox = new Q ComboBox;668 m_pMACComboBox = new QIComboBox(pSettingsPane1); 660 669 if (m_pMACComboBox) 661 {662 /* Add into layout: */663 670 m_pSettingsLayout1->addWidget(m_pMACComboBox, 1, 1, 1, 2); 664 }665 671 /* Create format combo-box label: */ 666 m_pMACComboBoxLabel = new QLabel ;672 m_pMACComboBoxLabel = new QLabel(pSettingsPane1); 667 673 if (m_pMACComboBoxLabel) 668 674 { 669 675 m_pMACComboBoxLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); 670 676 m_pMACComboBoxLabel->setBuddy(m_pMACComboBox); 671 672 /* Add into layout: */673 677 m_pSettingsLayout1->addWidget(m_pMACComboBoxLabel, 1, 0); 674 678 } 675 679 676 680 /* Create advanced label: */ 677 m_pAdditionalLabel = new QLabel ;681 m_pAdditionalLabel = new QLabel(pSettingsPane1); 678 682 if (m_pAdditionalLabel) 679 683 { 680 684 m_pAdditionalLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); 681 682 /* Add into layout: */683 685 m_pSettingsLayout1->addWidget(m_pAdditionalLabel, 2, 0); 684 686 } 685 687 /* Create manifest check-box: */ 686 m_pManifestCheckbox = new QCheckBox ;688 m_pManifestCheckbox = new QCheckBox(pSettingsPane1); 687 689 if (m_pManifestCheckbox) 688 {689 /* Add into layout: */690 690 m_pSettingsLayout1->addWidget(m_pManifestCheckbox, 2, 1); 691 }692 691 /* Create include ISOs check-box: */ 693 m_pIncludeISOsCheckbox = new QCheckBox ;692 m_pIncludeISOsCheckbox = new QCheckBox(pSettingsPane1); 694 693 if (m_pIncludeISOsCheckbox) 695 {696 /* Add into layout: */697 694 m_pSettingsLayout1->addWidget(m_pIncludeISOsCheckbox, 3, 1); 698 }699 695 700 696 /* Create placeholder: */ 701 QWidget *pPlaceholder = new QWidget ;697 QWidget *pPlaceholder = new QWidget(pSettingsPane1); 702 698 if (pPlaceholder) 703 {704 /* Add into layout: */705 699 m_pSettingsLayout1->addWidget(pPlaceholder, 4, 0, 1, 3); 706 }707 700 } 708 701 … … 712 705 713 706 /* Create settings pane 2: */ 714 QWidget *pSettingsPane2 = new QWidget ;707 QWidget *pSettingsPane2 = new QWidget(m_pSettingsWidget); 715 708 if (pSettingsPane2) 716 709 { … … 732 725 733 726 /* Create profile label: */ 734 m_pProfileLabel = new QLabel ;727 m_pProfileLabel = new QLabel(pSettingsPane2); 735 728 if (m_pProfileLabel) 736 729 { 737 730 m_pProfileLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); 738 739 /* Add into layout: */740 731 m_pSettingsLayout2->addWidget(m_pProfileLabel, 0, 0); 741 732 } … … 748 739 749 740 /* Create profile combo-box: */ 750 m_pProfileComboBox = new Q ComboBox;741 m_pProfileComboBox = new QIComboBox(pSettingsPane2); 751 742 if (m_pProfileComboBox) 752 743 { 753 744 m_pProfileLabel->setBuddy(m_pProfileComboBox); 754 755 /* Add into layout: */756 745 pSubLayout->addWidget(m_pProfileComboBox); 757 746 } 758 747 /* Create profile tool-button: */ 759 m_pProfileToolButton = new QIToolButton ;748 m_pProfileToolButton = new QIToolButton(pSettingsPane2); 760 749 if (m_pProfileToolButton) 761 750 { 762 751 m_pProfileToolButton->setIcon(UIIconPool::iconSet(":/cloud_profile_manager_16px.png", 763 752 ":/cloud_profile_manager_disabled_16px.png")); 764 765 /* Add into layout: */766 753 pSubLayout->addWidget(m_pProfileToolButton); 767 754 } … … 772 759 773 760 /* Create profile label: */ 774 m_p MachineLabel = new QLabel;775 if (m_p MachineLabel)761 m_pExportModeLabel = new QLabel(pSettingsPane2); 762 if (m_pExportModeLabel) 776 763 { 777 m_pMachineLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); 778 779 /* Add into layout: */ 780 m_pSettingsLayout2->addWidget(m_pMachineLabel, 1, 0); 764 m_pExportModeLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); 765 m_pSettingsLayout2->addWidget(m_pExportModeLabel, 1, 0); 781 766 } 782 /* Create Do Not Ask button: */ 783 m_pRadioDoNotAsk = new QRadioButton; 784 if (m_pRadioDoNotAsk) 767 768 /* Create button-group: */ 769 m_pExportModeButtonGroup = new QButtonGroup(pSettingsPane2); 770 if (m_pExportModeButtonGroup) 785 771 { 786 /* Add into layout: */ 787 m_pSettingsLayout2->addWidget(m_pRadioDoNotAsk, 1, 1); 788 } 789 /* Create Ask Then Export button: */ 790 m_pRadioAskThenExport = new QRadioButton; 791 if (m_pRadioAskThenExport) 792 { 793 /* Add into layout: */ 794 m_pSettingsLayout2->addWidget(m_pRadioAskThenExport, 2, 1); 795 } 796 /* Create Export Then Ask button: */ 797 m_pRadioExportThenAsk = new QRadioButton; 798 if (m_pRadioExportThenAsk) 799 { 800 /* Add into layout: */ 801 m_pSettingsLayout2->addWidget(m_pRadioExportThenAsk, 3, 1); 772 /* Create Do Not Ask button: */ 773 m_exportModeButtons[CloudExportMode_DoNotAsk] = new QRadioButton(pSettingsPane2); 774 if (m_exportModeButtons.value(CloudExportMode_DoNotAsk)) 775 { 776 m_pExportModeButtonGroup->addButton(m_exportModeButtons.value(CloudExportMode_DoNotAsk)); 777 m_pSettingsLayout2->addWidget(m_exportModeButtons.value(CloudExportMode_DoNotAsk), 1, 1); 778 } 779 /* Create Ask Then Export button: */ 780 m_exportModeButtons[CloudExportMode_AskThenExport] = new QRadioButton(pSettingsPane2); 781 if (m_exportModeButtons.value(CloudExportMode_AskThenExport)) 782 { 783 m_pExportModeButtonGroup->addButton(m_exportModeButtons.value(CloudExportMode_AskThenExport)); 784 m_pSettingsLayout2->addWidget(m_exportModeButtons.value(CloudExportMode_AskThenExport), 2, 1); 785 } 786 /* Create Export Then Ask button: */ 787 m_exportModeButtons[CloudExportMode_ExportThenAsk] = new QRadioButton(pSettingsPane2); 788 if (m_exportModeButtons.value(CloudExportMode_ExportThenAsk)) 789 { 790 m_pExportModeButtonGroup->addButton(m_exportModeButtons.value(CloudExportMode_ExportThenAsk)); 791 m_pSettingsLayout2->addWidget(m_exportModeButtons.value(CloudExportMode_ExportThenAsk), 3, 1); 792 } 802 793 } 803 794 } … … 811 802 } 812 803 } 813 814 /* Populate formats: */815 populateFormats();816 /* Populate MAC address policies: */817 populateMACAddressPolicies();818 /* Populate profiles: */819 populateProfiles();820 /* Populate profile: */821 populateProfile();822 804 823 805 /* Setup connections: */ … … 828 810 connect(m_pFileSelector, &UIEmptyFilePathSelector::pathChanged, 829 811 this, &UIWizardExportAppPageBasic2::sltHandleFileSelectorChange); 830 connect(m_pFormatComboBox, static_cast<void(Q ComboBox::*)(int)>(&QComboBox::currentIndexChanged),812 connect(m_pFormatComboBox, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::currentIndexChanged), 831 813 this, &UIWizardExportAppPageBasic2::sltHandleFormatComboChange); 832 connect(m_pMACComboBox, static_cast<void(Q ComboBox::*)(int)>(&QComboBox::currentIndexChanged),814 connect(m_pMACComboBox, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::currentIndexChanged), 833 815 this, &UIWizardExportAppPageBasic2::sltHandleMACAddressExportPolicyComboChange); 834 connect(m_pProfileComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), 816 connect(m_pManifestCheckbox, &QCheckBox::stateChanged, 817 this, &UIWizardExportAppPageBasic2::sltHandleManifestCheckBoxChange); 818 connect(m_pIncludeISOsCheckbox, &QCheckBox::stateChanged, 819 this, &UIWizardExportAppPageBasic2::sltHandleIncludeISOsCheckBoxChange); 820 connect(m_pProfileComboBox, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::currentIndexChanged), 835 821 this, &UIWizardExportAppPageBasic2::sltHandleProfileComboChange); 822 connect(m_pExportModeButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton*, bool)>(&QButtonGroup::buttonToggled), 823 this, &UIWizardExportAppPageBasic2::sltHandleRadioButtonToggled); 836 824 connect(m_pProfileToolButton, &QIToolButton::clicked, 837 825 this, &UIWizardExportAppPageBasic2::sltHandleProfileButtonClick); 838 839 /* Register fields: */ 840 registerField("format", this, "format"); 841 registerField("isFormatCloudOne", this, "isFormatCloudOne"); 842 registerField("path", this, "path"); 843 registerField("macAddressExportPolicy", this, "macAddressExportPolicy"); 844 registerField("manifestSelected", this, "manifestSelected"); 845 registerField("includeISOsSelected", this, "includeISOsSelected"); 846 registerField("providerShortName", this, "providerShortName"); 847 registerField("cloudAppliance", this, "cloudAppliance"); 848 registerField("client", this, "client"); 849 registerField("vsd", this, "vsd"); 850 registerField("vsdExportForm", this, "vsdExportForm"); 851 registerField("cloudExportMode", this, "cloudExportMode"); 826 } 827 828 UIWizardExportApp *UIWizardExportAppPageBasic2::wizard() const 829 { 830 return qobject_cast<UIWizardExportApp*>(UINativeWizardPage::wizard()); 852 831 } 853 832 … … 859 838 /* Translate objects: */ 860 839 m_strDefaultApplianceName = UIWizardExportApp::tr("Appliance"); 840 refreshFileSelectorName(m_strFileSelectorName, wizard()->machineNames(), m_strDefaultApplianceName, wizard()->isFormatCloudOne()); 841 refreshFileSelectorPath(m_pFileSelector, m_strFileSelectorName, m_strFileSelectorExt, wizard()->isFormatCloudOne()); 861 842 862 843 /* Translate format label: */ … … 869 850 "<p>The <b>Oracle Cloud Infrastructure</b> format supports exporting to remote cloud servers only. " 870 851 "Main virtual disk of each selected machine will be uploaded to remote server.</p>")); 852 853 /* Translate settings label: */ 854 if (wizard()->isFormatCloudOne()) 855 m_pLabelSettings->setText(UIWizardExportApp:: 856 tr("<p>Please choose one of cloud service profiles you have registered to export virtual " 857 "machines to. It will be used to establish network connection required to upload your " 858 "virtual machine files to a remote cloud facility.</p>")); 859 else 860 m_pLabelSettings->setText(UIWizardExportApp:: 861 tr("<p>Please choose a filename to export the virtual appliance to. Besides that you can " 862 "specify a certain amount of options which affects the size and content of resulting " 863 "archive.</p>")); 871 864 872 865 /* Translate file selector: */ … … 887 880 * We are enumerating starting from 0 for simplicity: */ 888 881 for (int i = 0; i < m_pFormatComboBox->count(); ++i) 889 if (isFormatCloudOne( i))882 if (isFormatCloudOne(m_pFormatComboBox, i)) 890 883 { 891 884 m_pFormatComboBox->setItemText(i, m_pFormatComboBox->itemData(i, FormatData_Name).toString()); … … 903 896 { 904 897 m_pMACComboBox->setItemText(i, UIWizardExportApp::tr("Include all network adapter MAC addresses")); 905 m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Include all network adapter MAC addresses in exported appliance archive."), Qt::ToolTipRole); 898 m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Include all network adapter MAC addresses in exported " 899 "appliance archive."), Qt::ToolTipRole); 906 900 break; 907 901 } … … 909 903 { 910 904 m_pMACComboBox->setItemText(i, UIWizardExportApp::tr("Include only NAT network adapter MAC addresses")); 911 m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Include only NAT network adapter MAC addresses in exported appliance archive."), Qt::ToolTipRole); 905 m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Include only NAT network adapter MAC addresses in exported " 906 "appliance archive."), Qt::ToolTipRole); 912 907 break; 913 908 } … … 915 910 { 916 911 m_pMACComboBox->setItemText(i, UIWizardExportApp::tr("Strip all network adapter MAC addresses")); 917 m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Strip all network adapter MAC addresses from exported appliance archive."), Qt::ToolTipRole); 912 m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Strip all network adapter MAC addresses from exported " 913 "appliance archive."), Qt::ToolTipRole); 918 914 break; 919 915 } … … 927 923 m_pManifestCheckbox->setToolTip(UIWizardExportApp::tr("Create a Manifest file for automatic data integrity checks on import.")); 928 924 m_pManifestCheckbox->setText(UIWizardExportApp::tr("&Write Manifest file")); 929 m_pIncludeISOsCheckbox->setToolTip(UIWizardExportApp::tr("Include ISO image files in exported VM archive."));925 m_pIncludeISOsCheckbox->setToolTip(UIWizardExportApp::tr("Include ISO image files into exported VM archive.")); 930 926 m_pIncludeISOsCheckbox->setText(UIWizardExportApp::tr("&Include ISO image files")); 931 927 … … 935 931 936 932 /* Translate option label: */ 937 m_p MachineLabel->setText(UIWizardExportApp::tr("Machine Creation:"));938 m_ pRadioDoNotAsk->setText(UIWizardExportApp::tr("Do not ask me about it, leave custom &image for future usage"));939 m_ pRadioAskThenExport->setText(UIWizardExportApp::tr("Ask me about it &before exporting disk as custom image"));940 m_ pRadioExportThenAsk->setText(UIWizardExportApp::tr("Ask me about it &after exporting disk as custom image"));933 m_pExportModeLabel->setText(UIWizardExportApp::tr("Machine Creation:")); 934 m_exportModeButtons.value(CloudExportMode_DoNotAsk)->setText(UIWizardExportApp::tr("Do not ask me about it, leave custom &image for future usage")); 935 m_exportModeButtons.value(CloudExportMode_AskThenExport)->setText(UIWizardExportApp::tr("Ask me about it &before exporting disk as custom image")); 936 m_exportModeButtons.value(CloudExportMode_ExportThenAsk)->setText(UIWizardExportApp::tr("Ask me about it &after exporting disk as custom image")); 941 937 942 938 /* Adjust label widths: */ … … 947 943 labels << m_pAdditionalLabel; 948 944 labels << m_pProfileLabel; 949 labels << m_p MachineLabel;945 labels << m_pExportModeLabel; 950 946 int iMaxWidth = 0; 951 947 foreach (QWidget *pLabel, labels) … … 955 951 m_pSettingsLayout2->setColumnMinimumWidth(0, iMaxWidth); 956 952 957 /* Refresh file selector name: */958 refreshFileSelectorName();959 960 /* Update page appearance: */961 updatePageAppearance();962 963 953 /* Update tool-tips: */ 964 updateFormatComboToolTip( );965 updateMACAddressExportPolicyComboToolTip( );954 updateFormatComboToolTip(m_pFormatComboBox); 955 updateMACAddressExportPolicyComboToolTip(m_pMACComboBox); 966 956 } 967 957 968 958 void UIWizardExportAppPageBasic2::initializePage() 969 959 { 960 /* Populate formats: */ 961 populateFormats(m_pFormatComboBox, m_fExportToOCIByDefault); 962 /* Populate MAC address policies: */ 963 populateMACAddressPolicies(m_pMACComboBox); 970 964 /* Translate page: */ 971 965 retranslateUi(); 972 966 973 /* Refresh file selector name: */ 974 // refreshFileSelectorName(); already called from retranslateUi(); 975 /* Refresh file selector extension: */ 976 refreshFileSelectorExtension(); 977 /* Refresh manifest check-box access: */ 978 refreshManifestCheckBoxAccess(); 979 /* Refresh include ISOs check-box access: */ 980 refreshIncludeISOsCheckBoxAccess(); 981 982 /* Choose default cloud export option: */ 983 m_pRadioExportThenAsk->setChecked(true); 967 /* Choose initially focused widget: */ 968 if (wizard()->isFormatCloudOne()) 969 m_pProfileComboBox->setFocus(); 970 else 971 m_pFileSelector->setFocus(); 972 973 /* Fetch it, asynchronously: */ 974 QMetaObject::invokeMethod(this, "sltHandleFormatComboChange", Qt::QueuedConnection); 984 975 } 985 976 … … 990 981 991 982 /* Check whether there was cloud target selected: */ 992 if ( isFormatCloudOne())983 if (wizard()->isFormatCloudOne()) 993 984 fResult = m_comCloudProfile.isNotNull(); 994 985 else 995 fResult = UICommon::hasAllowedExtension( path().toLower(), OVFFileExts);986 fResult = UICommon::hasAllowedExtension(wizard()->path().toLower(), OVFFileExts); 996 987 997 988 /* Return result: */ … … 1005 996 1006 997 /* Check whether there was cloud target selected: */ 1007 if ( isFormatCloudOne())1008 { 1009 /* Create appliance and populate form properties: */1010 populateFormProperties();1011 /* Which arerequired to continue to the next page: */1012 fResult = field("cloudAppliance").value<CAppliance>().isNotNull()1013 && field("client").value<CCloudClient>().isNotNull()1014 && field("vsd").value<CVirtualSystemDescription>().isNotNull()1015 && field("vsdExportForm").value<CVirtualSystemDescriptionForm>().isNotNull();998 if (wizard()->isFormatCloudOne()) 999 { 1000 /* Update cloud stuff: */ 1001 updateCloudStuff(); 1002 /* Which is required to continue to the next page: */ 1003 fResult = wizard()->cloudAppliance().isNotNull() 1004 && wizard()->cloudClient().isNotNull() 1005 && wizard()->vsd().isNotNull() 1006 && wizard()->vsdExportForm().isNotNull(); 1016 1007 } 1017 1008 … … 1020 1011 } 1021 1012 1022 void UIWizardExportAppPageBasic2::updatePageAppearance()1023 {1024 /* Call to base-class: */1025 UIWizardExportAppPage2::updatePageAppearance();1026 1027 /* Update page appearance according to chosen storage-type: */1028 if (isFormatCloudOne())1029 {1030 m_pLabelSettings->setText(UIWizardExportApp::1031 tr("<p>Please choose one of cloud service profiles you have registered to export virtual "1032 "machines to. It will be used to establish network connection required to upload your "1033 "virtual machine files to a remote cloud facility.</p>"));1034 m_pProfileComboBox->setFocus();1035 }1036 else1037 {1038 m_pLabelSettings->setText(UIWizardExportApp::1039 tr("<p>Please choose a filename to export the virtual appliance to. Besides that you can "1040 "specify a certain amount of options which affects the size and content of resulting "1041 "archive.</p>"));1042 m_pFileSelector->setFocus();1043 }1044 }1045 1046 1013 void UIWizardExportAppPageBasic2::sltHandleFormatComboChange() 1047 1014 { 1048 /* Update tool-tip: */ 1049 updateFormatComboToolTip(); 1050 1051 /* Refresh required settings: */ 1052 updatePageAppearance(); 1053 refreshFileSelectorExtension(); 1054 refreshManifestCheckBoxAccess(); 1055 refreshIncludeISOsCheckBoxAccess(); 1056 populateProfiles(); 1057 populateProfile(); 1015 updateFormat(); 1058 1016 emit completeChanged(); 1059 1017 } … … 1061 1019 void UIWizardExportAppPageBasic2::sltHandleFileSelectorChange() 1062 1020 { 1063 /* Remember changed name, except empty one: */ 1064 if (!m_pFileSelector->path().isEmpty()) 1065 m_strFileSelectorName = QFileInfo(m_pFileSelector->path()).completeBaseName(); 1066 1067 /* Refresh required settings: */ 1021 /* Skip empty paths: */ 1022 if (m_pFileSelector->path().isEmpty()) 1023 return; 1024 1025 m_strFileSelectorName = QFileInfo(m_pFileSelector->path()).completeBaseName(); 1026 wizard()->setPath(m_pFileSelector->path()); 1068 1027 emit completeChanged(); 1069 1028 } … … 1071 1030 void UIWizardExportAppPageBasic2::sltHandleMACAddressExportPolicyComboChange() 1072 1031 { 1073 /* Update tool-tip: */ 1074 updateMACAddressExportPolicyComboToolTip(); 1032 updateMACAddressExportPolicyComboToolTip(m_pMACComboBox); 1033 wizard()->setMACAddressExportPolicy(m_pMACComboBox->currentData().value<MACAddressExportPolicy>()); 1034 emit completeChanged(); 1035 } 1036 1037 void UIWizardExportAppPageBasic2::sltHandleManifestCheckBoxChange() 1038 { 1039 wizard()->setManifestSelected(m_pManifestCheckbox->isChecked()); 1040 emit completeChanged(); 1041 } 1042 1043 void UIWizardExportAppPageBasic2::sltHandleIncludeISOsCheckBoxChange() 1044 { 1045 wizard()->setIncludeISOsSelected(m_pIncludeISOsCheckbox->isChecked()); 1046 emit completeChanged(); 1075 1047 } 1076 1048 1077 1049 void UIWizardExportAppPageBasic2::sltHandleProfileComboChange() 1078 1050 { 1079 /* Refresh required settings: */ 1080 populateProfile(); 1051 updateProfile(); 1052 emit completeChanged(); 1053 } 1054 1055 void UIWizardExportAppPageBasic2::sltHandleRadioButtonToggled(QAbstractButton *pButton, bool fToggled) 1056 { 1057 /* Handle checked buttons only: */ 1058 if (!fToggled) 1059 return; 1060 1061 /* Update cloud export mode field value: */ 1062 wizard()->setCloudExportMode(m_exportModeButtons.key(pButton)); 1063 emit completeChanged(); 1081 1064 } 1082 1065 … … 1087 1070 gpManager->openCloudProfileManager(); 1088 1071 } 1072 1073 void UIWizardExportAppPageBasic2::updateFormat() 1074 { 1075 /* Update combo tool-tip: */ 1076 updateFormatComboToolTip(m_pFormatComboBox); 1077 1078 /* Update wizard fields: */ 1079 wizard()->setFormat(format(m_pFormatComboBox)); 1080 wizard()->setFormatCloudOne(isFormatCloudOne(m_pFormatComboBox)); 1081 1082 /* Refresh settings widget state: */ 1083 refreshStackedWidget(m_pSettingsWidget, wizard()->isFormatCloudOne()); 1084 1085 /* Update export settings: */ 1086 refreshFileSelectorExtension(m_strFileSelectorExt, m_pFileSelector, wizard()->isFormatCloudOne()); 1087 refreshFileSelectorPath(m_pFileSelector, m_strFileSelectorName, m_strFileSelectorExt, wizard()->isFormatCloudOne()); 1088 refreshManifestCheckBoxAccess(m_pManifestCheckbox, wizard()->isFormatCloudOne()); 1089 refreshIncludeISOsCheckBoxAccess(m_pIncludeISOsCheckbox, wizard()->isFormatCloudOne()); 1090 refreshProfileCombo(m_pProfileComboBox, wizard()->format(), wizard()->isFormatCloudOne()); 1091 refreshCloudExportMode(m_exportModeButtons, wizard()->isFormatCloudOne()); 1092 1093 /* Update profile: */ 1094 updateProfile(); 1095 } 1096 1097 void UIWizardExportAppPageBasic2::updateProfile() 1098 { 1099 /* Update wizard fields: */ 1100 wizard()->setProfileName(profileName(m_pProfileComboBox)); 1101 1102 /* Update export settings: */ 1103 refreshCloudProfile(m_comCloudProfile, 1104 wizard()->format(), 1105 wizard()->profileName(), 1106 wizard()->isFormatCloudOne()); 1107 } 1108 1109 void UIWizardExportAppPageBasic2::updateCloudStuff() 1110 { 1111 /* Create appliance, client, VSD and VSD export form: */ 1112 CAppliance comAppliance; 1113 CCloudClient comClient; 1114 CVirtualSystemDescription comDescription; 1115 CVirtualSystemDescriptionForm comForm; 1116 refreshCloudStuff(comAppliance, 1117 comClient, 1118 comDescription, 1119 comForm, 1120 m_comCloudProfile, 1121 wizard()->machineIDs(), 1122 wizard()->uri(), 1123 wizard()->cloudExportMode()); 1124 wizard()->setCloudAppliance(comAppliance); 1125 wizard()->setCloudClient(comClient); 1126 wizard()->setVsd(comDescription); 1127 wizard()->setVsdExportForm(comForm); 1128 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic2.h
r91261 r91368 5 5 6 6 /* 7 * Copyright (C) 2009-202 0Oracle Corporation7 * Copyright (C) 2009-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 22 22 #endif 23 23 24 /* Qt includes: */25 #include <QVariant>26 27 24 /* GUI includes: */ 28 #include "UI ApplianceEditorWidget.h"29 #include "UIWizard Page.h"25 #include "UINativeWizardPage.h" 26 #include "UIWizardExportApp.h" 30 27 31 28 /* COM includes: */ … … 34 31 #include "CCloudClient.h" 35 32 #include "CCloudProfile.h" 36 #include "CCloudProvider.h"37 #include "CCloudProviderManager.h"38 33 #include "CVirtualSystemDescription.h" 39 34 #include "CVirtualSystemDescriptionForm.h" 40 35 41 36 /* Forward declarations: */ 37 class QAbstractButton; 38 class QButtonGroup; 42 39 class QCheckBox; 43 class QComboBox;44 40 class QGridLayout; 45 41 class QLabel; 46 class QLineEdit;47 class QRadioButton;48 42 class QStackedWidget; 49 class Q TableWidget;43 class QIComboBox; 50 44 class QIRichTextLabel; 51 45 class QIToolButton; 52 46 class UIEmptyFilePathSelector; 53 47 54 55 /** MAC address export policies. */56 enum MACAddressExportPolicy57 {58 MACAddressExportPolicy_KeepAllMACs,59 MACAddressExportPolicy_StripAllNonNATMACs,60 MACAddressExportPolicy_StripAllMACs,61 MACAddressExportPolicy_MAX62 };63 Q_DECLARE_METATYPE(MACAddressExportPolicy);64 65 48 /** Format combo data fields. */ 66 49 enum 67 50 { 68 FormatData_ID = Qt::UserRole + 1, 69 FormatData_Name = Qt::UserRole + 2, 70 FormatData_ShortName = Qt::UserRole + 3, 71 FormatData_IsItCloudFormat = Qt::UserRole + 4 51 FormatData_Name = Qt::UserRole + 1, 52 FormatData_ShortName = Qt::UserRole + 2, 53 FormatData_IsItCloudFormat = Qt::UserRole + 3 72 54 }; 73 55 … … 78 60 }; 79 61 80 /** Cloud export option modes. */ 81 enum CloudExportMode 82 { 83 CloudExportMode_Invalid, 84 CloudExportMode_AskThenExport, 85 CloudExportMode_ExportThenAsk, 86 CloudExportMode_DoNotAsk 87 }; 88 Q_DECLARE_METATYPE(CloudExportMode); 89 90 91 /** UIWizardPageBase extension for 2nd page of the Export Appliance wizard. */ 92 class UIWizardExportAppPage2 : public UIWizardPageBase 93 { 62 /** Namespace for 2nd basic page of the Export Appliance wizard. */ 63 namespace UIWizardExportAppPage2 64 { 65 /** Populates formats. */ 66 void populateFormats(QIComboBox *pCombo, bool fExportToOCIByDefault); 67 /** Populates MAC address policies. */ 68 void populateMACAddressPolicies(QIComboBox *pCombo); 69 70 /** Returns current format of @a pCombo specified. */ 71 QString format(QIComboBox *pCombo); 72 /** Returns whether format under certain @a iIndex is cloud one. */ 73 bool isFormatCloudOne(QIComboBox *pCombo, int iIndex = -1); 74 75 /** Refresh stacked widget. */ 76 void refreshStackedWidget(QStackedWidget *pStackedWidget, 77 bool fIsFormatCloudOne); 78 79 /** Refresh file selector name. */ 80 void refreshFileSelectorName(QString &strFileSelectorName, 81 const QStringList &machineNames, 82 const QString &strDefaultApplianceName, 83 bool fIsFormatCloudOne); 84 /** Refresh file selector extension. */ 85 void refreshFileSelectorExtension(QString &strFileSelectorExt, 86 UIEmptyFilePathSelector *pFileSelector, 87 bool fIsFormatCloudOne); 88 /** Refresh file selector path. */ 89 void refreshFileSelectorPath(UIEmptyFilePathSelector *pFileSelector, 90 const QString &strFileSelectorName, 91 const QString &strFileSelectorExt, 92 bool fIsFormatCloudOne); 93 /** Refresh Manifest check-box access. */ 94 void refreshManifestCheckBoxAccess(QCheckBox *pCheckBox, 95 bool fIsFormatCloudOne); 96 /** Refresh Include ISOs check-box access. */ 97 void refreshIncludeISOsCheckBoxAccess(QCheckBox *pCheckBox, 98 bool fIsFormatCloudOne); 99 100 /** Refresh profile combo. */ 101 void refreshProfileCombo(QIComboBox *pCombo, 102 const QString &strFormat, 103 bool fIsFormatCloudOne); 104 /** Refresh cloud profile. */ 105 void refreshCloudProfile(CCloudProfile &comCloudProfile, 106 const QString &strShortProviderName, 107 const QString &strProfileName, 108 bool fIsFormatCloudOne); 109 /** Refresh cloud export mode. */ 110 void refreshCloudExportMode(const QMap<CloudExportMode, QAbstractButton*> &radios, 111 bool fIsFormatCloudOne); 112 /** Refresh cloud stuff. */ 113 void refreshCloudStuff(CAppliance &comCloudAppliance, 114 CCloudClient &comCloudClient, 115 CVirtualSystemDescription &comCloudVsd, 116 CVirtualSystemDescriptionForm &comCloudVsdExportForm, 117 const CCloudProfile &comCloudProfile, 118 const QList<QUuid> &machineIDs, 119 const QString &strUri, 120 const CloudExportMode enmCloudExportMode); 121 122 /** Returns current profile name of @a pCombo specified. */ 123 QString profileName(QIComboBox *pCombo); 124 /** Returns current cloud export mode chosen in @a radioButtons specified. */ 125 CloudExportMode cloudExportMode(const QMap<CloudExportMode, QAbstractButton*> &radioButtons); 126 127 /** Updates format combo tool-tips. */ 128 void updateFormatComboToolTip(QIComboBox *pCombo); 129 /** Updates MAC address export policy combo tool-tips. */ 130 void updateMACAddressExportPolicyComboToolTip(QIComboBox *pCombo); 131 } 132 133 /** UINativeWizardPage extension for 2nd basic page of the Export Appliance wizard, 134 * based on UIWizardAddCloudVMPage2 namespace functions. */ 135 class UIWizardExportAppPageBasic2 : public UINativeWizardPage 136 { 137 Q_OBJECT; 138 139 public: 140 141 /** Constructs 2nd basic page. */ 142 UIWizardExportAppPageBasic2(bool fExportToOCIByDefault); 143 94 144 protected: 95 145 96 /** Constructs 2nd page base. */ 97 UIWizardExportAppPage2(bool fExportToOCIByDefault); 98 99 /** Populates formats. */ 100 void populateFormats(); 101 /** Populates MAC address policies. */ 102 void populateMACAddressPolicies(); 103 /** Populates profiles. */ 104 void populateProfiles(); 105 /** Populates profile. */ 106 void populateProfile(); 107 /** Populates form properties. */ 108 void populateFormProperties(); 109 110 /** Updates page appearance. */ 111 virtual void updatePageAppearance(); 112 113 /** Refresh file selector name. */ 114 void refreshFileSelectorName(); 115 /** Refresh file selector extension. */ 116 void refreshFileSelectorExtension(); 117 /** Refresh file selector path. */ 118 void refreshFileSelectorPath(); 119 /** Refresh Manifest check-box access. */ 120 void refreshManifestCheckBoxAccess(); 121 /** Refresh Include ISOs check-box access. */ 122 void refreshIncludeISOsCheckBoxAccess(); 123 124 /** Updates format combo tool-tips. */ 125 void updateFormatComboToolTip(); 126 /** Updates MAC address export policy combo tool-tips. */ 127 void updateMACAddressExportPolicyComboToolTip(); 128 129 /** Defines @a strFormat. */ 130 void setFormat(const QString &strFormat); 131 /** Returns format. */ 132 QString format() const; 133 /** Returns whether format under certain @a iIndex is cloud one. */ 134 bool isFormatCloudOne(int iIndex = -1) const; 135 136 /** Defines @a strPath. */ 137 void setPath(const QString &strPath); 138 /** Returns path. */ 139 QString path() const; 140 141 /** Defines @a enmMACAddressExportPolicy. */ 142 void setMACAddressExportPolicy(MACAddressExportPolicy enmMACAddressExportPolicy); 143 /** Returns MAC address export policy. */ 144 MACAddressExportPolicy macAddressExportPolicy() const; 145 146 /** Defines whether manifest @a fSelected. */ 147 void setManifestSelected(bool fChecked); 148 /** Returns whether manifest selected. */ 149 bool isManifestSelected() const; 150 151 /** Defines whether include ISOs @a fSelected. */ 152 void setIncludeISOsSelected(bool fChecked); 153 /** Returns whether include ISOs selected. */ 154 bool isIncludeISOsSelected() const; 155 156 /** Defines provider by @a uId. */ 157 void setProviderById(const QUuid &uId); 158 /** Returns provider ID. */ 159 QUuid providerId() const; 160 /** Returns provider short name. */ 161 QString providerShortName() const; 162 /** Returns profile name. */ 163 QString profileName() const; 164 /** Returns Cloud Appliance object. */ 165 CAppliance cloudAppliance() const; 166 /** Returns Cloud Client object. */ 167 CCloudClient client() const; 168 /** Returns Virtual System Description object. */ 169 CVirtualSystemDescription vsd() const; 170 /** Returns Virtual System Description Export Form object. */ 171 CVirtualSystemDescriptionForm vsdExportForm() const; 172 /** Returns cloud export mode. */ 173 CloudExportMode cloudExportMode() const; 146 /** Returns wizard this page belongs to. */ 147 UIWizardExportApp *wizard() const; 148 149 /** Handles translation event. */ 150 virtual void retranslateUi() /* override */; 151 152 /** Performs page initialization. */ 153 virtual void initializePage() /* override */; 154 155 /** Returns whether page is complete. */ 156 virtual bool isComplete() const /* override */; 157 158 /** Performs page validation. */ 159 virtual bool validatePage() /* override */; 160 161 private slots: 162 163 /** Handles change in format combo-box. */ 164 void sltHandleFormatComboChange(); 165 166 /** Handles change in file-name selector. */ 167 void sltHandleFileSelectorChange(); 168 169 /** Handles change in MAC address export policy combo-box. */ 170 void sltHandleMACAddressExportPolicyComboChange(); 171 172 /** Handles change in manifest check-box. */ 173 void sltHandleManifestCheckBoxChange(); 174 175 /** Handles change in include ISOs check-box. */ 176 void sltHandleIncludeISOsCheckBoxChange(); 177 178 /** Handles change in profile combo-box. */ 179 void sltHandleProfileComboChange(); 180 181 /** Handles cloud export radio-button clicked. */ 182 void sltHandleRadioButtonToggled(QAbstractButton *pButton, bool fToggled); 183 184 /** Handles profile tool-button click. */ 185 void sltHandleProfileButtonClick(); 186 187 private: 188 189 /** Updates format. */ 190 void updateFormat(); 191 /** Updates profile. */ 192 void updateProfile(); 193 /** Updates cloud stuff. */ 194 void updateCloudStuff(); 174 195 175 196 /** Holds whether default format should be Export to OCI. */ 176 197 bool m_fExportToOCIByDefault; 177 198 178 /** Holds the Cloud Provider Manager reference. */179 CCloudProviderManager m_comCloudProviderManager;180 /** Holds the Cloud Provider object reference. */181 CCloudProvider m_comCloudProvider;182 /** Holds the Cloud Profile object reference. */183 CCloudProfile m_comCloudProfile;184 /** Holds the Appliance object reference. */185 CAppliance m_comAppliance;186 /** Holds the Cloud Client object reference. */187 CCloudClient m_comClient;188 /** Holds the Virtual System Description object reference. */189 CVirtualSystemDescription m_comVSD;190 /** Holds the Virtual System Description Export Form object reference. */191 CVirtualSystemDescriptionForm m_comVSDExportForm;192 193 199 /** Holds the default appliance name. */ 194 200 QString m_strDefaultApplianceName; 195 196 201 /** Holds the file selector name. */ 197 202 QString m_strFileSelectorName; … … 199 204 QString m_strFileSelectorExt; 200 205 206 /** Holds the Cloud Profile object instance. */ 207 CCloudProfile m_comCloudProfile; 208 209 210 /** Holds the format label instance. */ 211 QIRichTextLabel *m_pLabelFormat; 212 /** Holds the settings label instance. */ 213 QIRichTextLabel *m_pLabelSettings; 214 201 215 /** Holds the format layout. */ 202 216 QGridLayout *m_pFormatLayout; 203 /** Holds the settings layout 1. */204 QGridLayout *m_pSettingsLayout1;205 /** Holds the settings layout 2. */206 QGridLayout *m_pSettingsLayout2;207 208 217 /** Holds the format combo-box label instance. */ 209 QLabel *m_pFormatComboBoxLabel;218 QLabel *m_pFormatComboBoxLabel; 210 219 /** Holds the format combo-box instance. */ 211 Q ComboBox*m_pFormatComboBox;220 QIComboBox *m_pFormatComboBox; 212 221 213 222 /** Holds the settings widget instance. */ 214 223 QStackedWidget *m_pSettingsWidget; 215 224 225 /** Holds the settings layout 1. */ 226 QGridLayout *m_pSettingsLayout1; 216 227 /** Holds the file selector label instance. */ 217 228 QLabel *m_pFileSelectorLabel; 218 229 /** Holds the file selector instance. */ 219 230 UIEmptyFilePathSelector *m_pFileSelector; 220 221 231 /** Holds the MAC address policy combo-box label instance. */ 222 QLabel *m_pMACComboBoxLabel;232 QLabel *m_pMACComboBoxLabel; 223 233 /** Holds the MAC address policy check-box instance. */ 224 QComboBox *m_pMACComboBox; 225 234 QIComboBox *m_pMACComboBox; 226 235 /** Holds the additional label instance. */ 227 QLabel *m_pAdditionalLabel;236 QLabel *m_pAdditionalLabel; 228 237 /** Holds the manifest check-box instance. */ 229 QCheckBox *m_pManifestCheckbox;238 QCheckBox *m_pManifestCheckbox; 230 239 /** Holds the include ISOs check-box instance. */ 231 QCheckBox *m_pIncludeISOsCheckbox; 232 240 QCheckBox *m_pIncludeISOsCheckbox; 241 242 /** Holds the settings layout 2. */ 243 QGridLayout *m_pSettingsLayout2; 233 244 /** Holds the profile label instance. */ 234 QLabel *m_pProfileLabel;245 QLabel *m_pProfileLabel; 235 246 /** Holds the profile combo-box instance. */ 236 Q ComboBox *m_pProfileComboBox;247 QIComboBox *m_pProfileComboBox; 237 248 /** Holds the profile management tool-button instance. */ 238 QIToolButton *m_pProfileToolButton; 239 240 /** Holds the machine label instance. */ 241 QLabel *m_pMachineLabel; 242 /** Holds the don't ask radio button instance. */ 243 QRadioButton *m_pRadioDoNotAsk; 244 /** Holds the ask then export radio button instance. */ 245 QRadioButton *m_pRadioAskThenExport; 246 /** Holds the export then ask radio button instance. */ 247 QRadioButton *m_pRadioExportThenAsk; 249 QIToolButton *m_pProfileToolButton; 250 251 /** Holds the export mode label instance. */ 252 QLabel *m_pExportModeLabel; 253 /** Holds the export mode button group instance. */ 254 QButtonGroup *m_pExportModeButtonGroup; 255 /** Holds the map of export mode button instances. */ 256 QMap<CloudExportMode, QAbstractButton*> m_exportModeButtons; 248 257 }; 249 258 250 251 /** UIWizardPage extension for 2nd page of the Export Appliance wizard, extends UIWizardExportAppPage2 as well. */252 class UIWizardExportAppPageBasic2 : public UIWizardPage, public UIWizardExportAppPage2253 {254 Q_OBJECT;255 Q_PROPERTY(QString format READ format WRITE setFormat);256 Q_PROPERTY(bool isFormatCloudOne READ isFormatCloudOne);257 Q_PROPERTY(QString path READ path WRITE setPath);258 Q_PROPERTY(MACAddressExportPolicy macAddressExportPolicy READ macAddressExportPolicy WRITE setMACAddressExportPolicy);259 Q_PROPERTY(bool manifestSelected READ isManifestSelected WRITE setManifestSelected);260 Q_PROPERTY(bool includeISOsSelected READ isIncludeISOsSelected WRITE setIncludeISOsSelected);261 Q_PROPERTY(QString providerShortName READ providerShortName);262 Q_PROPERTY(CAppliance cloudAppliance READ cloudAppliance);263 Q_PROPERTY(CCloudClient client READ client);264 Q_PROPERTY(CVirtualSystemDescription vsd READ vsd);265 Q_PROPERTY(CVirtualSystemDescriptionForm vsdExportForm READ vsdExportForm);266 Q_PROPERTY(CloudExportMode cloudExportMode READ cloudExportMode);267 268 public:269 270 /** Constructs 2nd basic page. */271 UIWizardExportAppPageBasic2(bool fExportToOCIByDefault);272 273 protected:274 275 /** Allows access wizard from base part. */276 UIWizard *wizardImp() const { return UIWizardPage::wizard(); }277 /** Allows access page from base part. */278 UIWizardPage* thisImp() { return this; }279 /** Allows access wizard-field from base part. */280 QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); }281 282 /** Handles translation event. */283 virtual void retranslateUi() /* override */;284 285 /** Performs page initialization. */286 virtual void initializePage() /* override */;287 288 /** Returns whether page is complete. */289 virtual bool isComplete() const /* override */;290 291 /** Performs page validation. */292 virtual bool validatePage() /* override */;293 294 /** Updates page appearance. */295 virtual void updatePageAppearance() /* override */;296 297 private slots:298 299 /** Handles change in format combo-box. */300 void sltHandleFormatComboChange();301 302 /** Handles change in file-name selector. */303 void sltHandleFileSelectorChange();304 305 /** Handles change in MAC address export policy combo-box. */306 void sltHandleMACAddressExportPolicyComboChange();307 308 /** Handles change in profile combo-box. */309 void sltHandleProfileComboChange();310 311 /** Handles profile tool-button click. */312 void sltHandleProfileButtonClick();313 314 private:315 316 /** Holds the format label instance. */317 QIRichTextLabel *m_pLabelFormat;318 319 /** Holds the settings label instance. */320 QIRichTextLabel *m_pLabelSettings;321 };322 323 259 #endif /* !FEQT_INCLUDED_SRC_wizards_exportappliance_UIWizardExportAppPageBasic2_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic3.cpp
r91262 r91368 5 5 6 6 /* 7 * Copyright (C) 2009-202 0Oracle Corporation7 * Copyright (C) 2009-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 25 25 #include "UIApplianceExportEditorWidget.h" 26 26 #include "UICommon.h" 27 #include "UIFormEditorWidget.h" 27 28 #include "UIMessageCenter.h" 28 29 #include "UIWizardExportApp.h" … … 33 34 #include "CVirtualSystemDescriptionForm.h" 34 35 36 /* Namespaces: */ 37 using namespace UIWizardExportAppPage3; 38 35 39 36 40 /********************************************************************************************************************************* … … 38 42 *********************************************************************************************************************************/ 39 43 40 UIWizardExportAppPage3::UIWizardExportAppPage3() 41 : m_pSettingsCntLayout(0)42 , m_pApplianceWidget(0) 43 { 44 } 45 46 void UIWizardExportAppPage3::updatePageAppearance() 47 { 48 /* Check whether there was cloud target selected: */49 const bool fIsFormatCloudOne = fieldImp("isFormatCloudOne").toBool();50 /* Update page appearance according to chosen source: */51 m_pSettingsCntLayout->setCurrentIndex((int)fIsFormatCloudOne); 52 } 53 54 void UIWizardExportAppPage3::refreshApplianceSettingsWidget() 55 { 44 void UIWizardExportAppPage3::refreshStackedLayout(QStackedLayout *pStackedLayout, 45 bool fIsFormatCloudOne) 46 { 47 /* Update stack appearance according to chosen format: */ 48 pStackedLayout->setCurrentIndex((int)fIsFormatCloudOne); 49 } 50 51 void UIWizardExportAppPage3::refreshApplianceSettingsWidget(UIApplianceExportEditorWidget *pApplianceWidget, 52 const QList<QUuid> &machineIDs, 53 const QString &strUri, 54 bool fIsFormatCloudOne) 55 { 56 /* Nothing for cloud case? */ 57 if (fIsFormatCloudOne) 58 return; 59 56 60 /* Acquire appliance: */ 57 CAppliance *pAppliance = m_pApplianceWidget->init();61 CAppliance *pAppliance = pApplianceWidget->init(); 58 62 if (pAppliance->isOk()) 59 63 { 60 64 /* Iterate over all the selected machine uuids: */ 61 const QList<QUuid> uuids = fieldImp("machineIDs").value<QList<QUuid> >(); 62 foreach (const QUuid &uMachineId, uuids) 65 foreach (const QUuid &uMachineId, machineIDs) 63 66 { 64 67 /* Get the machine with the uMachineId: */ … … 68 71 { 69 72 /* Add the export description to our appliance object: */ 70 CVirtualSystemDescription comVsd = comMachine.ExportTo(*pAppliance, qobject_cast<UIWizardExportApp*>(wizardImp())->uri());73 CVirtualSystemDescription comVsd = comMachine.ExportTo(*pAppliance, strUri); 71 74 if (comMachine.isOk() && comVsd.isNotNull()) 72 75 { … … 80 83 } 81 84 else 82 return msgCenter().cannotExportAppliance(comMachine, pAppliance->GetPath() , thisImp());85 return msgCenter().cannotExportAppliance(comMachine, pAppliance->GetPath()); 83 86 } 84 87 else … … 86 89 } 87 90 /* Make sure the settings widget get the new descriptions: */ 88 m_pApplianceWidget->populate(); 89 } 90 } 91 92 void UIWizardExportAppPage3::refreshFormPropertiesTable() 93 { 94 /* Acquire VSD form: */ 95 CVirtualSystemDescriptionForm comForm = fieldImp("vsdExportForm").value<CVirtualSystemDescriptionForm>(); 91 pApplianceWidget->populate(); 92 } 93 } 94 95 void UIWizardExportAppPage3::refreshFormPropertiesTable(UIFormEditorWidget *pFormEditor, 96 const CVirtualSystemDescriptionForm &comVsdExportForm, 97 bool fIsFormatCloudOne) 98 { 99 /* Nothing for local case? */ 100 if (!fIsFormatCloudOne) 101 return; 102 96 103 /* Make sure the properties table get the new description form: */ 97 if (comForm.isNotNull()) 98 m_pFormEditor->setVirtualSystemDescriptionForm(comForm); 99 } 100 101 CAppliance UIWizardExportAppPage3::localAppliance() const 102 { 103 CAppliance *pAppliance = m_pApplianceWidget->appliance(); 104 return pAppliance ? *pAppliance : CAppliance(); 104 if (comVsdExportForm.isNotNull()) 105 pFormEditor->setVirtualSystemDescriptionForm(comVsdExportForm); 105 106 } 106 107 … … 117 118 { 118 119 /* Create label: */ 119 m_pLabel = new QIRichTextLabel ;120 m_pLabel = new QIRichTextLabel(this); 120 121 if (m_pLabel) 121 {122 /* Add into layout: */123 122 pMainLayout->addWidget(m_pLabel); 124 }125 123 126 124 /* Create settings container layout: */ 127 m_pSettings CntLayout = new QStackedLayout;128 if (m_pSettings CntLayout)125 m_pSettingsLayout = new QStackedLayout(this); 126 if (m_pSettingsLayout) 129 127 { 130 128 /* Create appliance widget container: */ … … 139 137 140 138 /* Create appliance widget: */ 141 m_pApplianceWidget = new UIApplianceExportEditorWidget ;139 m_pApplianceWidget = new UIApplianceExportEditorWidget(pApplianceWidgetCnt); 142 140 if (m_pApplianceWidget) 143 141 { 144 142 m_pApplianceWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); 145 146 /* Add into layout: */147 143 pApplianceWidgetLayout->addWidget(m_pApplianceWidget); 148 144 } … … 150 146 151 147 /* Add into layout: */ 152 m_pSettings CntLayout->addWidget(pApplianceWidgetCnt);148 m_pSettingsLayout->addWidget(pApplianceWidgetCnt); 153 149 } 154 150 … … 166 162 m_pFormEditor = new UIFormEditorWidget(pFormEditorCnt); 167 163 if (m_pFormEditor) 168 {169 /* Add into layout: */170 164 pFormEditorLayout->addWidget(m_pFormEditor); 171 }172 165 } 173 166 174 167 /* Add into layout: */ 175 m_pSettings CntLayout->addWidget(pFormEditorCnt);168 m_pSettingsLayout->addWidget(pFormEditorCnt); 176 169 } 177 170 178 171 /* Add into layout: */ 179 pMainLayout->addLayout(m_pSettings CntLayout);172 pMainLayout->addLayout(m_pSettingsLayout); 180 173 } 181 174 } 182 183 /* Register fields: */ 184 registerField("localAppliance", this, "localAppliance"); 175 } 176 177 UIWizardExportApp *UIWizardExportAppPageBasic3::wizard() const 178 { 179 return qobject_cast<UIWizardExportApp*>(UINativeWizardPage::wizard()); 185 180 } 186 181 … … 190 185 setTitle(UIWizardExportApp::tr("Virtual system settings")); 191 186 192 /* Update page appearance: */ 193 updatePageAppearance(); 187 /* Translate label: */ 188 if (wizard()->isFormatCloudOne()) 189 m_pLabel->setText(UIWizardExportApp::tr("This is the descriptive information which will be used to determine settings " 190 "for a cloud storage your VM being exported to. You can change it by double " 191 "clicking on individual lines.")); 192 else 193 m_pLabel->setText(UIWizardExportApp::tr("This is the descriptive information which will be added to the virtual " 194 "appliance. You can change it by double clicking on individual lines.")); 194 195 } 195 196 … … 199 200 retranslateUi(); 200 201 201 /* Check whether there was cloud target selected: */ 202 const bool fIsFormatCloudOne = field("isFormatCloudOne").toBool(); 203 if (fIsFormatCloudOne) 204 refreshFormPropertiesTable(); 202 /* Refresh settings layout state: */ 203 refreshStackedLayout(m_pSettingsLayout, wizard()->isFormatCloudOne()); 204 /* Refresh corresponding widgets: */ 205 refreshApplianceSettingsWidget(m_pApplianceWidget, wizard()->machineIDs(), wizard()->uri(), wizard()->isFormatCloudOne()); 206 refreshFormPropertiesTable(m_pFormEditor, wizard()->vsdExportForm(), wizard()->isFormatCloudOne()); 207 208 /* Choose initially focused widget: */ 209 if (wizard()->isFormatCloudOne()) 210 m_pFormEditor->setFocus(); 205 211 else 206 refreshApplianceSettingsWidget(); 207 208 /* Listen for custom button clicks: */ 209 connect(wizard(), &UIWizard::customButtonClicked, 210 this, &UIWizardExportAppPageBasic3::sltHandleCustomButtonClicked, 211 Qt::UniqueConnection); 212 } 213 214 void UIWizardExportAppPageBasic3::cleanupPage() 215 { 216 /* Call to base-class: */ 217 UIWizardPage::cleanupPage(); 218 219 /* Stop listen for custom button clicks: */ 220 disconnect(wizard(), &UIWizard::customButtonClicked, 221 this, &UIWizardExportAppPageBasic3::sltHandleCustomButtonClicked); 212 m_pApplianceWidget->setFocus(); 222 213 } 223 214 … … 227 218 bool fResult = true; 228 219 229 /* Lock finish button: */230 startProcessing();231 232 220 /* Check whether there was cloud target selected: */ 233 const bool fIsFormatCloudOne = fieldImp("isFormatCloudOne").toBool(); 234 if (fIsFormatCloudOne) 221 if (wizard()->isFormatCloudOne()) 235 222 { 236 223 /* Make sure table has own data committed: */ … … 238 225 239 226 /* Check whether we have proper VSD form: */ 240 CVirtualSystemDescriptionForm comForm = fieldImp("vsdExportForm").value<CVirtualSystemDescriptionForm>();227 CVirtualSystemDescriptionForm comForm = wizard()->vsdExportForm(); 241 228 fResult = comForm.isNotNull(); 242 229 Assert(fResult); … … 256 243 /* Prepare export: */ 257 244 m_pApplianceWidget->prepareExport(); 245 wizard()->setLocalAppliance(*m_pApplianceWidget->appliance()); 258 246 } 259 247 260 248 /* Try to export appliance: */ 261 249 if (fResult) 262 fResult = qobject_cast<UIWizardExportApp*>(wizard())->exportAppliance(); 263 264 /* Unlock finish button: */ 265 endProcessing(); 250 fResult = wizard()->exportAppliance(); 266 251 267 252 /* Return result: */ 268 253 return fResult; 269 254 } 270 271 void UIWizardExportAppPageBasic3::updatePageAppearance()272 {273 /* Call to base-class: */274 UIWizardExportAppPage3::updatePageAppearance();275 276 /* Check whether there was cloud target selected: */277 const bool fIsFormatCloudOne = field("isFormatCloudOne").toBool();278 if (fIsFormatCloudOne)279 {280 m_pLabel->setText(UIWizardExportApp::tr("This is the descriptive information which will be used to determine settings "281 "for a cloud storage your VM being exported to. You can change it by double "282 "clicking on individual lines."));283 m_pFormEditor->setFocus();284 }285 else286 {287 m_pLabel->setText(UIWizardExportApp::tr("This is the descriptive information which will be added to the virtual "288 "appliance. You can change it by double clicking on individual lines."));289 m_pApplianceWidget->setFocus();290 }291 }292 293 void UIWizardExportAppPageBasic3::sltHandleCustomButtonClicked(int iId)294 {295 /* Handle 2nd button: */296 if (iId == QWizard::CustomButton2)297 {298 /* Reset widget to default: */299 m_pApplianceWidget->restoreDefaults();300 }301 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic3.h
r91262 r91368 5 5 6 6 /* 7 * Copyright (C) 2009-202 0Oracle Corporation7 * Copyright (C) 2009-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 24 24 /* Qt includes: */ 25 25 #include <QList> 26 #include <QVariant>27 26 28 27 /* GUI includes: */ 29 #include "UIExtraDataDefs.h" 30 #include "UIFormEditorWidget.h" 31 #include "UIWizardPage.h" 28 #include "UINativeWizardPage.h" 32 29 33 30 /* COM includes: */ 31 #include "COMEnums.h" 34 32 #include "CAppliance.h" 35 33 … … 38 36 class QIRichTextLabel; 39 37 class UIApplianceExportEditorWidget; 38 class UIFormEditorWidget; 40 39 class UIWizardExportApp; 41 40 42 43 /** UIWizardPageBase extension for 3rd page of the Export Appliance wizard. */ 44 class UIWizardExportAppPage3 : public UIWizardPageBase 41 /** Namespace for 3rd basic page of the Export Appliance wizard. */ 42 namespace UIWizardExportAppPage3 45 43 { 46 protected: 47 48 /** Constructs 3rd page base. */ 49 UIWizardExportAppPage3(); 50 51 /** Updates page appearance. */ 52 virtual void updatePageAppearance(); 44 /** Refresh stacked layout. */ 45 void refreshStackedLayout(QStackedLayout *pStackedLayout, 46 bool fIsFormatCloudOne); 53 47 54 48 /** Refreshes appliance settings widget. */ 55 void refreshApplianceSettingsWidget(); 49 void refreshApplianceSettingsWidget(UIApplianceExportEditorWidget *pApplianceWidget, 50 const QList<QUuid> &machineIDs, 51 const QString &strUri, 52 bool fIsFormatCloudOne); 56 53 /** Refreshes form properties table. */ 57 void refreshFormPropertiesTable(); 54 void refreshFormPropertiesTable(UIFormEditorWidget *pFormEditor, 55 const CVirtualSystemDescriptionForm &comVsdExportForm, 56 bool fIsFormatCloudOne); 57 } 58 58 59 /** Returns Local Appliance object. */ 60 CAppliance localAppliance() const; 61 62 /** Holds the settings container layout instance. */ 63 QStackedLayout *m_pSettingsCntLayout; 64 65 /** Holds the appliance widget reference. */ 66 UIApplianceExportEditorWidget *m_pApplianceWidget; 67 /** Holds the Form Editor widget instance. */ 68 UIFormEditorWidgetPointer m_pFormEditor; 69 }; 70 71 72 /** UIWizardPage extension for 3rd page of the Export Appliance wizard, extends UIWizardExportAppPage3 as well. */ 73 class UIWizardExportAppPageBasic3 : public UIWizardPage, public UIWizardExportAppPage3 59 /** UINativeWizardPage extension for 3rd basic page of the Export Appliance wizard, 60 * based on UIWizardAddCloudVMPage3 namespace functions. */ 61 class UIWizardExportAppPageBasic3 : public UINativeWizardPage 74 62 { 75 63 Q_OBJECT; 76 Q_PROPERTY(CAppliance localAppliance READ localAppliance);77 64 78 65 public: … … 83 70 protected: 84 71 85 /** Allows access wizard from base part. */ 86 UIWizard *wizardImp() const { return UIWizardPage::wizard(); } 87 /** Allows access page from base part. */ 88 UIWizardPage* thisImp() { return this; } 89 /** Allows access wizard-field from base part. */ 90 QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); } 72 /** Returns wizard this page belongs to. */ 73 UIWizardExportApp *wizard() const; 91 74 92 75 /** Handles translation event. */ … … 95 78 /** Performs page initialization. */ 96 79 virtual void initializePage() /* override */; 97 /** Performs page cleanup. */98 virtual void cleanupPage() /* override */;99 80 100 81 /** Performs page validation. */ 101 82 virtual bool validatePage() /* override */; 102 103 /** Updates page appearance. */104 virtual void updatePageAppearance() /* override */;105 106 private slots:107 108 /** Handles custom button clicked.109 * @param iId Brings clicked button id. */110 void sltHandleCustomButtonClicked(int iId);111 83 112 84 private: … … 114 86 /** Holds the label instance. */ 115 87 QIRichTextLabel *m_pLabel; 88 89 /** Holds the settings container layout instance. */ 90 QStackedLayout *m_pSettingsLayout; 91 92 /** Holds the appliance widget reference. */ 93 UIApplianceExportEditorWidget *m_pApplianceWidget; 94 /** Holds the Form Editor widget instance. */ 95 UIFormEditorWidget *m_pFormEditor; 116 96 }; 117 97 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageExpert.cpp
r91262 r91368 5 5 6 6 /* 7 * Copyright (C) 2009-202 0Oracle Corporation7 * Copyright (C) 2009-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 17 18 18 /* Qt includes: */ 19 #include <QButtonGroup> 19 20 #include <QCheckBox> 20 21 #include <QGridLayout> … … 31 32 32 33 /* GUI includes: */ 34 #include "QIComboBox.h" 33 35 #include "QIToolButton.h" 34 36 #include "UICommon.h" … … 36 38 #include "UIConverter.h" 37 39 #include "UIEmptyFilePathSelector.h" 40 #include "UIFormEditorWidget.h" 38 41 #include "UIIconPool.h" 39 42 #include "UIMessageCenter.h" … … 41 44 #include "UIVirtualBoxManager.h" 42 45 #include "UIWizardExportApp.h" 46 #include "UIWizardExportAppPageBasic1.h" 47 #include "UIWizardExportAppPageBasic2.h" 48 #include "UIWizardExportAppPageBasic3.h" 43 49 #include "UIWizardExportAppPageExpert.h" 50 51 /* Namespaces: */ 52 using namespace UIWizardExportAppPage1; 53 using namespace UIWizardExportAppPage2; 54 using namespace UIWizardExportAppPage3; 44 55 45 56 … … 49 60 50 61 UIWizardExportAppPageExpert::UIWizardExportAppPageExpert(const QStringList &selectedVMNames, bool fExportToOCIByDefault) 51 : UIWizardExportAppPage2(fExportToOCIByDefault)52 , m_f Polished(false)62 : m_selectedVMNames(selectedVMNames) 63 , m_fExportToOCIByDefault(fExportToOCIByDefault) 53 64 , m_pSelectorCnt(0) 65 , m_pVMSelector(0) 54 66 , m_pApplianceCnt(0) 67 , m_pSettingsLayout(0) 68 , m_pApplianceWidget(0) 69 , m_pFormEditor(0) 55 70 , m_pSettingsCnt(0) 71 , m_pFormatLayout(0) 72 , m_pFormatComboBoxLabel(0) 73 , m_pFormatComboBox(0) 74 , m_pSettingsWidget(0) 75 , m_pSettingsLayout1(0) 76 , m_pFileSelectorLabel(0) 77 , m_pFileSelector(0) 78 , m_pMACComboBoxLabel(0) 79 , m_pMACComboBox(0) 80 , m_pAdditionalLabel(0) 81 , m_pManifestCheckbox(0) 82 , m_pIncludeISOsCheckbox(0) 83 , m_pSettingsLayout2(0) 84 , m_pProfileLabel(0) 85 , m_pProfileComboBox(0) 86 , m_pProfileToolButton(0) 87 , m_pExportModeLabel(0) 88 , m_pExportModeButtonGroup(0) 56 89 { 57 90 /* Create widgets: */ … … 62 95 63 96 /* Create VM selector container: */ 64 m_pSelectorCnt = new QGroupBox ;97 m_pSelectorCnt = new QGroupBox(this); 65 98 if (m_pSelectorCnt) 66 99 { … … 70 103 { 71 104 /* Create VM selector: */ 72 m_pVMSelector = new QListWidget ;105 m_pVMSelector = new QListWidget(m_pSelectorCnt); 73 106 if (m_pVMSelector) 74 107 { 75 108 m_pVMSelector->setAlternatingRowColors(true); 76 109 m_pVMSelector->setSelectionMode(QAbstractItemView::ExtendedSelection); 77 78 /* Add into layout: */79 110 pSelectorCntLayout->addWidget(m_pVMSelector); 80 111 } … … 86 117 87 118 /* Create appliance widget container: */ 88 m_pApplianceCnt = new QGroupBox ;119 m_pApplianceCnt = new QGroupBox(this); 89 120 if (m_pApplianceCnt) 90 121 { … … 94 125 { 95 126 /* Create settings container layout: */ 96 m_pSettings CntLayout = new QStackedLayout;97 if (m_pSettings CntLayout)127 m_pSettingsLayout = new QStackedLayout; 128 if (m_pSettingsLayout) 98 129 { 99 130 /* Create appliance widget container: */ … … 108 139 109 140 /* Create appliance widget: */ 110 m_pApplianceWidget = new UIApplianceExportEditorWidget ;141 m_pApplianceWidget = new UIApplianceExportEditorWidget(pApplianceWidgetCnt); 111 142 if (m_pApplianceWidget) 112 143 { 113 144 m_pApplianceWidget->setMinimumHeight(250); 114 145 m_pApplianceWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); 115 116 /* Add into layout: */117 146 pApplianceWidgetLayout->addWidget(m_pApplianceWidget); 118 147 } … … 120 149 121 150 /* Add into layout: */ 122 m_pSettings CntLayout->addWidget(pApplianceWidgetCnt);151 m_pSettingsLayout->addWidget(pApplianceWidgetCnt); 123 152 } 124 153 … … 136 165 m_pFormEditor = new UIFormEditorWidget(pFormEditorCnt); 137 166 if (m_pFormEditor) 138 {139 /* Add into layout: */140 167 pFormEditorLayout->addWidget(m_pFormEditor); 141 }142 168 } 143 169 144 170 /* Add into layout: */ 145 m_pSettings CntLayout->addWidget(pFormEditorCnt);171 m_pSettingsLayout->addWidget(pFormEditorCnt); 146 172 } 147 173 148 174 /* Add into layout: */ 149 pApplianceCntLayout->addLayout(m_pSettings CntLayout);175 pApplianceCntLayout->addLayout(m_pSettingsLayout); 150 176 } 151 177 } … … 156 182 157 183 /* Create settings widget container: */ 158 m_pSettingsCnt = new QGroupBox ;184 m_pSettingsCnt = new QGroupBox(this); 159 185 if (m_pSettingsCnt) 160 186 { … … 179 205 180 206 /* Create format combo-box: */ 181 m_pFormatComboBox = new Q ComboBox;207 m_pFormatComboBox = new QIComboBox(m_pSettingsCnt); 182 208 if (m_pFormatComboBox) 183 {184 /* Add into layout: */185 209 m_pFormatLayout->addWidget(m_pFormatComboBox, 0, 1); 186 }187 210 /* Create format combo-box label: */ 188 m_pFormatComboBoxLabel = new QLabel ;211 m_pFormatComboBoxLabel = new QLabel(m_pSettingsCnt); 189 212 if (m_pFormatComboBoxLabel) 190 213 { 191 214 m_pFormatComboBoxLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); 192 215 m_pFormatComboBoxLabel->setBuddy(m_pFormatComboBox); 193 194 /* Add into layout: */195 216 m_pFormatLayout->addWidget(m_pFormatComboBoxLabel, 0, 0); 196 217 } … … 205 226 { 206 227 /* Create settings pane 1: */ 207 QWidget *pSettingsPane1 = new QWidget ;228 QWidget *pSettingsPane1 = new QWidget(m_pSettingsWidget); 208 229 if (pSettingsPane1) 209 230 { … … 243 264 244 265 /* Create MAC policy combo-box: */ 245 m_pMACComboBox = new Q ComboBox;266 m_pMACComboBox = new QIComboBox; 246 267 if (m_pMACComboBox) 247 268 { … … 298 319 299 320 /* Create settings pane 2: */ 300 QWidget *pSettingsPane2 = new QWidget ;321 QWidget *pSettingsPane2 = new QWidget(m_pSettingsWidget); 301 322 if (pSettingsPane2) 302 323 { … … 313 334 314 335 /* Create profile label: */ 315 m_pProfileLabel = new QLabel ;336 m_pProfileLabel = new QLabel(pSettingsPane2); 316 337 if (m_pProfileLabel) 317 338 { 318 339 m_pProfileLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 319 320 /* Add into layout: */321 340 m_pSettingsLayout2->addWidget(m_pProfileLabel, 0, 0); 322 341 } … … 329 348 330 349 /* Create profile combo-box: */ 331 m_pProfileComboBox = new Q ComboBox;350 m_pProfileComboBox = new QIComboBox(pSettingsPane2); 332 351 if (m_pProfileComboBox) 333 352 { 334 353 m_pProfileLabel->setBuddy(m_pProfileComboBox); 335 336 /* Add into layout: */337 354 pSubLayout->addWidget(m_pProfileComboBox); 338 355 } 339 356 /* Create profile tool-button: */ 340 m_pProfileToolButton = new QIToolButton ;357 m_pProfileToolButton = new QIToolButton(pSettingsPane2); 341 358 if (m_pProfileToolButton) 342 359 { 343 360 m_pProfileToolButton->setIcon(UIIconPool::iconSet(":/cloud_profile_manager_16px.png", 344 361 ":/cloud_profile_manager_disabled_16px.png")); 345 346 /* Add into layout: */347 362 pSubLayout->addWidget(m_pProfileToolButton); 348 363 } … … 353 368 354 369 /* Create profile label: */ 355 m_pMachineLabel = new QLabel; 356 if (m_pMachineLabel) 357 { 358 m_pMachineLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); 359 360 /* Add into layout: */ 361 m_pSettingsLayout2->addWidget(m_pMachineLabel, 1, 0); 362 } 363 /* Create Do Not Ask button: */ 364 m_pRadioDoNotAsk = new QRadioButton; 365 if (m_pRadioDoNotAsk) 366 { 367 /* Add into layout: */ 368 m_pSettingsLayout2->addWidget(m_pRadioDoNotAsk, 1, 1); 369 } 370 /* Create Ask Then Export button: */ 371 m_pRadioAskThenExport = new QRadioButton; 372 if (m_pRadioAskThenExport) 373 { 374 /* Add into layout: */ 375 m_pSettingsLayout2->addWidget(m_pRadioAskThenExport, 2, 1); 376 } 377 /* Create Export Then Ask button: */ 378 m_pRadioExportThenAsk = new QRadioButton; 379 if (m_pRadioExportThenAsk) 380 { 381 /* Add into layout: */ 382 m_pSettingsLayout2->addWidget(m_pRadioExportThenAsk, 3, 1); 370 m_pExportModeLabel = new QLabel(pSettingsPane2); 371 if (m_pExportModeLabel) 372 { 373 m_pExportModeLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); 374 m_pSettingsLayout2->addWidget(m_pExportModeLabel, 1, 0); 375 } 376 377 /* Create button-group: */ 378 m_pExportModeButtonGroup = new QButtonGroup(pSettingsPane2); 379 if (m_pExportModeButtonGroup) 380 { 381 /* Create Do Not Ask button: */ 382 m_exportModeButtons[CloudExportMode_DoNotAsk] = new QRadioButton(pSettingsPane2); 383 if (m_exportModeButtons.value(CloudExportMode_DoNotAsk)) 384 { 385 m_pExportModeButtonGroup->addButton(m_exportModeButtons.value(CloudExportMode_DoNotAsk)); 386 m_pSettingsLayout2->addWidget(m_exportModeButtons.value(CloudExportMode_DoNotAsk), 1, 1); 387 } 388 /* Create Ask Then Export button: */ 389 m_exportModeButtons[CloudExportMode_AskThenExport] = new QRadioButton(pSettingsPane2); 390 if (m_exportModeButtons.value(CloudExportMode_AskThenExport)) 391 { 392 m_pExportModeButtonGroup->addButton(m_exportModeButtons.value(CloudExportMode_AskThenExport)); 393 m_pSettingsLayout2->addWidget(m_exportModeButtons.value(CloudExportMode_AskThenExport), 2, 1); 394 } 395 /* Create Export Then Ask button: */ 396 m_exportModeButtons[CloudExportMode_ExportThenAsk] = new QRadioButton(pSettingsPane2); 397 if (m_exportModeButtons.value(CloudExportMode_ExportThenAsk)) 398 { 399 m_pExportModeButtonGroup->addButton(m_exportModeButtons.value(CloudExportMode_ExportThenAsk)); 400 m_pSettingsLayout2->addWidget(m_exportModeButtons.value(CloudExportMode_ExportThenAsk), 3, 1); 401 } 383 402 } 384 403 } … … 397 416 } 398 417 } 399 400 /* Populate VM selector items: */401 populateVMSelectorItems(selectedVMNames);402 /* Populate formats: */403 populateFormats();404 /* Populate MAC address policies: */405 populateMACAddressPolicies();406 418 407 419 /* Setup connections: */ … … 410 422 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigCloudProfileChanged, 411 423 this, &UIWizardExportAppPageExpert::sltHandleFormatComboChange); 412 connect(m_pVMSelector, &QListWidget::itemSelectionChanged, this, &UIWizardExportAppPageExpert::sltVMSelectionChangeHandler); 424 connect(m_pVMSelector, &QListWidget::itemSelectionChanged, 425 this, &UIWizardExportAppPageExpert::sltHandleVMItemSelectionChanged); 413 426 connect(m_pFileSelector, &UIEmptyFilePathSelector::pathChanged, 414 427 this, &UIWizardExportAppPageExpert::sltHandleFileSelectorChange); 415 connect(m_pFormatComboBox, static_cast<void(Q ComboBox::*)(int)>(&QComboBox::currentIndexChanged),428 connect(m_pFormatComboBox, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::currentIndexChanged), 416 429 this, &UIWizardExportAppPageExpert::sltHandleFormatComboChange); 417 connect(m_pMACComboBox, static_cast<void(Q ComboBox::*)(int)>(&QComboBox::currentIndexChanged),430 connect(m_pMACComboBox, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::currentIndexChanged), 418 431 this, &UIWizardExportAppPageExpert::sltHandleMACAddressExportPolicyComboChange); 419 connect(m_pProfileComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), 432 connect(m_pManifestCheckbox, &QCheckBox::stateChanged, 433 this, &UIWizardExportAppPageExpert::sltHandleManifestCheckBoxChange); 434 connect(m_pIncludeISOsCheckbox, &QCheckBox::stateChanged, 435 this, &UIWizardExportAppPageExpert::sltHandleIncludeISOsCheckBoxChange); 436 connect(m_pProfileComboBox, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::currentIndexChanged), 420 437 this, &UIWizardExportAppPageExpert::sltHandleProfileComboChange); 438 connect(m_pExportModeButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton*, bool)>(&QButtonGroup::buttonToggled), 439 this, &UIWizardExportAppPageExpert::sltHandleRadioButtonToggled); 421 440 connect(m_pProfileToolButton, &QIToolButton::clicked, 422 441 this, &UIWizardExportAppPageExpert::sltHandleProfileButtonClick); 423 424 /* Register fields: */ 425 registerField("machineNames", this, "machineNames"); 426 registerField("machineIDs", this, "machineIDs"); 427 registerField("format", this, "format"); 428 registerField("isFormatCloudOne", this, "isFormatCloudOne"); 429 registerField("path", this, "path"); 430 registerField("macAddressExportPolicy", this, "macAddressExportPolicy"); 431 registerField("manifestSelected", this, "manifestSelected"); 432 registerField("includeISOsSelected", this, "includeISOsSelected"); 433 registerField("providerShortName", this, "providerShortName"); 434 registerField("cloudAppliance", this, "cloudAppliance"); 435 registerField("client", this, "client"); 436 registerField("vsd", this, "vsd"); 437 registerField("vsdExportForm", this, "vsdExportForm"); 438 registerField("cloudExportMode", this, "cloudExportMode"); 439 registerField("localAppliance", this, "localAppliance"); 442 } 443 444 UIWizardExportApp *UIWizardExportAppPageExpert::wizard() const 445 { 446 return qobject_cast<UIWizardExportApp*>(UINativeWizardPage::wizard()); 440 447 } 441 448 … … 444 451 /* Translate objects: */ 445 452 m_strDefaultApplianceName = UIWizardExportApp::tr("Appliance"); 453 refreshFileSelectorName(m_strFileSelectorName, wizard()->machineNames(), m_strDefaultApplianceName, wizard()->isFormatCloudOne()); 454 refreshFileSelectorPath(m_pFileSelector, m_strFileSelectorName, m_strFileSelectorExt, wizard()->isFormatCloudOne()); 446 455 447 456 /* Translate group-boxes: */ … … 467 476 * We are enumerating starting from 0 for simplicity: */ 468 477 for (int i = 0; i < m_pFormatComboBox->count(); ++i) 469 if (isFormatCloudOne( i))478 if (isFormatCloudOne(m_pFormatComboBox, i)) 470 479 { 471 480 m_pFormatComboBox->setItemText(i, m_pFormatComboBox->itemData(i, FormatData_Name).toString()); … … 483 492 { 484 493 m_pMACComboBox->setItemText(i, UIWizardExportApp::tr("Include all network adapter MAC addresses")); 485 m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Include all network adapter MAC addresses in exported appliance archive."), Qt::ToolTipRole); 494 m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Include all network adapter MAC addresses in exported " 495 "appliance archive."), Qt::ToolTipRole); 486 496 break; 487 497 } … … 489 499 { 490 500 m_pMACComboBox->setItemText(i, UIWizardExportApp::tr("Include only NAT network adapter MAC addresses")); 491 m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Include only NAT network adapter MAC addresses in exported appliance archive."), Qt::ToolTipRole); 501 m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Include only NAT network adapter MAC addresses in exported " 502 "appliance archive."), Qt::ToolTipRole); 492 503 break; 493 504 } … … 495 506 { 496 507 m_pMACComboBox->setItemText(i, UIWizardExportApp::tr("Strip all network adapter MAC addresses")); 497 m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Strip all network adapter MAC addresses from exported appliance archive."), Qt::ToolTipRole); 508 m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Strip all network adapter MAC addresses from exported " 509 "appliance archive."), Qt::ToolTipRole); 498 510 break; 499 511 } … … 505 517 /* Translate addtional stuff: */ 506 518 m_pAdditionalLabel->setText(UIWizardExportApp::tr("Additionally:")); 507 m_pManifestCheckbox->setToolTip(UIWizardExportApp::tr("Create s a manifest file for automatic data integrity checks on import."));519 m_pManifestCheckbox->setToolTip(UIWizardExportApp::tr("Create a Manifest file for automatic data integrity checks on import.")); 508 520 m_pManifestCheckbox->setText(UIWizardExportApp::tr("&Write Manifest file")); 509 m_pIncludeISOsCheckbox->setToolTip(UIWizardExportApp::tr("Include sISO image files into exported VM archive."));521 m_pIncludeISOsCheckbox->setToolTip(UIWizardExportApp::tr("Include ISO image files into exported VM archive.")); 510 522 m_pIncludeISOsCheckbox->setText(UIWizardExportApp::tr("&Include ISO image files")); 511 523 512 524 /* Translate profile stuff: */ 513 525 m_pProfileLabel->setText(UIWizardExportApp::tr("&Profile:")); 514 m_pProfileToolButton->setToolTip(UIWizardExportApp::tr("Open sCloud Profile Manager..."));526 m_pProfileToolButton->setToolTip(UIWizardExportApp::tr("Open Cloud Profile Manager...")); 515 527 516 528 /* Translate option label: */ 517 m_p MachineLabel->setText(UIWizardExportApp::tr("Machine Creation:"));518 m_ pRadioDoNotAsk->setText(UIWizardExportApp::tr("Do not ask me about it, leave custom &image for future usage"));519 m_ pRadioAskThenExport->setText(UIWizardExportApp::tr("Ask me about it &before exporting disk as custom image"));520 m_ pRadioExportThenAsk->setText(UIWizardExportApp::tr("Ask me about it &after exporting disk as custom image"));529 m_pExportModeLabel->setText(UIWizardExportApp::tr("Machine Creation:")); 530 m_exportModeButtons.value(CloudExportMode_DoNotAsk)->setText(UIWizardExportApp::tr("Do not ask me about it, leave custom &image for future usage")); 531 m_exportModeButtons.value(CloudExportMode_AskThenExport)->setText(UIWizardExportApp::tr("Ask me about it &before exporting disk as custom image")); 532 m_exportModeButtons.value(CloudExportMode_ExportThenAsk)->setText(UIWizardExportApp::tr("Ask me about it &after exporting disk as custom image")); 521 533 522 534 /* Adjust label widths: */ … … 527 539 labels << m_pAdditionalLabel; 528 540 labels << m_pProfileLabel; 529 labels << m_p MachineLabel;541 labels << m_pExportModeLabel; 530 542 int iMaxWidth = 0; 531 543 foreach (QWidget *pLabel, labels) … … 535 547 m_pSettingsLayout2->setColumnMinimumWidth(0, iMaxWidth); 536 548 537 /* Refresh file selector name: */538 refreshFileSelectorName();539 540 549 /* Update tool-tips: */ 541 updateFormatComboToolTip( );542 updateMACAddressExportPolicyComboToolTip( );550 updateFormatComboToolTip(m_pFormatComboBox); 551 updateMACAddressExportPolicyComboToolTip(m_pMACComboBox); 543 552 } 544 553 545 554 void UIWizardExportAppPageExpert::initializePage() 546 555 { 547 /* If wasn't polished yet: */ 548 if (!m_fPolished) 549 { 550 QMetaObject::invokeMethod(this, "sltHandleFormatComboChange", Qt::QueuedConnection); 551 m_fPolished = true; 552 } 553 556 /* Populate VM items: */ 557 populateVMItems(m_pVMSelector, m_selectedVMNames); 558 /* Populate formats: */ 559 populateFormats(m_pFormatComboBox, m_fExportToOCIByDefault); 560 /* Populate MAC address policies: */ 561 populateMACAddressPolicies(m_pMACComboBox); 554 562 /* Translate page: */ 555 563 retranslateUi(); 556 564 557 /* Choose default cloud export option: */ 558 m_pRadioExportThenAsk->setChecked(true); 559 560 /* Listen for custom button clicks: */ 561 connect(wizard(), &UIWizard::customButtonClicked, 562 this, &UIWizardExportAppPageExpert::sltHandleCustomButtonClicked, 563 Qt::UniqueConnection); 564 } 565 566 void UIWizardExportAppPageExpert::cleanupPage() 567 { 568 /* Do not pass call to base-class, we don't want field values to be reseted. */ 569 570 /* Stop listen for custom button clicks: */ 571 disconnect(wizard(), &UIWizard::customButtonClicked, 572 this, &UIWizardExportAppPageExpert::sltHandleCustomButtonClicked); 565 /* Fetch it, asynchronously: */ 566 QMetaObject::invokeMethod(this, "sltHandleFormatComboChange", Qt::QueuedConnection); 573 567 } 574 568 575 569 bool UIWizardExportAppPageExpert::isComplete() const 576 570 { 571 /* Initial result: */ 577 572 bool fResult = true; 578 573 579 574 /* There should be at least one vm selected: */ 580 575 if (fResult) 581 fResult = (m_pVMSelector->selectedItems().size() > 0);576 fResult = wizard()->machineNames().size() > 0; 582 577 583 578 /* Check appliance settings: */ 584 579 if (fResult) 585 580 { 586 const bool fOVF = field("format").toString() == "ovf-0.9"587 || field("format").toString() == "ovf-1.0"588 || field("format").toString() == "ovf-2.0";589 const bool fCSP = field("isFormatCloudOne").toBool();581 const bool fOVF = wizard()->format() == "ovf-0.9" 582 || wizard()->format() == "ovf-1.0" 583 || wizard()->format() == "ovf-2.0"; 584 const bool fCSP = wizard()->isFormatCloudOne(); 590 585 591 586 fResult = ( fOVF 592 && UICommon::hasAllowedExtension( path().toLower(), OVFFileExts))587 && UICommon::hasAllowedExtension(wizard()->path().toLower(), OVFFileExts)) 593 588 || ( fCSP 594 && field("cloudAppliance").value<CAppliance>().isNotNull()595 && field("client").value<CCloudClient>().isNotNull()596 && field("vsd").value<CVirtualSystemDescription>().isNotNull()597 && field("vsdExportForm").value<CVirtualSystemDescriptionForm>().isNotNull());589 && wizard()->cloudAppliance().isNotNull() 590 && wizard()->cloudClient().isNotNull() 591 && wizard()->vsd().isNotNull() 592 && wizard()->vsdExportForm().isNotNull()); 598 593 } 599 594 595 /* Return result: */ 600 596 return fResult; 601 597 } … … 606 602 bool fResult = true; 607 603 608 /* Lock finish button: */609 startProcessing();610 611 604 /* Check whether there was cloud target selected: */ 612 const bool fIsFormatCloudOne = fieldImp("isFormatCloudOne").toBool(); 613 if (fIsFormatCloudOne) 605 if (wizard()->isFormatCloudOne()) 614 606 { 615 607 /* Make sure table has own data committed: */ … … 617 609 618 610 /* Check whether we have proper VSD form: */ 619 CVirtualSystemDescriptionForm comForm = fieldImp("vsdExportForm").value<CVirtualSystemDescriptionForm>();611 CVirtualSystemDescriptionForm comForm = wizard()->vsdExportForm(); 620 612 fResult = comForm.isNotNull(); 621 613 Assert(fResult); … … 633 625 else 634 626 { 627 /* Ask user about machines which are in Saved state currently: */ 628 QStringList savedMachines; 629 refreshSavedMachines(savedMachines, m_pVMSelector); 630 if (!savedMachines.isEmpty()) 631 fResult = msgCenter().confirmExportMachinesInSaveState(savedMachines, this); 632 635 633 /* Prepare export: */ 636 m_pApplianceWidget->prepareExport(); 634 if (fResult) 635 { 636 m_pApplianceWidget->prepareExport(); 637 wizard()->setLocalAppliance(*m_pApplianceWidget->appliance()); 638 } 637 639 } 638 640 639 641 /* Try to export appliance: */ 640 642 if (fResult) 641 fResult = qobject_cast<UIWizardExportApp*>(wizard())->exportAppliance(); 642 643 /* Unlock finish button: */ 644 endProcessing(); 643 fResult = wizard()->exportAppliance(); 645 644 646 645 /* Return result: */ … … 648 647 } 649 648 650 void UIWizardExportAppPageExpert::sltVMSelectionChangeHandler() 651 { 652 /* Refresh required settings: */ 653 refreshFileSelectorName(); 654 populateFormProperties(); 655 656 /* Check whether there was cloud target selected: */ 657 const bool fIsFormatCloudOne = field("isFormatCloudOne").toBool(); 658 if (fIsFormatCloudOne) 659 refreshFormPropertiesTable(); 660 else 661 refreshApplianceSettingsWidget(); 662 663 /* Broadcast complete-change: */ 649 void UIWizardExportAppPageExpert::sltHandleVMItemSelectionChanged() 650 { 651 updateMachines(); 664 652 emit completeChanged(); 665 653 } … … 667 655 void UIWizardExportAppPageExpert::sltHandleFormatComboChange() 668 656 { 669 /* Update tool-tip: */ 670 updateFormatComboToolTip(); 671 672 /* Refresh required settings: */ 673 UIWizardExportAppPage2::updatePageAppearance(); 674 UIWizardExportAppPage3::updatePageAppearance(); 675 refreshFileSelectorExtension(); 676 refreshManifestCheckBoxAccess(); 677 refreshIncludeISOsCheckBoxAccess(); 678 populateProfiles(); 679 populateProfile(); 680 populateFormProperties(); 681 682 /* Check whether there was cloud target selected: */ 683 const bool fIsFormatCloudOne = field("isFormatCloudOne").toBool(); 684 if (fIsFormatCloudOne) 685 refreshFormPropertiesTable(); 686 else 687 refreshApplianceSettingsWidget(); 688 689 /* Broadcast complete-change: */ 657 updateFormat(); 690 658 emit completeChanged(); 691 659 } … … 693 661 void UIWizardExportAppPageExpert::sltHandleFileSelectorChange() 694 662 { 695 /* Remember changed name, except empty one: */ 696 if (!m_pFileSelector->path().isEmpty()) 697 m_strFileSelectorName = QFileInfo(m_pFileSelector->path()).completeBaseName(); 698 699 /* Broadcast complete-change: */ 663 /* Skip empty paths: */ 664 if (m_pFileSelector->path().isEmpty()) 665 return; 666 667 m_strFileSelectorName = QFileInfo(m_pFileSelector->path()).completeBaseName(); 668 wizard()->setPath(m_pFileSelector->path()); 700 669 emit completeChanged(); 701 670 } … … 703 672 void UIWizardExportAppPageExpert::sltHandleMACAddressExportPolicyComboChange() 704 673 { 705 /* Update tool-tip: */ 706 updateMACAddressExportPolicyComboToolTip(); 707 } 708 709 void UIWizardExportAppPageExpert::sltHandleCustomButtonClicked(int iId) 710 { 711 /* Handle 2nd button: */ 712 if (iId == QWizard::CustomButton2) 713 { 714 /* Reset widget to default: */ 715 m_pApplianceWidget->restoreDefaults(); 716 } 674 updateMACAddressExportPolicyComboToolTip(m_pMACComboBox); 675 wizard()->setMACAddressExportPolicy(m_pMACComboBox->currentData().value<MACAddressExportPolicy>()); 676 emit completeChanged(); 677 } 678 679 void UIWizardExportAppPageExpert::sltHandleManifestCheckBoxChange() 680 { 681 wizard()->setManifestSelected(m_pManifestCheckbox->isChecked()); 682 emit completeChanged(); 683 } 684 685 void UIWizardExportAppPageExpert::sltHandleIncludeISOsCheckBoxChange() 686 { 687 wizard()->setIncludeISOsSelected(m_pIncludeISOsCheckbox->isChecked()); 688 emit completeChanged(); 717 689 } 718 690 719 691 void UIWizardExportAppPageExpert::sltHandleProfileComboChange() 720 692 { 721 /* Refresh required settings: */722 populateProfile();723 populateFormProperties(); 724 725 /* Check whether there was cloud target selected: */ 726 const bool fIsFormatCloudOne = field("isFormatCloudOne").toBool(); 727 if (fIsFormatCloudOne)728 refreshFormPropertiesTable();729 else730 refreshApplianceSettingsWidget(); 731 732 /* Broadcast complete-change: */693 updateProfile(); 694 emit completeChanged(); 695 } 696 697 void UIWizardExportAppPageExpert::sltHandleRadioButtonToggled(QAbstractButton *pButton, bool fToggled) 698 { 699 /* Handle checked buttons only: */ 700 if (!fToggled) 701 return; 702 703 /* Update cloud export mode field value: */ 704 wizard()->setCloudExportMode(m_exportModeButtons.key(pButton)); 733 705 emit completeChanged(); 734 706 } … … 740 712 gpManager->openCloudProfileManager(); 741 713 } 714 715 void UIWizardExportAppPageExpert::updateMachines() 716 { 717 /* Update wizard fields: */ 718 wizard()->setMachineNames(machineNames(m_pVMSelector)); 719 wizard()->setMachineIDs(machineIDs(m_pVMSelector)); 720 721 /* Refresh required settings: */ 722 refreshFileSelectorName(m_strFileSelectorName, wizard()->machineNames(), m_strDefaultApplianceName, wizard()->isFormatCloudOne()); 723 refreshFileSelectorPath(m_pFileSelector, m_strFileSelectorName, m_strFileSelectorExt, wizard()->isFormatCloudOne()); 724 725 /* Update cloud stuff: */ 726 updateCloudStuff(); 727 } 728 729 void UIWizardExportAppPageExpert::updateFormat() 730 { 731 /* Update combo tool-tip: */ 732 updateFormatComboToolTip(m_pFormatComboBox); 733 734 /* Update wizard fields: */ 735 wizard()->setFormat(format(m_pFormatComboBox)); 736 wizard()->setFormatCloudOne(isFormatCloudOne(m_pFormatComboBox)); 737 738 /* Refresh settings widget state: */ 739 refreshStackedWidget(m_pSettingsWidget, wizard()->isFormatCloudOne()); 740 refreshStackedLayout(m_pSettingsLayout, wizard()->isFormatCloudOne()); 741 742 /* Update export settings: */ 743 refreshFileSelectorExtension(m_strFileSelectorExt, m_pFileSelector, wizard()->isFormatCloudOne()); 744 refreshFileSelectorPath(m_pFileSelector, m_strFileSelectorName, m_strFileSelectorExt, wizard()->isFormatCloudOne()); 745 refreshManifestCheckBoxAccess(m_pManifestCheckbox, wizard()->isFormatCloudOne()); 746 refreshIncludeISOsCheckBoxAccess(m_pIncludeISOsCheckbox, wizard()->isFormatCloudOne()); 747 refreshProfileCombo(m_pProfileComboBox, wizard()->format(), wizard()->isFormatCloudOne()); 748 refreshCloudExportMode(m_exportModeButtons, wizard()->isFormatCloudOne()); 749 750 /* Update profile: */ 751 updateProfile(); 752 } 753 754 void UIWizardExportAppPageExpert::updateProfile() 755 { 756 /* Update wizard fields: */ 757 wizard()->setProfileName(profileName(m_pProfileComboBox)); 758 759 /* Update export settings: */ 760 refreshCloudProfile(m_comCloudProfile, 761 wizard()->format(), 762 wizard()->profileName(), 763 wizard()->isFormatCloudOne()); 764 765 /* Update cloud stuff: */ 766 updateCloudStuff(); 767 } 768 769 void UIWizardExportAppPageExpert::updateCloudStuff() 770 { 771 /* Create appliance, client, VSD and VSD export form: */ 772 CAppliance comAppliance; 773 CCloudClient comClient; 774 CVirtualSystemDescription comDescription; 775 CVirtualSystemDescriptionForm comForm; 776 refreshCloudStuff(comAppliance, 777 comClient, 778 comDescription, 779 comForm, 780 m_comCloudProfile, 781 wizard()->machineIDs(), 782 wizard()->uri(), 783 wizard()->cloudExportMode()); 784 wizard()->setCloudAppliance(comAppliance); 785 wizard()->setCloudClient(comClient); 786 wizard()->setVsd(comDescription); 787 wizard()->setVsdExportForm(comForm); 788 789 /* Refresh corresponding widgets: */ 790 refreshApplianceSettingsWidget(m_pApplianceWidget, wizard()->machineIDs(), wizard()->uri(), wizard()->isFormatCloudOne()); 791 refreshFormPropertiesTable(m_pFormEditor, wizard()->vsdExportForm(), wizard()->isFormatCloudOne()); 792 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageExpert.h
r91262 r91368 5 5 6 6 /* 7 * Copyright (C) 2009-202 0Oracle Corporation7 * Copyright (C) 2009-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 23 23 24 24 /* GUI includes: */ 25 #include "UIWizardExportAppPageBasic1.h" 26 #include "UIWizardExportAppPageBasic2.h" 27 #include "UIWizardExportAppPageBasic3.h" 25 #include "UINativeWizardPage.h" 26 #include "UIWizardExportApp.h" 27 28 /* COM includes: */ 29 #include "COMEnums.h" 30 #include "CAppliance.h" 31 #include "CCloudClient.h" 32 #include "CCloudProfile.h" 33 #include "CVirtualSystemDescription.h" 34 #include "CVirtualSystemDescriptionForm.h" 28 35 29 36 /* Forward declarations: */ 37 class QAbstractButton; 38 class QButtonGroup; 39 class QCheckBox; 40 class QGridLayout; 30 41 class QGroupBox; 42 class QLabel; 43 class QListWidget; 44 class QStackedLayout; 45 class QStackedWidget; 46 class QIComboBox; 47 class QIToolButton; 48 class UIApplianceExportEditorWidget; 49 class UIEmptyFilePathSelector; 50 class UIFormEditorWidget; 51 class UIWizardExportApp; 31 52 32 53 /** UIWizardPage extension for UIWizardExportAppPage1, UIWizardExportAppPage2 and UIWizardExportAppPage3. */ 33 class UIWizardExportAppPageExpert : public UIWizardPage, 34 public UIWizardExportAppPage1, 35 public UIWizardExportAppPage2, 36 public UIWizardExportAppPage3 54 class UIWizardExportAppPageExpert : public UINativeWizardPage 37 55 { 38 56 Q_OBJECT; 39 Q_PROPERTY(QStringList machineNames READ machineNames);40 Q_PROPERTY(QList<QUuid> machineIDs READ machineIDs);41 Q_PROPERTY(QString format READ format WRITE setFormat);42 Q_PROPERTY(bool isFormatCloudOne READ isFormatCloudOne);43 Q_PROPERTY(QString path READ path WRITE setPath);44 Q_PROPERTY(MACAddressExportPolicy macAddressExportPolicy READ macAddressExportPolicy WRITE setMACAddressExportPolicy);45 Q_PROPERTY(bool manifestSelected READ isManifestSelected WRITE setManifestSelected);46 Q_PROPERTY(bool includeISOsSelected READ isIncludeISOsSelected WRITE setIncludeISOsSelected);47 Q_PROPERTY(QString providerShortName READ providerShortName);48 Q_PROPERTY(CAppliance cloudAppliance READ cloudAppliance);49 Q_PROPERTY(CCloudClient client READ client);50 Q_PROPERTY(CVirtualSystemDescription vsd READ vsd);51 Q_PROPERTY(CVirtualSystemDescriptionForm vsdExportForm READ vsdExportForm);52 Q_PROPERTY(CloudExportMode cloudExportMode READ cloudExportMode);53 Q_PROPERTY(CAppliance localAppliance READ localAppliance);54 57 55 58 public: … … 61 64 protected: 62 65 63 /** Allows access wizard from base part. */ 64 UIWizard *wizardImp() const { return UIWizardPage::wizard(); } 65 /** Allows access page from base part. */ 66 UIWizardPage* thisImp() { return this; } 67 /** Allows access wizard-field from base part. */ 68 QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); } 66 /** Returns wizard this page belongs to. */ 67 UIWizardExportApp *wizard() const; 69 68 70 69 /** Handles translation event. */ … … 73 72 /** Performs page initialization. */ 74 73 virtual void initializePage() /* override */; 75 /** Performs page uninitialization. */76 virtual void cleanupPage() /* override */;77 74 78 75 /** Returns whether page is complete. */ … … 85 82 86 83 /** Handles VM selector index change. */ 87 void slt VMSelectionChangeHandler();84 void sltHandleVMItemSelectionChanged(); 88 85 89 86 /** Handles format combo change. */ … … 96 93 void sltHandleMACAddressExportPolicyComboChange(); 97 94 98 /** Handles custom button clicked. 99 * @param iId Brings clicked button id. */ 100 void sltHandleCustomButtonClicked(int iId); 95 /** Handles change in manifest check-box. */ 96 void sltHandleManifestCheckBoxChange(); 97 98 /** Handles change in include ISOs check-box. */ 99 void sltHandleIncludeISOsCheckBoxChange(); 101 100 102 101 /** Handles change in profile combo-box. */ 103 102 void sltHandleProfileComboChange(); 104 103 104 /** Handles cloud export radio-button clicked. */ 105 void sltHandleRadioButtonToggled(QAbstractButton *pButton, bool fToggled); 106 105 107 /** Handles profile tool-button click. */ 106 108 void sltHandleProfileButtonClick(); … … 108 110 private: 109 111 110 /** Holds whether starting page was polished. */ 111 bool m_fPolished; 112 /** Updates machines. */ 113 void updateMachines(); 114 /** Updates format. */ 115 void updateFormat(); 116 /** Updates profile. */ 117 void updateProfile(); 118 /** Updates cloud stuff. */ 119 void updateCloudStuff(); 120 121 /** Holds the list of selected VM names. */ 122 const QStringList m_selectedVMNames; 123 /** Holds whether default format should be Export to OCI. */ 124 bool m_fExportToOCIByDefault; 125 126 /** Holds the default appliance name. */ 127 QString m_strDefaultApplianceName; 128 /** Holds the file selector name. */ 129 QString m_strFileSelectorName; 130 /** Holds the file selector ext. */ 131 QString m_strFileSelectorExt; 132 133 /** Holds the Cloud Profile object reference. */ 134 CCloudProfile m_comCloudProfile; 135 112 136 113 137 /** Holds the VM selector container instance. */ 114 QGroupBox *m_pSelectorCnt; 138 QGroupBox *m_pSelectorCnt; 139 140 /** Holds the VM selector instance. */ 141 QListWidget *m_pVMSelector; 142 143 115 144 /** Holds the appliance widget container reference. */ 116 QGroupBox *m_pApplianceCnt; 145 QGroupBox *m_pApplianceCnt; 146 147 /** Holds the settings container layout instance. */ 148 QStackedLayout *m_pSettingsLayout; 149 150 /** Holds the appliance widget reference. */ 151 UIApplianceExportEditorWidget *m_pApplianceWidget; 152 /** Holds the Form Editor widget instance. */ 153 UIFormEditorWidget *m_pFormEditor; 154 155 117 156 /** Holds the settings widget container reference. */ 118 157 QGroupBox *m_pSettingsCnt; 158 159 /** Holds the format layout. */ 160 QGridLayout *m_pFormatLayout; 161 /** Holds the format combo-box label instance. */ 162 QLabel *m_pFormatComboBoxLabel; 163 /** Holds the format combo-box instance. */ 164 QIComboBox *m_pFormatComboBox; 165 166 /** Holds the settings widget instance. */ 167 QStackedWidget *m_pSettingsWidget; 168 169 /** Holds the settings layout 1. */ 170 QGridLayout *m_pSettingsLayout1; 171 /** Holds the file selector label instance. */ 172 QLabel *m_pFileSelectorLabel; 173 /** Holds the file selector instance. */ 174 UIEmptyFilePathSelector *m_pFileSelector; 175 /** Holds the MAC address policy combo-box label instance. */ 176 QLabel *m_pMACComboBoxLabel; 177 /** Holds the MAC address policy check-box instance. */ 178 QIComboBox *m_pMACComboBox; 179 /** Holds the additional label instance. */ 180 QLabel *m_pAdditionalLabel; 181 /** Holds the manifest check-box instance. */ 182 QCheckBox *m_pManifestCheckbox; 183 /** Holds the include ISOs check-box instance. */ 184 QCheckBox *m_pIncludeISOsCheckbox; 185 186 /** Holds the settings layout 2. */ 187 QGridLayout *m_pSettingsLayout2; 188 /** Holds the profile label instance. */ 189 QLabel *m_pProfileLabel; 190 /** Holds the profile combo-box instance. */ 191 QIComboBox *m_pProfileComboBox; 192 /** Holds the profile management tool-button instance. */ 193 QIToolButton *m_pProfileToolButton; 194 195 /** Holds the export mode label instance. */ 196 QLabel *m_pExportModeLabel; 197 /** Holds the export mode button group instance. */ 198 QButtonGroup *m_pExportModeButtonGroup; 199 /** Holds the map of export mode button instances. */ 200 QMap<CloudExportMode, QAbstractButton*> m_exportModeButtons; 119 201 }; 120 202
Note:
See TracChangeset
for help on using the changeset viewer.