Changeset 78046 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Apr 8, 2019 3:41:31 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppDefs.h
r78044 r78046 33 33 Q_DECLARE_METATYPE(ImportAppliancePointer); 34 34 35 /** Import source types. */ 36 enum ImportSourceType 37 { 38 ImportSourceType_Invalid, 39 ImportSourceType_Local, 40 ImportSourceType_Cloud 41 }; 42 Q_DECLARE_METATYPE(ImportSourceType); 43 35 44 #endif /* !FEQT_INCLUDED_SRC_wizards_importappliance_UIWizardImportAppDefs_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic1.cpp
r78044 r78046 18 18 /* Qt includes: */ 19 19 #include <QFileInfo> 20 #include <QLabel> 21 #include <QStackedLayout> 20 22 #include <QVBoxLayout> 21 23 22 24 /* GUI includes: */ 25 #include "QIComboBox.h" 23 26 #include "QIRichTextLabel.h" 24 27 #include "VBoxGlobal.h" … … 30 33 31 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 49 50 /********************************************************************************************************************************* 32 51 * Class UIWizardImportAppPage1 implementation. * 33 52 *********************************************************************************************************************************/ 34 53 35 54 UIWizardImportAppPage1::UIWizardImportAppPage1() 36 : m_pFileSelector(0) 55 : m_pSourceLabel(0) 56 , m_pSourceSelector(0) 57 , m_pStackedLayout(0) 58 , m_pFileSelector(0) 37 59 { 38 60 } … … 58 80 } 59 81 60 /* Create file-path selector: */61 m_pFileSelector = new UIEmptyFilePathSelector(this);62 if ( m_pFileSelector)82 /* Create source selector layout: */ 83 QHBoxLayout *pSourceSelectorLayout = new QHBoxLayout; 84 if (pSourceSelectorLayout) 63 85 { 64 m_pFileSelector->setHomeDir(vboxGlobal().documentsPath()); 65 m_pFileSelector->setMode(UIEmptyFilePathSelector::Mode_File_Open); 66 m_pFileSelector->setButtonPosition(UIEmptyFilePathSelector::RightPosition); 67 m_pFileSelector->setEditable(true); 86 /* Create source label: */ 87 m_pSourceLabel = new QLabel(this); 88 if (m_pSourceLabel) 89 { 90 m_pSourceLabel->hide(); 91 m_pSourceLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); 92 m_pSourceLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 93 94 /* Add into layout: */ 95 pSourceSelectorLayout->addWidget(m_pSourceLabel); 96 } 97 98 /* Create source selector: */ 99 m_pSourceSelector = new QIComboBox(this); 100 if (m_pSourceSelector) 101 { 102 m_pSourceLabel->setBuddy(m_pSourceSelector); 103 m_pSourceSelector->hide(); 104 m_pSourceSelector->addItem(QString(), QVariant::fromValue(ImportSourceType_Local)); 105 m_pSourceSelector->addItem(QString(), QVariant::fromValue(ImportSourceType_Cloud)); 106 connect(m_pSourceSelector, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::activated), 107 this, static_cast<void(UIWizardImportAppPageBasic1::*)(int)>(&UIWizardImportAppPageBasic1::sltHandleSourceChange)); 108 109 /* Add into layout: */ 110 pSourceSelectorLayout->addWidget(m_pSourceSelector); 111 } 68 112 69 113 /* Add into layout: */ 70 pMainLayout->addWidget(m_pFileSelector); 114 pMainLayout->addLayout(pSourceSelectorLayout); 115 } 116 117 /* Create stacked layout: */ 118 m_pStackedLayout = new QStackedLayout; 119 if (m_pStackedLayout) 120 { 121 /* Create local container: */ 122 QWidget *pLocalContainer = new QWidget(this); 123 if (pLocalContainer) 124 { 125 /* Create local container layout: */ 126 QVBoxLayout *pLocalContainerLayout = new QVBoxLayout(pLocalContainer); 127 if (pLocalContainerLayout) 128 { 129 pLocalContainerLayout->setContentsMargins(0, 0, 0, 0); 130 pLocalContainerLayout->setSpacing(0); 131 132 /* Create file-path selector: */ 133 m_pFileSelector = new UIEmptyFilePathSelector(this); 134 if (m_pFileSelector) 135 { 136 m_pFileSelector->setHomeDir(vboxGlobal().documentsPath()); 137 m_pFileSelector->setMode(UIEmptyFilePathSelector::Mode_File_Open); 138 m_pFileSelector->setButtonPosition(UIEmptyFilePathSelector::RightPosition); 139 m_pFileSelector->setEditable(true); 140 141 /* Add into layout: */ 142 pLocalContainerLayout->addWidget(m_pFileSelector); 143 } 144 145 /* Add stretch: */ 146 pLocalContainerLayout->addStretch(); 147 } 148 149 /* Add into layout: */ 150 m_stackedLayoutIndexMap[ImportSourceType_Local] = m_pStackedLayout->addWidget(pLocalContainer); 151 } 152 153 /* Create cloud container: */ 154 QWidget *pCloudContainer = new QWidget(this); 155 if (pCloudContainer) 156 { 157 /* Create cloud container layout: */ 158 QVBoxLayout *pCloudContainerLayout = new QVBoxLayout(pCloudContainer); 159 if (pCloudContainerLayout) 160 { 161 pCloudContainerLayout->setContentsMargins(0, 0, 0, 0); 162 pCloudContainerLayout->setSpacing(0); 163 164 /* Add stretch: */ 165 pCloudContainerLayout->addStretch(); 166 } 167 168 /* Add into layout: */ 169 m_stackedLayoutIndexMap[ImportSourceType_Cloud] = m_pStackedLayout->addWidget(pCloudContainer); 170 } 171 172 /* Add into layout: */ 173 pMainLayout->addLayout(m_pStackedLayout); 71 174 } 72 175 … … 77 180 /* Setup connections: */ 78 181 connect(m_pFileSelector, &UIEmptyFilePathSelector::pathChanged, this, &UIWizardImportAppPageBasic1::completeChanged); 182 } 183 184 void UIWizardImportAppPageBasic1::sltHandleSourceChange(int iIndex) 185 { 186 m_pStackedLayout->setCurrentIndex(m_stackedLayoutIndexMap.value(m_pSourceSelector->itemData(iIndex).value<ImportSourceType>())); 79 187 } 80 188 … … 88 196 "saved in the Open Virtualization Format (OVF). " 89 197 "To continue, select the file to import below.</p>")); 198 199 /* Translate source selector: */ 200 m_pSourceLabel->setText(tr("Source:")); 201 for (int i = 0; i < m_pSourceSelector->count(); ++i) 202 m_pSourceSelector->setItemText(i, ImportSourceTypeConverter::toString(m_pSourceSelector->itemData(i).value<ImportSourceType>())); 90 203 91 204 /* Translate file selector: */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic1.h
r78037 r78046 23 23 24 24 /* GUI includes: */ 25 #include "UIWizardImportAppDefs.h" 25 26 #include "UIWizardPage.h" 26 27 27 28 /* Forward declarations: */ 29 class QLabel; 30 class QStackedLayout; 31 class QIComboBox; 28 32 class QIRichTextLabel; 29 33 class UIEmptyFilePathSelector; 34 35 /** Source type converter namespace. */ 36 namespace ImportSourceTypeConverter 37 { 38 /** Converts QString <= ImportSourceType. */ 39 QString toString(ImportSourceType enmType); 40 } 30 41 31 42 /** UIWizardPageBase extension for 1st page of the Import Appliance wizard. */ … … 36 47 /** Constructs 1st page base. */ 37 48 UIWizardImportAppPage1(); 49 50 /** Holds the source type label instance. */ 51 QLabel *m_pSourceLabel; 52 /** Holds the source type selector instance. */ 53 QIComboBox *m_pSourceSelector; 54 55 /** Holds the stacked layout instance. */ 56 QStackedLayout *m_pStackedLayout; 57 /** Holds the stacked layout widget indexes map. */ 58 QMap<ImportSourceType, int> m_stackedLayoutIndexMap; 38 59 39 60 /** Holds the file selector instance. */ … … 50 71 /** Constructs 1st basic page. */ 51 72 UIWizardImportAppPageBasic1(); 73 74 private slots: 75 76 /** Handles change of import source to one with specified @a iIndex. */ 77 void sltHandleSourceChange(int iIndex); 52 78 53 79 private:
Note:
See TracChangeset
for help on using the changeset viewer.