Changeset 87850 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Feb 23, 2021 4:38:31 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic1.cpp
r87775 r87850 34 34 35 35 UIWizardNewVDPage1::UIWizardNewVDPage1() 36 : m_pFormatButtonGroup(0) 36 37 { 37 38 } … … 76 77 } 77 78 79 QWidget *UIWizardNewVDPage1::createFormatButtonGroup(bool fExpertMode) 80 { 81 QWidget *pContainerWidget = new QWidget; 82 QVBoxLayout *pContainerLayout = new QVBoxLayout(pContainerWidget); 83 pContainerLayout->setContentsMargins(0, 0, 0, 0); 84 85 m_pFormatButtonGroup = new QButtonGroup; 86 if (m_pFormatButtonGroup) 87 { 88 /* Enumerate medium formats in special order: */ 89 CSystemProperties properties = uiCommon().virtualBox().GetSystemProperties(); 90 const QVector<CMediumFormat> &formats = properties.GetMediumFormats(); 91 QMap<QString, CMediumFormat> vdi, preferred, others; 92 foreach (const CMediumFormat &format, formats) 93 { 94 /* VDI goes first: */ 95 if (format.GetName() == "VDI") 96 vdi[format.GetId()] = format; 97 else 98 { 99 const QVector<KMediumFormatCapabilities> &capabilities = format.GetCapabilities(); 100 /* Then goes preferred: */ 101 if (capabilities.contains(KMediumFormatCapabilities_Preferred)) 102 preferred[format.GetId()] = format; 103 /* Then others: */ 104 else 105 others[format.GetId()] = format; 106 } 107 } 108 109 /* Create buttons for VDI, preferred and others: */ 110 foreach (const QString &strId, vdi.keys()) 111 addFormatButton(pContainerWidget, pContainerLayout, vdi.value(strId), fExpertMode); 112 foreach (const QString &strId, preferred.keys()) 113 addFormatButton(pContainerWidget, pContainerLayout, preferred.value(strId), fExpertMode); 114 if (fExpertMode) 115 { 116 foreach (const QString &strId, others.keys()) 117 addFormatButton(pContainerWidget, pContainerLayout, others.value(strId)); 118 } 119 120 if (!m_pFormatButtonGroup->buttons().isEmpty()) 121 { 122 m_pFormatButtonGroup->button(0)->click(); 123 m_pFormatButtonGroup->button(0)->setFocus(); 124 } 125 } 126 127 128 129 return pContainerWidget; 130 } 131 78 132 CMediumFormat UIWizardNewVDPage1::mediumFormat() const 79 133 { 80 return m_pFormatButtonGroup ->checkedButton() ? m_formats[m_pFormatButtonGroup->checkedId()] : CMediumFormat();134 return m_pFormatButtonGroup && m_pFormatButtonGroup->checkedButton() ? m_formats[m_pFormatButtonGroup->checkedId()] : CMediumFormat(); 81 135 } 82 136 … … 97 151 { 98 152 m_pLabel = new QIRichTextLabel(this); 99 QVBoxLayout *pFormatLayout = new QVBoxLayout;100 {101 m_pFormatButtonGroup = new QButtonGroup(this);102 {103 /* Enumerate medium formats in special order: */104 CSystemProperties properties = uiCommon().virtualBox().GetSystemProperties();105 const QVector<CMediumFormat> &formats = properties.GetMediumFormats();106 QMap<QString, CMediumFormat> vdi, preferred;107 foreach (const CMediumFormat &format, formats)108 {109 /* VDI goes first: */110 if (format.GetName() == "VDI")111 vdi[format.GetId()] = format;112 else113 {114 const QVector<KMediumFormatCapabilities> &capabilities = format.GetCapabilities();115 /* Then preferred: */116 if (capabilities.contains(KMediumFormatCapabilities_Preferred))117 preferred[format.GetId()] = format;118 }119 }120 121 /* Create buttons for VDI and preferred: */122 foreach (const QString &strId, vdi.keys())123 addFormatButton(this, pFormatLayout, vdi.value(strId));124 foreach (const QString &strId, preferred.keys())125 addFormatButton(this, pFormatLayout, preferred.value(strId));126 127 if (!m_pFormatButtonGroup->buttons().isEmpty())128 {129 m_pFormatButtonGroup->button(0)->click();130 m_pFormatButtonGroup->button(0)->setFocus();131 }132 }133 }134 153 pMainLayout->addWidget(m_pLabel); 135 pMainLayout->addLayout(pFormatLayout); 154 pMainLayout->addWidget(createFormatButtonGroup(false)); 155 136 156 pMainLayout->addStretch(); 137 157 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic1.h
r87775 r87850 47 47 void addFormatButton(QWidget *pParent, QVBoxLayout *pFormatsLayout, CMediumFormat medFormat, bool fPreferred = false); 48 48 49 QWidget *createFormatButtonGroup(bool fExperMode); 50 49 51 /* Stuff for 'mediumFormat' field: */ 50 52 CMediumFormat mediumFormat() const; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic3.cpp
r82968 r87850 154 154 QString UIWizardNewVDPage3::defaultExtension(const CMediumFormat &mediumFormatRef) 155 155 { 156 /* Load extension / device list: */ 157 QVector<QString> fileExtensions; 158 QVector<KDeviceType> deviceTypes; 159 CMediumFormat mediumFormat(mediumFormatRef); 160 mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes); 161 for (int i = 0; i < fileExtensions.size(); ++i) 162 if (deviceTypes[i] == KDeviceType_HardDisk) 163 return fileExtensions[i].toLower(); 156 if (!mediumFormatRef.isNull()) 157 { 158 /* Load extension / device list: */ 159 QVector<QString> fileExtensions; 160 QVector<KDeviceType> deviceTypes; 161 CMediumFormat mediumFormat(mediumFormatRef); 162 mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes); 163 for (int i = 0; i < fileExtensions.size(); ++i) 164 if (deviceTypes[i] == KDeviceType_HardDisk) 165 return fileExtensions[i].toLower(); 166 } 164 167 AssertMsgFailed(("Extension can't be NULL!\n")); 165 168 return QString(); -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageExpert.cpp
r87845 r87850 47 47 UIWizardNewVDPageExpert::UIWizardNewVDPageExpert(const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize) 48 48 : UIWizardNewVDPage3(strDefaultName, strDefaultPath) 49 , m_pFormatGroupBox(0) 50 , m_pVariantGroupBox(0) 51 , m_pLocationGroupBox(0) 52 , m_pSizeGroupBox(0) 49 53 { 50 54 /* Get default extension for new virtual-disk: */ … … 52 56 QGridLayout *pMainLayout = new QGridLayout(this); 53 57 { 54 m_pLocation Cnt= new QGroupBox(this);55 { 56 m_pLocation Cnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);57 QHBoxLayout *pLocation CntLayout = new QHBoxLayout(m_pLocationCnt);58 m_pLocationGroupBox = new QGroupBox(this); 59 { 60 m_pLocationGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 61 QHBoxLayout *pLocationGroupBoxLayout = new QHBoxLayout(m_pLocationGroupBox); 58 62 { 59 m_pLocationEditor = new QLineEdit(m_pLocation Cnt);60 m_pLocationOpenButton = new QIToolButton(m_pLocation Cnt);63 m_pLocationEditor = new QLineEdit(m_pLocationGroupBox); 64 m_pLocationOpenButton = new QIToolButton(m_pLocationGroupBox); 61 65 { 62 66 m_pLocationOpenButton->setAutoRaise(true); 63 67 m_pLocationOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", "select_file_disabled_16px.png")); 64 68 } 65 pLocation CntLayout->addWidget(m_pLocationEditor);66 pLocation CntLayout->addWidget(m_pLocationOpenButton);69 pLocationGroupBoxLayout->addWidget(m_pLocationEditor); 70 pLocationGroupBoxLayout->addWidget(m_pLocationOpenButton); 67 71 } 68 72 } … … 82 86 m_pFormatGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 83 87 QVBoxLayout *pFormatGroupBoxLayout = new QVBoxLayout(m_pFormatGroupBox); 84 { 85 m_pFormatButtonGroup = new QButtonGroup(m_pFormatGroupBox); 86 { 87 /* Enumerate medium formats in special order: */ 88 CSystemProperties properties = uiCommon().virtualBox().GetSystemProperties(); 89 const QVector<CMediumFormat> &formats = properties.GetMediumFormats(); 90 QMap<QString, CMediumFormat> vdi, preferred, others; 91 foreach (const CMediumFormat &format, formats) 92 { 93 /* VDI goes first: */ 94 if (format.GetName() == "VDI") 95 vdi[format.GetId()] = format; 96 else 97 { 98 const QVector<KMediumFormatCapabilities> &capabilities = format.GetCapabilities(); 99 /* Then goes preferred: */ 100 if (capabilities.contains(KMediumFormatCapabilities_Preferred)) 101 preferred[format.GetId()] = format; 102 /* Then others: */ 103 else 104 others[format.GetId()] = format; 105 } 106 } 107 108 /* Create buttons for VDI, preferred and others: */ 109 foreach (const QString &strId, vdi.keys()) 110 addFormatButton(this, pFormatGroupBoxLayout, vdi.value(strId), true); 111 foreach (const QString &strId, preferred.keys()) 112 addFormatButton(this, pFormatGroupBoxLayout, preferred.value(strId), true); 113 foreach (const QString &strId, others.keys()) 114 addFormatButton(this, pFormatGroupBoxLayout, others.value(strId)); 115 116 if (!m_pFormatButtonGroup->buttons().isEmpty()) 117 { 118 m_pFormatButtonGroup->button(0)->click(); 119 m_pFormatButtonGroup->button(0)->setFocus(); 120 } 121 } 122 } 88 pFormatGroupBoxLayout->addWidget(createFormatButtonGroup(true)); 123 89 } 124 90 m_pVariantGroupBox = new QGroupBox(this); … … 144 110 } 145 111 } 146 pMainLayout->addWidget(m_pLocation Cnt, 0, 0, 1, 2);112 pMainLayout->addWidget(m_pLocationGroupBox, 0, 0, 1, 2); 147 113 pMainLayout->addWidget(m_pSizeGroupBox, 1, 0, 1, 2); 148 114 pMainLayout->addWidget(m_pFormatGroupBox, 2, 0, Qt::AlignTop); … … 232 198 { 233 199 /* Translate widgets: */ 234 m_pLocationCnt->setTitle(UIWizardNewVD::tr("File &location")); 235 m_pLocationOpenButton->setToolTip(UIWizardNewVD::tr("Choose a location for new virtual hard disk file...")); 236 m_pSizeGroupBox->setTitle(UIWizardNewVD::tr("File &size")); 237 m_pFormatGroupBox->setTitle(UIWizardNewVD::tr("Hard disk file &type")); 238 QList<QAbstractButton*> buttons = m_pFormatButtonGroup->buttons(); 239 for (int i = 0; i < buttons.size(); ++i) 240 { 241 QAbstractButton *pButton = buttons[i]; 242 UIMediumFormat enmFormat = gpConverter->fromInternalString<UIMediumFormat>(m_formatNames[m_pFormatButtonGroup->id(pButton)]); 243 pButton->setText(gpConverter->toString(enmFormat)); 244 } 245 m_pVariantGroupBox->setTitle(UIWizardNewVD::tr("Storage on physical hard disk")); 246 m_pDynamicalButton->setText(UIWizardNewVD::tr("&Dynamically allocated")); 247 m_pFixedButton->setText(UIWizardNewVD::tr("&Fixed size")); 248 m_pSplitBox->setText(UIWizardNewVD::tr("&Split into files of less than 2GB")); 200 if (m_pLocationGroupBox) 201 m_pLocationGroupBox->setTitle(UIWizardNewVD::tr("File &location")); 202 if (m_pLocationOpenButton) 203 m_pLocationOpenButton->setToolTip(UIWizardNewVD::tr("Choose a location for new virtual hard disk file...")); 204 if (m_pSizeGroupBox) 205 m_pSizeGroupBox->setTitle(UIWizardNewVD::tr("File &size")); 206 if (m_pFormatGroupBox) 207 m_pFormatGroupBox->setTitle(UIWizardNewVD::tr("Hard disk file &type")); 208 if (m_pFormatButtonGroup) 209 { 210 QList<QAbstractButton*> buttons = m_pFormatButtonGroup->buttons(); 211 for (int i = 0; i < buttons.size(); ++i) 212 { 213 QAbstractButton *pButton = buttons[i]; 214 UIMediumFormat enmFormat = gpConverter->fromInternalString<UIMediumFormat>(m_formatNames[m_pFormatButtonGroup->id(pButton)]); 215 pButton->setText(gpConverter->toString(enmFormat)); 216 } 217 } 218 if (m_pVariantGroupBox) 219 m_pVariantGroupBox->setTitle(UIWizardNewVD::tr("Storage on physical hard disk")); 220 if (m_pDynamicalButton) 221 m_pDynamicalButton->setText(UIWizardNewVD::tr("&Dynamically allocated")); 222 if (m_pFixedButton) 223 m_pFixedButton->setText(UIWizardNewVD::tr("&Fixed size")); 224 if (m_pSplitBox) 225 m_pSplitBox->setText(UIWizardNewVD::tr("&Split into files of less than 2GB")); 249 226 } 250 227 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageExpert.h
r87845 r87850 80 80 QGroupBox *m_pFormatGroupBox; 81 81 QGroupBox *m_pVariantGroupBox; 82 QGroupBox *m_pLocation Cnt;82 QGroupBox *m_pLocationGroupBox; 83 83 QGroupBox *m_pSizeGroupBox; 84 84 };
Note:
See TracChangeset
for help on using the changeset viewer.