- Timestamp:
- Jul 30, 2021 1:38:15 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/wizards
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageExpert.cpp
r90356 r90427 30 30 31 31 /* GUI includes: */ 32 #include "UIWizardDiskEditors.h" 32 33 #include "UIConverter.h" 33 34 #include "UIWizardNewVDPageExpert.h" … … 40 41 #include "QILineEdit.h" 41 42 #include "UIMediumSizeEditor.h" 43 #include "UIWizardNewVDPageSizeLocation.h" 42 44 43 45 /* COM includes: */ … … 45 47 46 48 47 UIWizardNewVDPageExpert::UIWizardNewVDPageExpert(const QString & /*strDefaultName*/, const QString &/*strDefaultPath*/, qulonglong /*uDefaultSize*/)49 UIWizardNewVDPageExpert::UIWizardNewVDPageExpert(const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize) 48 50 : UINativeWizardPage() 49 , m_pFormatGroupBox(0) 50 , m_pVariantGroupBox(0) 51 , m_pLocationGroupBox(0) 52 , m_pSizeGroupBox(0) 53 { 54 /* Get default extension for new virtual-disk: */ 55 /* Create widgets: */ 56 // QGridLayout *pMainLayout = new QGridLayout(this); 57 // { 58 // m_pLocationGroupBox = new QGroupBox(this); 59 // { 60 // m_pLocationGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 61 // QHBoxLayout *pLocationGroupBoxLayout = new QHBoxLayout(m_pLocationGroupBox); 62 // { 63 // m_pLocationEditor = new QLineEdit(m_pLocationGroupBox); 64 // m_pLocationOpenButton = new QIToolButton(m_pLocationGroupBox); 65 // { 66 // m_pLocationOpenButton->setAutoRaise(true); 67 // m_pLocationOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", "select_file_disabled_16px.png")); 68 // } 69 // pLocationGroupBoxLayout->addWidget(m_pLocationEditor); 70 // pLocationGroupBoxLayout->addWidget(m_pLocationOpenButton); 71 // } 72 // } 73 // m_pSizeGroupBox = new QGroupBox(this); 74 // { 75 // m_pSizeGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 76 // QVBoxLayout *pSizeGroupBoxLayout = new QVBoxLayout(m_pSizeGroupBox); 77 // { 78 // m_pMediumSizeEditor = new UIMediumSizeEditor; 79 // { 80 // pSizeGroupBoxLayout->addWidget(m_pMediumSizeEditor); 81 // } 82 // } 83 // } 84 // m_pFormatGroupBox = new QGroupBox(this); 85 // { 86 // m_pFormatGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 87 // QVBoxLayout *pFormatGroupBoxLayout = new QVBoxLayout(m_pFormatGroupBox); 88 // pFormatGroupBoxLayout->addWidget(createFormatButtonGroup(true)); 89 // } 90 // m_pVariantGroupBox = new QGroupBox(this); 91 // { 92 // m_pVariantGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 93 // QVBoxLayout *pVariantGroupBoxLayout = new QVBoxLayout(m_pVariantGroupBox); 94 // { 95 // m_pFixedCheckBox = new QCheckBox; 96 // m_pSplitBox = new QCheckBox(m_pVariantGroupBox); 97 // pVariantGroupBoxLayout->addWidget(m_pFixedCheckBox); 98 // pVariantGroupBoxLayout->addWidget(m_pSplitBox); 99 // } 100 // } 101 // pMainLayout->addWidget(m_pLocationGroupBox, 0, 0, 1, 2); 102 // pMainLayout->addWidget(m_pSizeGroupBox, 1, 0, 1, 2); 103 // pMainLayout->addWidget(m_pFormatGroupBox, 2, 0, Qt::AlignTop); 104 // pMainLayout->addWidget(m_pVariantGroupBox, 2, 1, Qt::AlignTop); 105 // setMediumSize(uDefaultSize); 106 // sltMediumFormatChanged(); 107 // } 108 109 // /* Setup connections: */ 110 // connect(m_pFormatButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked), 111 // this, &UIWizardNewVDPageExpert::sltMediumFormatChanged); 51 , m_pSizeAndPathGroup(0) 52 , m_pFormatGroup(0) 53 , m_pVariantGroup(0) 54 , m_strDefaultName(strDefaultName) 55 , m_strDefaultPath(strDefaultPath) 56 , m_uDefaultSize(uDefaultSize) 57 , m_uMediumSizeMin(_4M) 58 , m_uMediumSizeMax(uiCommon().virtualBox().GetSystemProperties().GetInfoVDSize()) 59 { 60 prepare(); 61 } 62 63 void UIWizardNewVDPageExpert::prepare() 64 { 65 QGridLayout *pMainLayout = new QGridLayout(this); 66 m_pSizeAndPathGroup = new UIMediumSizeAndPathGroupBox(true /* fExpertMode */, 0); 67 m_pFormatGroup = new UIDiskFormatsGroupBox(true /* fExpertMode */, 0); 68 m_pVariantGroup = new UIDiskVariantGroupBox(true /* fExpertMode */, 0); 69 70 pMainLayout->addWidget(m_pSizeAndPathGroup, 0, 0, 2, 2); 71 pMainLayout->addWidget(m_pFormatGroup, 2, 0, 6, 1); 72 pMainLayout->addWidget(m_pVariantGroup, 2, 1, 6, 1); 73 74 connect(m_pFormatGroup, &UIDiskFormatsGroupBox::sigMediumFormatChanged, 75 this, &UIWizardNewVDPageExpert::sltMediumFormatChanged); 112 76 // connect(m_pFixedCheckBox, &QAbstractButton::toggled, 113 77 // this, &UIWizardNewVDPageExpert::completeChanged); … … 116 80 // connect(m_pLocationEditor, &QLineEdit::textChanged, 117 81 // this, &UIWizardNewVDPageExpert::completeChanged); 118 // connect(m_pLocationOpenButton, &QIToolButton::clicked,119 //this, &UIWizardNewVDPageExpert::sltSelectLocationButtonClicked);82 connect(m_pSizeAndPathGroup, &UIMediumSizeAndPathGroupBox::sigMediumLocationButtonClicked, 83 this, &UIWizardNewVDPageExpert::sltSelectLocationButtonClicked); 120 84 // connect(m_pMediumSizeEditor, &UIMediumSizeEditor::sigSizeChanged, 121 85 // this, &UIWizardNewVDPageExpert::completeChanged); 122 86 123 // /* Register classes: */ 124 // qRegisterMetaType<CMediumFormat>(); 125 // /* Register fields: */ 126 // registerField("mediumFormat", this, "mediumFormat"); 127 // registerField("mediumVariant", this, "mediumVariant"); 128 // registerField("mediumPath", this, "mediumPath"); 129 // registerField("mediumSize", this, "mediumSize"); 87 88 retranslateUi(); 89 130 90 } 131 91 132 92 void UIWizardNewVDPageExpert::sltMediumFormatChanged() 133 93 { 134 // CMediumFormat comMediumFormat = mediumFormat(); 135 // if (comMediumFormat.isNull()) 136 // { 137 // AssertMsgFailed(("No medium format set!")); 138 // return; 139 // } 140 // updateMediumVariantWidgetsAfterFormatChange(comMediumFormat); 141 // updateLocationEditorAfterFormatChange(comMediumFormat, m_formatExtensions); 142 143 // /* Broadcast complete-change: */ 144 // completeChanged(); 94 AssertReturnVoid(m_pFormatGroup); 95 newVDWizardPropertySet(MediumFormat, m_pFormatGroup->mediumFormat()); 96 updateDiskWidgetsAfterMediumFormatChange(); 97 completeChanged(); 145 98 } 146 99 147 100 void UIWizardNewVDPageExpert::sltSelectLocationButtonClicked() 148 101 { 149 /* Call to base-class: */ 150 //onSelectLocationButtonClicked(); 102 UIWizardNewVD *pWizard = qobject_cast<UIWizardNewVD*>(wizard()); 103 AssertReturnVoid(pWizard); 104 QString strSelectedPath = UIWizardNewVDSizeLocation::selectNewMediumLocation(pWizard); 105 if (strSelectedPath.isEmpty()) 106 return; 107 QString strMediumPath = 108 UIDiskEditorGroupBox::appendExtension(strSelectedPath, 109 UIDiskEditorGroupBox::defaultExtensionForMediumFormat(pWizard->mediumFormat())); 110 QFileInfo mediumPath(strMediumPath); 111 m_pSizeAndPathGroup->setMediumPath(QDir::toNativeSeparators(mediumPath.absoluteFilePath())); 151 112 } 152 113 … … 181 142 void UIWizardNewVDPageExpert::initializePage() 182 143 { 183 // /* Get default extension for new virtual-disk: */ 184 // m_strDefaultExtension = defaultExtension(field("mediumFormat").value<CMediumFormat>()); 185 // /* Set default name as text for location editor: */ 186 // if (m_pLocationEditor) 187 // m_pLocationEditor->setText(absoluteFilePath(m_strDefaultName, m_strDefaultPath, m_strDefaultExtension)); 188 189 190 // /* Translate page: */ 191 // retranslateUi(); 144 /* First set the medium format of the wizard: */ 145 AssertReturnVoid(m_pFormatGroup); 146 const CMediumFormat &comMediumFormat = m_pFormatGroup->mediumFormat(); 147 AssertReturnVoid(!comMediumFormat.isNull()); 148 newVDWizardPropertySet(MediumFormat, comMediumFormat); 149 150 QString strExtension = UIDiskEditorGroupBox::defaultExtensionForMediumFormat(comMediumFormat); 151 QString strMediumFilePath = 152 UIDiskEditorGroupBox::constructMediumFilePath(UIDiskVariantGroupBox::appendExtension(m_strDefaultName, 153 strExtension), m_strDefaultPath); 154 m_pSizeAndPathGroup->blockSignals(true); 155 m_pSizeAndPathGroup->setMediumPath(strMediumFilePath); 156 m_pSizeAndPathGroup->blockSignals(false); 157 newVDWizardPropertySet(MediumPath, m_pSizeAndPathGroup->mediumPath()); 158 159 m_pSizeAndPathGroup->blockSignals(true); 160 m_pSizeAndPathGroup->setMediumSize(m_uDefaultSize > m_uMediumSizeMin && m_uDefaultSize < m_uMediumSizeMax ? m_uDefaultSize : m_uMediumSizeMin); 161 m_pSizeAndPathGroup->blockSignals(false); 162 newVDWizardPropertySet(MediumSize, m_pSizeAndPathGroup->mediumSize()); 163 164 m_pVariantGroup->blockSignals(true); 165 m_pVariantGroup->updateMediumVariantWidgetsAfterFormatChange(comMediumFormat); 166 m_pVariantGroup->blockSignals(false); 167 168 newVDWizardPropertySet(MediumVariant, m_pVariantGroup->mediumVariant()); 169 170 retranslateUi(); 192 171 } 193 172 … … 237 216 return fResult; 238 217 } 218 219 void UIWizardNewVDPageExpert::updateDiskWidgetsAfterMediumFormatChange() 220 { 221 UIWizardNewVD *pWizard = qobject_cast<UIWizardNewVD*>(wizard()); 222 AssertReturnVoid(pWizard && m_pVariantGroup && m_pSizeAndPathGroup && m_pFormatGroup); 223 const CMediumFormat &comMediumFormat = pWizard->mediumFormat(); 224 AssertReturnVoid(!comMediumFormat.isNull()); 225 226 /* Block signals of the updated widgets to avoid calling corresponding slots since they add the parameters to m_userModifiedParameters: */ 227 m_pVariantGroup->blockSignals(true); 228 m_pVariantGroup->updateMediumVariantWidgetsAfterFormatChange(comMediumFormat); 229 m_pVariantGroup->blockSignals(false); 230 231 m_pSizeAndPathGroup->blockSignals(true); 232 m_pSizeAndPathGroup->updateMediumPath(comMediumFormat, m_pFormatGroup->formatExtensions()); 233 m_pSizeAndPathGroup->blockSignals(false); 234 /* Update the wizard parameters explicitly since we blocked th signals: */ 235 newVDWizardPropertySet(MediumPath, m_pSizeAndPathGroup->mediumPath()); 236 newVDWizardPropertySet(MediumVariant, m_pVariantGroup->mediumVariant()); 237 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageExpert.h
r90356 r90427 27 27 /* Forward declarations: */ 28 28 class QGroupBox; 29 class UIDiskFormatsGroupBox; 30 class UIDiskVariantGroupBox; 31 class UIMediumSizeAndPathGroupBox; 29 32 30 33 /* Expert page of the New Virtual Hard Drive wizard: */ … … 35 38 public: 36 39 37 /* Constructor: */38 40 UIWizardNewVDPageExpert(const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize); 39 41 … … 43 45 private slots: 44 46 45 /* Medium format stuff: */46 47 void sltMediumFormatChanged(); 47 48 /* Location editors stuff: */49 48 void sltSelectLocationButtonClicked(); 50 49 … … 55 54 56 55 /* Prepare stuff: */ 56 void prepare(); 57 57 void initializePage(); 58 58 … … 60 60 bool isComplete() const; 61 61 bool validatePage(); 62 void updateDiskWidgetsAfterMediumFormatChange(); 63 62 64 63 65 /* Widgets: */ 64 QGroupBox *m_pFormatGroupBox; 65 QGroupBox *m_pVariantGroupBox; 66 QGroupBox *m_pLocationGroupBox; 67 QGroupBox *m_pSizeGroupBox; 66 UIMediumSizeAndPathGroupBox *m_pSizeAndPathGroup; 67 UIDiskFormatsGroupBox *m_pFormatGroup; 68 UIDiskVariantGroupBox *m_pVariantGroup; 69 70 QString m_strDefaultName; 71 QString m_strDefaultPath; 72 qulonglong m_uDefaultSize; 73 qulonglong m_uMediumSizeMin; 74 qulonglong m_uMediumSizeMax; 68 75 }; 69 76 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageSizeLocation.cpp
r90413 r90427 21 21 22 22 /* GUI includes: */ 23 #include "QIFileDialog.h" 23 24 #include "UIWizardNewVDPageSizeLocation.h" 24 25 #include "UIWizardNewVD.h" … … 29 30 /* COM includes: */ 30 31 #include "CSystemProperties.h" 32 33 34 QString UIWizardNewVDSizeLocation::selectNewMediumLocation(UIWizardNewVD *pWizard) 35 { 36 AssertReturn(pWizard, QString()); 37 QString strChosenFilePath; 38 /* Get current folder and filename: */ 39 QFileInfo fullFilePath(pWizard->mediumPath()); 40 QDir folder = fullFilePath.path(); 41 QString strFileName = fullFilePath.fileName(); 42 43 /* Set the first parent folder that exists as the current: */ 44 while (!folder.exists() && !folder.isRoot()) 45 { 46 QFileInfo folderInfo(folder.absolutePath()); 47 if (folder == QDir(folderInfo.absolutePath())) 48 break; 49 folder = folderInfo.absolutePath(); 50 } 51 AssertReturn(folder.exists() && !folder.isRoot(), strChosenFilePath); 52 53 QVector<QString> fileExtensions; 54 QVector<KDeviceType> deviceTypes; 55 CMediumFormat mediumFormat = pWizard->mediumFormat(); 56 mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes); 57 QStringList validExtensionList; 58 for (int i = 0; i < fileExtensions.size(); ++i) 59 if (deviceTypes[i] == KDeviceType_HardDisk) 60 validExtensionList << QString("*.%1").arg(fileExtensions[i]); 61 /* Compose full filter list: */ 62 QString strBackendsList = QString("%1 (%2)").arg(mediumFormat.GetName()).arg(validExtensionList.join(" ")); 63 64 strChosenFilePath = QIFileDialog::getSaveFileName(folder.absoluteFilePath(strFileName), 65 strBackendsList, pWizard, 66 UICommon::tr("Please choose a location for new virtual hard disk file")); 67 return strChosenFilePath; 68 } 69 31 70 32 71 UIWizardNewVDPageSizeLocation::UIWizardNewVDPageSizeLocation(const QString &strDefaultName, … … 61 100 void UIWizardNewVDPageSizeLocation::sltSelectLocationButtonClicked() 62 101 { 102 63 103 } 64 104 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageSizeLocation.h
r90407 r90427 28 28 class CMediumFormat; 29 29 class UIMediumSizeAndPathGroupBox; 30 class UIWizardNewVD; 31 32 namespace UIWizardNewVDSizeLocation 33 { 34 QString selectNewMediumLocation(UIWizardNewVD *pWizard); 35 } 30 36 31 37 class SHARED_LIBRARY_STUFF UIWizardNewVDPageSizeLocation : public UINativeWizardPage -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMDiskPageBasic.cpp
r90413 r90427 91 91 strBackendsList, pWizard, 92 92 UICommon::tr("Please choose a location for new virtual hard disk file")); 93 94 // if (!strChosenFilePath.isEmpty())95 // {96 // /* If valid file extension is missed, append it: */97 // if (QFileInfo(strChosenFilePath).suffix().isEmpty())98 // strChosenFilePath += QString(".%1").arg(m_strDefaultExtension);99 // }100 93 return strChosenFilePath; 101 // if (m_pLocationEditor) 102 // { 103 // m_pLocationEditor->setText(QDir::toNativeSeparators(strChosenFilePath)); 104 // m_pLocationEditor->selectAll(); 105 // m_pLocationEditor->setFocus(); 106 // } 107 // } 108 } 109 94 } 110 95 111 96 UIWizardNewVMDiskPageBasic::UIWizardNewVMDiskPageBasic()
Note:
See TracChangeset
for help on using the changeset viewer.