Changeset 87890 in vbox
- Timestamp:
- Feb 26, 2021 3:18:33 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/wizards
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic2.cpp
r87878 r87890 35 35 , m_pFixedButton(0) 36 36 , m_pSplitBox(0) 37 { 37 , m_pDescriptionLabel(0) 38 , m_pDynamicLabel(0) 39 , m_pFixedLabel(0) 40 , m_pSplitLabel(0) 41 { 42 } 43 44 QWidget *UIWizardNewVDPage2::createMediumVariantWidgets(bool fWithLabels) 45 { 46 QWidget *pContainerWidget = new QWidget; 47 QVBoxLayout *pMainLayout = new QVBoxLayout(pContainerWidget); 48 if (pMainLayout) 49 { 50 if (fWithLabels) 51 { 52 m_pDescriptionLabel = new QIRichTextLabel; 53 m_pDynamicLabel = new QIRichTextLabel; 54 m_pFixedLabel = new QIRichTextLabel; 55 m_pSplitLabel = new QIRichTextLabel; 56 } 57 QVBoxLayout *pVariantLayout = new QVBoxLayout; 58 if (pVariantLayout) 59 { 60 m_pVariantButtonGroup = new QButtonGroup; 61 { 62 m_pDynamicalButton = new QRadioButton; 63 { 64 m_pDynamicalButton->click(); 65 m_pDynamicalButton->setFocus(); 66 } 67 m_pFixedButton = new QRadioButton; 68 m_pVariantButtonGroup->addButton(m_pDynamicalButton, 0); 69 m_pVariantButtonGroup->addButton(m_pFixedButton, 1); 70 } 71 m_pSplitBox = new QCheckBox; 72 pVariantLayout->addWidget(m_pDynamicalButton); 73 pVariantLayout->addWidget(m_pFixedButton); 74 pVariantLayout->addWidget(m_pSplitBox); 75 } 76 if (fWithLabels) 77 { 78 pMainLayout->addWidget(m_pDescriptionLabel); 79 pMainLayout->addWidget(m_pDynamicLabel); 80 pMainLayout->addWidget(m_pFixedLabel); 81 pMainLayout->addWidget(m_pSplitLabel); 82 } 83 pMainLayout->addLayout(pVariantLayout); 84 pMainLayout->addStretch(); 85 } 86 return pContainerWidget; 38 87 } 39 88 … … 77 126 void UIWizardNewVDPage2::retranslateWidgets() 78 127 { 79 m_pDynamicalButton->setText(UIWizardNewVD::tr("&Dynamically allocated")); 80 m_pFixedButton->setText(UIWizardNewVD::tr("&Fixed size")); 81 m_pSplitBox->setText(UIWizardNewVD::tr("&Split into files of less than 2GB")); 128 if (m_pDynamicalButton) 129 m_pDynamicalButton->setText(UIWizardNewVD::tr("&Dynamically allocated")); 130 if (m_pFixedButton) 131 m_pFixedButton->setText(UIWizardNewVD::tr("&Fixed size")); 132 if (m_pSplitBox) 133 m_pSplitBox->setText(UIWizardNewVD::tr("&Split into files of less than 2GB")); 134 135 136 /* Translate rich text labels: */ 137 if (m_pDescriptionLabel) 138 m_pDescriptionLabel->setText(UIWizardNewVD::tr("Please choose whether the new virtual hard disk file should grow as it is used " 139 "(dynamically allocated) or if it should be created at its maximum size (fixed size).")); 140 if (m_pDynamicLabel) 141 m_pDynamicLabel->setText(UIWizardNewVD::tr("<p>A <b>dynamically allocated</b> hard disk file will only use space " 142 "on your physical hard disk as it fills up (up to a maximum <b>fixed size</b>), " 143 "although it will not shrink again automatically when space on it is freed.</p>")); 144 if (m_pFixedLabel) 145 m_pFixedLabel->setText(UIWizardNewVD::tr("<p>A <b>fixed size</b> hard disk file may take longer to create on some " 146 "systems but is often faster to use.</p>")); 147 if (m_pSplitLabel) 148 m_pSplitLabel->setText(UIWizardNewVD::tr("<p>You can also choose to <b>split</b> the hard disk file into several files " 149 "of up to two gigabytes each. This is mainly useful if you wish to store the " 150 "virtual machine on removable USB devices or old systems, some of which cannot " 151 "handle very large files.")); 152 } 153 154 void UIWizardNewVDPage2::setWidgetVisibility(CMediumFormat &mediumFormat) 155 { 156 ULONG uCapabilities = 0; 157 QVector<KMediumFormatCapabilities> capabilities; 158 capabilities = mediumFormat.GetCapabilities(); 159 for (int i = 0; i < capabilities.size(); i++) 160 uCapabilities |= capabilities[i]; 161 162 bool fIsCreateDynamicPossible = uCapabilities & KMediumFormatCapabilities_CreateDynamic; 163 bool fIsCreateFixedPossible = uCapabilities & KMediumFormatCapabilities_CreateFixed; 164 bool fIsCreateSplitPossible = uCapabilities & KMediumFormatCapabilities_CreateSplit2G; 165 if (m_pDynamicLabel) 166 m_pDynamicLabel->setHidden(!fIsCreateDynamicPossible); 167 if (m_pDynamicalButton) 168 m_pDynamicalButton->setHidden(!fIsCreateDynamicPossible); 169 if (m_pFixedLabel) 170 m_pFixedLabel->setHidden(!fIsCreateFixedPossible); 171 if (m_pFixedButton) 172 m_pFixedButton->setHidden(!fIsCreateFixedPossible); 173 if (m_pSplitLabel) 174 m_pSplitLabel->setHidden(!fIsCreateSplitPossible); 175 if (m_pSplitBox) 176 m_pSplitBox->setHidden(!fIsCreateSplitPossible); 82 177 } 83 178 … … 86 181 /* Create widgets: */ 87 182 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 88 { 89 m_pDescriptionLabel = new QIRichTextLabel(this); 90 m_pDynamicLabel = new QIRichTextLabel(this); 91 m_pFixedLabel = new QIRichTextLabel(this); 92 m_pSplitLabel = new QIRichTextLabel(this); 93 QVBoxLayout *pVariantLayout = new QVBoxLayout; 94 { 95 m_pVariantButtonGroup = new QButtonGroup(this); 96 { 97 m_pDynamicalButton = new QRadioButton(this); 98 { 99 m_pDynamicalButton->click(); 100 m_pDynamicalButton->setFocus(); 101 } 102 m_pFixedButton = new QRadioButton(this); 103 m_pVariantButtonGroup->addButton(m_pDynamicalButton, 0); 104 m_pVariantButtonGroup->addButton(m_pFixedButton, 1); 105 } 106 m_pSplitBox = new QCheckBox(this); 107 pVariantLayout->addWidget(m_pDynamicalButton); 108 pVariantLayout->addWidget(m_pFixedButton); 109 pVariantLayout->addWidget(m_pSplitBox); 110 } 111 pMainLayout->addWidget(m_pDescriptionLabel); 112 pMainLayout->addWidget(m_pDynamicLabel); 113 pMainLayout->addWidget(m_pFixedLabel); 114 pMainLayout->addWidget(m_pSplitLabel); 115 pMainLayout->addLayout(pVariantLayout); 116 pMainLayout->addStretch(); 117 } 183 pMainLayout->addWidget(createMediumVariantWidgets(true)); 184 pMainLayout->addStretch(); 118 185 119 186 /* Setup connections: */ … … 132 199 /* Translate page: */ 133 200 setTitle(UIWizardNewVD::tr("Storage on physical hard disk")); 134 135 /* Translate widgets: */136 m_pDescriptionLabel->setText(UIWizardNewVD::tr("Please choose whether the new virtual hard disk file should grow as it is used "137 "(dynamically allocated) or if it should be created at its maximum size (fixed size)."));138 m_pDynamicLabel->setText(UIWizardNewVD::tr("<p>A <b>dynamically allocated</b> hard disk file will only use space "139 "on your physical hard disk as it fills up (up to a maximum <b>fixed size</b>), "140 "although it will not shrink again automatically when space on it is freed.</p>"));141 m_pFixedLabel->setText(UIWizardNewVD::tr("<p>A <b>fixed size</b> hard disk file may take longer to create on some "142 "systems but is often faster to use.</p>"));143 m_pSplitLabel->setText(UIWizardNewVD::tr("<p>You can also choose to <b>split</b> the hard disk file into several files "144 "of up to two gigabytes each. This is mainly useful if you wish to store the "145 "virtual machine on removable USB devices or old systems, some of which cannot "146 "handle very large files."));147 201 } 148 202 … … 151 205 /* Translate page: */ 152 206 retranslateUi(); 153 154 /* Setup visibility: */155 207 CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>(); 156 ULONG uCapabilities = 0; 157 QVector<KMediumFormatCapabilities> capabilities; 158 capabilities = mediumFormat.GetCapabilities(); 159 for (int i = 0; i < capabilities.size(); i++) 160 uCapabilities |= capabilities[i]; 161 162 bool fIsCreateDynamicPossible = uCapabilities & KMediumFormatCapabilities_CreateDynamic; 163 bool fIsCreateFixedPossible = uCapabilities & KMediumFormatCapabilities_CreateFixed; 164 bool fIsCreateSplitPossible = uCapabilities & KMediumFormatCapabilities_CreateSplit2G; 165 m_pDynamicLabel->setHidden(!fIsCreateDynamicPossible); 166 m_pDynamicalButton->setHidden(!fIsCreateDynamicPossible); 167 m_pFixedLabel->setHidden(!fIsCreateFixedPossible); 168 m_pFixedButton->setHidden(!fIsCreateFixedPossible); 169 m_pSplitLabel->setHidden(!fIsCreateSplitPossible); 170 m_pSplitBox->setHidden(!fIsCreateSplitPossible); 208 setWidgetVisibility(mediumFormat); 171 209 } 172 210 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic2.h
r87889 r87890 26 26 27 27 /* Forward declarations: */ 28 class CMediumFormat; 28 29 class QButtonGroup; 29 30 class QRadioButton; … … 37 38 protected: 38 39 39 /* Constructor: */40 /** Constructor: */ 40 41 UIWizardNewVDPage2(); 41 42 42 /* Stuff for 'variant' field: */43 QWidget *createMediumVariantWidgets(bool fWithLabels); 43 44 qulonglong mediumVariant() const; 44 45 void setMediumVariant(qulonglong uMediumVariant); 45 46 void retranslateWidgets(); 47 /** Check Medium format capability and decide if certain widgets can be shown. */ 48 void setWidgetVisibility(CMediumFormat &mediumFormat); 49 /** @name Widgets 50 * @{ */ 51 QButtonGroup *m_pVariantButtonGroup; 52 QRadioButton *m_pDynamicalButton; 53 QRadioButton *m_pFixedButton; 54 QCheckBox *m_pSplitBox; 55 /** @} */ 46 56 47 /* Widgets: */ 48 QButtonGroup *m_pVariantButtonGroup; 49 QRadioButton *m_pDynamicalButton; 50 QRadioButton *m_pFixedButton; 51 QCheckBox *m_pSplitBox; 57 /** @name Rich text labels. Declared/defined here since the are shared in more than one child class 58 * @{ */ 59 QIRichTextLabel *m_pDescriptionLabel; 60 QIRichTextLabel *m_pDynamicLabel; 61 QIRichTextLabel *m_pFixedLabel; 62 QIRichTextLabel *m_pSplitLabel; 63 /** @} */ 52 64 }; 53 65 … … 74 86 /* Validation stuff: */ 75 87 bool isComplete() const; 76 77 /* Widgets: */78 QIRichTextLabel *m_pDescriptionLabel;79 QIRichTextLabel *m_pDynamicLabel;80 QIRichTextLabel *m_pFixedLabel;81 QIRichTextLabel *m_pSplitLabel;82 88 }; 83 89 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic5.cpp
r87889 r87890 35 35 36 36 UIWizardNewVMPageBasic5::UIWizardNewVMPageBasic5() 37 : m_pLabel(0)38 37 { 39 38 prepare(); … … 60 59 61 60 m_strDefaultExtension = defaultExtension(m_mediumFormat); 61 62 /* Since the medium format is static we can decide widget visibility here: */ 63 setWidgetVisibility(m_mediumFormat); 62 64 } 63 65 … … 69 71 void UIWizardNewVMPageBasic5::prepare() 70 72 { 73 74 71 75 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 76 pMainLayout->addWidget(createMediumVariantWidgets(true)); 77 pMainLayout->addStretch(); 72 78 73 m_pLabel = new QIRichTextLabel(this); 74 pMainLayout->addWidget(m_pLabel); 79 // connect(m_pVariantButtonGroup,static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked), 80 // this, &UIWizardNewVDPageBasic2::completeChanged); 81 // connect(m_pSplitBox, &QCheckBox::stateChanged, 82 // this, &UIWizardNewVDPageBasic2::completeChanged); 75 83 76 pMainLayout->addStretch(); 77 createConnections(); 84 // QVBoxLayout *pMainLayout = new QVBoxLayout(this); 85 86 87 // m_pLabel = new QIRichTextLabel(this); 88 // pMainLayout->addWidget(m_pLabel); 89 90 // pMainLayout->addStretch(); 91 // createConnections(); 78 92 } 79 93 … … 84 98 void UIWizardNewVMPageBasic5::retranslateUi() 85 99 { 86 setTitle(UIWizardNewVM::tr("Hardware")); 100 setTitle(UIWizardNewVM::tr("Storage on physical hard disk")); 101 UIWizardNewVDPage2::retranslateWidgets(); 87 102 88 if (m_pLabel)89 m_pLabel->setText(UIWizardNewVM::tr("<p>You can modify virtual machine's hardware by changing amount of RAM and "90 "virtual CPU count.</p>"));91 103 92 104 //retranslateWidgets(); … … 100 112 m_strDefaultPath = fieldImp("machineFolder").toString(); 101 113 // fieldImp("type").value<CGuestOSType>().GetRecommendedHDD() 114 102 115 retranslateUi(); 103 116 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic5.h
r87889 r87890 85 85 86 86 87 /** Widgets. */88 QIRichTextLabel *m_pLabel;89 87 /** For guided new vm wizard VDI is the only format. Thus we have no UI item for it. */ 90 88 CMediumFormat m_mediumFormat;
Note:
See TracChangeset
for help on using the changeset viewer.