Changeset 87892 in vbox
- Timestamp:
- Feb 26, 2021 6:26:25 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.cpp
r87865 r87892 17 17 18 18 /* Qt includes: */ 19 #include <QButtonGroup>20 19 #include <QCheckBox> 21 20 #include <QDir> -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.h
r87602 r87892 36 36 class UIFilePathSelector; 37 37 class UINameAndSystemEditor; 38 class QButtonGroup;39 38 40 39 /** 1st page of the New Virtual Machine wizard (base part): */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic4.cpp
r87886 r87892 17 17 18 18 /* Qt includes: */ 19 #include <QButtonGroup> 19 20 #include <QGridLayout> 20 21 #include <QMetaType> … … 34 35 #include "UIWizardNewVMPageBasic4.h" 35 36 37 Q_DECLARE_METATYPE(SelectedDiskSource); 38 36 39 UIWizardNewVMPage4::UIWizardNewVMPage4() 37 40 : m_fRecommendedNoDisk(false) 38 , m_pDisk Skip(0)39 , m_pDisk Create(0)40 , m_pDisk Present(0)41 , m_pDiskEmpty(0) 42 , m_pDiskNew(0) 43 , m_pDiskExisting(0) 41 44 , m_pDiskSelector(0) 42 , m_pVMMButton(0) 43 { 44 } 45 46 void UIWizardNewVMPage4::updateVirtualDiskSource() 47 { 48 if (!m_pDiskSelector || !m_pVMMButton) 49 return; 50 51 /* Enable/disable controls: */ 52 m_pDiskSelector->setEnabled(m_pDiskPresent->isChecked()); 53 m_pVMMButton->setEnabled(m_pDiskPresent->isChecked()); 54 55 /* Fetch filed values: */ 56 // if (m_pDiskSkip->isChecked()) 57 // { 58 // m_uVirtualDiskId = QUuid(); 59 // } 60 // else if (m_pDiskPresent->isChecked()) 61 // { 62 // m_uVirtualDiskId = m_pDiskSelector->id(); 63 // } 45 , m_pDiskSelectionButton(0) 46 , m_enmSelectedDiskSource(SelectedDiskSource_New) 47 { 48 } 49 50 SelectedDiskSource UIWizardNewVMPage4::selectedDiskSource() const 51 { 52 return m_enmSelectedDiskSource; 53 } 54 55 void UIWizardNewVMPage4::setSelectedDiskSource(SelectedDiskSource enmSelectedDiskSource) 56 { 57 m_enmSelectedDiskSource = enmSelectedDiskSource; 64 58 } 65 59 … … 80 74 /* Update medium-combo if necessary: */ 81 75 m_pDiskSelector->setCurrentItem(uMediumId); 82 /* Update hard disk source: */83 updateVirtualDiskSource();84 76 /* Focus on hard disk combo: */ 85 77 m_pDiskSelector->setFocus(); … … 102 94 m_virtualDisk = pWizard->virtualDisk(); 103 95 m_pDiskSelector->setCurrentItem(m_virtualDisk.GetId()); 104 m_pDisk Present->click();96 m_pDiskExisting->click(); 105 97 } 106 98 if (pWizard) … … 135 127 void UIWizardNewVMPage4::retranslateWidgets() 136 128 { 137 if (m_pDiskSkip) 138 m_pDiskSkip->setText(UIWizardNewVM::tr("&Do not add a virtual hard disk")); 139 if (m_pDiskCreate) 140 m_pDiskCreate->setText(UIWizardNewVM::tr("&Create a virtual hard disk now")); 141 if (m_pDiskPresent) 142 m_pDiskPresent->setText(UIWizardNewVM::tr("&Use an existing virtual hard disk file")); 143 if (m_pVMMButton) 144 m_pVMMButton->setToolTip(UIWizardNewVM::tr("Choose a virtual hard disk file...")); 129 if (m_pDiskEmpty) 130 m_pDiskEmpty->setText(UIWizardNewVM::tr("&Do not add a virtual hard disk")); 131 if (m_pDiskNew) 132 m_pDiskNew->setText(UIWizardNewVM::tr("&Create a virtual hard disk now")); 133 if (m_pDiskExisting) 134 m_pDiskExisting->setText(UIWizardNewVM::tr("&Use an existing virtual hard disk file")); 135 if (m_pDiskSelectionButton) 136 m_pDiskSelectionButton->setToolTip(UIWizardNewVM::tr("Choose a virtual hard disk file...")); 137 } 138 139 void UIWizardNewVMPage4::setEnableDiskSelectionWidgets(bool fEnabled) 140 { 141 if (!m_pDiskSelector || !m_pDiskSelectionButton) 142 return; 143 144 m_pDiskSelector->setEnabled(fEnabled); 145 m_pDiskSelectionButton->setEnabled(fEnabled); 145 146 } 146 147 … … 149 150 QWidget *pDiskContainer = new QWidget; 150 151 QGridLayout *pDiskLayout = new QGridLayout(pDiskContainer); 151 152 m_pDiskSkip = new QRadioButton; 153 m_pDiskCreate = new QRadioButton; 154 m_pDiskPresent = new QRadioButton; 152 m_pDiskSourceButtonGroup = new QButtonGroup; 153 m_pDiskEmpty = new QRadioButton; 154 m_pDiskNew = new QRadioButton; 155 m_pDiskExisting = new QRadioButton; 156 m_pDiskSourceButtonGroup->addButton(m_pDiskEmpty); 157 m_pDiskSourceButtonGroup->addButton(m_pDiskNew); 158 m_pDiskSourceButtonGroup->addButton(m_pDiskExisting); 155 159 QStyleOptionButton options; 156 options.initFrom(m_pDisk Present);157 int iWidth = m_pDisk Present->style()->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth, &options, m_pDiskPresent);160 options.initFrom(m_pDiskExisting); 161 int iWidth = m_pDiskExisting->style()->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth, &options, m_pDiskExisting); 158 162 pDiskLayout->setColumnMinimumWidth(0, iWidth); 159 163 m_pDiskSelector = new UIMediaComboBox; … … 162 166 m_pDiskSelector->repopulate(); 163 167 } 164 m_p VMMButton = new QIToolButton;165 { 166 m_p VMMButton->setAutoRaise(true);167 m_p VMMButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_disabled_16px.png"));168 } 169 pDiskLayout->addWidget(m_pDisk Skip, 0, 0, 1, 3);170 pDiskLayout->addWidget(m_pDisk Create, 1, 0, 1, 3);171 pDiskLayout->addWidget(m_pDisk Present, 2, 0, 1, 3);168 m_pDiskSelectionButton = new QIToolButton; 169 { 170 m_pDiskSelectionButton->setAutoRaise(true); 171 m_pDiskSelectionButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_disabled_16px.png")); 172 } 173 pDiskLayout->addWidget(m_pDiskEmpty, 0, 0, 1, 3); 174 pDiskLayout->addWidget(m_pDiskNew, 1, 0, 1, 3); 175 pDiskLayout->addWidget(m_pDiskExisting, 2, 0, 1, 3); 172 176 pDiskLayout->addWidget(m_pDiskSelector, 3, 1); 173 pDiskLayout->addWidget(m_p VMMButton, 3, 2);177 pDiskLayout->addWidget(m_pDiskSelectionButton, 3, 2); 174 178 return pDiskContainer; 175 179 } … … 180 184 prepare(); 181 185 qRegisterMetaType<CMedium>(); 186 qRegisterMetaType<SelectedDiskSource>(); 182 187 registerField("virtualDisk", this, "virtualDisk"); 188 registerField("diskSource", this, "diskSource"); 183 189 } 184 190 185 191 int UIWizardNewVMPageBasic4::nextId() const 186 192 { 187 if (m_pDisk Create->isChecked())193 if (m_pDiskNew->isChecked()) 188 194 return UIWizardNewVM::Page5; 189 195 return UIWizardNewVM::Page8; … … 199 205 200 206 pMainLayout->addStretch(); 201 updateVirtualDiskSource();207 setEnableDiskSelectionWidgets(m_enmSelectedDiskSource == SelectedDiskSource_Existing); 202 208 createConnections(); 203 209 } … … 205 211 void UIWizardNewVMPageBasic4::createConnections() 206 212 { 207 connect(m_pDiskSkip, &QRadioButton::toggled, 208 this, &UIWizardNewVMPageBasic4::sltVirtualDiskSourceChanged); 209 connect(m_pDiskCreate, &QRadioButton::toggled, 210 this, &UIWizardNewVMPageBasic4::sltVirtualDiskSourceChanged); 211 connect(m_pDiskPresent, &QRadioButton::toggled, 212 this, &UIWizardNewVMPageBasic4::sltVirtualDiskSourceChanged); 213 connect(m_pDiskSourceButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton *)>(&QButtonGroup::buttonClicked), 214 this, &UIWizardNewVMPageBasic4::sltHandleSelectedDiskSourceChange); 213 215 connect(m_pDiskSelector, static_cast<void(UIMediaComboBox::*)(int)>(&UIMediaComboBox::currentIndexChanged), 214 this, &UIWizardNewVMPageBasic4::sltVirtual DiskSourceChanged);215 connect(m_p VMMButton, &QIToolButton::clicked,216 this, &UIWizardNewVMPageBasic4::sltVirtualSelectedDiskSourceChanged); 217 connect(m_pDiskSelectionButton, &QIToolButton::clicked, 216 218 this, &UIWizardNewVMPageBasic4::sltGetWithFileOpenDialog); 217 219 } 218 220 219 void UIWizardNewVMPageBasic4::sltVirtualDiskSourceChanged() 220 { 221 /* Call to base-class: */ 222 updateVirtualDiskSource(); 223 224 /* Broadcast complete-change: */ 221 void UIWizardNewVMPageBasic4::sltHandleSelectedDiskSourceChange() 222 { 223 if (!m_pDiskSourceButtonGroup) 224 return; 225 226 if (m_pDiskSourceButtonGroup->checkedButton() == m_pDiskEmpty) 227 setSelectedDiskSource(SelectedDiskSource_Empty); 228 else if (m_pDiskSourceButtonGroup->checkedButton() == m_pDiskExisting) 229 setSelectedDiskSource(SelectedDiskSource_Existing); 230 else 231 setSelectedDiskSource(SelectedDiskSource_New); 232 233 setEnableDiskSelectionWidgets(m_enmSelectedDiskSource == SelectedDiskSource_Existing); 234 completeChanged(); 235 } 236 237 void UIWizardNewVMPageBasic4::sltVirtualSelectedDiskSourceChanged() 238 { 225 239 emit completeChanged(); 226 240 } … … 261 275 if (type.GetRecommendedHDD() != 0) 262 276 { 263 if (m_pDisk Create)277 if (m_pDiskNew) 264 278 { 265 m_pDisk Create->setFocus();266 m_pDisk Create->setChecked(true);279 m_pDiskNew->setFocus(); 280 m_pDiskNew->setChecked(true); 267 281 } 268 282 m_fRecommendedNoDisk = false; … … 270 284 else 271 285 { 272 if (m_pDisk Skip)286 if (m_pDiskEmpty) 273 287 { 274 m_pDisk Skip->setFocus();275 m_pDisk Skip->setChecked(true);288 m_pDiskEmpty->setFocus(); 289 m_pDiskEmpty->setChecked(true); 276 290 } 277 291 m_fRecommendedNoDisk = true; 278 }292 } 279 293 if (m_pDiskSelector) 280 294 m_pDiskSelector->setCurrentIndex(0); … … 290 304 bool UIWizardNewVMPageBasic4::isComplete() const 291 305 { 292 if (!m_pDisk Skip)306 if (!m_pDiskEmpty) 293 307 return false; 294 return m_pDisk Skip->isChecked() ||295 !m_pDisk Present->isChecked() ||308 return m_pDiskEmpty->isChecked() || 309 !m_pDiskExisting->isChecked() || 296 310 !uiCommon().medium(m_pDiskSelector->id()).isNull(); 297 311 } … … 303 317 304 318 // /* Ensure unused virtual-disk is deleted: */ 305 // if (m_pDisk Skip->isChecked() || m_pDiskCreate->isChecked() || (!m_virtualDisk.isNull() && m_uVirtualDiskId != m_virtualDisk.GetId()))319 // if (m_pDiskEmpty->isChecked() || m_pDiskNew->isChecked() || (!m_virtualDisk.isNull() && m_uVirtualDiskId != m_virtualDisk.GetId())) 306 320 // ensureNewVirtualDiskDeleted(); 307 321 308 // if (m_pDisk Skip->isChecked())322 // if (m_pDiskEmpty->isChecked()) 309 323 // { 310 324 // /* Ask user about disk-less machine unless that's the recommendation: */ … … 312 326 // fResult = msgCenter().confirmHardDisklessMachine(thisImp()); 313 327 // } 314 // else if (m_pDisk Create->isChecked())328 // else if (m_pDiskNew->isChecked()) 315 329 // { 316 330 // /* Show the New Virtual Hard Drive wizard: */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic4.h
r87886 r87892 33 33 34 34 /* Forward declarations: */ 35 class QButtonGroup; 35 36 class QRadioButton; 36 37 class QIRichTextLabel; … … 38 39 class UIMediaComboBox; 39 40 40 /** 3rd page of the New Virtual Machine wizard (base part). */ 41 enum SelectedDiskSource 42 { 43 SelectedDiskSource_Empty = 0, 44 SelectedDiskSource_New, 45 SelectedDiskSource_Existing, 46 SelectedDiskSource_Max 47 }; 48 41 49 class UIWizardNewVMPage4 : public UIWizardPageBase 42 50 { … … 49 57 protected: 50 58 51 /** Constructor. */52 59 UIWizardNewVMPage4(); 53 60 54 /** Handlers. */ 55 void updateVirtualDiskSource(); 61 SelectedDiskSource selectedDiskSource() const; 62 void setSelectedDiskSource(SelectedDiskSource enmSelectedDiskSource); 63 56 64 void getWithFileOpenDialog(); 57 65 bool getWithNewVirtualDiskWizard(); 58 66 59 67 60 61 68 QWidget *createDiskWidgets(); 62 69 63 /** Helpers. */64 70 void ensureNewVirtualDiskDeleted(); 65 71 void retranslateWidgets(); 66 72 67 /** Input. */73 void setEnableDiskSelectionWidgets(bool fEnable); 68 74 bool m_fRecommendedNoDisk; 69 75 … … 75 81 /** @name Widgets 76 82 * @{ */ 77 QRadioButton *m_pDiskSkip; 78 QRadioButton *m_pDiskCreate; 79 QRadioButton *m_pDiskPresent; 83 QButtonGroup *m_pDiskSourceButtonGroup; 84 QRadioButton *m_pDiskEmpty; 85 QRadioButton *m_pDiskNew; 86 QRadioButton *m_pDiskExisting; 80 87 UIMediaComboBox *m_pDiskSelector; 81 QIToolButton *m_p VMMButton;88 QIToolButton *m_pDiskSelectionButton; 82 89 /** @} */ 83 90 SelectedDiskSource m_enmSelectedDiskSource; 84 91 }; 85 92 86 /** 3rd page of the New Virtual Machine wizard (basic extension). */87 93 class UIWizardNewVMPageBasic4 : public UIWizardPage, public UIWizardNewVMPage4 88 94 { 89 95 Q_OBJECT; 90 96 Q_PROPERTY(CMedium virtualDisk READ virtualDisk WRITE setVirtualDisk); 97 Q_PROPERTY(SelectedDiskSource selectedDiskSource READ selectedDiskSource WRITE setSelectedDiskSource); 91 98 92 99 public: … … 107 114 private slots: 108 115 109 /** Handlers. */110 void sltVirtual DiskSourceChanged();116 void sltHandleSelectedDiskSourceChange(); 117 void sltVirtualSelectedDiskSourceChanged(); 111 118 void sltGetWithFileOpenDialog(); 112 119 … … 114 121 115 122 116 /** Prepare stuff. */117 123 void prepare(); 118 124 void createConnections(); … … 121 127 void cleanupPage(); 122 128 123 /** Validation stuff. */124 129 bool isComplete() const; 125 //virtual bool validatePage() /* override */;126 130 127 /** Widgets. */128 131 QIRichTextLabel *m_pLabel; 129 132 }; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp
r87886 r87892 17 17 18 18 /* Qt includes: */ 19 #include <QButtonGroup>20 19 #include <QCheckBox> 21 20 #include <QGridLayout> … … 61 60 62 61 pMainLayout->addStretch(); 63 updateVirtualDiskSource(); 62 64 63 } 65 64 … … 145 144 void UIWizardNewVMPageExpert::sltVirtualDiskSourceChanged() 146 145 { 147 /* Call to base-class: */148 updateVirtualDiskSource();149 150 146 /* Broadcast complete-change: */ 151 147 emit completeChanged(); … … 239 235 240 236 /* Connections for disk and hardware stuff: */ 241 if (m_pDisk Skip)242 { 243 connect(m_pDisk Skip, &QRadioButton::toggled,237 if (m_pDiskEmpty) 238 { 239 connect(m_pDiskEmpty, &QRadioButton::toggled, 244 240 this, &UIWizardNewVMPageExpert::sltVirtualDiskSourceChanged); 245 connect(m_pDisk Skip, &QRadioButton::toggled,241 connect(m_pDiskEmpty, &QRadioButton::toggled, 246 242 this, &UIWizardNewVMPageExpert::sltValueModified); 247 243 } 248 if (m_pDisk Create)249 { 250 connect(m_pDisk Create, &QRadioButton::toggled,244 if (m_pDiskNew) 245 { 246 connect(m_pDiskNew, &QRadioButton::toggled, 251 247 this, &UIWizardNewVMPageExpert::sltVirtualDiskSourceChanged); 252 connect(m_pDisk Create, &QRadioButton::toggled,248 connect(m_pDiskNew, &QRadioButton::toggled, 253 249 this, &UIWizardNewVMPageExpert::sltValueModified); 254 250 } 255 if (m_pDisk Present)256 { 257 connect(m_pDisk Present, &QRadioButton::toggled,251 if (m_pDiskExisting) 252 { 253 connect(m_pDiskExisting, &QRadioButton::toggled, 258 254 this, &UIWizardNewVMPageExpert::sltVirtualDiskSourceChanged); 259 connect(m_pDisk Present, &QRadioButton::toggled,255 connect(m_pDiskExisting, &QRadioButton::toggled, 260 256 this, &UIWizardNewVMPageExpert::sltValueModified); 261 257 } … … 263 259 connect(m_pDiskSelector, static_cast<void(UIMediaComboBox::*)(int)>(&UIMediaComboBox::currentIndexChanged), 264 260 this, &UIWizardNewVMPageExpert::sltVirtualDiskSourceChanged); 265 if (m_p VMMButton)266 connect(m_p VMMButton, &QIToolButton::clicked,261 if (m_pDiskSelectionButton) 262 connect(m_pDiskSelectionButton, &QIToolButton::clicked, 267 263 this, &UIWizardNewVMPageExpert::sltGetWithFileOpenDialog); 268 264 if (m_pBaseMemoryEditor) … … 299 295 300 296 /* Prepare initial disk choice: */ 301 if (!m_userSetWidgets.contains(m_pDisk Create) &&302 !m_userSetWidgets.contains(m_pDisk Skip) &&303 !m_userSetWidgets.contains(m_pDisk Present))297 if (!m_userSetWidgets.contains(m_pDiskNew) && 298 !m_userSetWidgets.contains(m_pDiskEmpty) && 299 !m_userSetWidgets.contains(m_pDiskExisting)) 304 300 { 305 301 if (type.GetRecommendedHDD() != 0) 306 302 { 307 if (m_pDisk Create)303 if (m_pDiskNew) 308 304 { 309 m_pDisk Create->setFocus();310 m_pDisk Create->setChecked(true);305 m_pDiskNew->setFocus(); 306 m_pDiskNew->setChecked(true); 311 307 } 312 308 m_fRecommendedNoDisk = false; … … 314 310 else 315 311 { 316 if (m_pDisk Skip)312 if (m_pDiskEmpty) 317 313 { 318 m_pDisk Skip->setFocus();319 m_pDisk Skip->setChecked(true);314 m_pDiskEmpty->setFocus(); 315 m_pDiskEmpty->setChecked(true); 320 316 } 321 317 m_fRecommendedNoDisk = true; … … 405 401 } 406 402 407 if (m_pDisk Present->isChecked() && uiCommon().medium(m_pDiskSelector->id()).isNull())403 if (m_pDiskExisting->isChecked() && uiCommon().medium(m_pDiskSelector->id()).isNull()) 408 404 { 409 405 m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Disk, … … 464 460 if (fResult) 465 461 { 466 if (m_pDisk Create->isChecked())462 if (m_pDiskNew->isChecked()) 467 463 { 468 464 /* Show the New Virtual Hard Drive wizard if necessary: */
Note:
See TracChangeset
for help on using the changeset viewer.