Changeset 84874 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jun 18, 2020 8:07:25 PM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp
r84870 r84874 132 132 m_machine.ApplyDefaults(QString()); 133 133 /* correct the RAM size. IMachine::applyDefaults may have overwritten the user setting: */ 134 m_machine.SetMemorySize(field(" ram").toUInt());134 m_machine.SetMemorySize(field("baseMemory").toUInt()); 135 135 /* Correct the VRAM size since API does not take fullscreen memory requirements into account: */ 136 136 CGraphicsAdapter comGraphics = m_machine.GetGraphicsAdapter(); … … 154 154 155 155 /* RAM size: */ 156 m_machine.SetMemorySize(field(" ram").toInt());156 m_machine.SetMemorySize(field("baseMemory").toInt()); 157 157 158 158 /* Graphics Controller type: */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic2.cpp
r82968 r84874 25 25 26 26 /* GUI includes: */ 27 #include "QIRichTextLabel.h" 28 #include "UIBaseMemoryEditor.h" 29 #include "UIBaseMemorySlider.h" 30 #include "UICommon.h" 27 31 #include "UIWizardNewVMPageBasic2.h" 28 32 #include "UIWizardNewVM.h" 29 #include "UICommon.h"30 #include "UIBaseMemorySlider.h"31 #include "QIRichTextLabel.h"32 33 33 34 34 35 UIWizardNewVMPage2::UIWizardNewVMPage2() 36 : m_pBaseMemoryEditor(0) 37 , m_pRamLabel(0) 35 38 { 36 39 } 37 40 38 void UIWizardNewVMPage2::onRamSliderValueChanged() 41 int UIWizardNewVMPage2::baseMemory() const 39 42 { 40 /* Update 'ram' field editor connected to slider: */ 41 m_pRamEditor->blockSignals(true); 42 m_pRamEditor->setValue(m_pRamSlider->value()); 43 m_pRamEditor->blockSignals(false); 44 } 45 46 void UIWizardNewVMPage2::onRamEditorValueChanged() 47 { 48 /* Update 'ram' field slider connected to editor: */ 49 m_pRamSlider->blockSignals(true); 50 m_pRamSlider->setValue(m_pRamEditor->value()); 51 m_pRamSlider->blockSignals(false); 43 if (!m_pBaseMemoryEditor) 44 return 0; 45 return m_pBaseMemoryEditor->value(); 52 46 } 53 47 54 48 UIWizardNewVMPageBasic2::UIWizardNewVMPageBasic2() 49 : m_pLabel(0) 55 50 { 56 51 /* Create widget: */ … … 60 55 QGridLayout *pMemoryLayout = new QGridLayout; 61 56 { 62 m_pRamSlider = new UIBaseMemorySlider(this); 63 { 64 m_pRamSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 65 m_pRamSlider->setOrientation(Qt::Horizontal); 66 } 67 m_pRamEditor = new QSpinBox(this); 68 { 69 m_pRamEditor->setMinimum(m_pRamSlider->minimum()); 70 m_pRamEditor->setMaximum(m_pRamSlider->maximum()); 71 uiCommon().setMinimumWidthAccordingSymbolCount(m_pRamEditor, 5); 72 } 73 m_pRamUnits = new QLabel(this); 74 { 75 m_pRamUnits->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 76 } 77 m_pRamMin = new QLabel(this); 78 { 79 m_pRamMin->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 80 } 81 m_pRamMax = new QLabel(this); 82 { 83 m_pRamMax->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 84 } 85 pMemoryLayout->addWidget(m_pRamSlider, 0, 0, 1, 3); 86 pMemoryLayout->addWidget(m_pRamEditor, 0, 3); 87 pMemoryLayout->addWidget(m_pRamUnits, 0, 4); 88 pMemoryLayout->addWidget(m_pRamMin, 1, 0); 89 pMemoryLayout->setColumnStretch(1, 1); 90 pMemoryLayout->addWidget(m_pRamMax, 1, 2); 57 m_pRamLabel = new QLabel; 58 m_pBaseMemoryEditor = new UIBaseMemoryEditor; 59 pMemoryLayout->addWidget(m_pRamLabel, 0, 0, 1, 1, Qt::AlignRight|Qt::AlignTop); 60 pMemoryLayout->addWidget(m_pBaseMemoryEditor, 0, 1, 1, 4); 91 61 } 92 pMainLayout->addWidget(m_pLabel); 62 if (m_pLabel) 63 pMainLayout->addWidget(m_pLabel); 93 64 pMainLayout->addLayout(pMemoryLayout); 94 65 pMainLayout->addStretch(); 95 66 } 96 67 97 /* Setup connections: */98 connect(m_pRamSlider, &UIBaseMemorySlider::valueChanged,99 this, &UIWizardNewVMPageBasic2::sltRamSliderValueChanged);100 connect(m_pRamEditor, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged),101 this, &UIWizardNewVMPageBasic2::sltRamEditorValueChanged);102 68 103 69 /* Register fields: */ 104 registerField("ram", m_pRamSlider, "value", SIGNAL(valueChanged(int))); 105 } 106 107 void UIWizardNewVMPageBasic2::sltRamSliderValueChanged() 108 { 109 /* Call to base-class: */ 110 onRamSliderValueChanged(); 111 112 /* Broadcast complete-change: */ 113 emit completeChanged(); 114 } 115 116 void UIWizardNewVMPageBasic2::sltRamEditorValueChanged() 117 { 118 /* Call to base-class: */ 119 onRamEditorValueChanged(); 120 121 /* Broadcast complete-change: */ 122 emit completeChanged(); 70 registerField("baseMemory", this, "baseMemory"); 123 71 } 124 72 … … 126 74 { 127 75 /* Translate page: */ 128 setTitle(UIWizardNewVM::tr(" Memory size"));76 setTitle(UIWizardNewVM::tr("Virtual Machine Settings")); 129 77 130 78 /* Translate widgets: */ 131 QString strRecommendedRAM = field("type").value<CGuestOSType>().isNull() ? 132 QString() : QString::number(field("type").value<CGuestOSType>().GetRecommendedRAM()); 133 m_pLabel->setText(UIWizardNewVM::tr("<p>Select the amount of memory (RAM) in megabytes " 134 "to be allocated to the virtual machine.</p>" 135 "<p>The recommended memory size is <b>%1</b> MB.</p>") 136 .arg(strRecommendedRAM)); 137 m_pRamUnits->setText(UICommon::tr("MB", "size suffix MBytes=1024 KBytes")); 138 m_pRamMin->setText(QString("%1 %2").arg(m_pRamSlider->minRAM()).arg(UICommon::tr("MB", "size suffix MBytes=1024 KBytes"))); 139 m_pRamMax->setText(QString("%1 %2").arg(m_pRamSlider->maxRAM()).arg(UICommon::tr("MB", "size suffix MBytes=1024 KBytes"))); 79 if (m_pLabel) 80 m_pLabel->setText(UIWizardNewVM::tr("<p>You can modify the virtual machine's hardware.</p>")); 81 82 if (m_pRamLabel) 83 m_pRamLabel->setText(UIWizardNewVM::tr("Base Memory:")); 140 84 } 141 85 … … 147 91 /* Get recommended 'ram' field value: */ 148 92 CGuestOSType type = field("type").value<CGuestOSType>(); 149 m_pRamSlider->setValue(type.GetRecommendedRAM()); 150 m_pRamEditor->setValue(type.GetRecommendedRAM()); 93 m_pBaseMemoryEditor->setValue(type.GetRecommendedRAM()); 151 94 152 95 /* 'Ram' field should have focus initially: */ 153 m_p RamSlider->setFocus();96 m_pBaseMemoryEditor->setFocus(); 154 97 } 155 98 156 99 bool UIWizardNewVMPageBasic2::isComplete() const 157 100 { 158 /* Make sure 'ram' field feats the bounds: */ 159 return m_pRamSlider->value() >= qMax(1, (int)m_pRamSlider->minRAM()) && 160 m_pRamSlider->value() <= (int)m_pRamSlider->maxRAM(); 101 return UIWizardPage::isComplete(); 161 102 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic2.h
r82968 r84874 27 27 /* Forward declarations: */ 28 28 class UIBaseMemorySlider; 29 class UIBaseMemoryEditor; 29 30 class QSpinBox; 30 31 class QLabel; … … 39 40 UIWizardNewVMPage2(); 40 41 41 /* Handlers: */ 42 void onRamSliderValueChanged(); 43 void onRamEditorValueChanged(); 42 int baseMemory() const; 44 43 45 44 /* Widgets: */ 46 UIBaseMemorySlider *m_pRamSlider; 47 QSpinBox *m_pRamEditor; 48 QLabel *m_pRamMin; 49 QLabel *m_pRamMax; 50 QLabel *m_pRamUnits; 45 UIBaseMemoryEditor *m_pBaseMemoryEditor; 46 QLabel *m_pRamLabel; 51 47 }; 52 48 … … 55 51 { 56 52 Q_OBJECT; 53 Q_PROPERTY(int baseMemory READ baseMemory); 57 54 58 55 public: … … 62 59 63 60 private slots: 64 65 /* Handlers: */66 void sltRamSliderValueChanged();67 void sltRamEditorValueChanged();68 61 69 62 private: … … 83 76 84 77 #endif /* !FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageBasic2_h */ 85 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp
r82968 r84874 30 30 #include "QIToolButton.h" 31 31 #include "UIBaseMemorySlider.h" 32 #include "UIBaseMemoryEditor.h" 32 33 #include "UIIconPool.h" 33 34 #include "UIMediaComboBox.h" … … 58 59 QGridLayout *pMemoryCntLayout = new QGridLayout(m_pMemoryCnt); 59 60 { 60 m_pRamSlider = new UIBaseMemorySlider(m_pMemoryCnt); 61 { 62 m_pRamSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 63 m_pRamSlider->setOrientation(Qt::Horizontal); 64 } 65 m_pRamEditor = new QSpinBox(m_pMemoryCnt); 66 { 67 m_pRamEditor->setMinimum(m_pRamSlider->minimum()); 68 m_pRamEditor->setMaximum(m_pRamSlider->maximum()); 69 uiCommon().setMinimumWidthAccordingSymbolCount(m_pRamEditor, 5); 70 } 71 m_pRamUnits = new QLabel(m_pMemoryCnt); 72 { 73 m_pRamUnits->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 74 } 75 m_pRamMin = new QLabel(m_pMemoryCnt); 76 { 77 m_pRamMin->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 78 } 79 m_pRamMax = new QLabel(m_pMemoryCnt); 80 { 81 m_pRamMax->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 82 } 83 pMemoryCntLayout->addWidget(m_pRamSlider, 0, 0, 1, 3); 84 pMemoryCntLayout->addWidget(m_pRamEditor, 0, 3); 85 pMemoryCntLayout->addWidget(m_pRamUnits, 0, 4); 86 pMemoryCntLayout->addWidget(m_pRamMin, 1, 0); 87 pMemoryCntLayout->setColumnStretch(1, 1); 88 pMemoryCntLayout->addWidget(m_pRamMax, 1, 2); 61 m_pBaseMemoryEditor = new UIBaseMemoryEditor; 62 pMemoryCntLayout->addWidget(m_pBaseMemoryEditor, 0, 0, 1, 4); 89 63 } 90 64 } … … 135 109 connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged, 136 110 this, &UIWizardNewVMPageExpert::sltOsTypeChanged); 137 connect(m_pRamSlider, &UIBaseMemorySlider::valueChanged,138 this, &UIWizardNewVMPageExpert::sltRamSliderValueChanged);139 connect(m_pRamEditor, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged),140 this, &UIWizardNewVMPageExpert::sltRamEditorValueChanged);141 111 connect(m_pDiskSkip, &QRadioButton::toggled, 142 112 this, &UIWizardNewVMPageExpert::sltVirtualDiskSourceChanged); … … 158 128 registerField("machineFolder", this, "machineFolder"); 159 129 registerField("machineBaseName", this, "machineBaseName"); 160 registerField(" ram", m_pRamSlider, "value", SIGNAL(valueChanged(int)));130 registerField("baseMemory", this, "baseMemory"); 161 131 registerField("virtualDisk", this, "virtualDisk"); 162 132 registerField("virtualDiskId", this, "virtualDiskId"); … … 171 141 /* Fetch recommended RAM value: */ 172 142 CGuestOSType type = m_pNameAndSystemEditor->type(); 173 m_pRamSlider->setValue(type.GetRecommendedRAM());174 m_pRamEditor->setValue(type.GetRecommendedRAM());175 143 176 144 composeMachineFilePath(); … … 192 160 /* Fetch recommended RAM value: */ 193 161 CGuestOSType type = m_pNameAndSystemEditor->type(); 194 m_pRamSlider->setValue(type.GetRecommendedRAM()); 195 m_pRamEditor->setValue(type.GetRecommendedRAM()); 196 197 /* Broadcast complete-change: */ 198 emit completeChanged(); 199 } 200 201 void UIWizardNewVMPageExpert::sltRamSliderValueChanged() 202 { 203 /* Call to base-class: */ 204 onRamSliderValueChanged(); 205 206 /* Broadcast complete-change: */ 207 emit completeChanged(); 208 } 209 210 void UIWizardNewVMPageExpert::sltRamEditorValueChanged() 211 { 212 /* Call to base-class: */ 213 onRamEditorValueChanged(); 162 m_pBaseMemoryEditor->setValue(type.GetRecommendedRAM()); 214 163 215 164 /* Broadcast complete-change: */ … … 237 186 m_pNameAndSystemCnt->setTitle(UIWizardNewVM::tr("Name and operating system")); 238 187 m_pMemoryCnt->setTitle(UIWizardNewVM::tr("&Memory size")); 239 m_pRamUnits->setText(UICommon::tr("MB", "size suffix MBytes=1024 KBytes"));240 m_pRamMin->setText(QString("%1 %2").arg(m_pRamSlider->minRAM()).arg(UICommon::tr("MB", "size suffix MBytes=1024 KBytes")));241 m_pRamMax->setText(QString("%1 %2").arg(m_pRamSlider->maxRAM()).arg(UICommon::tr("MB", "size suffix MBytes=1024 KBytes")));242 188 m_pDiskCnt->setTitle(UIWizardNewVM::tr("Hard disk")); 243 189 m_pDiskSkip->setText(UIWizardNewVM::tr("&Do not add a virtual hard disk")); … … 255 201 CGuestOSType type = field("type").value<CGuestOSType>(); 256 202 ULONG recommendedRam = type.GetRecommendedRAM(); 257 m_pRamSlider->setValue(recommendedRam); 258 m_pRamEditor->setValue(recommendedRam); 259 203 m_pBaseMemoryEditor->setValue(recommendedRam); 260 204 } 261 205 … … 273 217 * 'virtualDisk' field feats the rules: */ 274 218 return UIWizardPage::isComplete() && 275 (m_pRamSlider->value() >= qMax(1, (int)m_pRamSlider->minRAM()) && m_pRamSlider->value() <= (int)m_pRamSlider->maxRAM()) &&276 219 (m_pDiskSkip->isChecked() || !m_pDiskPresent->isChecked() || !uiCommon().medium(m_pDiskSelector->id()).isNull()); 277 220 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.h
r82968 r84874 43 43 Q_PROPERTY(QUuid virtualDiskId READ virtualDiskId WRITE setVirtualDiskId); 44 44 Q_PROPERTY(QString virtualDiskLocation READ virtualDiskLocation WRITE setVirtualDiskLocation); 45 Q_PROPERTY(int baseMemory READ baseMemory); 45 46 46 47 public: … … 64 65 void sltPathChanged(const QString &strNewPath); 65 66 void sltOsTypeChanged(); 66 void sltRamSliderValueChanged();67 void sltRamEditorValueChanged();68 67 void sltVirtualDiskSourceChanged(); 69 68 void sltGetWithFileOpenDialog();
Note:
See TracChangeset
for help on using the changeset viewer.