Changeset 91256 in vbox
- Timestamp:
- Sep 15, 2021 3:50:45 PM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/wizards
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDExpertPage.cpp
r91222 r91256 93 93 QString strMediumPath = 94 94 UIDiskEditorGroupBox::appendExtension(strSelectedPath, 95 UIDisk FormatsGroupBox::defaultExtension(pWizard->mediumFormat(), pWizard->deviceType()));95 UIDiskEditorGroupBox::defaultExtension(pWizard->mediumFormat(), pWizard->deviceType())); 96 96 QFileInfo mediumPath(strMediumPath); 97 97 m_pMediumSizePathGroupBox->setMediumPath(QDir::toNativeSeparators(mediumPath.absoluteFilePath())); … … 118 118 QString strMediumPath = 119 119 UIDiskEditorGroupBox::appendExtension(strPath, 120 UIDisk FormatsGroupBox::defaultExtension(pWizard->mediumFormat(), pWizard->deviceType()));120 UIDiskEditorGroupBox::defaultExtension(pWizard->mediumFormat(), pWizard->deviceType())); 121 121 pWizard->setMediumPath(strMediumPath); 122 122 emit completeChanged(); … … 141 141 m_pMediumSizePathGroupBox->setMediumSize(pWizard->sourceDiskLogicalSize()); 142 142 pWizard->setMediumSize(m_pMediumSizePathGroupBox->mediumSize()); 143 QString strExtension = UIDisk FormatsGroupBox::defaultExtension(pWizard->mediumFormat(), pWizard->deviceType());143 QString strExtension = UIDiskEditorGroupBox::defaultExtension(pWizard->mediumFormat(), pWizard->deviceType()); 144 144 QString strSourceDiskPath = QDir::toNativeSeparators(QFileInfo(pWizard->sourceDiskFilePath()).absolutePath()); 145 145 /* Disk name without the format extension: */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPathSizePage.cpp
r91222 r91256 73 73 if (!m_userModifiedParameters.contains("MediumPath")) 74 74 { 75 QString strExtension = UIDisk FormatsGroupBox::defaultExtension(pWizard->mediumFormat(), pWizard->deviceType());75 QString strExtension = UIDiskEditorGroupBox::defaultExtension(pWizard->mediumFormat(), pWizard->deviceType()); 76 76 QString strSourceDiskPath = QDir::toNativeSeparators(QFileInfo(pWizard->sourceDiskFilePath()).absolutePath()); 77 77 /* Disk name without the format extension: */ … … 119 119 QString strMediumPath = 120 120 UIDiskEditorGroupBox::appendExtension(strSelectedPath, 121 UIDisk FormatsGroupBox::defaultExtension(pWizard->mediumFormat(), pWizard->deviceType()));121 UIDiskEditorGroupBox::defaultExtension(pWizard->mediumFormat(), pWizard->deviceType())); 122 122 QFileInfo mediumPath(strMediumPath); 123 123 m_pMediumSizePathGroupBox->setMediumPath(QDir::toNativeSeparators(mediumPath.absoluteFilePath())); … … 131 131 QString strMediumPath = 132 132 UIDiskEditorGroupBox::appendExtension(strPath, 133 UIDisk FormatsGroupBox::defaultExtension(pWizard->mediumFormat(), pWizard->deviceType()));133 UIDiskEditorGroupBox::defaultExtension(pWizard->mediumFormat(), pWizard->deviceType())); 134 134 pWizard->setMediumPath(strMediumPath); 135 135 emit completeChanged(); -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardDiskEditors.cpp
r91254 r91256 168 168 169 169 /********************************************************************************************************************************* 170 * UIDiskFormat sGroupBoximplementation. *170 * UIDiskFormatBase implementation. * 171 171 *********************************************************************************************************************************/ 172 172 173 UIDiskFormatsGroupBox::UIDiskFormatsGroupBox(bool fExpertMode, KDeviceType enmDeviceType, QWidget *pParent /* = 0 */) 174 : UIDiskEditorGroupBox(fExpertMode, pParent) 175 , UIDiskFormatBase(enmDeviceType) 176 , m_pFormatButtonGroup(0) 177 , m_pMainLayout(0) 178 { 179 prepare(); 180 181 } 182 183 CMediumFormat UIDiskFormatsGroupBox::mediumFormat() const 184 { 185 return m_pFormatButtonGroup && 186 m_pFormatButtonGroup->checkedButton() ? m_formatList[m_pFormatButtonGroup->checkedId()].m_comFormat : CMediumFormat(); 187 } 188 189 void UIDiskFormatsGroupBox::setMediumFormat(const CMediumFormat &mediumFormat) 190 { 191 int iPosition = -1; 192 for (int i = 0; i < m_formatList.size(); ++i) 193 { 194 if (mediumFormat == m_formatList[i].m_comFormat) 195 iPosition = i; 196 } 197 if (iPosition >= 0) 198 { 199 m_pFormatButtonGroup->button(iPosition)->click(); 200 m_pFormatButtonGroup->button(iPosition)->setFocus(); 201 } 202 } 203 204 const CMediumFormat &UIDiskFormatsGroupBox::VDIMediumFormat() const 173 UIDiskFormatBase::UIDiskFormatBase(KDeviceType enmDeviceType, bool fExpertMode) 174 : m_enmDeviceType(enmDeviceType) 175 , m_fExpertMode(fExpertMode) 176 { 177 } 178 179 const CMediumFormat &UIDiskFormatBase::VDIMediumFormat() const 205 180 { 206 181 return m_comVDIMediumFormat; 207 182 } 208 183 209 void UIDiskFormatsGroupBox::prepare() 210 { 211 m_pMainLayout = new QVBoxLayout(this); 212 populateFormats(); 213 createFormatWidgets(); 214 retranslateUi(); 215 } 216 217 void UIDiskFormatsGroupBox::populateFormats(){ 184 void UIDiskFormatBase::populateFormats(){ 218 185 /* Enumerate medium formats in special order: */ 219 186 CSystemProperties properties = uiCommon().virtualBox().GetSystemProperties(); … … 250 217 } 251 218 252 void UIDiskFormatsGroupBox::retranslateUi() 253 { 254 if (m_fExpertMode) 255 setTitle(tr("Hard Disk File &Type")); 256 257 QList<QAbstractButton*> buttons = m_pFormatButtonGroup ? m_pFormatButtonGroup->buttons() : QList<QAbstractButton*>(); 258 for (int i = 0; i < buttons.size(); ++i) 259 { 260 QAbstractButton *pButton = buttons[i]; 261 UIMediumFormat enmFormat = gpConverter->fromInternalString<UIMediumFormat>(m_formatList[m_pFormatButtonGroup->id(pButton)].m_strName); 262 pButton->setText(gpConverter->toString(enmFormat)); 263 } 264 } 265 266 void UIDiskFormatsGroupBox::addFormat(CMediumFormat medFormat, bool fPreferred /* = false */) 219 void UIDiskFormatBase::addFormat(CMediumFormat medFormat, bool fPreferred /* = false */) 267 220 { 268 221 /* Check that medium format supports creation: */ … … 283 236 if (!deviceTypes.contains(m_enmDeviceType)) 284 237 return; 285 m_formatList << Format(medFormat, medFormat.GetName(),defaultExtension(medFormat, m_enmDeviceType), fPreferred);286 } 287 288 const QStringList UIDiskFormatsGroupBox::formatExtensions() const238 m_formatList << Format(medFormat, UIDiskEditorGroupBox::defaultExtension(medFormat, m_enmDeviceType), fPreferred); 239 } 240 241 QStringList UIDiskFormatBase::formatExtensions() const 289 242 { 290 243 QStringList extensionList; … … 294 247 } 295 248 249 bool UIDiskFormatBase::isExpertMode() const 250 { 251 return m_fExpertMode; 252 } 253 254 /********************************************************************************************************************************* 255 * UIDiskFormatsGroupBox implementation. * 256 *********************************************************************************************************************************/ 257 258 UIDiskFormatsGroupBox::UIDiskFormatsGroupBox(bool fExpertMode, KDeviceType enmDeviceType, QWidget *pParent /* = 0 */) 259 : QIWithRetranslateUI<QWidget>(pParent) 260 , UIDiskFormatBase(enmDeviceType, fExpertMode) 261 , m_pFormatButtonGroup(0) 262 , m_pMainLayout(0) 263 { 264 prepare(); 265 } 266 267 CMediumFormat UIDiskFormatsGroupBox::mediumFormat() const 268 { 269 return m_pFormatButtonGroup && 270 m_pFormatButtonGroup->checkedButton() ? m_formatList[m_pFormatButtonGroup->checkedId()].m_comFormat : CMediumFormat(); 271 } 272 273 void UIDiskFormatsGroupBox::setMediumFormat(const CMediumFormat &mediumFormat) 274 { 275 int iPosition = -1; 276 for (int i = 0; i < m_formatList.size(); ++i) 277 { 278 if (mediumFormat == m_formatList[i].m_comFormat) 279 iPosition = i; 280 } 281 if (iPosition >= 0) 282 { 283 m_pFormatButtonGroup->button(iPosition)->click(); 284 m_pFormatButtonGroup->button(iPosition)->setFocus(); 285 } 286 } 287 288 void UIDiskFormatsGroupBox::prepare() 289 { 290 m_pMainLayout = new QVBoxLayout(this); 291 populateFormats(); 292 createFormatWidgets(); 293 retranslateUi(); 294 } 295 296 void UIDiskFormatsGroupBox::retranslateUi() 297 { 298 QList<QAbstractButton*> buttons = m_pFormatButtonGroup ? m_pFormatButtonGroup->buttons() : QList<QAbstractButton*>(); 299 for (int i = 0; i < buttons.size(); ++i) 300 { 301 QAbstractButton *pButton = buttons[i]; 302 const CMediumFormat &format = m_formatList[m_pFormatButtonGroup->id(pButton)].m_comFormat; 303 if (format.isNull()) 304 continue; 305 UIMediumFormat enmFormat = gpConverter->fromInternalString<UIMediumFormat>(format.GetName()); 306 pButton->setText(gpConverter->toString(enmFormat)); 307 } 308 } 309 296 310 void UIDiskFormatsGroupBox::createFormatWidgets() 297 311 { … … 308 322 309 323 /* Make the preferred button font bold: */ 310 if (m_formatList[i].m_fPreferred && m_fExpertMode)324 if (m_formatList[i].m_fPreferred && isExpertMode()) 311 325 { 312 326 QFont font = pFormatButton->font(); … … 561 575 { 562 576 /* Compose virtual-disk extension: */ 563 QString strDefaultExtension = UIDisk FormatsGroupBox::defaultExtension(mediumFormat, enmDeviceType);577 QString strDefaultExtension = UIDiskEditorGroupBox::defaultExtension(mediumFormat, enmDeviceType); 564 578 /* Update m_pLocationEditor's text if necessary: */ 565 579 if (!m_pLocationEditor->text().isEmpty() && !strDefaultExtension.isEmpty()) -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardDiskEditors.h
r91254 r91256 74 74 }; 75 75 76 class UIDiskFormatBase77 {78 79 public:80 81 UIDiskFormatBase(KDeviceType enmDeviceType)82 : m_enmDeviceType(enmDeviceType)83 {}84 85 protected:86 87 struct Format88 {89 CMediumFormat m_comFormat;90 QString m_strName;91 QString m_strExtension;92 bool m_fPreferred;93 Format(const CMediumFormat &comFormat, const QString &strName,94 const QString &strExtension, bool fPreferred)95 : m_comFormat(comFormat)96 , m_strName(strName)97 , m_strExtension(strExtension)98 , m_fPreferred(fPreferred){}99 Format(){}100 };101 102 QVector<Format> m_formatList;103 CMediumFormat m_comVDIMediumFormat;104 KDeviceType m_enmDeviceType;105 106 };107 108 class SHARED_LIBRARY_STUFF UIDiskFormatsGroupBox : public UIDiskEditorGroupBox, public UIDiskFormatBase109 {110 Q_OBJECT;111 112 signals:113 114 void sigMediumFormatChanged();115 116 public:117 118 UIDiskFormatsGroupBox(bool fExpertMode, KDeviceType enmDeviceType, QWidget *pParent = 0);119 CMediumFormat mediumFormat() const;120 void setMediumFormat(const CMediumFormat &mediumFormat);121 const CMediumFormat &VDIMediumFormat() const;122 const QStringList formatExtensions() const;123 124 private:125 126 void prepare();127 void populateFormats();128 void addFormat(CMediumFormat medFormat, bool fPreferred = false);129 void createFormatWidgets();130 virtual void retranslateUi() /* override final */;131 132 133 QButtonGroup *m_pFormatButtonGroup;134 QVBoxLayout *m_pMainLayout;135 };136 76 137 77 class SHARED_LIBRARY_STUFF UIDiskVariantGroupBox : public UIDiskEditorGroupBox … … 209 149 }; 210 150 151 /** Base class for the widgets used to select virtual medium format. It implements mutual functioanlity 152 * like finding name, extension etc for a CMediumFormat and device type. */ 153 class SHARED_LIBRARY_STUFF UIDiskFormatBase 154 { 155 public: 156 157 UIDiskFormatBase(KDeviceType enmDeviceType, bool fExpertMode); 158 const CMediumFormat &VDIMediumFormat() const; 159 QStringList formatExtensions() const; 160 161 protected: 162 163 struct Format 164 { 165 CMediumFormat m_comFormat; 166 QString m_strExtension; 167 bool m_fPreferred; 168 Format(const CMediumFormat &comFormat, 169 const QString &strExtension, bool fPreferred) 170 : m_comFormat(comFormat) 171 , m_strExtension(strExtension) 172 , m_fPreferred(fPreferred){} 173 Format(){} 174 }; 175 176 void addFormat(CMediumFormat medFormat, bool fPreferred = false); 177 void populateFormats(); 178 bool isExpertMode() const; 179 QVector<Format> m_formatList; 180 181 private: 182 183 CMediumFormat m_comVDIMediumFormat; 184 KDeviceType m_enmDeviceType; 185 bool m_fExpertMode; 186 }; 187 188 class SHARED_LIBRARY_STUFF UIDiskFormatsGroupBox : public QIWithRetranslateUI<QWidget>, public UIDiskFormatBase 189 { 190 Q_OBJECT; 191 192 signals: 193 194 void sigMediumFormatChanged(); 195 196 public: 197 198 UIDiskFormatsGroupBox(bool fExpertMode, KDeviceType enmDeviceType, QWidget *pParent = 0); 199 CMediumFormat mediumFormat() const; 200 void setMediumFormat(const CMediumFormat &mediumFormat); 201 202 private: 203 204 void prepare(); 205 void createFormatWidgets(); 206 virtual void retranslateUi() /* override final */; 207 208 QButtonGroup *m_pFormatButtonGroup; 209 QVBoxLayout *m_pMainLayout; 210 }; 211 211 212 #endif /* !FEQT_INCLUDED_SRC_wizards_editors_UIWizardDiskEditors_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDExpertPage.cpp
r91061 r91256 82 82 QString strMediumPath = 83 83 UIDiskEditorGroupBox::appendExtension(strPath, 84 UIDisk FormatsGroupBox::defaultExtension(pWizard->mediumFormat(), KDeviceType_HardDisk));84 UIDiskEditorGroupBox::defaultExtension(pWizard->mediumFormat(), KDeviceType_HardDisk)); 85 85 pWizard->setMediumPath(strMediumPath); 86 86 emit completeChanged(); … … 115 115 QString strMediumPath = 116 116 UIDiskEditorGroupBox::appendExtension(strSelectedPath, 117 UIDisk FormatsGroupBox::defaultExtension(pWizard->mediumFormat(), KDeviceType_HardDisk));117 UIDiskEditorGroupBox::defaultExtension(pWizard->mediumFormat(), KDeviceType_HardDisk)); 118 118 QFileInfo mediumPath(strMediumPath); 119 119 m_pSizeAndPathGroup->setMediumPath(QDir::toNativeSeparators(mediumPath.absoluteFilePath())); … … 135 135 pWizard->setMediumFormat(comMediumFormat); 136 136 137 QString strExtension = UIDisk FormatsGroupBox::defaultExtension(comMediumFormat, KDeviceType_HardDisk);137 QString strExtension = UIDiskEditorGroupBox::defaultExtension(comMediumFormat, KDeviceType_HardDisk); 138 138 QString strMediumFilePath = 139 139 UIDiskEditorGroupBox::constructMediumFilePath(UIDiskVariantGroupBox::appendExtension(m_strDefaultName, -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDSizeLocationPage.cpp
r91061 r91256 70 70 QString strMediumPath = 71 71 UIDiskEditorGroupBox::appendExtension(strSelectedPath, 72 UIDisk FormatsGroupBox::defaultExtension(pWizard->mediumFormat(), KDeviceType_HardDisk));72 UIDiskEditorGroupBox::defaultExtension(pWizard->mediumFormat(), KDeviceType_HardDisk)); 73 73 QFileInfo mediumPath(strMediumPath); 74 74 m_pMediumSizePathGroup->setMediumPath(QDir::toNativeSeparators(mediumPath.absoluteFilePath())); … … 90 90 QString strMediumPath = 91 91 UIDiskEditorGroupBox::appendExtension(strPath, 92 UIDisk FormatsGroupBox::defaultExtension(pWizard->mediumFormat(), KDeviceType_HardDisk));92 UIDiskEditorGroupBox::defaultExtension(pWizard->mediumFormat(), KDeviceType_HardDisk)); 93 93 pWizard->setMediumPath(strMediumPath); 94 94 emit completeChanged(); … … 107 107 if (!m_userModifiedParameters.contains("MediumPath")) 108 108 { 109 QString strExtension = UIDisk FormatsGroupBox::defaultExtension(pWizard->mediumFormat(), KDeviceType_HardDisk);109 QString strExtension = UIDiskEditorGroupBox::defaultExtension(pWizard->mediumFormat(), KDeviceType_HardDisk); 110 110 QString strMediumFilePath = 111 111 UIDiskEditorGroupBox::constructMediumFilePath(UIDiskVariantGroupBox::appendExtension(m_strDefaultName, -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMDiskPage.cpp
r91220 r91256 296 296 setWidgetVisibility(pWizard->mediumFormat()); 297 297 } 298 QString strDefaultExtension = UIDisk FormatsGroupBox::defaultExtension(pWizard->mediumFormat(), KDeviceType_HardDisk);298 QString strDefaultExtension = UIDiskEditorGroupBox::defaultExtension(pWizard->mediumFormat(), KDeviceType_HardDisk); 299 299 300 300 /* We set the medium name and path according to machine name/path and do not allow user change these in the guided mode: */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMExpertPage.cpp
r91220 r91256 688 688 QString strMediumPath = 689 689 UIDiskEditorGroupBox::appendExtension(strSelectedPath, 690 UIDisk FormatsGroupBox::defaultExtension(pWizard->mediumFormat(), KDeviceType_HardDisk));690 UIDiskEditorGroupBox::defaultExtension(pWizard->mediumFormat(), KDeviceType_HardDisk)); 691 691 QFileInfo mediumPath(strMediumPath); 692 692 m_pSizeAndLocationGroup->setMediumPath(QDir::toNativeSeparators(mediumPath.absoluteFilePath())); … … 806 806 strMediumPath = uiCommon().virtualBox().GetSystemProperties().GetDefaultMachineFolder(); 807 807 } 808 QString strExtension = UIDisk FormatsGroupBox::defaultExtension(pWizard->mediumFormat(), KDeviceType_HardDisk);808 QString strExtension = UIDiskEditorGroupBox::defaultExtension(pWizard->mediumFormat(), KDeviceType_HardDisk); 809 809 if (m_pSizeAndLocationGroup) 810 810 {
Note:
See TracChangeset
for help on using the changeset viewer.