Changeset 78062 in vbox
- Timestamp:
- Apr 9, 2019 1:52:22 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/wizards
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic2.cpp
r78061 r78062 47 47 /* COM includes: */ 48 48 #include "CCloudClient.h" 49 #include "CCloudProvider.h"50 49 51 50 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppDefs.h
r78046 r78062 33 33 Q_DECLARE_METATYPE(ImportAppliancePointer); 34 34 35 /** Import source types. */36 enum ImportSourceType37 {38 ImportSourceType_Invalid,39 ImportSourceType_Local,40 ImportSourceType_Cloud41 };42 Q_DECLARE_METATYPE(ImportSourceType);43 44 35 #endif /* !FEQT_INCLUDED_SRC_wizards_importappliance_UIWizardImportAppDefs_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic1.cpp
r78061 r78062 27 27 #include "VBoxGlobal.h" 28 28 #include "UIEmptyFilePathSelector.h" 29 #include "UIMessageCenter.h" 29 30 #include "UIWizardImportApp.h" 30 31 #include "UIWizardImportAppPageBasic1.h" 31 32 #include "UIWizardImportAppPageBasic2.h" 32 33 34 /*********************************************************************************************************************************35 * Namespace ImportSourceTypeConverter implementation. *36 *********************************************************************************************************************************/37 38 QString ImportSourceTypeConverter::toString(ImportSourceType enmType)39 {40 switch (enmType)41 {42 case ImportSourceType_Local: return QApplication::translate("UIWizardImportApp", "Local File System");43 case ImportSourceType_Cloud: return QApplication::translate("UIWizardImportApp", "Cloud Content Provider");44 default: break;45 }46 return QString();47 }48 33 49 34 … … 58 43 , m_pFileSelector(0) 59 44 { 45 } 46 47 void UIWizardImportAppPage1::populateSources() 48 { 49 AssertReturnVoid(m_pSourceComboBox->count() == 0); 50 51 /* Compose hardcoded sources list: */ 52 QStringList sources; 53 sources << "local"; 54 /* Add that list to combo: */ 55 foreach (const QString &strShortName, sources) 56 { 57 /* Compose empty item, fill it's data: */ 58 m_pSourceComboBox->addItem(QString()); 59 m_pSourceComboBox->setItemData(m_pSourceComboBox->count() - 1, strShortName, SourceData_ShortName); 60 } 61 62 /* Initialize Cloud Provider Manager: */ 63 CVirtualBox comVBox = vboxGlobal().virtualBox(); 64 m_comCloudProviderManager = comVBox.GetCloudProviderManager(); 65 /* Show error message if necessary: */ 66 if (!comVBox.isOk()) 67 msgCenter().cannotAcquireCloudProviderManager(comVBox); 68 else 69 { 70 /* Acquire existing providers: */ 71 const QVector<CCloudProvider> providers = m_comCloudProviderManager.GetProviders(); 72 /* Show error message if necessary: */ 73 if (!m_comCloudProviderManager.isOk()) 74 msgCenter().cannotAcquireCloudProviderManagerParameter(m_comCloudProviderManager); 75 else 76 { 77 /* Iterate through existing providers: */ 78 foreach (const CCloudProvider &comProvider, providers) 79 { 80 /* Skip if we have nothing to populate (file missing?): */ 81 if (comProvider.isNull()) 82 continue; 83 84 /* Compose empty item, fill it's data: */ 85 m_pSourceComboBox->addItem(QString()); 86 m_pSourceComboBox->setItemData(m_pSourceComboBox->count() - 1, comProvider.GetId(), SourceData_ID); 87 m_pSourceComboBox->setItemData(m_pSourceComboBox->count() - 1, comProvider.GetName(), SourceData_Name); 88 m_pSourceComboBox->setItemData(m_pSourceComboBox->count() - 1, comProvider.GetShortName(), SourceData_ShortName); 89 m_pSourceComboBox->setItemData(m_pSourceComboBox->count() - 1, true, SourceData_IsItCloudFormat); 90 } 91 } 92 } 93 94 /* Set default: */ 95 setSource("local"); 96 } 97 98 void UIWizardImportAppPage1::updatePageAppearance() 99 { 100 /* Update page appearance according to chosen source: */ 101 m_pStackedLayout->setCurrentIndex((int)isSourceCloudOne()); 102 } 103 104 void UIWizardImportAppPage1::updateSourceComboToolTip() 105 { 106 const int iCurrentIndex = m_pSourceComboBox->currentIndex(); 107 const QString strCurrentToolTip = m_pSourceComboBox->itemData(iCurrentIndex, Qt::ToolTipRole).toString(); 108 AssertMsg(!strCurrentToolTip.isEmpty(), ("Data not found!")); 109 m_pSourceComboBox->setToolTip(strCurrentToolTip); 110 } 111 112 void UIWizardImportAppPage1::setSource(const QString &strSource) 113 { 114 const int iIndex = m_pSourceComboBox->findData(strSource, SourceData_ShortName); 115 AssertMsg(iIndex != -1, ("Data not found!")); 116 m_pSourceComboBox->setCurrentIndex(iIndex); 117 } 118 119 QString UIWizardImportAppPage1::source() const 120 { 121 const int iIndex = m_pSourceComboBox->currentIndex(); 122 return m_pSourceComboBox->itemData(iIndex, SourceData_ShortName).toString(); 123 } 124 125 bool UIWizardImportAppPage1::isSourceCloudOne(int iIndex /* = -1 */) const 126 { 127 if (iIndex == -1) 128 iIndex = m_pSourceComboBox->currentIndex(); 129 return m_pSourceComboBox->itemData(iIndex, SourceData_IsItCloudFormat).toBool(); 60 130 } 61 131 … … 102 172 m_pSourceLabel->setBuddy(m_pSourceComboBox); 103 173 m_pSourceComboBox->hide(); 104 m_pSourceComboBox->addItem(QString(), QVariant::fromValue(ImportSourceType_Local));105 m_pSourceComboBox->addItem(QString(), QVariant::fromValue(ImportSourceType_Cloud));106 174 connect(m_pSourceComboBox, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::activated), 107 175 this, &UIWizardImportAppPageBasic1::sltHandleSourceChange); … … 148 216 149 217 /* Add into layout: */ 150 m_ stackedLayoutIndexMap[ImportSourceType_Local] = m_pStackedLayout->addWidget(pLocalContainer);218 m_pStackedLayout->addWidget(pLocalContainer); 151 219 } 152 220 … … 167 235 168 236 /* Add into layout: */ 169 m_ stackedLayoutIndexMap[ImportSourceType_Cloud] = m_pStackedLayout->addWidget(pCloudContainer);237 m_pStackedLayout->addWidget(pCloudContainer); 170 238 } 171 239 … … 178 246 } 179 247 248 /* Populate sources: */ 249 populateSources(); 250 180 251 /* Setup connections: */ 181 252 connect(m_pFileSelector, &UIEmptyFilePathSelector::pathChanged, this, &UIWizardImportAppPageBasic1::completeChanged); 253 254 /* Register fields: */ 255 registerField("source", this, "source"); 256 registerField("isSourceCloudOne", this, "isSourceCloudOne"); 182 257 } 183 258 … … 194 269 /* Translate source label: */ 195 270 m_pSourceLabel->setText(tr("&Source:")); 271 /* Translate hardcoded values of Source combo-box: */ 272 m_pSourceComboBox->setItemText(0, UIWizardImportApp::tr("Local File System")); 273 m_pSourceComboBox->setItemData(0, UIWizardImportApp::tr("Import from local file system."), Qt::ToolTipRole); 196 274 /* Translate received values of Source combo-box. 197 275 * We are enumerating starting from 0 for simplicity: */ 198 276 for (int i = 0; i < m_pSourceComboBox->count(); ++i) 199 m_pSourceComboBox->setItemText(i, ImportSourceTypeConverter::toString(m_pSourceComboBox->itemData(i).value<ImportSourceType>())); 277 if (isSourceCloudOne(i)) 278 { 279 m_pSourceComboBox->setItemText(i, m_pSourceComboBox->itemData(i, SourceData_Name).toString()); 280 m_pSourceComboBox->setItemData(i, UIWizardImportApp::tr("Import from cloud service provider."), Qt::ToolTipRole); 281 } 200 282 201 283 /* Translate file selector: */ … … 203 285 m_pFileSelector->setFileDialogTitle(UIWizardImportApp::tr("Please choose a virtual appliance file to import")); 204 286 m_pFileSelector->setFileFilters(UIWizardImportApp::tr("Open Virtualization Format (%1)").arg("*.ova *.ovf")); 287 288 /* Update page appearance: */ 289 updatePageAppearance(); 290 291 /* Update tool-tips: */ 292 updateSourceComboToolTip(); 205 293 } 206 294 … … 238 326 } 239 327 240 void UIWizardImportAppPageBasic1::sltHandleSourceChange(int iIndex) 241 { 242 m_pStackedLayout->setCurrentIndex(m_stackedLayoutIndexMap.value(m_pSourceComboBox->itemData(iIndex).value<ImportSourceType>())); 243 } 328 void UIWizardImportAppPageBasic1::sltHandleSourceChange() 329 { 330 /* Update tool-tip: */ 331 updateSourceComboToolTip(); 332 333 /* Refresh required settings: */ 334 updatePageAppearance(); 335 emit completeChanged(); 336 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic1.h
r78061 r78062 26 26 #include "UIWizardPage.h" 27 27 28 /* COM includes: */ 29 #include "COMEnums.h" 30 #include "CCloudProfile.h" 31 #include "CCloudProvider.h" 32 #include "CCloudProviderManager.h" 33 28 34 /* Forward declarations: */ 29 35 class QLabel; … … 33 39 class UIEmptyFilePathSelector; 34 40 35 /** Source type converter namespace. */36 namespace ImportSourceTypeConverter 41 /** Source combo data fields. */ 42 enum 37 43 { 38 /** Converts QString <= ImportSourceType. */ 39 QString toString(ImportSourceType enmType); 40 } 44 SourceData_ID = Qt::UserRole + 1, 45 SourceData_Name = Qt::UserRole + 2, 46 SourceData_ShortName = Qt::UserRole + 3, 47 SourceData_IsItCloudFormat = Qt::UserRole + 4 48 }; 41 49 42 50 /** UIWizardPageBase extension for 1st page of the Import Appliance wizard. */ … … 48 56 UIWizardImportAppPage1(); 49 57 58 /** Populates sources. */ 59 void populateSources(); 60 61 /** Updates page appearance. */ 62 virtual void updatePageAppearance(); 63 64 /** Updates source combo tool-tips. */ 65 void updateSourceComboToolTip(); 66 67 /** Defines @a strSource. */ 68 void setSource(const QString &strSource); 69 /** Returns source. */ 70 QString source() const; 71 /** Returns whether source under certain @a iIndex is cloud one. */ 72 bool isSourceCloudOne(int iIndex = -1) const; 73 74 /** Holds whether default source should be Import from OCI. */ 75 bool m_fImportFromOCIByDefault; 76 77 /** Holds the Cloud Provider Manager reference. */ 78 CCloudProviderManager m_comCloudProviderManager; 79 /** Holds the Cloud Provider object reference. */ 80 CCloudProvider m_comCloudProvider; 81 /** Holds the Cloud Profile object reference. */ 82 CCloudProfile m_comCloudProfile; 83 50 84 /** Holds the source type label instance. */ 51 85 QLabel *m_pSourceLabel; … … 54 88 55 89 /** Holds the stacked layout instance. */ 56 QStackedLayout *m_pStackedLayout; 57 /** Holds the stacked layout widget indexes map. */ 58 QMap<ImportSourceType, int> m_stackedLayoutIndexMap; 90 QStackedLayout *m_pStackedLayout; 59 91 60 92 /** Holds the file selector instance. */ … … 66 98 { 67 99 Q_OBJECT; 100 Q_PROPERTY(QString source READ source WRITE setSource); 101 Q_PROPERTY(bool isSourceCloudOne READ isSourceCloudOne); 68 102 69 103 public: … … 88 122 private slots: 89 123 90 /** Handles change of import source to one with specified @a iIndex. */91 void sltHandleSourceChange( int iIndex);124 /** Handles import source change. */ 125 void sltHandleSourceChange(); 92 126 93 127 private:
Note:
See TracChangeset
for help on using the changeset viewer.