Changeset 37331 in vbox
- Timestamp:
- Jun 6, 2011 4:30:51 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 72091
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 6 edited
- 1 copied
- 6 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r37200 r37331 320 320 src/settings/machine/UIMachineSettingsSFDetails.h \ 321 321 src/wizards/newvm/UINewVMWzd.h \ 322 src/wizards/newhd/UINewHDW zd.h \322 src/wizards/newhd/UINewHDWizard.h \ 323 323 src/wizards/firstrun/UIFirstRunWzd.h \ 324 324 src/wizards/exportappliance/UIExportApplianceWzd.h \ … … 394 394 src/runtime/UIIndicatorsPool.cpp \ 395 395 src/runtime/UIMachine.cpp \ 396 src/runtime/UIMachineMenuBar.cpp 396 src/runtime/UIMachineMenuBar.cpp \ 397 src/wizards/newhd/UINewHDWizard.cpp 397 398 398 399 VirtualBox_QT_MOCSRCS.darwin += \ … … 485 486 src/settings/machine/UIMachineSettingsSFDetails.cpp \ 486 487 src/wizards/newvm/UINewVMWzd.cpp \ 487 src/wizards/newhd/UINewHDW zd.cpp \488 src/wizards/newhd/UINewHDWizard.cpp \ 488 489 src/wizards/firstrun/UIFirstRunWzd.cpp \ 489 490 src/wizards/exportappliance/UIExportApplianceWzd.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/VBoxUI.pro
r34543 r37331 53 53 src/wizards/newvm/UINewVMWzdPage4.ui \ 54 54 src/wizards/newvm/UINewVMWzdPage5.ui \ 55 src/wizards/newhd/UINewHDWzdPage1.ui \ 56 src/wizards/newhd/UINewHDWzdPage2.ui \ 57 src/wizards/newhd/UINewHDWzdPage3.ui \ 58 src/wizards/newhd/UINewHDWzdPage4.ui \ 55 src/wizards/newhd/UINewHDWizardPageWelcome.ui \ 56 src/wizards/newhd/UINewHDWizardPageFormat.ui \ 57 src/wizards/newhd/UINewHDWizardPageVariant.ui \ 58 src/wizards/newhd/UINewHDWizardPageOptions.ui \ 59 src/wizards/newhd/UINewHDWizardPageSummary.ui \ 59 60 src/wizards/firstrun/UIFirstRunWzdPage1.ui \ 60 61 src/wizards/firstrun/UIFirstRunWzdPage2.ui \ -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp
r34983 r37331 37 37 #include "VBoxGlobal.h" 38 38 #include "VBoxMediaManagerDlg.h" 39 #include "UINewHDW zd.h"39 #include "UINewHDWizard.h" 40 40 #include "VBoxProblemReporter.h" 41 41 #include "UIToolBar.h" … … 952 952 AssertReturnVoid (currentTreeWidgetType() == VBoxDefs::MediumType_HardDisk); 953 953 954 UINewHDW zd dlg (this);954 UINewHDWizard dlg (this); 955 955 956 956 if (dlg.exec() == QDialog::Accepted) -
trunk/src/VBox/Frontends/VirtualBox/src/globals/COMDefs.h
r35638 r37331 633 633 // constructors & destructor 634 634 635 CInterface() 635 CInterface() 636 636 { 637 637 clear(); … … 639 639 640 640 CInterface (const CInterface &that) : B (that) 641 { 642 clear(); 641 { 642 clear(); 643 643 mIface = that.mIface; 644 644 addref(ptr()); 645 645 } 646 646 647 CInterface (I *aIface) 648 { 647 CInterface (I *aIface) 648 { 649 649 clear(); 650 650 setPtr (aIface); 651 addref (aIface); 652 } 653 654 virtual ~CInterface() 655 { 651 addref (aIface); 652 } 653 654 virtual ~CInterface() 655 { 656 656 detach(); 657 657 #ifdef DEBUG … … 677 677 (void **) &pObj); 678 678 #endif 679 679 680 680 if (SUCCEEDED (B::mRC)) 681 681 setPtr(pObj); 682 682 else 683 683 setPtr(NULL); 684 684 685 685 /* fetch error info, but don't assert if it's missing -- many other 686 686 * reasons can lead to an error (w/o providing error info), not only … … 732 732 733 733 /** Detaches from the underlying interface pointer. */ 734 void detach() 735 { 734 void detach() 735 { 736 736 #ifdef DEBUG 737 737 Assert(!mDead); 738 738 #endif 739 release (ptr()); 740 setPtr(NULL); 739 release (ptr()); 740 setPtr(NULL); 741 741 } 742 742 743 743 /** Returns @c true if not attached to any interface pointer. */ 744 bool isNull() const 745 { 744 bool isNull() const 745 { 746 746 #ifdef DEBUG 747 747 Assert(!mDead); 748 748 #endif 749 return mIface == NULL; 749 return mIface == NULL; 750 750 } 751 751 … … 786 786 * else but in generated wrappers and for debugging. You've been warned. 787 787 */ 788 I *raw() const 788 I *raw() const 789 789 { 790 790 return ptr(); … … 819 819 void clear() 820 820 { 821 mIface = NULL; 821 mIface = NULL; 822 822 #ifdef DEBUG 823 823 mDead = false; … … 910 910 Q_DECLARE_METATYPE(CConsole); 911 911 Q_DECLARE_METATYPE(CHostNetworkInterface); 912 Q_DECLARE_METATYPE(CMediumFormat); 912 913 913 914 /** @} */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp
r37168 r37331 21 21 #include "QIWidgetValidator.h" 22 22 #include "UIIconPool.h" 23 #include "UINewHDW zd.h"23 #include "UINewHDWizard.h" 24 24 #include "VBoxGlobal.h" 25 25 #include "QIFileDialog.h" … … 2918 2918 QString UIMachineSettingsStorage::getWithNewHDWizard() 2919 2919 { 2920 /* Run New HD Wizard */2921 UINewHDWzd dlg(this);2922 2920 /* Initialize variables: */ 2923 2921 CGuestOSType guestOSType = vboxGlobal().virtualBox().GetGuestOSType(m_strMachineGuestOSTypeId); 2924 dlg.setRecommendedSize(guestOSType.GetRecommendedHDD());2925 2922 QFileInfo fileInfo(m_strMachineSettingsFilePath); 2926 dlg.setDefaultPath(fileInfo.absolutePath()); 2923 /* Run New HD Wizard: */ 2924 UINewHDWizard dlg(this, QString(), fileInfo.absolutePath(), guestOSType.GetRecommendedHDD()); 2927 2925 2928 2926 return dlg.exec() == QDialog::Accepted ? dlg.hardDisk().GetId() : QString(); -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizard.cpp
r37181 r37331 3 3 * 4 4 * VBox frontends: Qt4 GUI ("VirtualBox"): 5 * UINewHDW zd class implementation5 * UINewHDWizard class implementation 6 6 */ 7 7 8 8 /* 9 * Copyright (C) 2006-201 0Oracle Corporation9 * Copyright (C) 2006-2011 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 18 */ 19 19 20 /* Local includes */ 21 #include "UIIconPool.h" 22 #include "UINewHDWzd.h" 20 /* Global includes: */ 21 #include <QCheckBox> 22 #include <QRadioButton> 23 #include <QRegExpValidator> 24 25 /* Local includes: */ 23 26 #include "VBoxGlobal.h" 24 27 #include "VBoxProblemReporter.h" 25 26 /* Global includes */ 28 #include "QIFileDialog.h" 29 #include "UIIconPool.h" 30 #include "UINewHDWizard.h" 27 31 #include "iprt/path.h" 28 #include <QFileDialog> 29 #include <QRegExpValidator> 30 31 32 UINewHDWzd::UINewHDWzd(QWidget *pParent) : QIWizard(pParent) 33 { 34 /* Create & add pages */ 35 addPage(new UINewHDWzdPage1); 36 addPage(new UINewHDWzdPage2); 37 addPage(new UINewHDWzdPage3); 38 addPage(new UINewHDWzdPage4); 39 40 /* Initial translate */ 32 33 /* Class to manage page variants: */ 34 class UIExclusivenessManager : public QObject 35 { 36 Q_OBJECT; 37 38 public: 39 40 /* Constructor: */ 41 UIExclusivenessManager(QWidget *pParent) : QObject(pParent) {} 42 43 /* Wrapper for adding different children: */ 44 void addWidget(QWidget *pWidget, const QVariant &data) 45 { 46 /* Add radio-button: */ 47 if (QRadioButton *pRadioButton = qobject_cast<QRadioButton*>(pWidget)) 48 addRadioButton(pRadioButton, data); 49 /* Add check-box: */ 50 if (QCheckBox *pCheckBox = qobject_cast<QCheckBox*>(pWidget)) 51 addCheckBox(pCheckBox, data); 52 } 53 54 /* Wrapper for different children data: */ 55 QVariant data(QWidget *pWidget) const 56 { 57 /* Return data for radio-button: */ 58 if (QRadioButton *pRadioButton = qobject_cast<QRadioButton*>(pWidget)) 59 return dataOfRadioButton(pRadioButton); 60 /* Return data for check-box: */ 61 if (QCheckBox *pCheckBox = qobject_cast<QCheckBox*>(pWidget)) 62 return dataOfCheckBox(pCheckBox); 63 /* Return empty data: */ 64 return QVariant(); 65 } 66 67 void reset() 68 { 69 /* Make sure all radio-buttons are unchecked: */ 70 QList<QRadioButton*> radioButtons = m_radioButtons.keys(); 71 for (int i = 0; i < radioButtons.size(); ++i) 72 { 73 if (radioButtons[i]->isChecked()) 74 { 75 radioButtons[i]->setAutoExclusive(false); 76 radioButtons[i]->setChecked(false); 77 radioButtons[i]->setAutoExclusive(true); 78 } 79 } 80 /* Make sure all check-boxes are unchecked: */ 81 QList<QCheckBox*> checkBoxes = m_checkBoxes.keys(); 82 for (int i = 0; i < checkBoxes.size(); ++i) 83 { 84 if (checkBoxes[i]->isChecked()) 85 checkBoxes[i]->setChecked(false); 86 } 87 } 88 89 signals: 90 91 void sigNotifyAboutStateChange(QVariant exclusiveData, QList<QVariant> optionsData); 92 93 private slots: 94 95 void sltRadioButtonToggled() 96 { 97 recalculateState(); 98 } 99 100 void sltCheckBoxToggled() 101 { 102 recalculateState(); 103 } 104 105 private: 106 107 void addRadioButton(QRadioButton *pRadioButton, const QVariant &exclusiveData) 108 { 109 /* Setup the connections: */ 110 connect(pRadioButton, SIGNAL(toggled(bool)), this, SLOT(sltRadioButtonToggled())); 111 /* Add radio-button into corresponding list: */ 112 m_radioButtons.insert(pRadioButton, exclusiveData); 113 } 114 115 void addCheckBox(QCheckBox *pCheckBox, const QVariant &optionData) 116 { 117 /* Setup the connections: */ 118 connect(pCheckBox, SIGNAL(toggled(bool)), this, SLOT(sltCheckBoxToggled())); 119 /* Add check-box into corresponding list: */ 120 m_checkBoxes.insert(pCheckBox, optionData); 121 } 122 123 QVariant dataOfRadioButton(QRadioButton *pRadioButton) const 124 { 125 /* Return radio-button data if present: */ 126 if (m_radioButtons.contains(pRadioButton)) 127 return m_radioButtons[pRadioButton]; 128 /* Return empty data: */ 129 return QVariant(); 130 } 131 132 QVariant dataOfCheckBox(QCheckBox *pCheckBox) const 133 { 134 /* Return check-box data if present: */ 135 if (m_checkBoxes.contains(pCheckBox)) 136 return m_checkBoxes[pCheckBox]; 137 /* Return empty data: */ 138 return QVariant(); 139 } 140 141 void recalculateState() 142 { 143 /* Prepare current state: */ 144 QList<bool> currentState; 145 /* Get the list of radio-buttons: */ 146 QList<QRadioButton*> radioButtons = m_radioButtons.keys(); 147 /* Get the list of check-boxes: */ 148 QList<QCheckBox*> checkBoxes = m_checkBoxes.keys(); 149 150 /* Calculate current state: */ 151 for (int i = 0; i < radioButtons.size(); ++i) 152 currentState << radioButtons[i]->isChecked(); 153 for (int i = 0; i < checkBoxes.size(); ++i) 154 currentState << checkBoxes[i]->isChecked(); 155 156 /* Check if state was changed: */ 157 if (m_state == currentState) 158 return; 159 160 /* Search for exclusive data: */ 161 QVariant exclusiveData; 162 for (int i = 0; i < radioButtons.size(); ++i) 163 { 164 if (radioButtons[i]->isChecked()) 165 { 166 exclusiveData = m_radioButtons[radioButtons[i]]; 167 break; 168 } 169 } 170 171 /* Search for options data: */ 172 QList<QVariant> optionsData; 173 for (int i = 0; i < checkBoxes.size(); ++i) 174 { 175 if (checkBoxes[i]->isChecked()) 176 optionsData << m_checkBoxes[checkBoxes[i]]; 177 } 178 179 /* Notify listeners about state-change: */ 180 emit sigNotifyAboutStateChange(exclusiveData, optionsData); 181 } 182 183 QMap<QRadioButton*, QVariant> m_radioButtons; 184 QMap<QCheckBox*, QVariant> m_checkBoxes; 185 QList<bool> m_state; 186 }; 187 188 UINewHDWizard::UINewHDWizard(QWidget *pParent, const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize) 189 : QIWizard(pParent) 190 { 191 /* Create & add pages: */ 192 addPage(new UINewHDWizardPageWelcome); 193 addPage(new UINewHDWizardPageFormat); 194 addPage(new UINewHDWizardPageVariant); 195 addPage(new UINewHDWizardPageOptions(strDefaultName, strDefaultPath, uDefaultSize)); 196 addPage(new UINewHDWizardPageSummary); 197 198 /* Translate wizard: */ 41 199 retranslateUi(); 42 200 43 /* Initial translate all pages*/201 /* Translate wizard pages: */ 44 202 retranslateAllPages(); 45 203 46 /* Resize to 'golden ratio'*/204 /* Resize wizard to 'golden ratio': */ 47 205 resizeToGoldenRatio(); 48 206 49 207 #ifdef Q_WS_MAC 50 /* Assign background image */208 /* Assign background image: */ 51 209 assignBackground(":/vmw_new_harddisk_bg.png"); 52 210 #else /* Q_WS_MAC */ 53 /* Assign watermark */211 /* Assign watermark: */ 54 212 assignWatermark(":/vmw_new_harddisk.png"); 55 213 #endif /* Q_WS_MAC */ 56 214 } 57 215 58 CMedium UINewHDW zd::hardDisk() const59 { 60 /* Get 'hardDisk' field value from page 4*/216 CMedium UINewHDWizard::hardDisk() const 217 { 218 /* Return 'hardDisk' field value from 'summary' page: */ 61 219 return field("hardDisk").value<CMedium>(); 62 220 } 63 221 64 void UINewHDWzd::setRecommendedName(const QString &strName) 65 { 66 /* Set 'initialName' field value for page 3 */ 67 setField("initialName", strName); 68 } 69 70 void UINewHDWzd::setRecommendedSize(qulonglong uSize) 71 { 72 /* Set 'initialSize' field value for page 3 */ 73 setField("initialSize", uSize); 74 } 75 76 void UINewHDWzd::setDefaultPath(const QString &strDefaultPath) 77 { 78 m_strDefaultPath = strDefaultPath; 79 } 80 81 QString UINewHDWzd::absoluteFilePath(const QString &strFileName) 82 { 83 /* Wrap file-info around received file name: */ 84 QFileInfo fi(strFileName); 85 /* If there is no path info at all or its relative: */ 86 if (fi.fileName() == strFileName || fi.isRelative()) 87 { 88 /* Resolve path on the basis of m_strDefaultPath: */ 89 fi = QFileInfo(m_strDefaultPath, strFileName); 90 } 91 /* Return full absolute hard disk file path: */ 92 return QDir::toNativeSeparators(fi.absoluteFilePath()); 93 } 94 95 void UINewHDWzd::retranslateUi() 96 { 97 /* Wizard title */ 222 void UINewHDWizard::retranslateUi() 223 { 224 /* Assign wizard title: */ 98 225 setWindowTitle(tr("Create New Virtual Disk")); 99 226 } 100 227 101 UINewHDWzdPage1::UINewHDWzdPage1() 102 { 103 /* Decorate page */ 104 Ui::UINewHDWzdPage1::setupUi(this); 105 } 106 107 void UINewHDWzdPage1::retranslateUi() 108 { 109 /* Translate uic generated strings */ 110 Ui::UINewHDWzdPage1::retranslateUi(this); 111 112 /* Wizard page 1 title */ 113 setTitle(tr("Welcome to the Create New Virtual Disk Wizard!")); 114 115 116 m_pPage1Text1->setText(tr("<p>This wizard will help you to create a new virtual hard disk " 117 "for your virtual machine.</p><p>%1</p>") 118 .arg(standardHelpText())); 119 } 120 121 void UINewHDWzdPage1::initializePage() 122 { 123 /* Fill and translate */ 228 UINewHDWizardPageWelcome::UINewHDWizardPageWelcome() 229 { 230 /* Decorate page: */ 231 Ui::UINewHDWizardPageWelcome::setupUi(this); 232 } 233 234 void UINewHDWizardPageWelcome::retranslateUi() 235 { 236 /* Translate uic generated strings: */ 237 Ui::UINewHDWizardPageWelcome::retranslateUi(this); 238 239 /* Set 'welcome' page title: */ 240 setTitle(tr("Welcome to the virtual disk creation wizard")); 241 242 /* Append page text with common part: */ 243 QString strCommonPart = QString("<p>%1</p>").arg(standardHelpText()); 244 m_pLabel->setText(m_pLabel->text() + strCommonPart); 245 } 246 247 void UINewHDWizardPageWelcome::initializePage() 248 { 249 /* Retranslate page: */ 124 250 retranslateUi(); 125 251 } 126 252 127 UINewHDWzdPage2::UINewHDWzdPage2() 128 : m_strType(QString()) 129 , m_bFixed(false) 130 { 131 /* Decorate page */ 132 Ui::UINewHDWzdPage2::setupUi(this); 133 134 /* Register 'type', 'fixed' fields */ 135 registerField("type*", this, "type"); 136 registerField("fixed", this, "fixed"); 137 138 /* Setup connections */ 139 connect (m_pTypeDynamic, SIGNAL(clicked(bool)), this, SLOT(onTypeChanged())); 140 connect (m_pTypeFixed, SIGNAL(clicked(bool)), this, SLOT(onTypeChanged())); 141 } 142 143 void UINewHDWzdPage2::retranslateUi() 144 { 145 /* Translate uic generated strings */ 146 Ui::UINewHDWzdPage2::retranslateUi(this); 147 148 /* Wizard page 2 title */ 149 setTitle(tr("Hard Disk Storage Type")); 150 } 151 152 void UINewHDWzdPage2::initializePage() 153 { 154 /* Fill and translate */ 253 UINewHDWizardPageFormat::UINewHDWizardPageFormat() 254 : m_pExclusivenessManager(0) 255 , m_pDefaultButton(0) 256 { 257 /* Decorate page: */ 258 Ui::UINewHDWizardPageFormat::setupUi(this); 259 260 /* Register extended metatypes: */ 261 qRegisterMetaType<CMediumFormat>(); 262 263 /* Register 'mediumFormat' field: */ 264 registerField("mediumFormat", this, "mediumFormat"); 265 266 /* Create exclusiveness manager: */ 267 m_pExclusivenessManager = new UIExclusivenessManager(this); 268 connect(m_pExclusivenessManager, SIGNAL(sigNotifyAboutStateChange(QVariant, QList<QVariant>)), this, SLOT(sltUpdateFormat(QVariant))); 269 270 /* Enumerate supportable formats: */ 271 CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties(); 272 QVector<CMediumFormat> mediumFormats = systemProperties.GetMediumFormats(); 273 for (int iMediumFormatIndex = 0; iMediumFormatIndex < mediumFormats.size(); ++iMediumFormatIndex) 274 { 275 /* Get iterated medium format: */ 276 CMediumFormat mediumFormat = mediumFormats[iMediumFormatIndex]; 277 278 /* Check that medium format supports creation: */ 279 ULONG uFormatCapabilities = mediumFormat.GetCapabilities(); 280 if (!(uFormatCapabilities & MediumFormatCapabilities_CreateFixed || 281 uFormatCapabilities & MediumFormatCapabilities_CreateDynamic)) 282 continue; 283 284 /* Check that medium format supports creation of hard-disks: */ 285 QVector<QString> fileExtensions; 286 QVector<KDeviceType> deviceTypes; 287 mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes); 288 if (!deviceTypes.contains(KDeviceType_HardDisk)) 289 continue; 290 291 /* Create corresponding radio-button: */ 292 QRadioButton *pFormatButton = new QRadioButton(m_pFormatContainer); 293 m_pExclusivenessManager->addWidget(pFormatButton, QVariant::fromValue(mediumFormat)); 294 if (mediumFormat.GetName().toLower() == "vdi") 295 { 296 m_pFormatsLayout->insertWidget(0, pFormatButton); 297 m_pDefaultButton = pFormatButton; 298 } 299 else 300 m_pFormatsLayout->addWidget(pFormatButton); 301 } 302 } 303 304 /* static */ 305 QString UINewHDWizardPageFormat::fullFormatName(const QString &strBaseFormatName) 306 { 307 if (strBaseFormatName == "VDI") 308 return tr("&VDI (VirtualBox hard disk file)"); 309 else if (strBaseFormatName == "VHD") 310 return tr("V&HD"); 311 else if (strBaseFormatName == "VMDK") 312 return tr("V&MDK"); 313 return strBaseFormatName; 314 } 315 316 void UINewHDWizardPageFormat::sltUpdateFormat(QVariant formatData) 317 { 318 /* Get medium format: */ 319 CMediumFormat mediumFormat = formatData.value<CMediumFormat>(); 320 321 /* Check if medium format was changed: */ 322 if (m_mediumFormat == mediumFormat) 323 return; 324 325 /* Update medium format: */ 326 m_mediumFormat = mediumFormat; 327 328 /* Notify wizard sub-system about complete status changed: */ 329 emit completeChanged(); 330 } 331 332 void UINewHDWizardPageFormat::retranslateUi() 333 { 334 /* Translate uic generated strings: */ 335 Ui::UINewHDWizardPageFormat::retranslateUi(this); 336 337 /* Set 'format' page title: */ 338 setTitle(tr("Virtual disk file type")); 339 340 /* Translate 'format' buttons: */ 341 QList<QRadioButton*> formatButtons = findChildren<QRadioButton*>(); 342 for (int i = 0; i < formatButtons.size(); ++i) 343 { 344 QRadioButton *pFormatButton = formatButtons[i]; 345 CMediumFormat mediumFormat = m_pExclusivenessManager->data(pFormatButton).value<CMediumFormat>(); 346 pFormatButton->setText(fullFormatName(mediumFormat.GetName())); 347 } 348 } 349 350 void UINewHDWizardPageFormat::initializePage() 351 { 352 /* Retranslate page: */ 155 353 retranslateUi(); 156 354 157 /* Prepare initial choice */ 158 m_pTypeDynamic->click(); 159 160 /* 'Dynamic' choice should have focus initially */ 161 m_pTypeDynamic->setFocus(); 162 } 163 164 void UINewHDWzdPage2::onTypeChanged() 165 { 166 if (m_pTypeDynamic->isChecked()) 167 { 168 /* 'Dynamic' storage type */ 169 m_strType = VBoxGlobal::removeAccelMark(m_pTypeDynamic->text()); 170 m_bFixed = false; 171 } 172 else if (m_pTypeFixed->isChecked()) 173 { 174 /* 'Fixed' storage type */ 175 m_strType = VBoxGlobal::removeAccelMark(m_pTypeFixed->text()); 176 m_bFixed = true; 177 } 178 else 179 { 180 /* Not complete */ 181 m_strType.clear(); 182 m_bFixed = false; 183 } 355 /* Make sure first of buttons (default) is checked: */ 356 m_pDefaultButton->setChecked(true); 357 m_pDefaultButton->setFocus(); 358 } 359 360 void UINewHDWizardPageFormat::cleanupPage() 361 { 362 /* Reset exclusiveness manager: */ 363 m_pExclusivenessManager->reset(); 364 /* Call for base-class: */ 365 UINewHDWizardPage::cleanupPage(); 366 } 367 368 bool UINewHDWizardPageFormat::isComplete() const 369 { 370 return !m_mediumFormat.isNull(); 371 } 372 373 UINewHDWizardPageVariant::UINewHDWizardPageVariant() 374 : m_pExclusivenessManager(0) 375 , m_pDynamicalButton(0), m_pFixedButton(0), m_pSplitBox(0) 376 , m_uMediumVariant(KMediumVariant_Max) 377 { 378 /* Decorate page: */ 379 Ui::UINewHDWizardPageVariant::setupUi(this); 380 381 /* Register 'mediumVariant' field: */ 382 registerField("mediumVariant", this, "mediumVariant"); 383 384 /* Unfortuanelly, KMediumVariant is very messy, 385 * so we can't enumerate it to make sure GUI will not hard-code its values, 386 * we can only use hard-coded values that we need: */ 387 388 /* Create exclusiveness manager: */ 389 m_pExclusivenessManager = new UIExclusivenessManager(this); 390 connect(m_pExclusivenessManager, SIGNAL(sigNotifyAboutStateChange(QVariant, QList<QVariant>)), this, SLOT(sltUpdateVariant(QVariant, QList<QVariant>))); 391 392 /* Create 'dynamical' (standard) variant radio-button: */ 393 m_pDynamicalButton = new QRadioButton(m_pVariantContainer); 394 m_pVariantsLayout->addWidget(m_pDynamicalButton); 395 m_pExclusivenessManager->addWidget(m_pDynamicalButton, QVariant((qulonglong)KMediumVariant_Standard)); 396 397 /* Create 'fixed' variant radio-button: */ 398 m_pFixedButton = new QRadioButton(m_pVariantContainer); 399 m_pVariantsLayout->addWidget(m_pFixedButton); 400 m_pExclusivenessManager->addWidget(m_pFixedButton, QVariant((qulonglong)(KMediumVariant_Standard | KMediumVariant_Fixed))); 401 402 /* Create '2GByte' variant check-box: */ 403 m_pSplitBox = new QCheckBox(m_pVariantContainer); 404 m_pVariantsLayout->addWidget(m_pSplitBox); 405 m_pExclusivenessManager->addWidget(m_pSplitBox, QVariant((qulonglong)(KMediumVariant_VmdkSplit2G))); 406 } 407 408 /* static */ 409 QString UINewHDWizardPageVariant::variantToString(qulonglong uMediumVariant) 410 { 411 switch (uMediumVariant) 412 { 413 case (qulonglong)KMediumVariant_Standard: 414 return tr("Dynamically expanding storage"); 415 case (qulonglong)(KMediumVariant_Standard | KMediumVariant_Fixed): 416 return tr("Fixed size storage"); 417 case (qulonglong)(KMediumVariant_Standard | KMediumVariant_VmdkSplit2G): 418 return tr("Dynamically expanding storage split into files of less than 2GB"); 419 case (qulonglong)(KMediumVariant_Standard | KMediumVariant_Fixed | KMediumVariant_VmdkSplit2G): 420 return tr("Fixed size storage split into files of less than 2GB"); 421 default: 422 break; 423 } 424 return QString(); 425 } 426 427 void UINewHDWizardPageVariant::sltUpdateVariant(QVariant exclusiveData, QList<QVariant> optionsData) 428 { 429 /* Gather new data: */ 430 qulonglong uMediumVariant = exclusiveData.isNull() ? (qulonglong)KMediumVariant_Max : exclusiveData.toULongLong(); 431 for (int i = 0; i < optionsData.size(); ++i) 432 uMediumVariant |= optionsData[i].toULongLong(); 433 434 /* Check if medium variant was changed: */ 435 if (m_uMediumVariant == uMediumVariant) 436 return; 437 438 /* Update medium variant: */ 439 m_uMediumVariant = uMediumVariant; 440 441 /* Notify wizard sub-system about complete status changed: */ 184 442 emit completeChanged(); 185 443 } 186 444 187 UINewHDWzdPage3::UINewHDWzdPage3() 188 : m_strInitialName("NewHardDisk1.vdi") 189 , m_strCurrentName(QString()) 190 , m_strLocation(QString()) 191 , m_uInitialSize(2 * _1K) 192 , m_uCurrentSize(0) 193 , m_uMinVDISize(_4M) 194 , m_uMaxVDISize(vboxGlobal().virtualBox().GetSystemProperties().GetInfoVDSize()) 445 void UINewHDWizardPageVariant::retranslateUi() 446 { 447 /* Translate uic generated strings: */ 448 Ui::UINewHDWizardPageVariant::retranslateUi(this); 449 450 /* Set 'variant' page title: */ 451 setTitle(tr("Virtual disk storage details")); 452 453 /* Translate other text: */ 454 QString strText = m_pLabel->text(); 455 CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>(); 456 if (mediumFormat.isNull() || (mediumFormat.GetCapabilities() & KMediumFormatCapabilities_CreateDynamic)) 457 strText += tr("<p>A <b>dynamically expanding</b> virtual disk file will only use space on your physical hard disk as it fills up, " 458 "although it will not shrink again automatically when space on it is freed.</p>"); 459 if (mediumFormat.isNull() || (mediumFormat.GetCapabilities() & KMediumFormatCapabilities_CreateFixed)) 460 strText += tr("<p>A <b>fixed size</b> virtual disk file may take longer to create on some systems but is often faster to use.</p>"); 461 if (mediumFormat.isNull() || (mediumFormat.GetCapabilities() & KMediumFormatCapabilities_CreateSplit2G)) 462 strText += tr("<p>You can also choose to <b>split</b> the virtual disk into several files of up to two gigabytes each. " 463 "This is mainly useful if you wish to store the virtual machine on removable USB devices or old systems, " 464 "some of which cannot handle very large files."); 465 m_pLabel->setText(strText); 466 467 /* Translate buttons: */ 468 m_pDynamicalButton->setText(tr("&Dynamically expanding")); 469 m_pFixedButton->setText(tr("&Fixed size")); 470 m_pSplitBox->setText(tr("&Split into files of less than 2GB")); 471 } 472 473 void UINewHDWizardPageVariant::initializePage() 474 { 475 /* Retranslate page: */ 476 retranslateUi(); 477 478 /* Setup visibility: */ 479 CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>(); 480 ULONG uCapabilities = mediumFormat.GetCapabilities(); 481 m_pDynamicalButton->setVisible(uCapabilities & KMediumFormatCapabilities_CreateDynamic); 482 m_pFixedButton->setVisible(uCapabilities & KMediumFormatCapabilities_CreateFixed); 483 m_pSplitBox->setVisible(uCapabilities & KMediumFormatCapabilities_CreateSplit2G); 484 /* Make sure first of buttons (default) is checked if visible: */ 485 if (!m_pDynamicalButton->isHidden()) 486 { 487 m_pDynamicalButton->setChecked(true); 488 m_pDynamicalButton->setFocus(); 489 } 490 } 491 492 void UINewHDWizardPageVariant::cleanupPage() 493 { 494 /* Reset exclusiveness manager: */ 495 m_pExclusivenessManager->reset(); 496 /* Call for base-class: */ 497 UINewHDWizardPage::cleanupPage(); 498 } 499 500 bool UINewHDWizardPageVariant::isComplete() const 501 { 502 return m_uMediumVariant != KMediumVariant_Max; 503 } 504 505 UINewHDWizardPageOptions::UINewHDWizardPageOptions(const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize) 506 : m_strDefaultPath(strDefaultPath) 507 , m_strMediumName(strDefaultName.isEmpty() ? QString("NewHardDisk1") : strDefaultName) 508 , m_uMediumSize(uDefaultSize == 0 ? (qulonglong)_1G * 2 : uDefaultSize) 509 , m_uMediumSizeMin(_4M) 510 , m_uMediumSizeMax(vboxGlobal().virtualBox().GetSystemProperties().GetInfoVDSize()) 195 511 , m_iSliderScale(0) 196 512 { 197 /* Decorate page */ 198 Ui::UINewHDWzdPage3::setupUi(this); 199 200 /* Register 'initialName', 'currentName', 'location' & 201 * 'initialSize', 'currentSize' fields */ 202 registerField("initialName", this, "initialName"); 203 registerField("currentName", this, "currentName"); 204 registerField("location", this, "location"); 205 registerField("initialSize", this, "initialSize"); 206 registerField("currentSize", this, "currentSize"); 513 /* Decorate page: */ 514 Ui::UINewHDWizardPageOptions::setupUi(this); 515 516 /* Register 'mediumName', 'mediumPath', 'mediumSize' fields: */ 517 registerField("mediumName", this, "mediumName"); 518 registerField("mediumPath", this, "mediumPath"); 519 registerField("mediumSize", this, "mediumSize"); 207 520 208 521 /* Detect how many steps to recognize between adjacent powers of 2 209 * to ensure that the last slider step is exactly m_uM axVDISize*/210 int iPower = log2i(m_uM axVDISize);522 * to ensure that the last slider step is exactly m_uMediumSizeMax: */ 523 int iPower = log2i(m_uMediumSizeMax); 211 524 qulonglong uTickMB = qulonglong (1) << iPower; 212 if (uTickMB < m_uM axVDISize)525 if (uTickMB < m_uMediumSizeMax) 213 526 { 214 527 qulonglong uTickMBNext = qulonglong (1) << (iPower + 1); 215 qulonglong uGap = uTickMBNext - m_uM axVDISize;528 qulonglong uGap = uTickMBNext - m_uMediumSizeMax; 216 529 m_iSliderScale = (int)((uTickMBNext - uTickMB) / uGap); 217 530 } 218 531 m_iSliderScale = qMax(m_iSliderScale, 8); 219 532 220 /* Setup size-editor field */533 /* Setup size-editor field: */ 221 534 m_pSizeEditor->setFixedWidthByText("88888.88 MB"); 222 535 m_pSizeEditor->setAlignment(Qt::AlignRight); 223 536 m_pSizeEditor->setValidator(new QRegExpValidator(QRegExp(vboxGlobal().sizeRegexp()), this)); 224 537 225 /* Setup size-slider */538 /* Setup size-slider: */ 226 539 m_pSizeSlider->setFocusPolicy(Qt::StrongFocus); 227 540 m_pSizeSlider->setPageStep(m_iSliderScale); 228 541 m_pSizeSlider->setSingleStep(m_iSliderScale / 8); 229 542 m_pSizeSlider->setTickInterval(0); 230 m_pSizeSlider->setMinimum(sizeMBToSlider(m_uMinVDISize, m_iSliderScale)); 231 m_pSizeSlider->setMaximum(sizeMBToSlider(m_uMaxVDISize, m_iSliderScale)); 232 m_pSizeMin->setText(vboxGlobal().formatSize(m_uMinVDISize)); 233 m_pSizeMax->setText(vboxGlobal().formatSize(m_uMaxVDISize)); 234 235 /* Attach button icon */ 236 m_pLocationSelector->setIcon(UIIconPool::iconSet(":/select_file_16px.png", 237 "select_file_dis_16px.png")); 238 239 /* Setup page connections */ 240 connect(m_pLocationEditor, SIGNAL(textChanged(const QString &)), this, SLOT(onLocationEditorTextChanged(const QString &))); 241 connect(m_pLocationSelector, SIGNAL(clicked()), this, SLOT(onSelectLocationButtonClicked())); 242 connect(m_pSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(onSizeSliderValueChanged(int))); 243 connect(m_pSizeEditor, SIGNAL(textChanged(const QString &)), this, SLOT(onSizeEditorTextChanged(const QString &))); 244 } 245 246 void UINewHDWzdPage3::retranslateUi() 247 { 248 /* Translate uic generated strings */ 249 Ui::UINewHDWzdPage3::retranslateUi(this); 250 251 /* Wizard page 3 title */ 252 setTitle(tr("Virtual Disk Location and Size")); 253 } 254 255 void UINewHDWzdPage3::initializePage() 256 { 257 /* Fill and translate */ 543 m_pSizeSlider->setMinimum(sizeMBToSlider(m_uMediumSizeMin, m_iSliderScale)); 544 m_pSizeSlider->setMaximum(sizeMBToSlider(m_uMediumSizeMax, m_iSliderScale)); 545 m_pSizeMin->setText(vboxGlobal().formatSize(m_uMediumSizeMin)); 546 m_pSizeMax->setText(vboxGlobal().formatSize(m_uMediumSizeMax)); 547 548 /* Attach button icon: */ 549 m_pLocationSelector->setIcon(UIIconPool::iconSet(":/select_file_16px.png", "select_file_dis_16px.png")); 550 551 /* Setup page connections: */ 552 connect(m_pLocationEditor, SIGNAL(textChanged(const QString &)), this, SLOT(sltLocationEditorTextChanged(const QString &))); 553 connect(m_pLocationSelector, SIGNAL(clicked()), this, SLOT(sltSelectLocationButtonClicked())); 554 connect(m_pSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(sltSizeSliderValueChanged(int))); 555 connect(m_pSizeEditor, SIGNAL(textChanged(const QString &)), this, SLOT(sltSizeEditorTextChanged(const QString &))); 556 } 557 558 void UINewHDWizardPageOptions::retranslateUi() 559 { 560 /* Translate uic generated strings: */ 561 Ui::UINewHDWizardPageOptions::retranslateUi(this); 562 563 /* Set 'options' page title: */ 564 setTitle(tr("Virtual disk file location and size")); 565 } 566 567 void UINewHDWizardPageOptions::initializePage() 568 { 569 /* Retranslate page: */ 258 570 retranslateUi(); 259 571 260 /* Initialise location */ 261 m_pLocationEditor->setText(m_strInitialName); 262 263 /* Initialise size */ 264 m_pSizeSlider->setValue(sizeMBToSlider(m_uInitialSize, m_iSliderScale)); 265 266 /* 'Size' editor should have focus initially */ 572 /* Initialize name: */ 573 m_pLocationEditor->setText(m_strMediumName); 574 /* Initialize size: */ 575 m_pSizeSlider->setValue(sizeMBToSlider(m_uMediumSize, m_iSliderScale)); 576 /* 'Size' editor should have focus initially: */ 267 577 m_pSizeEditor->setFocus(); 268 } 269 270 void UINewHDWzdPage3::cleanupPage() 271 { 272 /* Do not call superclass method! */ 273 } 274 275 bool UINewHDWzdPage3::isComplete() const 276 { 277 /* Check what 'currentSize' field value feats the bounds & 278 * what 'currentName' field text is not empty! */ 279 return field("currentSize").toULongLong() >= m_uMinVDISize && 280 field("currentSize").toULongLong() <= m_uMaxVDISize && 281 !field("currentName").toString().trimmed().isEmpty(); 282 } 283 284 bool UINewHDWzdPage3::validatePage() 285 { 286 QString location = qobject_cast<UINewHDWzd*>(wizard())->absoluteFilePath(m_strLocation); 287 if (QFileInfo(location).exists()) 288 { 289 vboxProblem().sayCannotOverwriteHardDiskStorage(this, location); 578 /* Get default extension: */ 579 m_strDefaultExtension = defaultExtension(field("mediumFormat").value<CMediumFormat>()); 580 m_strMediumPath = absoluteFilePath(toFileName(m_strMediumName, m_strDefaultExtension), m_strDefaultPath); 581 } 582 583 void UINewHDWizardPageOptions::cleanupPage() 584 { 585 /* Reset widgets: */ 586 m_pLocationEditor->clear(); 587 m_pSizeSlider->setValue(0); 588 /* Call for base-class: */ 589 UINewHDWizardPage::cleanupPage(); 590 } 591 592 bool UINewHDWizardPageOptions::isComplete() const 593 { 594 /* Check what current size feats the bounds & current name is not empty! */ 595 return m_uMediumSize >= m_uMediumSizeMin && m_uMediumSize <= m_uMediumSizeMax && 596 !m_strMediumName.trimmed().isEmpty(); 597 } 598 599 bool UINewHDWizardPageOptions::validatePage() 600 { 601 if (QFileInfo(m_strMediumPath).exists()) 602 { 603 vboxProblem().sayCannotOverwriteHardDiskStorage(this, m_strMediumPath); 290 604 return false; 291 605 } … … 293 607 } 294 608 295 void UINewHDWzdPage3::onLocationEditorTextChanged(const QString &strText) 296 { 297 /* Set current name */ 298 m_strCurrentName = strText; 299 300 /* Set current fileName */ 301 m_strLocation = toFileName(strText); 609 void UINewHDWizardPageOptions::sltLocationEditorTextChanged(const QString &strText) 610 { 611 /* Set current medium name: */ 612 m_strMediumName = strText; 613 /* Set current medium path: */ 614 m_strMediumPath = absoluteFilePath(toFileName(m_strMediumName, m_strDefaultExtension), m_strDefaultPath); 302 615 303 616 /* Notify wizard sub-system about complete status changed: */ … … 305 618 } 306 619 307 void UINewHDWzdPage3::onSelectLocationButtonClicked() 308 { 309 /* Get parent wizard: */ 310 UINewHDWzd *pWizard = qobject_cast<UINewHDWzd*>(wizard()); 311 620 void UINewHDWizardPageOptions::sltSelectLocationButtonClicked() 621 { 312 622 /* Get current folder and filename: */ 313 QFileInfo fullFilePath( pWizard->absoluteFilePath(m_strLocation));623 QFileInfo fullFilePath(m_strMediumPath); 314 624 QDir folder = fullFilePath.path(); 315 625 QString strFileName = fullFilePath.fileName(); 316 626 317 /* Set the first parent fol er that exists as the current: */627 /* Set the first parent folder that exists as the current: */ 318 628 while (!folder.exists() && !folder.isRoot()) 319 folder = QFileInfo(folder.absolutePath()).dir(); 629 { 630 QFileInfo folderInfo(folder.absolutePath()); 631 if (folder == QDir(folderInfo.absolutePath())) 632 break; 633 folder = folderInfo.absolutePath(); 634 } 320 635 321 636 /* But if it doesn't exists at all: */ … … 323 638 { 324 639 /* Use recommended one folder: */ 325 QFileInfo defaultFilePath( pWizard->absoluteFilePath(strFileName));640 QFileInfo defaultFilePath(absoluteFilePath(strFileName, m_strDefaultPath)); 326 641 folder = defaultFilePath.path(); 327 642 } 328 643 329 QString selected = QFileDialog::getSaveFileName(this, tr("Select a file for the new hard disk image file"), 330 folder.absoluteFilePath(strFileName), tr("Hard disk images (*.vdi)")); 331 332 if (!selected.isEmpty()) 333 { 334 if (QFileInfo(selected).completeSuffix().isEmpty()) 335 selected += ".vdi"; 336 m_pLocationEditor->setText(QDir::toNativeSeparators(selected)); 644 /* Prepare backends list: */ 645 CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>(); 646 QVector<QString> fileExtensions; 647 QVector<KDeviceType> deviceTypes; 648 mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes); 649 QStringList validExtensionList; 650 for (int i = 0; i < fileExtensions.size(); ++i) 651 if (deviceTypes[i] == KDeviceType_HardDisk) 652 validExtensionList << QString("*.%1").arg(fileExtensions[i]); 653 /* Compose full filter list: */ 654 QString strBackendsList = QString("%1 (%2)").arg(mediumFormat.GetName()).arg(validExtensionList.join(" ")); 655 656 /* Open corresponding file-dialog: */ 657 QString strChosenFilePath = QIFileDialog::getSaveFileName(folder.absoluteFilePath(strFileName), 658 strBackendsList, this, 659 tr("Select a file for the new hard disk image file")); 660 661 /* If there was something really chosen: */ 662 if (!strChosenFilePath.isEmpty()) 663 { 664 /* If valid file extension is missed, append it: */ 665 if (QFileInfo(strChosenFilePath).completeSuffix().isEmpty()) 666 strChosenFilePath += QString(".%1").arg(m_strDefaultExtension); 667 m_pLocationEditor->setText(QDir::toNativeSeparators(strChosenFilePath)); 337 668 m_pLocationEditor->selectAll(); 338 669 m_pLocationEditor->setFocus(); … … 340 671 } 341 672 342 void UINewHDW zdPage3::onSizeSliderValueChanged(int iValue)673 void UINewHDWizardPageOptions::sltSizeSliderValueChanged(int iValue) 343 674 { 344 675 /* Update currently stored size: */ 345 m_u CurrentSize = sliderToSizeMB(iValue, m_iSliderScale);676 m_uMediumSize = sliderToSizeMB(iValue, m_iSliderScale); 346 677 /* Update tooltip: */ 347 updateSizeToolTip(m_u CurrentSize);678 updateSizeToolTip(m_uMediumSize); 348 679 /* Notify size-editor about size had changed preventing callback: */ 349 680 m_pSizeEditor->blockSignals(true); 350 m_pSizeEditor->setText(vboxGlobal().formatSize(m_u CurrentSize));681 m_pSizeEditor->setText(vboxGlobal().formatSize(m_uMediumSize)); 351 682 m_pSizeEditor->blockSignals(false); 683 352 684 /* Notify wizard sub-system about complete status changed: */ 353 685 emit completeChanged(); 354 686 } 355 687 356 void UINewHDW zdPage3::onSizeEditorTextChanged(const QString &strValue)688 void UINewHDWizardPageOptions::sltSizeEditorTextChanged(const QString &strValue) 357 689 { 358 690 /* Update currently stored size: */ 359 m_u CurrentSize = vboxGlobal().parseSize(strValue);691 m_uMediumSize = vboxGlobal().parseSize(strValue); 360 692 /* Update tooltip: */ 361 updateSizeToolTip(m_u CurrentSize);693 updateSizeToolTip(m_uMediumSize); 362 694 /* Notify size-slider about size had changed preventing callback: */ 363 695 m_pSizeSlider->blockSignals(true); 364 m_pSizeSlider->setValue(sizeMBToSlider(m_u CurrentSize, m_iSliderScale));696 m_pSizeSlider->setValue(sizeMBToSlider(m_uMediumSize, m_iSliderScale)); 365 697 m_pSizeSlider->blockSignals(false); 698 366 699 /* Notify wizard sub-system about complete status changed: */ 367 700 emit completeChanged(); 368 701 } 369 702 370 QString UINewHDWzdPage3::toFileName(const QString &strName) 371 { 372 QString fileName = QDir::toNativeSeparators(strName); 373 374 /* Remove all trailing dots to avoid multiple dots before .vdi */ 375 int len; 376 while (len = fileName.length(), len > 0 && fileName [len - 1] == '.') 377 fileName.truncate(len - 1); 378 379 QString ext = QFileInfo(fileName).completeSuffix(); 380 381 if (RTPathCompare(ext.toUtf8(), "vdi") != 0) 382 fileName += ".vdi"; 383 384 return fileName; 385 } 386 387 int UINewHDWzdPage3::log2i(qulonglong uValue) 703 /* static */ 704 QString UINewHDWizardPageOptions::absoluteFilePath(const QString &strFileName, const QString &strDefaultPath) 705 { 706 /* Wrap file-info around received file name: */ 707 QFileInfo fileInfo(strFileName); 708 /* If path-info is relative or there is no path-info at all: */ 709 if (fileInfo.fileName() == strFileName || fileInfo.isRelative()) 710 { 711 /* Resolve path on the basis of default path we have: */ 712 fileInfo = QFileInfo(strDefaultPath, strFileName); 713 } 714 /* Return full absolute hard disk file path: */ 715 return QDir::toNativeSeparators(fileInfo.absoluteFilePath()); 716 } 717 718 /* static */ 719 QString UINewHDWizardPageOptions::toFileName(const QString &strName, const QString &strExtension) 720 { 721 /* Convert passed name to native separators (it can be full, actually): */ 722 QString strFileName = QDir::toNativeSeparators(strName); 723 724 /* Remove all trailing dots to avoid multiple dots before extension: */ 725 int iLen; 726 while (iLen = strFileName.length(), iLen > 0 && strFileName[iLen - 1] == '.') 727 strFileName.truncate(iLen - 1); 728 729 /* Add passed extension if its not done yet: */ 730 if (QFileInfo(strFileName).completeSuffix().toLower() != strExtension) 731 strFileName += QString(".%1").arg(strExtension); 732 733 /* Return result: */ 734 return strFileName; 735 } 736 737 /* static */ 738 QString UINewHDWizardPageOptions::defaultExtension(CMediumFormat mediumFormat) 739 { 740 /* Load extension / device list: */ 741 QVector<QString> fileExtensions; 742 QVector<KDeviceType> deviceTypes; 743 mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes); 744 for (int i = 0; i < fileExtensions.size(); ++i) 745 if (deviceTypes[i] == KDeviceType_HardDisk) 746 return fileExtensions[i].toLower(); 747 AssertMsgFailed(("Extension can't be NULL!\n")); 748 return QString(); 749 } 750 751 /* static */ 752 int UINewHDWizardPageOptions::log2i(qulonglong uValue) 388 753 { 389 754 int iPower = -1; 390 755 while (uValue) 391 756 { 392 ++ 757 ++iPower; 393 758 uValue >>= 1; 394 759 } … … 396 761 } 397 762 398 int UINewHDWzdPage3::sizeMBToSlider(qulonglong uValue, int iSliderScale) 763 /* static */ 764 int UINewHDWizardPageOptions::sizeMBToSlider(qulonglong uValue, int iSliderScale) 399 765 { 400 766 int iPower = log2i(uValue); … … 405 771 } 406 772 407 qulonglong UINewHDWzdPage3::sliderToSizeMB(int uValue, int iSliderScale) 773 /* static */ 774 qulonglong UINewHDWizardPageOptions::sliderToSizeMB(int uValue, int iSliderScale) 408 775 { 409 776 int iPower = uValue / iSliderScale; … … 414 781 } 415 782 416 void UINewHDW zdPage3::updateSizeToolTip(qulonglong uSize)783 void UINewHDWizardPageOptions::updateSizeToolTip(qulonglong uSize) 417 784 { 418 785 QString strToolTip = tr("<nobr>%1 (%2 B)</nobr>").arg(vboxGlobal().formatSize(uSize)).arg(uSize); … … 421 788 } 422 789 423 UINewHDW zdPage4::UINewHDWzdPage4()424 { 425 /* Decorate page */426 Ui::UINewHDW zdPage4::setupUi(this);427 428 /* Register CMedium class */790 UINewHDWizardPageSummary::UINewHDWizardPageSummary() 791 { 792 /* Decorate page: */ 793 Ui::UINewHDWizardPageSummary::setupUi(this); 794 795 /* Register CMedium class: */ 429 796 qRegisterMetaType<CMedium>(); 430 797 431 /* Register 'hardDisk' field */798 /* Register 'hardDisk' field: */ 432 799 registerField("hardDisk", this, "hardDisk"); 433 800 434 /* Disable the background painting of the summary widget */ 435 m_pSummaryText->viewport()->setAutoFillBackground (false); 436 /* Make the summary field read-only */ 437 m_pSummaryText->setReadOnly (true); 438 } 439 440 void UINewHDWzdPage4::retranslateUi() 441 { 442 /* Translate uic generated strings */ 443 Ui::UINewHDWzdPage4::retranslateUi(this); 444 445 /* Wizard page 4 title */ 801 /* Disable the background painting of the summary widget: */ 802 m_pSummaryText->viewport()->setAutoFillBackground(false); 803 } 804 805 void UINewHDWizardPageSummary::retranslateUi() 806 { 807 /* Translate uic generated strings: */ 808 Ui::UINewHDWizardPageSummary::retranslateUi(this); 809 810 /* Set 'summary' page title: */ 446 811 setTitle(tr("Summary")); 447 812 448 /* Compose common summary */ 449 QString summary; 450 451 QString type = field("type").toString(); 452 QString location = qobject_cast<UINewHDWzd*>(wizard())->absoluteFilePath(field("location").toString()); 453 QString sizeFormatted = VBoxGlobal::formatSize(field("currentSize").toULongLong()); 454 QString sizeUnformatted = tr("%1 B").arg(field("currentSize").toULongLong()); 455 456 summary += QString 813 /* Compose common summary: */ 814 QString strSummary; 815 816 CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>(); 817 qulonglong uVariant = field("mediumVariant").toULongLong(); 818 QString strMediumPath = field("mediumPath").toString(); 819 QString sizeFormatted = VBoxGlobal::formatSize(field("mediumSize").toULongLong()); 820 QString sizeUnformatted = tr("%1 B").arg(field("mediumSize").toULongLong()); 821 822 strSummary += QString 457 823 ( 458 824 "<tr><td><nobr>%1: </nobr></td><td><nobr>%2</nobr></td></tr>" 459 825 "<tr><td><nobr>%3: </nobr></td><td><nobr>%4</nobr></td></tr>" 460 "<tr><td><nobr>%5: </nobr></td><td><nobr>%6 (%7)</nobr></td></tr>" 826 "<tr><td><nobr>%5: </nobr></td><td><nobr>%6</nobr></td></tr>" 827 "<tr><td><nobr>%7: </nobr></td><td><nobr>%8 (%9)</nobr></td></tr>" 461 828 ) 462 .arg (tr("Type", "summary"), type) 463 .arg (tr("Location", "summary"), location) 464 .arg (tr("Size", "summary"), sizeFormatted, sizeUnformatted) 465 ; 466 /* Feat summary to 3 lines */ 467 setSummaryFieldLinesNumber(m_pSummaryText, 3); 468 469 m_pSummaryText->setText("<table cellspacing=0 cellpadding=0>" + summary + "</table>"); 470 471 m_pPage4Text2->setText(tr("If the above settings are correct, press the <b>%1</b> button. " 472 "Once you press it, a new hard disk will be created.") 473 .arg(VBoxGlobal::replaceHtmlEntities(VBoxGlobal::removeAccelMark(wizard()->buttonText(QWizard::FinishButton))))); 474 } 475 476 void UINewHDWzdPage4::initializePage() 477 { 478 /* Fill and translate */ 829 .arg(tr("File type", "summary"), mediumFormat.isNull() ? QString() : VBoxGlobal::removeAccelMark(UINewHDWizardPageFormat::fullFormatName(mediumFormat.GetName()))) 830 .arg(tr("Details", "summary"), UINewHDWizardPageVariant::variantToString(uVariant)) 831 .arg(tr("Location", "summary"), strMediumPath) 832 .arg(tr("Size", "summary"), sizeFormatted, sizeUnformatted); 833 834 /* Feat summary to 4 lines: */ 835 setSummaryFieldLinesNumber(m_pSummaryText, 4); 836 837 m_pSummaryText->setText("<table cellspacing=0 cellpadding=0>" + strSummary + "</table>"); 838 839 m_pLabel2->setText(tr("If the above settings are correct, press the <b>%1</b> button. " 840 "Once you press it a new virtual disk file will be created.") 841 .arg(VBoxGlobal::replaceHtmlEntities(VBoxGlobal::removeAccelMark(wizard()->buttonText(QWizard::FinishButton))))); 842 } 843 844 void UINewHDWizardPageSummary::initializePage() 845 { 846 /* Retranslate page: */ 479 847 retranslateUi(); 480 848 481 /* Summary should have focus initially */849 /* Summary should have focus initially: */ 482 850 m_pSummaryText->setFocus(); 483 851 } 484 852 485 bool UINewHDWzdPage4::validatePage() 486 { 853 bool UINewHDWizardPageSummary::validatePage() 854 { 855 /* Start performing long-time operation: */ 487 856 startProcessing(); 488 /* Try to construct hard disk */857 /* Try to construct hard disk: */ 489 858 bool fResult = createHardDisk(); 859 /* Finish performing long-time operation: */ 490 860 endProcessing(); 861 /* Return operation result: */ 491 862 return fResult; 492 863 } 493 864 494 bool UINewHDWzdPage4::createHardDisk() 495 { 496 KMediumVariant variant = KMediumVariant_Standard; 497 QString location = qobject_cast<UINewHDWzd*>(wizard())->absoluteFilePath(field("location").toString()); 498 qulonglong size = field("currentSize").toULongLong(); 499 bool isFixed = field("fixed").toBool(); 500 501 AssertReturn(!location.isNull(), false); 502 AssertReturn(size > 0, false); 865 bool UINewHDWizardPageSummary::createHardDisk() 866 { 867 /* Gather attributes: */ 868 CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>(); 869 qulonglong uVariant = field("mediumVariant").toULongLong(); 870 QString strMediumPath = field("mediumPath").toString(); 871 qulonglong uSize = field("mediumSize").toULongLong(); 872 873 AssertReturn(!strMediumPath.isNull(), false); 874 AssertReturn(uSize > 0, false); 503 875 504 876 CVirtualBox vbox = vboxGlobal().virtualBox(); … … 506 878 CProgress progress; 507 879 508 CMedium hardDisk = vbox.CreateHardDisk( QString("VDI"), location);880 CMedium hardDisk = vbox.CreateHardDisk(mediumFormat.GetName(), strMediumPath); 509 881 510 882 if (!vbox.isOk()) 511 883 { 512 vboxProblem().cannotCreateHardDiskStorage(this, vbox, location, hardDisk, progress);884 vboxProblem().cannotCreateHardDiskStorage(this, vbox, strMediumPath, hardDisk, progress); 513 885 return false; 514 886 } 515 887 516 if (isFixed) 517 variant = (KMediumVariant)(KMediumVariant_Standard | KMediumVariant_Fixed); 518 519 progress = hardDisk.CreateBaseStorage(size, variant); 888 progress = hardDisk.CreateBaseStorage(uSize, uVariant); 520 889 521 890 if (!hardDisk.isOk()) 522 891 { 523 vboxProblem().cannotCreateHardDiskStorage(this, vbox, location, hardDisk, progress);892 vboxProblem().cannotCreateHardDiskStorage(this, vbox, strMediumPath, hardDisk, progress); 524 893 return false; 525 894 } … … 532 901 if (!progress.isOk() || progress.GetResultCode() != 0) 533 902 { 534 vboxProblem().cannotCreateHardDiskStorage(this, vbox, location, hardDisk, progress);903 vboxProblem().cannotCreateHardDiskStorage(this, vbox, strMediumPath, hardDisk, progress); 535 904 return false; 536 905 } 537 906 538 /* Inform everybody there is a new medium */907 /* Inform everybody there is a new medium: */ 539 908 vboxGlobal().addMedium(VBoxMedium(CMedium(hardDisk), VBoxDefs::MediumType_HardDisk, KMediumState_Created)); 540 909 … … 543 912 } 544 913 914 #include "UINewHDWizard.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizard.h
r37181 r37331 2 2 * 3 3 * VBox frontends: Qt4 GUI ("VirtualBox"): 4 * UINewHDW zd class declaration4 * UINewHDWizard class declaration 5 5 */ 6 6 7 7 /* 8 * Copyright (C) 2006-201 0Oracle Corporation8 * Copyright (C) 2006-2011 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 17 */ 18 18 19 #ifndef __UINewHDW zd_h__20 #define __UINewHDW zd_h__21 22 /* Local includes */19 #ifndef __UINewHDWizard_h__ 20 #define __UINewHDWizard_h__ 21 22 /* Local includes: */ 23 23 #include "QIWizard.h" 24 24 #include "COMDefs.h" 25 25 26 /* Generated includes */ 27 #include "UINewHDWzdPage1.gen.h" 28 #include "UINewHDWzdPage2.gen.h" 29 #include "UINewHDWzdPage3.gen.h" 30 #include "UINewHDWzdPage4.gen.h" 31 32 class UINewHDWzd : public QIWizard 33 { 34 Q_OBJECT; 35 36 public: 37 38 UINewHDWzd(QWidget *pParent); 39 26 /* Generated includes: */ 27 #include "UINewHDWizardPageWelcome.gen.h" 28 #include "UINewHDWizardPageFormat.gen.h" 29 #include "UINewHDWizardPageVariant.gen.h" 30 #include "UINewHDWizardPageOptions.gen.h" 31 #include "UINewHDWizardPageSummary.gen.h" 32 33 /* Forward declarations: */ 34 class QRadioButton; 35 class QCheckBox; 36 class UIExclusivenessManager; 37 38 /* New hard disk wizard class: */ 39 class UINewHDWizard : public QIWizard 40 { 41 Q_OBJECT; 42 43 public: 44 45 /* Constructor: */ 46 UINewHDWizard(QWidget *pParent, const QString &strDefaultName = QString(), const QString &strDefaultPath = QString(), qulonglong uDefaultSize = 0); 47 48 /* Returns created hard disk: */ 40 49 CMedium hardDisk() const; 41 50 42 void setRecommendedName(const QString &strName); 43 void setRecommendedSize(qulonglong uSize); 44 45 void setDefaultPath(const QString &strPath); 46 QString absoluteFilePath(const QString &strFileName); 51 private: 52 53 /* Translation stuff: */ 54 void retranslateUi(); 55 }; 56 57 /* Base wrapper for the wizard page 58 * of the new hard disk wizard class: */ 59 class UINewHDWizardPage : public QIWizardPage 60 { 61 Q_OBJECT; 62 63 public: 64 65 /* Constructor: */ 66 UINewHDWizardPage() {} 47 67 48 68 protected: 49 69 50 void retranslateUi(); 51 52 private: 53 54 QString m_strDefaultPath; 55 }; 56 57 class UINewHDWzdPage1 : public QIWizardPage, public Ui::UINewHDWzdPage1 58 { 59 Q_OBJECT; 60 61 public: 62 63 UINewHDWzdPage1(); 70 /* Returns parent wizard object: */ 71 UINewHDWizard* wizard() { return qobject_cast<UINewHDWizard*>(QIWizardPage::wizard()); } 72 }; 73 74 /* Welcome page of the new hard-disk wizard: */ 75 class UINewHDWizardPageWelcome : public UINewHDWizardPage, public Ui::UINewHDWizardPageWelcome 76 { 77 Q_OBJECT; 78 79 public: 80 81 /* Constructor: */ 82 UINewHDWizardPageWelcome(); 83 84 private: 85 86 /* Translation stuff: */ 87 void retranslateUi(); 88 89 /* Prepare page: */ 90 void initializePage(); 91 }; 92 93 /* Format page of the new hard-disk wizard: */ 94 class UINewHDWizardPageFormat : public UINewHDWizardPage, public Ui::UINewHDWizardPageFormat 95 { 96 Q_OBJECT; 97 Q_PROPERTY(CMediumFormat mediumFormat READ mediumFormat WRITE setMediumFormat); 98 99 public: 100 101 /* Constructor: */ 102 UINewHDWizardPageFormat(); 103 104 /* Returns full medium format name: */ 105 static QString fullFormatName(const QString &strBaseFormatName); 106 107 private slots: 108 109 /* Handler for the 'format'-change signal: */ 110 void sltUpdateFormat(QVariant formatData); 111 112 private: 113 114 /* Translation stuff: */ 115 void retranslateUi(); 116 117 /* Prepare page: */ 118 void initializePage(); 119 /* Cleanup page: */ 120 void cleanupPage(); 121 122 /* Completeness validator: */ 123 bool isComplete() const; 124 125 /* Exclusiveness manager: */ 126 UIExclusivenessManager *m_pExclusivenessManager; 127 128 /* Defaut format (VDI) button: */ 129 QRadioButton *m_pDefaultButton; 130 131 /* Stuff for 'mediumFormat' field: */ 132 CMediumFormat mediumFormat() const { return m_mediumFormat; } 133 void setMediumFormat(const CMediumFormat &mediumFormat) { m_mediumFormat = mediumFormat; } 134 CMediumFormat m_mediumFormat; 135 }; 136 137 /* Variant page of the new hard-disk wizard: */ 138 class UINewHDWizardPageVariant : public UINewHDWizardPage, public Ui::UINewHDWizardPageVariant 139 { 140 Q_OBJECT; 141 Q_PROPERTY(qulonglong mediumVariant READ mediumVariant WRITE setMediumVariant); 142 143 public: 144 145 /* Constructor: */ 146 UINewHDWizardPageVariant(); 147 148 /* Returns the name of passed medium variant: */ 149 static QString variantToString(qulonglong uMediumVariant); 150 151 private slots: 152 153 /* Handler for the 'variant'-change signal: */ 154 void sltUpdateVariant(QVariant exclusiveData, QList<QVariant> optionsData); 155 156 private: 157 158 /* Translation stuff: */ 159 void retranslateUi(); 160 161 /* Prepare page: */ 162 void initializePage(); 163 /* Cleanup page: */ 164 void cleanupPage(); 165 166 /* Completeness validator: */ 167 bool isComplete() const; 168 169 /* Exclusiveness manager: */ 170 UIExclusivenessManager *m_pExclusivenessManager; 171 172 /* Defaut variant (dynamic) button: */ 173 QRadioButton *m_pDynamicalButton; 174 QRadioButton *m_pFixedButton; 175 QCheckBox *m_pSplitBox; 176 177 /* Stuff for 'variant' field: */ 178 qulonglong mediumVariant() const { return m_uMediumVariant; } 179 void setMediumVariant(qulonglong uMediumVariant) { m_uMediumVariant = uMediumVariant; } 180 qulonglong m_uMediumVariant; 181 }; 182 183 /* Options page of the new hard-disk wizard: */ 184 class UINewHDWizardPageOptions : public UINewHDWizardPage, public Ui::UINewHDWizardPageOptions 185 { 186 Q_OBJECT; 187 Q_PROPERTY(QString mediumName READ mediumName WRITE setMediumName); 188 Q_PROPERTY(QString mediumPath READ mediumPath WRITE setMediumPath); 189 Q_PROPERTY(qulonglong mediumSize READ mediumSize WRITE setMediumSize); 190 191 public: 192 193 /* Constructor: */ 194 UINewHDWizardPageOptions(const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize); 64 195 65 196 protected: 66 197 67 void retranslateUi(); 68 69 void initializePage(); 70 }; 71 72 class UINewHDWzdPage2 : public QIWizardPage, public Ui::UINewHDWzdPage2 73 { 74 Q_OBJECT; 75 Q_PROPERTY(QString type READ type WRITE setType); 76 Q_PROPERTY(bool fixed READ fixed WRITE setFixed); 77 78 public: 79 80 UINewHDWzdPage2(); 81 82 protected: 83 84 void retranslateUi(); 85 86 void initializePage(); 198 /* Translation stuff: */ 199 void retranslateUi(); 200 201 /* Prepare page: */ 202 void initializePage(); 203 /* Cleanup page: */ 204 void cleanupPage(); 205 206 /* Completeness validator: */ 207 bool isComplete() const; 208 /* Completeness finisher: */ 209 bool validatePage(); 87 210 88 211 private slots: 89 212 90 void onTypeChanged(); 91 92 private: 93 94 QString type() const { return m_strType; } 95 void setType(const QString &strType) { m_strType = strType; } 96 QString m_strType; 97 98 bool fixed() const { return m_bFixed; } 99 void setFixed(bool bFixed) { m_bFixed = bFixed; } 100 bool m_bFixed; 101 }; 102 103 class UINewHDWzdPage3 : public QIWizardPage, public Ui::UINewHDWzdPage3 104 { 105 Q_OBJECT; 106 Q_PROPERTY(QString initialName READ initialName WRITE setInitialName); 107 Q_PROPERTY(QString currentName READ currentName WRITE setCurrentName); 108 Q_PROPERTY(QString location READ location WRITE setLocation); 109 Q_PROPERTY(qulonglong initialSize READ initialSize WRITE setInitialSize); 110 Q_PROPERTY(qulonglong currentSize READ currentSize WRITE setCurrentSize); 111 112 public: 113 114 UINewHDWzdPage3(); 115 116 protected: 117 118 void retranslateUi(); 119 120 void initializePage(); 121 void cleanupPage(); 122 123 bool isComplete() const; 124 bool validatePage(); 125 126 private slots: 127 128 void onLocationEditorTextChanged(const QString &strName); 129 void onSelectLocationButtonClicked(); 130 131 void onSizeSliderValueChanged(int iValue); 132 void onSizeEditorTextChanged(const QString &strValue); 133 134 private: 135 136 static QString toFileName(const QString &strName); 137 213 /* Location editors stuff: */ 214 void sltLocationEditorTextChanged(const QString &strName); 215 void sltSelectLocationButtonClicked(); 216 217 /* Size editors stuff: */ 218 void sltSizeSliderValueChanged(int iValue); 219 void sltSizeEditorTextChanged(const QString &strValue); 220 221 private: 222 223 /* Returns 'file name' for the passed 'name': */ 224 static QString toFileName(const QString &strName, const QString &strExtension); 225 /* Returns 'absolute file path' for the passed 'file name': */ 226 static QString absoluteFilePath(const QString &strFileName, const QString &strDefaultPath); 227 /* Returns default extension for the passed medium format: */ 228 static QString defaultExtension(CMediumFormat mediumFormat); 229 230 /* Size editors stuff: */ 138 231 static int log2i(qulonglong uValue); 139 232 static int sizeMBToSlider(qulonglong uValue, int iSliderScale); 140 233 static qulonglong sliderToSizeMB(int uValue, int iSliderScale); 141 142 234 void updateSizeToolTip(qulonglong uSize); 143 235 144 QString initialName() const { return m_strInitialName; } 145 void setInitialName(const QString &strInitialName) { m_strInitialName = strInitialName; } 146 QString m_strInitialName; 147 148 QString currentName() const { return m_strCurrentName; } 149 void setCurrentName(const QString &strCurrentName) { m_strCurrentName = strCurrentName; } 150 QString m_strCurrentName; 151 152 QString location() const { return m_strLocation; } 153 void setLocation(const QString &strLocation) { m_strLocation = strLocation; } 154 QString m_strLocation; 155 156 qulonglong initialSize() const { return m_uInitialSize; } 157 void setInitialSize(qulonglong uInitialSize) { m_uInitialSize = uInitialSize; } 158 qulonglong m_uInitialSize; 159 160 qulonglong currentSize() const { return m_uCurrentSize; } 161 void setCurrentSize(qulonglong uCurrentSize) { m_uCurrentSize = uCurrentSize; } 162 qulonglong m_uCurrentSize; 163 164 qulonglong m_uMinVDISize; 165 qulonglong m_uMaxVDISize; 236 /* The default extension for the hard disk file: */ 237 QString m_strDefaultExtension; 238 239 /* The default path for the hard disk file: */ 240 QString m_strDefaultPath; 241 242 /* Stuff for 'mediumName' field: */ 243 QString mediumName() const { return m_strMediumName; } 244 void setMediumName(const QString &strMediumName) { m_strMediumName = strMediumName; } 245 QString m_strMediumName; 246 247 /* Stuff for 'mediumPath' field: */ 248 QString mediumPath() const { return m_strMediumPath; } 249 void setMediumPath(const QString &strMediumPath) { m_strMediumPath = strMediumPath; } 250 QString m_strMediumPath; 251 252 /* Stuff for 'mediumSize' field: */ 253 qulonglong mediumSize() const { return m_uMediumSize; } 254 void setMediumSize(qulonglong uMediumSize) { m_uMediumSize = uMediumSize; } 255 qulonglong m_uMediumSize; 256 257 /* Other size editors stuff: */ 258 qulonglong m_uMediumSizeMin; 259 qulonglong m_uMediumSizeMax; 166 260 int m_iSliderScale; 167 261 }; 168 262 169 class UINewHDWzdPage4 : public QIWizardPage, public Ui::UINewHDWzdPage4 263 /* Summary page of the new hard-disk wizard: */ 264 class UINewHDWizardPageSummary : public UINewHDWizardPage, public Ui::UINewHDWizardPageSummary 170 265 { 171 266 Q_OBJECT; … … 174 269 public: 175 270 176 UINewHDWzdPage4(); 271 /* Constructor: */ 272 UINewHDWizardPageSummary(); 177 273 178 274 protected: 179 275 180 void retranslateUi(); 181 182 void initializePage(); 183 276 /* Translation stuff: */ 277 void retranslateUi(); 278 279 /* Prepare page: */ 280 void initializePage(); 281 282 /* Completeness finisher: */ 184 283 bool validatePage(); 185 284 186 285 private: 187 286 287 /* Creates hard disk: */ 188 288 bool createHardDisk(); 189 289 290 /* Stuff for 'hardDisk' field: */ 190 291 CMedium hardDisk() const { return m_HardDisk; } 191 292 void setHardDisk(const CMedium &hardDisk) { m_HardDisk = hardDisk; } … … 195 296 Q_DECLARE_METATYPE(CMedium); 196 297 197 #endif // __UINewHDW zd_h__198 298 #endif // __UINewHDWizard_h__ 299 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizardPageFormat.ui
r37181 r37331 4 4 VBox frontends: Qt4 GUI ("VirtualBox"): 5 5 6 Copyright (C) 2009-201 0Oracle Corporation6 Copyright (C) 2009-2011 Oracle Corporation 7 7 8 8 This file is part of VirtualBox Open Source Edition (OSE), as … … 14 14 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 15 15 </comment> 16 <class>UINewHDW zdPage2</class>17 <widget class="QWidget" name="UINewHDW zdPage2">16 <class>UINewHDWizardPageFormat</class> 17 <widget class="QWidget" name="UINewHDWizardPageFormat"> 18 18 <property name="geometry"> 19 19 <rect> … … 30 30 </sizepolicy> 31 31 </property> 32 <layout class="QVBoxLayout" name="m_p Layout1">32 <layout class="QVBoxLayout" name="m_pMainLayout"> 33 33 <property name="bottomMargin" > 34 34 <number>0</number> 35 35 </property> 36 36 <item> 37 <widget class="QILabel" name="m_pPage2Text1"> 38 <property name="text"> 39 <string><p>Select the type of virtual hard disk you want to create.</p><p>A <b>dynamically expanding storage</b> initially occupies a very small amount of space on your physical hard disk. It will grow dynamically (up to the size specified) as the Guest OS claims disk space.</p><p>A <b>fixed-size storage</b> does not grow. It is stored in a file of approximately the same size as the size of the virtual hard disk. The creation of a fixed-size storage may take a long time depending on the storage size and the write performance of your harddisk.</p></string> 40 </property> 37 <widget class="QILabel" name="m_pLabel"> 41 38 <property name="wordWrap"> 42 39 <bool>true</bool> 40 </property> 41 <property name="text"> 42 <string><p>Please choose the type of file that you would like to use for the new virtual disk. If you do not need to use this virtual machine with other virtualization software you can leave this setting unchanged.</p></string> 43 43 </property> 44 44 </widget> 45 45 </item> 46 46 <item> 47 <widget class="QGroupBox" name="m_p TypeCnt">47 <widget class="QGroupBox" name="m_pFormatContainer"> 48 48 <property name="title"> 49 <string> Storage Type</string>49 <string>File type</string> 50 50 </property> 51 <layout class="QVBoxLayout" name="m_pLayout2"> 52 <item> 53 <widget class="QRadioButton" name="m_pTypeDynamic"> 54 <property name="text"> 55 <string>&Dynamically expanding storage</string> 56 </property> 57 </widget> 58 </item> 59 <item> 60 <widget class="QRadioButton" name="m_pTypeFixed"> 61 <property name="text"> 62 <string>&Fixed-size storage</string> 63 </property> 64 </widget> 65 </item> 66 </layout> 51 <layout class="QVBoxLayout" name="m_pFormatsLayout"/> 67 52 </widget> 68 53 </item> 69 54 <item> 70 <spacer name="m_pSpacer 1">55 <spacer name="m_pSpacer"> 71 56 <property name="sizeHint" stdset="0"> 72 57 <size> -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizardPageOptions.ui
r37181 r37331 4 4 VBox frontends: Qt4 GUI ("VirtualBox"): 5 5 6 Copyright (C) 2009-201 0Oracle Corporation6 Copyright (C) 2009-2011 Oracle Corporation 7 7 8 8 This file is part of VirtualBox Open Source Edition (OSE), as … … 14 14 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 15 15 </comment> 16 <class>UINewHDW zdPage3</class>17 <widget class="QWidget" name="UINewHDW zdPage3">16 <class>UINewHDWizardPageOptions</class> 17 <widget class="QWidget" name="UINewHDWizardPageOptions"> 18 18 <property name="geometry"> 19 19 <rect> … … 30 30 </sizepolicy> 31 31 </property> 32 <layout class="QVBoxLayout" name="m_p Layout1">32 <layout class="QVBoxLayout" name="m_pMainLayout"> 33 33 <property name="bottomMargin" > 34 34 <number>0</number> 35 35 </property> 36 36 <item> 37 <widget class="QILabel" name="m_pPage3Text1"> 38 <property name="text"> 39 <string><p>Press the <b>Select</b> button to select the location of a file to store the hard disk data or type a file name in the entry field.</p></string> 40 </property> 37 <widget class="QILabel" name="m_pLabel1"> 41 38 <property name="wordWrap"> 42 39 <bool>true</bool> 40 </property> 41 <property name="text"> 42 <string><p>Press the <b>Select</b> button to select the location of a file to store the virtual disk data or type a file name in the entry field.</p></string> 43 43 </property> 44 44 </widget> … … 49 49 <string>&Location</string> 50 50 </property> 51 <layout class="QHBoxLayout" name="m_p Layout2">51 <layout class="QHBoxLayout" name="m_pOptionsLayout"> 52 52 <item> 53 53 <widget class="QLineEdit" name="m_pLocationEditor"/> … … 64 64 </item> 65 65 <item> 66 <widget class="QILabel" name="m_pPage3Text2"> 67 <property name="text"> 68 <string><p>Select the size of the virtual hard disk in megabytes. This size will be reported to the Guest OS as the maximum size of this hard disk.</p></string> 69 </property> 66 <widget class="QILabel" name="m_pLabel2"> 70 67 <property name="wordWrap"> 71 68 <bool>true</bool> 69 </property> 70 <property name="text"> 71 <string><p>Select the size of the virtual disk in megabytes. This size will be reported to the Guest OS as the maximum size of this virtual disk.</p></string> 72 72 </property> 73 73 </widget> … … 78 78 <string>&Size</string> 79 79 </property> 80 <layout class="QGridLayout" name="m_p Layout3">80 <layout class="QGridLayout" name="m_pSizeLayout"> 81 81 <item row="0" column="0" colspan="3"> 82 82 <widget class="QSlider" name="m_pSizeSlider"> … … 116 116 </item> 117 117 <item row="1" column="1"> 118 <spacer name="m_pS pacer1">118 <spacer name="m_pSizeSpacer"> 119 119 <property name="orientation"> 120 120 <enum>Qt::Horizontal</enum> … … 142 142 </item> 143 143 <item> 144 <spacer name="m_pSpacer 2">144 <spacer name="m_pSpacer"> 145 145 <property name="sizeHint" stdset="0"> 146 146 <size> -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizardPageSummary.ui
r37181 r37331 4 4 VBox frontends: Qt4 GUI ("VirtualBox"): 5 5 6 Copyright (C) 2009-201 0Oracle Corporation6 Copyright (C) 2009-2011 Oracle Corporation 7 7 8 8 This file is part of VirtualBox Open Source Edition (OSE), as … … 14 14 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 15 15 </comment> 16 <class>UINewHDW zdPage4</class>17 <widget class="QWidget" name="UINewHDW zdPage4">16 <class>UINewHDWizardPageSummary</class> 17 <widget class="QWidget" name="UINewHDWizardPageSummary"> 18 18 <property name="geometry"> 19 19 <rect> … … 30 30 </sizepolicy> 31 31 </property> 32 <layout class="QVBoxLayout" name="m_p Layout1">32 <layout class="QVBoxLayout" name="m_pMainLayout"> 33 33 <property name="bottomMargin" > 34 34 <number>0</number> 35 35 </property> 36 36 <item> 37 <widget class="QILabel" name="m_pPage4Text1"> 38 <property name="text"> 39 <string>You are going to create a new virtual hard disk with the following parameters:</string> 40 </property> 37 <widget class="QILabel" name="m_pLabel1"> 41 38 <property name="wordWrap"> 42 39 <bool>true</bool> 40 </property> 41 <property name="text"> 42 <string>You are going to create a new virtual disk with the following parameters:</string> 43 43 </property> 44 44 </widget> … … 67 67 </item> 68 68 <item> 69 <widget class="QILabel" name="m_p Page4Text2">69 <widget class="QILabel" name="m_pLabel2"> 70 70 <property name="wordWrap"> 71 71 <bool>true</bool> … … 74 74 </item> 75 75 <item> 76 <spacer name="m_pSpacer 1">76 <spacer name="m_pSpacer"> 77 77 <property name="sizeHint" stdset="0"> 78 78 <size> -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizardPageVariant.ui
r37181 r37331 4 4 VBox frontends: Qt4 GUI ("VirtualBox"): 5 5 6 Copyright (C) 2009-201 0Oracle Corporation6 Copyright (C) 2009-2011 Oracle Corporation 7 7 8 8 This file is part of VirtualBox Open Source Edition (OSE), as … … 14 14 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 15 15 </comment> 16 <class>UINewHDW zdPage2</class>17 <widget class="QWidget" name="UINewHDW zdPage2">16 <class>UINewHDWizardPageVariant</class> 17 <widget class="QWidget" name="UINewHDWizardPageVariant"> 18 18 <property name="geometry"> 19 19 <rect> … … 30 30 </sizepolicy> 31 31 </property> 32 <layout class="QVBoxLayout" name="m_p Layout1">32 <layout class="QVBoxLayout" name="m_pMainLayout"> 33 33 <property name="bottomMargin" > 34 34 <number>0</number> 35 35 </property> 36 36 <item> 37 <widget class="QILabel" name="m_pPage2Text1"> 38 <property name="text"> 39 <string><p>Select the type of virtual hard disk you want to create.</p><p>A <b>dynamically expanding storage</b> initially occupies a very small amount of space on your physical hard disk. It will grow dynamically (up to the size specified) as the Guest OS claims disk space.</p><p>A <b>fixed-size storage</b> does not grow. It is stored in a file of approximately the same size as the size of the virtual hard disk. The creation of a fixed-size storage may take a long time depending on the storage size and the write performance of your harddisk.</p></string> 40 </property> 37 <widget class="QILabel" name="m_pLabel"> 41 38 <property name="wordWrap"> 42 39 <bool>true</bool> 40 </property> 41 <property name="text"> 42 <string><p>Please choose whether the new virtual disk file should expand as it is used or be created fully expanded.</p></string> 43 43 </property> 44 44 </widget> 45 45 </item> 46 46 <item> 47 <widget class="QGroupBox" name="m_p TypeCnt">47 <widget class="QGroupBox" name="m_pVariantContainer"> 48 48 <property name="title"> 49 <string>Storage Type</string>49 <string>Storage details</string> 50 50 </property> 51 <layout class="QVBoxLayout" name="m_pLayout2"> 52 <item> 53 <widget class="QRadioButton" name="m_pTypeDynamic"> 54 <property name="text"> 55 <string>&Dynamically expanding storage</string> 56 </property> 57 </widget> 58 </item> 59 <item> 60 <widget class="QRadioButton" name="m_pTypeFixed"> 61 <property name="text"> 62 <string>&Fixed-size storage</string> 63 </property> 64 </widget> 65 </item> 66 </layout> 51 <layout class="QVBoxLayout" name="m_pVariantsLayout"/> 67 52 </widget> 68 53 </item> 69 54 <item> 70 <spacer name="m_pSpacer 1">55 <spacer name="m_pSpacer"> 71 56 <property name="sizeHint" stdset="0"> 72 57 <size> -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizardPageWelcome.ui
r37181 r37331 4 4 VBox frontends: Qt4 GUI ("VirtualBox"): 5 5 6 Copyright (C) 2009-201 0Oracle Corporation6 Copyright (C) 2009-2011 Oracle Corporation 7 7 8 8 This file is part of VirtualBox Open Source Edition (OSE), as … … 14 14 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 15 15 </comment> 16 <class>UINewHDW zdPage1</class>17 <widget class="QWidget" name="UINewHDW zdPage1">16 <class>UINewHDWizardPageWelcome</class> 17 <widget class="QWidget" name="UINewHDWizardPageWelcome"> 18 18 <property name="geometry"> 19 19 <rect> … … 30 30 </sizepolicy> 31 31 </property> 32 <layout class="QVBoxLayout" name="m_p Layout1">32 <layout class="QVBoxLayout" name="m_pMainLayout"> 33 33 <property name="bottomMargin" > 34 34 <number>0</number> 35 35 </property> 36 36 <item> 37 <widget class="QILabel" name="m_p Page1Text1">37 <widget class="QILabel" name="m_pLabel"> 38 38 <property name="wordWrap"> 39 39 <bool>true</bool> 40 </property> 41 <property name="text"> 42 <string><p>This wizard will help you to create a new virtual disk for your virtual machine.</p></string> 40 43 </property> 41 44 </widget> 42 45 </item> 43 46 <item> 44 <spacer name="m_pSpacer 1">47 <spacer name="m_pSpacer"> 45 48 <property name="sizeHint" stdset="0"> 46 49 <size> -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.cpp
r37296 r37331 23 23 /* Local includes */ 24 24 #include "UIIconPool.h" 25 #include "UINewHDW zd.h"25 #include "UINewHDWizard.h" 26 26 #include "UINewVMWzd.h" 27 27 #include "QIFileDialog.h" … … 561 561 bool UINewVMWzdPage4::getWithNewHardDiskWizard() 562 562 { 563 UINewHDWzd dlg(this); 564 dlg.setRecommendedName(field("name").toString()); 565 dlg.setRecommendedSize(field("type").value<CGuestOSType>().GetRecommendedHDD()); 566 dlg.setDefaultPath(field("machineFolder").toString()); 563 UINewHDWizard dlg(this, field("name").toString(), field("machineFolder").toString(), field("type").value<CGuestOSType>().GetRecommendedHDD()); 567 564 568 565 if (dlg.exec() == QDialog::Accepted)
Note:
See TracChangeset
for help on using the changeset viewer.