Changeset 93226 in vbox
- Timestamp:
- Jan 13, 2022 1:12:39 PM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVMPageExpert.cpp
r93115 r93226 17 17 18 18 /* Qt includes: */ 19 #include <QGroupBox>20 19 #include <QHeaderView> 21 20 #include <QListWidget> … … 30 29 #include "UIIconPool.h" 31 30 #include "UINotificationCenter.h" 31 #include "UIToolBox.h" 32 32 #include "UIVirtualBoxEventHandler.h" 33 33 #include "UIVirtualBoxManager.h" … … 41 41 42 42 UIWizardNewCloudVMPageExpert::UIWizardNewCloudVMPageExpert() 43 : m_p CntLocation(0)43 : m_pToolBox(0) 44 44 , m_pProviderComboBox(0) 45 45 , m_pProfileComboBox(0) 46 46 , m_pProfileToolButton(0) 47 , m_pCntSource(0)48 47 , m_pSourceTabBar(0) 49 48 , m_pSourceImageList(0) 50 , m_pSettingsCnt(0)51 49 , m_pFormEditor(0) 52 50 { 53 51 /* Prepare main layout: */ 54 Q GridLayout *pLayoutMain = new QGridLayout(this);52 QVBoxLayout *pLayoutMain = new QVBoxLayout(this); 55 53 if (pLayoutMain) 56 54 { 57 pLayoutMain->setRowStretch(0, 0); 58 pLayoutMain->setRowStretch(1, 1); 59 60 /* Prepare location container: */ 61 m_pCntLocation = new QGroupBox(this); 62 if (m_pCntLocation) 55 /* Prepare tool-box: */ 56 m_pToolBox = new UIToolBox(this); 57 if (m_pToolBox) 63 58 { 64 /* Prepare location layout: */65 Q VBoxLayout *pLocationLayout = new QVBoxLayout(m_pCntLocation);66 if (p LocationLayout)59 /* Prepare location widget: */ 60 QWidget *pWidgetLocation = new QWidget(m_pToolBox); 61 if (pWidgetLocation) 67 62 { 68 /* Prepare location combo-box: */ 69 m_pProviderComboBox = new QIComboBox(m_pCntLocation); 70 if (m_pProviderComboBox) 71 pLocationLayout->addWidget(m_pProviderComboBox); 72 73 /* Prepare profile layout: */ 74 QHBoxLayout *pProfileLayout = new QHBoxLayout; 75 if (pProfileLayout) 63 /* Prepare location layout: */ 64 QVBoxLayout *pLayoutLocation = new QVBoxLayout(pWidgetLocation); 65 if (pLayoutLocation) 76 66 { 77 pProfileLayout->setContentsMargins(0, 0, 0, 0); 78 pProfileLayout->setSpacing(1); 79 80 /* Prepare profile combo-box: */ 81 m_pProfileComboBox = new QIComboBox(m_pCntLocation); 82 if (m_pProfileComboBox) 83 pProfileLayout->addWidget(m_pProfileComboBox); 84 85 /* Prepare profile tool-button: */ 86 m_pProfileToolButton = new QIToolButton(m_pCntLocation); 87 if (m_pProfileToolButton) 67 pLayoutLocation->setContentsMargins(0, 0, 0, 0); 68 69 /* Prepare provider combo-box: */ 70 m_pProviderComboBox = new QIComboBox(pWidgetLocation); 71 if (m_pProviderComboBox) 72 pLayoutLocation->addWidget(m_pProviderComboBox); 73 74 /* Prepare profile layout: */ 75 QHBoxLayout *pLayoutProfile = new QHBoxLayout; 76 if (pLayoutProfile) 88 77 { 89 m_pProfileToolButton->setIcon(UIIconPool::iconSet(":/cloud_profile_manager_16px.png", 90 ":/cloud_profile_manager_disabled_16px.png")); 91 pProfileLayout->addWidget(m_pProfileToolButton); 78 pLayoutProfile->setContentsMargins(0, 0, 0, 0); 79 pLayoutProfile->setSpacing(1); 80 81 /* Prepare profile combo-box: */ 82 m_pProfileComboBox = new QIComboBox(pWidgetLocation); 83 if (m_pProfileComboBox) 84 pLayoutProfile->addWidget(m_pProfileComboBox); 85 86 /* Prepare profile tool-button: */ 87 m_pProfileToolButton = new QIToolButton(pWidgetLocation); 88 if (m_pProfileToolButton) 89 { 90 m_pProfileToolButton->setIcon(UIIconPool::iconSet(":/cloud_profile_manager_16px.png", 91 ":/cloud_profile_manager_disabled_16px.png")); 92 pLayoutProfile->addWidget(m_pProfileToolButton); 93 } 94 95 /* Add into layout: */ 96 pLayoutLocation->addLayout(pLayoutProfile); 92 97 } 93 94 /* Add into layout: */95 pLocationLayout->addLayout(pProfileLayout);96 98 } 99 100 /* Add into tool-box: */ 101 m_pToolBox->insertPage(0, pWidgetLocation, QString()); 97 102 } 98 103 104 /* Prepare source widget: */ 105 QWidget *pWidgetSource = new QWidget(m_pToolBox); 106 if (pWidgetSource) 107 { 108 /* Prepare source layout: */ 109 QVBoxLayout *pLayoutSource = new QVBoxLayout(pWidgetSource); 110 if (pLayoutSource) 111 { 112 pLayoutSource->setContentsMargins(0, 0, 0, 0); 113 pLayoutSource->setSpacing(0); 114 115 /* Prepare source tab-bar: */ 116 m_pSourceTabBar = new QTabBar(pWidgetSource); 117 if (m_pSourceTabBar) 118 { 119 m_pSourceTabBar->addTab(QString()); 120 m_pSourceTabBar->addTab(QString()); 121 122 /* Add into layout: */ 123 pLayoutSource->addWidget(m_pSourceTabBar); 124 } 125 126 /* Prepare source image list: */ 127 m_pSourceImageList = new QListWidget(pWidgetSource); 128 if (m_pSourceImageList) 129 { 130 m_pSourceImageList->setSortingEnabled(true); 131 /* Make source image list fit 40/50 symbols 132 * horizontally and 8 lines vertically: */ 133 const QFontMetrics fm(m_pSourceImageList->font()); 134 const int iFontWidth = fm.width('x'); 135 #ifdef VBOX_WS_MAC 136 const int iTotalWidth = 40 * iFontWidth; 137 #else 138 const int iTotalWidth = 50 * iFontWidth; 139 #endif 140 const int iFontHeight = fm.height(); 141 const int iTotalHeight = 8 * iFontHeight; 142 m_pSourceImageList->setMinimumSize(QSize(iTotalWidth, iTotalHeight)); 143 m_pSourceImageList->setAlternatingRowColors(true); 144 145 /* Add into layout: */ 146 pLayoutSource->addWidget(m_pSourceImageList); 147 } 148 } 149 150 /* Add into tool-box: */ 151 m_pToolBox->insertPage(1, pWidgetSource, QString()); 152 } 153 154 /* Prepare settings widget: */ 155 QWidget *pWidgetSettings = new QWidget(m_pToolBox); 156 if (pWidgetSettings) 157 { 158 /* Prepare settings layout: */ 159 QVBoxLayout *pLayoutSettings = new QVBoxLayout(pWidgetSettings); 160 if (pLayoutSettings) 161 { 162 pLayoutSettings->setContentsMargins(0, 0, 0, 0); 163 164 /* Prepare form editor widget: */ 165 m_pFormEditor = new UIFormEditorWidget(pWidgetSettings); 166 if (m_pFormEditor) 167 { 168 /* Make form editor fit fit 40/50 symbols 169 * horizontally and 8 sections vertically: */ 170 const QFontMetrics fm(m_pSourceImageList->font()); 171 const int iFontWidth = fm.width('x'); 172 #ifdef VBOX_WS_MAC 173 const int iTotalWidth = 40 * iFontWidth; 174 #else 175 const int iTotalWidth = 50 * iFontWidth; 176 #endif 177 const int iSectionHeight = m_pFormEditor->verticalHeader() 178 ? m_pFormEditor->verticalHeader()->defaultSectionSize() 179 : fm.height(); 180 const int iTotalHeight = 8 * iSectionHeight; 181 m_pFormEditor->setMinimumSize(QSize(iTotalWidth, iTotalHeight)); 182 183 /* Add into layout: */ 184 pLayoutSettings->addWidget(m_pFormEditor); 185 } 186 } 187 188 /* Add into tool-box: */ 189 m_pToolBox->insertPage(2, pWidgetSettings, QString()); 190 } 191 99 192 /* Add into layout: */ 100 pLayoutMain->addWidget(m_pCntLocation, 0, 0); 101 } 102 103 /* Prepare source container: */ 104 m_pCntSource = new QGroupBox(this); 105 if (m_pCntSource) 106 { 107 /* Prepare source layout: */ 108 QVBoxLayout *pSourceLayout = new QVBoxLayout(m_pCntSource); 109 if (pSourceLayout) 110 { 111 pSourceLayout->setSpacing(0); 112 113 /* Prepare source tab-bar: */ 114 m_pSourceTabBar = new QTabBar(this); 115 if (m_pSourceTabBar) 116 { 117 m_pSourceTabBar->addTab(QString()); 118 m_pSourceTabBar->addTab(QString()); 119 120 /* Add into layout: */ 121 pSourceLayout->addWidget(m_pSourceTabBar); 122 } 123 124 /* Prepare source image list: */ 125 m_pSourceImageList = new QListWidget(m_pCntSource); 126 if (m_pSourceImageList) 127 { 128 m_pSourceImageList->setSortingEnabled(true); 129 /* Make source image list fit 40/50 symbols 130 * horizontally and 8 lines vertically: */ 131 const QFontMetrics fm(m_pSourceImageList->font()); 132 const int iFontWidth = fm.width('x'); 133 #ifdef VBOX_WS_MAC 134 const int iTotalWidth = 40 * iFontWidth; 135 #else 136 const int iTotalWidth = 50 * iFontWidth; 137 #endif 138 const int iFontHeight = fm.height(); 139 const int iTotalHeight = 8 * iFontHeight; 140 m_pSourceImageList->setMinimumSize(QSize(iTotalWidth, iTotalHeight)); 141 m_pSourceImageList->setAlternatingRowColors(true); 142 143 /* Add into layout: */ 144 pSourceLayout->addWidget(m_pSourceImageList); 145 } 146 } 147 148 /* Add into layout: */ 149 pLayoutMain->addWidget(m_pCntSource, 1, 0); 150 } 151 152 /* Prepare settings container: */ 153 m_pSettingsCnt = new QGroupBox(this); 154 if (m_pSettingsCnt) 155 { 156 /* Prepare settings layout: */ 157 QVBoxLayout *pSettingsLayout = new QVBoxLayout(m_pSettingsCnt); 158 if (pSettingsLayout) 159 { 160 /* Prepare form editor widget: */ 161 m_pFormEditor = new UIFormEditorWidget(m_pSettingsCnt); 162 if (m_pFormEditor) 163 { 164 /* Make form editor fit fit 40/50 symbols 165 * horizontally and 8 sections vertically: */ 166 const QFontMetrics fm(m_pSourceImageList->font()); 167 const int iFontWidth = fm.width('x'); 168 #ifdef VBOX_WS_MAC 169 const int iTotalWidth = 40 * iFontWidth; 170 #else 171 const int iTotalWidth = 50 * iFontWidth; 172 #endif 173 const int iSectionHeight = m_pFormEditor->verticalHeader() 174 ? m_pFormEditor->verticalHeader()->defaultSectionSize() 175 : fm.height(); 176 const int iTotalHeight = 8 * iSectionHeight; 177 m_pFormEditor->setMinimumSize(QSize(iTotalWidth, iTotalHeight)); 178 179 /* Add into layout: */ 180 pSettingsLayout->addWidget(m_pFormEditor); 181 } 182 } 183 184 /* Add into layout: */ 185 pLayoutMain->addWidget(m_pSettingsCnt, 0, 1, 2, 1); 193 pLayoutMain->addWidget(m_pToolBox); 186 194 } 187 195 } … … 211 219 void UIWizardNewCloudVMPageExpert::retranslateUi() 212 220 { 213 /* Translate location container: */ 214 m_pCntLocation->setTitle(UIWizardNewCloudVM::tr("Location")); 221 /* Translate tool-box: */ 222 if (m_pToolBox) 223 { 224 m_pToolBox->setPageTitle(0, UIWizardNewCloudVM::tr("Location")); 225 m_pToolBox->setPageTitle(1, UIWizardNewCloudVM::tr("Source")); 226 m_pToolBox->setPageTitle(2, UIWizardNewCloudVM::tr("Settings")); 227 } 215 228 216 229 /* Translate received values of Location combo-box. 217 230 * We are enumerating starting from 0 for simplicity: */ 218 for (int i = 0; i < m_pProviderComboBox->count(); ++i) 219 { 220 m_pProviderComboBox->setItemText(i, m_pProviderComboBox->itemData(i, ProviderData_Name).toString()); 221 m_pProviderComboBox->setItemData(i, UIWizardNewCloudVM::tr("Create VM for cloud service provider."), Qt::ToolTipRole); 222 } 223 224 /* Translate source container: */ 225 m_pCntSource->setTitle(UIWizardNewCloudVM::tr("Source")); 231 if (m_pProviderComboBox) 232 for (int i = 0; i < m_pProviderComboBox->count(); ++i) 233 { 234 m_pProviderComboBox->setItemText(i, m_pProviderComboBox->itemData(i, ProviderData_Name).toString()); 235 m_pProviderComboBox->setItemData(i, UIWizardNewCloudVM::tr("Create VM for cloud service provider."), Qt::ToolTipRole); 236 } 226 237 227 238 /* Translate source tab-bar: */ 228 m_pSourceTabBar->setTabText(0, UIWizardNewCloudVM::tr("&Boot Volumes")); 229 m_pSourceTabBar->setTabText(1, UIWizardNewCloudVM::tr("&Images")); 239 if (m_pSourceTabBar) 240 { 241 m_pSourceTabBar->setTabText(0, UIWizardNewCloudVM::tr("&Boot Volumes")); 242 m_pSourceTabBar->setTabText(1, UIWizardNewCloudVM::tr("&Images")); 243 } 230 244 231 245 /* Translate profile stuff: */ 232 m_pProfileToolButton->setToolTip(UIWizardNewCloudVM::tr("Open Cloud Profile Manager...")); 233 234 /* Translate settings container: */ 235 m_pSettingsCnt->setTitle(UIWizardNewCloudVM::tr("Settings")); 246 if (m_pProfileToolButton) 247 m_pProfileToolButton->setToolTip(UIWizardNewCloudVM::tr("Open Cloud Profile Manager...")); 236 248 237 249 /* Update tool-tips: */ … … 241 253 void UIWizardNewCloudVMPageExpert::initializePage() 242 254 { 255 /* Choose 1st tool to be chosen initially: */ 256 m_pToolBox->setCurrentPage(0); 243 257 /* Make sure form-editor knows notification-center: */ 244 258 m_pFormEditor->setNotificationCenter(wizard()->notificationCenter()); -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVMPageExpert.h
r93115 r93226 27 27 28 28 /* Forward declarations: */ 29 class QGroupBox;29 class UIToolBox; 30 30 class UIWizardNewCloudVM; 31 31 … … 84 84 QString m_strSourceImageId; 85 85 86 /** Holds the location container instance. */ 87 QGroupBox *m_pCntLocation; 86 /** Holds the tool-box instance. */ 87 UIToolBox *m_pToolBox; 88 88 89 /** Holds the location type combo-box instance. */ 89 90 QIComboBox *m_pProviderComboBox; … … 93 94 QIToolButton *m_pProfileToolButton; 94 95 95 /** Holds the source container instance. */96 QGroupBox *m_pCntSource;97 96 /** Holds the source tab-bar instance. */ 98 97 QTabBar *m_pSourceTabBar; … … 100 99 QListWidget *m_pSourceImageList; 101 100 102 /** Holds the settings container instance. */103 QGroupBox *m_pSettingsCnt;104 101 /** Holds the Form Editor widget instance. */ 105 102 UIFormEditorWidget *m_pFormEditor;
Note:
See TracChangeset
for help on using the changeset viewer.