Changeset 87972 in vbox
- Timestamp:
- Mar 5, 2021 2:55:53 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/wizards
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic2.cpp
r87941 r87972 174 174 } 175 175 176 void UIWizardNewVDPage2::updateMediumVariantWidgetsAfterFormatChange(const CMediumFormat &mediumFormat) 177 { 178 /* Enable/disable widgets: */ 179 ULONG uCapabilities = 0; 180 QVector<KMediumFormatCapabilities> capabilities; 181 capabilities = mediumFormat.GetCapabilities(); 182 for (int i = 0; i < capabilities.size(); i++) 183 uCapabilities |= capabilities[i]; 184 185 bool fIsCreateDynamicPossible = uCapabilities & KMediumFormatCapabilities_CreateDynamic; 186 bool fIsCreateFixedPossible = uCapabilities & KMediumFormatCapabilities_CreateFixed; 187 bool fIsCreateSplitPossible = uCapabilities & KMediumFormatCapabilities_CreateSplit2G; 188 189 if (m_pFixedCheckBox) 190 { 191 m_pFixedCheckBox->setEnabled(fIsCreateDynamicPossible || fIsCreateFixedPossible); 192 if (!fIsCreateDynamicPossible) 193 m_pFixedCheckBox->setChecked(true); 194 if (!fIsCreateFixedPossible) 195 m_pFixedCheckBox->setChecked(false); 196 } 197 m_pSplitBox->setEnabled(fIsCreateSplitPossible); 198 } 199 176 200 UIWizardNewVDPageBasic2::UIWizardNewVDPageBasic2() 177 201 { -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic2.h
r87929 r87972 46 46 /** Check Medium format capability and decide if certain widgets can be shown. */ 47 47 void setWidgetVisibility(CMediumFormat &mediumFormat); 48 void updateMediumVariantWidgetsAfterFormatChange(const CMediumFormat &mediumFormat); 48 49 /** @name Widgets 49 50 * @{ */ 50 QCheckBox 51 QCheckBox *m_pFixedCheckBox; 51 52 QCheckBox *m_pSplitBox; 52 53 /** @} */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic3.cpp
r87941 r87972 231 231 } 232 232 233 /* static */ 234 QString UIWizardNewVDPage3::stripFormatExtension(const QString &strFileName, const QStringList &formatExtensions) 235 { 236 QString result(strFileName); 237 foreach (const QString &strExtension, formatExtensions) 238 { 239 if (strFileName.endsWith(strExtension, Qt::CaseInsensitive)) 240 { 241 /* Add the dot to extenstion: */ 242 QString strExtensionWithDot(strExtension); 243 strExtensionWithDot.prepend('.'); 244 int iIndex = strFileName.lastIndexOf(strExtensionWithDot, -1, Qt::CaseInsensitive); 245 result.remove(iIndex, strExtensionWithDot.length()); 246 } 247 } 248 return result; 249 } 250 251 void UIWizardNewVDPage3::updateLocationEditorAfterFormatChange(const CMediumFormat &mediumFormat, const QStringList &formatExtensions) 252 { 253 /* Compose virtual-disk extension: */ 254 m_strDefaultExtension = defaultExtension(mediumFormat); 255 /* Update m_pLocationEditor's text if necessary: */ 256 if (!m_pLocationEditor->text().isEmpty() && !m_strDefaultExtension.isEmpty()) 257 { 258 QFileInfo fileInfo(m_pLocationEditor->text()); 259 if (fileInfo.suffix() != m_strDefaultExtension) 260 { 261 QFileInfo newFileInfo(fileInfo.absolutePath(), 262 QString("%1.%2"). 263 arg(stripFormatExtension(fileInfo.fileName(), formatExtensions)). 264 arg(m_strDefaultExtension)); 265 m_pLocationEditor->setText(newFileInfo.absoluteFilePath()); 266 } 267 } 268 } 269 233 270 void UIWizardNewVDPage3::retranslateWidgets() 234 271 { -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic3.h
r87938 r87972 58 58 59 59 virtual QString mediumPath() const; 60 /** A utility function thar strips the format extension from the @p strFileName. 61 * foo.dd.vdi becomes foo.dd. any extension which is not a format extension is left alone. */ 62 static QString stripFormatExtension(const QString &strFileName, const QStringList &formatExtensions); 63 void updateLocationEditorAfterFormatChange(const CMediumFormat &mediumFormat, const QStringList &formatExtensions); 60 64 61 65 qulonglong mediumSize() const; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageExpert.cpp
r87946 r87972 128 128 registerField("mediumPath", this, "mediumPath"); 129 129 registerField("mediumSize", this, "mediumSize"); 130 131 /* Initialization of m_strDefaultExtension is done here132 since first m_formats should be populated and fields should be registered: */133 m_strDefaultExtension = defaultExtension(mediumFormat());134 if (m_pLocationEditor)135 m_pLocationEditor->setText(absoluteFilePath(m_strDefaultName, m_strDefaultPath, m_strDefaultExtension));136 130 } 137 131 … … 146 140 } 147 141 148 /* Enable/disable widgets: */ 149 ULONG uCapabilities = 0; 150 QVector<KMediumFormatCapabilities> capabilities; 151 capabilities = mf.GetCapabilities(); 152 for (int i = 0; i < capabilities.size(); i++) 153 uCapabilities |= capabilities[i]; 154 155 bool fIsCreateDynamicPossible = uCapabilities & KMediumFormatCapabilities_CreateDynamic; 156 bool fIsCreateFixedPossible = uCapabilities & KMediumFormatCapabilities_CreateFixed; 157 bool fIsCreateSplitPossible = uCapabilities & KMediumFormatCapabilities_CreateSplit2G; 158 159 if (m_pFixedCheckBox) 160 { 161 if (!fIsCreateDynamicPossible) 162 { 163 m_pFixedCheckBox->setEnabled(false); 164 m_pFixedCheckBox->setChecked(true); 165 } 166 if (!fIsCreateFixedPossible) 167 { 168 m_pFixedCheckBox->setEnabled(false); 169 m_pFixedCheckBox->setChecked(false); 170 } 171 } 172 m_pSplitBox->setEnabled(fIsCreateSplitPossible); 173 174 /* Compose virtual-disk extension: */ 175 m_strDefaultExtension = defaultExtension(mf); 176 /* Update m_pLocationEditor's text if necessary: */ 177 if (!m_pLocationEditor->text().isEmpty() && !m_strDefaultExtension.isEmpty()) 178 { 179 QFileInfo fileInfo(m_pLocationEditor->text()); 180 if (fileInfo.suffix() != m_strDefaultExtension) 181 { 182 QFileInfo newFileInfo(fileInfo.absolutePath(), 183 QString("%1.%2").arg(stripFormatExtension(fileInfo.fileName())).arg(m_strDefaultExtension)); 184 m_pLocationEditor->setText(newFileInfo.absoluteFilePath()); 185 } 186 } 142 updateMediumVariantWidgetsAfterFormatChange(mf); 143 144 updateLocationEditorAfterFormatChange(mf, m_formatExtensions); 187 145 188 146 /* Broadcast complete-change: */ … … 226 184 void UIWizardNewVDPageExpert::initializePage() 227 185 { 186 /* Get default extension for new virtual-disk: */ 187 m_strDefaultExtension = defaultExtension(field("mediumFormat").value<CMediumFormat>()); 188 /* Set default name as text for location editor: */ 189 if (m_pLocationEditor) 190 m_pLocationEditor->setText(absoluteFilePath(m_strDefaultName, m_strDefaultPath, m_strDefaultExtension)); 191 192 228 193 /* Translate page: */ 229 194 retranslateUi(); … … 274 239 return fResult; 275 240 } 276 277 QString UIWizardNewVDPageExpert::stripFormatExtension(const QString &strFileName)278 {279 QString result(strFileName);280 foreach (const QString &strExtension, m_formatExtensions)281 {282 if (strFileName.endsWith(strExtension, Qt::CaseInsensitive))283 {284 /* Add the dot to extenstion: */285 QString strExtensionWithDot(strExtension);286 strExtensionWithDot.prepend('.');287 int iIndex = strFileName.lastIndexOf(strExtensionWithDot, -1, Qt::CaseInsensitive);288 result.remove(iIndex, strExtensionWithDot.length());289 }290 }291 return result;292 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageExpert.h
r87850 r87972 73 73 bool isComplete() const; 74 74 bool validatePage(); 75 /** Strips the format extension from the @p strFileName. foo.dd.vdi becomes foo.dd. any extension which is not76 * a format extension is left alone. */77 QString stripFormatExtension(const QString &strFileName);78 75 79 76 /* Widgets: */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp
r87958 r87972 44 44 #include "UIWizardNewVMPageExpert.h" 45 45 46 /* COM includes: */ 47 #include "CSystemProperties.h" 46 48 47 49 UIWizardNewVMPageExpert::UIWizardNewVMPageExpert(const QString &strGroup) … … 93 95 registerField("EFIEnabled", this, "EFIEnabled"); 94 96 97 registerField("mediumPath", this, "mediumPath"); 98 registerField("mediumFormat", this, "mediumFormat"); 99 95 100 disableEnableUnattendedRelatedWidgets(isUnattendedEnabled()); 96 101 } … … 102 107 103 108 composeMachineFilePath(); 109 updateVirtualDiskPathFromMachinePathName(); 104 110 /* Broadcast complete-change: */ 105 111 emit completeChanged(); … … 110 116 Q_UNUSED(strNewPath); 111 117 composeMachineFilePath(); 118 updateVirtualDiskPathFromMachinePathName(); 112 119 } 113 120 … … 330 337 setOSTypeDependedValues(); 331 338 disableEnableUnattendedRelatedWidgets(isUnattendedEnabled()); 339 updateVirtualDiskPathFromMachinePathName(); 332 340 } 333 341 … … 398 406 399 407 /* Disk file size widgets: */ 400 QLabel *pSizeEditorLabel = new QLabel("Disk Size:");401 pSizeEditorLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);408 m_pSizeEditorLabel = new QLabel; 409 m_pSizeEditorLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); 402 410 m_pSizeEditor = new UIMediumSizeEditor; 403 pSizeEditorLabel->setBuddy(m_pSizeEditor);411 m_pSizeEditorLabel->setBuddy(m_pSizeEditor); 404 412 405 413 /* Disk file format widgets: */ … … 418 426 pDiskContainerLayout->addWidget(m_pLocationOpenButton, 0, 3, 1, 1); 419 427 420 pDiskContainerLayout->addWidget( pSizeEditorLabel, 1, 0, 1, 1);428 pDiskContainerLayout->addWidget(m_pSizeEditorLabel, 1, 0, 1, 1); 421 429 pDiskContainerLayout->addWidget(m_pSizeEditor, 1, 1, 1, 3); 422 430 … … 548 556 m_userSetWidgets << pSenderWidget; 549 557 } 558 559 void UIWizardNewVMPageExpert::updateVirtualDiskPathFromMachinePathName() 560 { 561 QString strDiskFileName = machineBaseName().isEmpty() ? QString("NewVirtualDisk1") : machineBaseName(); 562 QString strDiskPath = machineFolder(); 563 if (strDiskPath.isEmpty()) 564 { 565 if (m_pNameAndSystemEditor) 566 strDiskPath = m_pNameAndSystemEditor->path(); 567 else 568 strDiskPath = uiCommon().virtualBox().GetSystemProperties().GetDefaultMachineFolder(); 569 } 570 QString strExtension = defaultExtension(mediumFormat()); 571 if (m_pLocationEditor) 572 m_pLocationEditor->setText(absoluteFilePath(strDiskFileName, strDiskPath, strExtension)); 573 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.h
r87958 r87972 67 67 Q_PROPERTY(bool EFIEnabled READ EFIEnabled); 68 68 69 70 // Q_PROPERTY(CMedium virtualDisk READ virtualDisk WRITE setVirtualDisk); 71 // Q_PROPERTY(SelectedDiskSource selectedDiskSource READ selectedDiskSource WRITE setSelectedDiskSource); 72 Q_PROPERTY(CMediumFormat mediumFormat READ mediumFormat); 73 // Q_PROPERTY(qulonglong mediumVariant READ mediumVariant WRITE setMediumVariant); 74 Q_PROPERTY(QString mediumPath READ mediumPath); 75 // Q_PROPERTY(qulonglong mediumSize READ mediumSize WRITE setMediumSize); 76 69 77 public: 70 78 … … 128 136 QWidget *createUnattendedWidgets(); 129 137 virtual QWidget *createNewDiskWidgets() /* override */; 138 void updateVirtualDiskPathFromMachinePathName(); 130 139 131 140 UIToolBox *m_pToolBox;
Note:
See TracChangeset
for help on using the changeset viewer.