VirtualBox

Changeset 47814 in vbox


Ignore:
Timestamp:
Aug 16, 2013 1:46:11 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: Wizards: New VM wizard: Rework RAM editor to be spin-box, add corresponding validation.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic2.cpp

    r46496 r47814  
    2424#include <QSpacerItem>
    2525#include <QLabel>
     26#include <QSpinBox>
    2627
    2728/* GUI includes: */
     
    3031#include "VBoxGlobal.h"
    3132#include "VBoxGuestRAMSlider.h"
    32 #include "QILineEdit.h"
    3333#include "QIRichTextLabel.h"
    3434
     
    3737}
    3838
    39 void UIWizardNewVMPage2::onRamSliderValueChanged(int iValue)
     39void UIWizardNewVMPage2::onRamSliderValueChanged()
    4040{
    4141    /* Update 'ram' field editor connected to slider: */
    4242    m_pRamEditor->blockSignals(true);
    43     m_pRamEditor->setText(QString::number(iValue));
     43    m_pRamEditor->setValue(m_pRamSlider->value());
    4444    m_pRamEditor->blockSignals(false);
    4545}
    4646
    47 void UIWizardNewVMPage2::onRamEditorTextChanged(const QString &strText)
     47void UIWizardNewVMPage2::onRamEditorValueChanged()
    4848{
    4949    /* Update 'ram' field slider connected to editor: */
    5050    m_pRamSlider->blockSignals(true);
    51     m_pRamSlider->setValue(strText.toInt());
     51    m_pRamSlider->setValue(m_pRamEditor->value());
    5252    m_pRamSlider->blockSignals(false);
    5353}
     
    6666                m_pRamSlider->setOrientation(Qt::Horizontal);
    6767            }
    68             m_pRamEditor = new QILineEdit(this);
     68            m_pRamEditor = new QSpinBox(this);
    6969            {
    70                 m_pRamEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    71                 m_pRamEditor->setFixedWidthByText("88888");
    72                 m_pRamEditor->setAlignment(Qt::AlignRight);
    73                 m_pRamEditor->setValidator(new QIntValidator(m_pRamSlider->minRAM(), m_pRamSlider->maxRAM(), this));
     70                m_pRamEditor->setMinimum(m_pRamSlider->minRAM());
     71                m_pRamEditor->setMaximum(m_pRamSlider->maxRAM());
     72                vboxGlobal().setMinimumWidthAccordingSymbolCount(m_pRamEditor, 5);
    7473            }
    7574            m_pRamUnits = new QLabel(this);
     
    9897
    9998    /* Setup connections: */
    100     connect(m_pRamSlider, SIGNAL(valueChanged(int)), this, SLOT(sltRamSliderValueChanged(int)));
    101     connect(m_pRamEditor, SIGNAL(textChanged(const QString&)), this, SLOT(sltRamEditorTextChanged(const QString&)));
     99    connect(m_pRamSlider, SIGNAL(valueChanged(int)), this, SLOT(sltRamSliderValueChanged()));
     100    connect(m_pRamEditor, SIGNAL(valueChanged(int)), this, SLOT(sltRamEditorValueChanged()));
    102101
    103102    /* Register fields: */
     
    105104}
    106105
    107 void UIWizardNewVMPageBasic2::sltRamSliderValueChanged(int iValue)
     106void UIWizardNewVMPageBasic2::sltRamSliderValueChanged()
    108107{
    109108    /* Call to base-class: */
    110     onRamSliderValueChanged(iValue);
     109    onRamSliderValueChanged();
    111110
    112111    /* Broadcast complete-change: */
     
    114113}
    115114
    116 void UIWizardNewVMPageBasic2::sltRamEditorTextChanged(const QString &strText)
     115void UIWizardNewVMPageBasic2::sltRamEditorValueChanged()
    117116{
    118117    /* Call to base-class: */
    119     onRamEditorTextChanged(strText);
     118    onRamEditorValueChanged();
    120119
    121120    /* Broadcast complete-change: */
     
    148147    CGuestOSType type = field("type").value<CGuestOSType>();
    149148    m_pRamSlider->setValue(type.GetRecommendedRAM());
    150     m_pRamEditor->setText(QString::number(type.GetRecommendedRAM()));
     149    m_pRamEditor->setValue(type.GetRecommendedRAM());
    151150
    152151    /* 'Ram' field should have focus initially: */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic2.h

    r41389 r47814  
    2525/* Forward declarations: */
    2626class VBoxGuestRAMSlider;
    27 class QILineEdit;
     27class QSpinBox;
    2828class QLabel;
    2929class QIRichTextLabel;
     
    3838
    3939    /* Handlers: */
    40     void onRamSliderValueChanged(int iValue);
    41     void onRamEditorTextChanged(const QString &strText);
     40    void onRamSliderValueChanged();
     41    void onRamEditorValueChanged();
    4242
    4343    /* Widgets: */
    4444    VBoxGuestRAMSlider *m_pRamSlider;
    45     QILineEdit *m_pRamEditor;
     45    QSpinBox *m_pRamEditor;
    4646    QLabel *m_pRamMin;
    4747    QLabel *m_pRamMax;
     
    6262
    6363    /* Handlers: */
    64     void sltRamSliderValueChanged(int iValue);
    65     void sltRamEditorTextChanged(const QString &strText);
     64    void sltRamSliderValueChanged();
     65    void sltRamEditorValueChanged();
    6666
    6767private:
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp

    r47184 r47814  
    2626#include <QLineEdit>
    2727#include <QLabel>
     28#include <QSpinBox>
    2829#include <QRadioButton>
    2930
     
    3536#include "VBoxGuestRAMSlider.h"
    3637#include "VBoxMediaComboBox.h"
    37 #include "QILineEdit.h"
    3838#include "QIToolButton.h"
    3939
     
    6666                    m_pRamSlider->setValue(m_pNameAndSystemEditor->type().GetRecommendedRAM());
    6767                }
    68                 m_pRamEditor = new QILineEdit(m_pMemoryCnt);
    69                 {
    70                     m_pRamEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    71                     m_pRamEditor->setFixedWidthByText("88888");
    72                     m_pRamEditor->setAlignment(Qt::AlignRight);
    73                     m_pRamEditor->setValidator(new QIntValidator(m_pRamSlider->minRAM(), m_pRamSlider->maxRAM(), this));
    74                     m_pRamEditor->setText(QString::number(m_pNameAndSystemEditor->type().GetRecommendedRAM()));
     68                m_pRamEditor = new QSpinBox(m_pMemoryCnt);
     69                {
     70                    m_pRamEditor->setMinimum(m_pRamSlider->minRAM());
     71                    m_pRamEditor->setMaximum(m_pRamSlider->maxRAM());
     72                    vboxGlobal().setMinimumWidthAccordingSymbolCount(m_pRamEditor, 5);
    7573                }
    7674                m_pRamUnits = new QLabel(m_pMemoryCnt);
     
    136134    connect(m_pNameAndSystemEditor, SIGNAL(sigNameChanged(const QString &)), this, SLOT(sltNameChanged(const QString &)));
    137135    connect(m_pNameAndSystemEditor, SIGNAL(sigOsTypeChanged()), this, SLOT(sltOsTypeChanged()));
    138     connect(m_pRamSlider, SIGNAL(valueChanged(int)), this, SLOT(sltRamSliderValueChanged(int)));
    139     connect(m_pRamEditor, SIGNAL(textChanged(const QString &)), this, SLOT(sltRamEditorTextChanged(const QString &)));
     136    connect(m_pRamSlider, SIGNAL(valueChanged(int)), this, SLOT(sltRamSliderValueChanged()));
     137    connect(m_pRamEditor, SIGNAL(valueChanged(int)), this, SLOT(sltRamEditorValueChanged()));
    140138    connect(m_pDiskSkip, SIGNAL(toggled(bool)), this, SLOT(sltVirtualDiskSourceChanged()));
    141139    connect(m_pDiskCreate, SIGNAL(toggled(bool)), this, SLOT(sltVirtualDiskSourceChanged()));
     
    165163    CGuestOSType type = m_pNameAndSystemEditor->type();
    166164    m_pRamSlider->setValue(type.GetRecommendedRAM());
    167     m_pRamEditor->setText(QString::number(type.GetRecommendedRAM()));
     165    m_pRamEditor->setValue(type.GetRecommendedRAM());
    168166
    169167    /* Broadcast complete-change: */
     
    179177    CGuestOSType type = m_pNameAndSystemEditor->type();
    180178    m_pRamSlider->setValue(type.GetRecommendedRAM());
    181     m_pRamEditor->setText(QString::number(type.GetRecommendedRAM()));
    182 
    183     /* Broadcast complete-change: */
    184     emit completeChanged();
    185 }
    186 
    187 void UIWizardNewVMPageExpert::sltRamSliderValueChanged(int iValue)
    188 {
    189     /* Call to base-class: */
    190     onRamSliderValueChanged(iValue);
    191 
    192     /* Broadcast complete-change: */
    193     emit completeChanged();
    194 }
    195 
    196 void UIWizardNewVMPageExpert::sltRamEditorTextChanged(const QString &strText)
    197 {
    198     /* Call to base-class: */
    199     onRamEditorTextChanged(strText);
     179    m_pRamEditor->setValue(type.GetRecommendedRAM());
     180
     181    /* Broadcast complete-change: */
     182    emit completeChanged();
     183}
     184
     185void UIWizardNewVMPageExpert::sltRamSliderValueChanged()
     186{
     187    /* Call to base-class: */
     188    onRamSliderValueChanged();
     189
     190    /* Broadcast complete-change: */
     191    emit completeChanged();
     192}
     193
     194void UIWizardNewVMPageExpert::sltRamEditorValueChanged()
     195{
     196    /* Call to base-class: */
     197    onRamEditorValueChanged();
    200198
    201199    /* Broadcast complete-change: */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.h

    r42616 r47814  
    6060    void sltNameChanged(const QString &strNewText);
    6161    void sltOsTypeChanged();
    62     void sltRamSliderValueChanged(int iValue);
    63     void sltRamEditorTextChanged(const QString &strText);
     62    void sltRamSliderValueChanged();
     63    void sltRamEditorValueChanged();
    6464    void sltVirtualDiskSourceChanged();
    6565    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