VirtualBox

Ignore:
Timestamp:
Jun 18, 2020 8:07:25 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9515. Using UIBaseMemortEditor instead of separate widget.

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  
    132132    m_machine.ApplyDefaults(QString());
    133133    /* 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());
    135135    /* Correct the VRAM size since API does not take fullscreen memory requirements into account: */
    136136    CGraphicsAdapter comGraphics = m_machine.GetGraphicsAdapter();
     
    154154
    155155    /* RAM size: */
    156     m_machine.SetMemorySize(field("ram").toInt());
     156    m_machine.SetMemorySize(field("baseMemory").toInt());
    157157
    158158    /* Graphics Controller type: */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic2.cpp

    r82968 r84874  
    2525
    2626/* GUI includes: */
     27#include "QIRichTextLabel.h"
     28#include "UIBaseMemoryEditor.h"
     29#include "UIBaseMemorySlider.h"
     30#include "UICommon.h"
    2731#include "UIWizardNewVMPageBasic2.h"
    2832#include "UIWizardNewVM.h"
    29 #include "UICommon.h"
    30 #include "UIBaseMemorySlider.h"
    31 #include "QIRichTextLabel.h"
    3233
    3334
    3435UIWizardNewVMPage2::UIWizardNewVMPage2()
     36    : m_pBaseMemoryEditor(0)
     37    , m_pRamLabel(0)
    3538{
    3639}
    3740
    38 void UIWizardNewVMPage2::onRamSliderValueChanged()
     41int UIWizardNewVMPage2::baseMemory() const
    3942{
    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();
    5246}
    5347
    5448UIWizardNewVMPageBasic2::UIWizardNewVMPageBasic2()
     49    : m_pLabel(0)
    5550{
    5651    /* Create widget: */
     
    6055        QGridLayout *pMemoryLayout = new QGridLayout;
    6156        {
    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);
    9161        }
    92         pMainLayout->addWidget(m_pLabel);
     62        if (m_pLabel)
     63            pMainLayout->addWidget(m_pLabel);
    9364        pMainLayout->addLayout(pMemoryLayout);
    9465        pMainLayout->addStretch();
    9566    }
    9667
    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);
    10268
    10369    /* 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");
    12371}
    12472
     
    12674{
    12775    /* Translate page: */
    128     setTitle(UIWizardNewVM::tr("Memory size"));
     76    setTitle(UIWizardNewVM::tr("Virtual Machine Settings"));
    12977
    13078    /* 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:"));
    14084}
    14185
     
    14791    /* Get recommended 'ram' field value: */
    14892    CGuestOSType type = field("type").value<CGuestOSType>();
    149     m_pRamSlider->setValue(type.GetRecommendedRAM());
    150     m_pRamEditor->setValue(type.GetRecommendedRAM());
     93    m_pBaseMemoryEditor->setValue(type.GetRecommendedRAM());
    15194
    15295    /* 'Ram' field should have focus initially: */
    153     m_pRamSlider->setFocus();
     96    m_pBaseMemoryEditor->setFocus();
    15497}
    15598
    15699bool UIWizardNewVMPageBasic2::isComplete() const
    157100{
    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();
    161102}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic2.h

    r82968 r84874  
    2727/* Forward declarations: */
    2828class UIBaseMemorySlider;
     29class UIBaseMemoryEditor;
    2930class QSpinBox;
    3031class QLabel;
     
    3940    UIWizardNewVMPage2();
    4041
    41     /* Handlers: */
    42     void onRamSliderValueChanged();
    43     void onRamEditorValueChanged();
     42    int baseMemory() const;
    4443
    4544    /* 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;
    5147};
    5248
     
    5551{
    5652    Q_OBJECT;
     53    Q_PROPERTY(int baseMemory READ baseMemory);
    5754
    5855public:
     
    6259
    6360private slots:
    64 
    65     /* Handlers: */
    66     void sltRamSliderValueChanged();
    67     void sltRamEditorValueChanged();
    6861
    6962private:
     
    8376
    8477#endif /* !FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageBasic2_h */
    85 
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp

    r82968 r84874  
    3030#include "QIToolButton.h"
    3131#include "UIBaseMemorySlider.h"
     32#include "UIBaseMemoryEditor.h"
    3233#include "UIIconPool.h"
    3334#include "UIMediaComboBox.h"
     
    5859            QGridLayout *pMemoryCntLayout = new QGridLayout(m_pMemoryCnt);
    5960            {
    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);
    8963            }
    9064        }
     
    135109    connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged,
    136110            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);
    141111    connect(m_pDiskSkip, &QRadioButton::toggled,
    142112            this, &UIWizardNewVMPageExpert::sltVirtualDiskSourceChanged);
     
    158128    registerField("machineFolder", this, "machineFolder");
    159129    registerField("machineBaseName", this, "machineBaseName");
    160     registerField("ram", m_pRamSlider, "value", SIGNAL(valueChanged(int)));
     130    registerField("baseMemory", this, "baseMemory");
    161131    registerField("virtualDisk", this, "virtualDisk");
    162132    registerField("virtualDiskId", this, "virtualDiskId");
     
    171141    /* Fetch recommended RAM value: */
    172142    CGuestOSType type = m_pNameAndSystemEditor->type();
    173     m_pRamSlider->setValue(type.GetRecommendedRAM());
    174     m_pRamEditor->setValue(type.GetRecommendedRAM());
    175143
    176144    composeMachineFilePath();
     
    192160    /* Fetch recommended RAM value: */
    193161    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());
    214163
    215164    /* Broadcast complete-change: */
     
    237186    m_pNameAndSystemCnt->setTitle(UIWizardNewVM::tr("Name and operating system"));
    238187    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")));
    242188    m_pDiskCnt->setTitle(UIWizardNewVM::tr("Hard disk"));
    243189    m_pDiskSkip->setText(UIWizardNewVM::tr("&Do not add a virtual hard disk"));
     
    255201    CGuestOSType type = field("type").value<CGuestOSType>();
    256202    ULONG recommendedRam = type.GetRecommendedRAM();
    257     m_pRamSlider->setValue(recommendedRam);
    258     m_pRamEditor->setValue(recommendedRam);
    259 
     203    m_pBaseMemoryEditor->setValue(recommendedRam);
    260204}
    261205
     
    273217     * 'virtualDisk' field feats the rules: */
    274218    return UIWizardPage::isComplete() &&
    275            (m_pRamSlider->value() >= qMax(1, (int)m_pRamSlider->minRAM()) && m_pRamSlider->value() <= (int)m_pRamSlider->maxRAM()) &&
    276219           (m_pDiskSkip->isChecked() || !m_pDiskPresent->isChecked() || !uiCommon().medium(m_pDiskSelector->id()).isNull());
    277220}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.h

    r82968 r84874  
    4343    Q_PROPERTY(QUuid virtualDiskId READ virtualDiskId WRITE setVirtualDiskId);
    4444    Q_PROPERTY(QString virtualDiskLocation READ virtualDiskLocation WRITE setVirtualDiskLocation);
     45    Q_PROPERTY(int baseMemory READ baseMemory);
    4546
    4647public:
     
    6465    void sltPathChanged(const QString &strNewPath);
    6566    void sltOsTypeChanged();
    66     void sltRamSliderValueChanged();
    67     void sltRamEditorValueChanged();
    6867    void sltVirtualDiskSourceChanged();
    6968    void sltGetWithFileOpenDialog();
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette