VirtualBox

Changeset 87891 in vbox for trunk


Ignore:
Timestamp:
Feb 26, 2021 4:54:52 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9950. Adding the size editor to the page

Location:
trunk/src/VBox/Frontends/VirtualBox/src/wizards
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic2.h

    r87890 r87891  
    6464};
    6565
    66 
    6766/* 2nd page of the New Virtual Hard Drive wizard (basic extension): */
    6867class SHARED_LIBRARY_STUFF UIWizardNewVDPageBasic2 : public UIWizardPage, public UIWizardNewVDPage2
     
    7372public:
    7473
    75     /* Constructor: */
    7674    UIWizardNewVDPageBasic2();
    7775
    7876private:
    7977
    80     /* Translation stuff: */
    8178    void retranslateUi();
    82 
    83     /* Prepare stuff: */
    8479    void initializePage();
    85 
    86     /* Validation stuff: */
    8780    bool isComplete() const;
    8881};
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic3.cpp

    r87878 r87891  
    5454    , m_pLocationEditor(0)
    5555    , m_pLocationOpenButton(0)
    56     , m_pEditorSize(0)
     56    , m_pSizeEditor(0)
     57    , m_pLocationLabel(0)
     58    , m_pSizeLabel(0)
    5759{
    5860}
     
    6365    , m_pLocationEditor(0)
    6466    , m_pLocationOpenButton(0)
    65     , m_pEditorSize(0)
     67    , m_pSizeEditor(0)
    6668{
    6769}
     
    216218qulonglong UIWizardNewVDPage3::mediumSize() const
    217219{
    218     return m_pEditorSize ? m_pEditorSize->mediumSize() : 0;
     220    return m_pSizeEditor ? m_pSizeEditor->mediumSize() : 0;
    219221}
    220222
    221223void UIWizardNewVDPage3::setMediumSize(qulonglong uMediumSize)
    222224{
    223     if (m_pEditorSize)
    224         m_pEditorSize->setMediumSize(uMediumSize);
     225    if (m_pSizeEditor)
     226        m_pSizeEditor->setMediumSize(uMediumSize);
    225227}
    226228
     
    250252        }
    251253        m_pSizeLabel = new QIRichTextLabel(this);
    252         m_pEditorSize = new UIMediumSizeEditor;
     254        m_pSizeEditor = new UIMediumSizeEditor;
    253255        setMediumSize(uDefaultSize);
    254256        pMainLayout->addWidget(m_pLocationLabel);
    255257        pMainLayout->addLayout(pLocationLayout);
    256258        pMainLayout->addWidget(m_pSizeLabel);
    257         pMainLayout->addWidget(m_pEditorSize);
     259        pMainLayout->addWidget(m_pSizeEditor);
    258260        pMainLayout->addStretch();
    259261    }
     
    262264    connect(m_pLocationEditor, &QLineEdit::textChanged,    this, &UIWizardNewVDPageBasic3::completeChanged);
    263265    connect(m_pLocationOpenButton, &QIToolButton::clicked, this, &UIWizardNewVDPageBasic3::sltSelectLocationButtonClicked);
    264     connect(m_pEditorSize, &UIMediumSizeEditor::sigSizeChanged, this, &UIWizardNewVDPageBasic3::completeChanged);
     266    connect(m_pSizeEditor, &UIMediumSizeEditor::sigSizeChanged, this, &UIWizardNewVDPageBasic3::completeChanged);
    265267
    266268    /* Register fields: */
     
    306308    if (!m_pLocationEditor)
    307309        return false;
    308     /* Make sure current name is not empty and current size feats the bounds: */
     310    /* Make sure current name is not empty and current size fits the bounds: */
    309311    return !m_pLocationEditor->text().trimmed().isEmpty() &&
    310312           mediumSize() >= m_uMediumSizeMin && mediumSize() <= m_uMediumSizeMax;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic3.h

    r87878 r87891  
    4545protected:
    4646
    47     /* Constructor: */
    4847    UIWizardNewVDPage3(const QString &strDefaultName, const QString &strDefaultPath);
    4948    UIWizardNewVDPage3();
    5049
    51     /* Handlers: */
    5250    void onSelectLocationButtonClicked();
    5351
    54     /* Location-editors stuff: */
    5552    static QString toFileName(const QString &strName, const QString &strExtension);
    56     /* Returns the full image file path except the extension. */
     53    /** Returns the full image file path except the extension. */
    5754    static QString absoluteFilePath(const QString &strFileName, const QString &strPath);
    58     /* Returns the full image file path including the extension. */
     55    /** Returns the full image file path including the extension. */
    5956    static QString absoluteFilePath(const QString &strFileName, const QString &strPath, const QString &strExtension);
    6057
    61     /* Stuff for 'mediumPath' field: */
    6258    QString mediumPath() const;
    6359
    64     /* Stuff for 'mediumSize' field: */
    6560    qulonglong mediumSize() const;
    6661    void setMediumSize(qulonglong uMediumSize);
    6762    void retranslateWidgets();
    6863
    69     /* Variables: */
    70     QString m_strDefaultName;
    71     QString m_strDefaultPath;
    72     QString m_strDefaultExtension;
    73     qulonglong m_uMediumSizeMin;
    74     qulonglong m_uMediumSizeMax;
     64    /** @name Widgets
     65     * @{ */
     66       QString m_strDefaultName;
     67       QString m_strDefaultPath;
     68       QString m_strDefaultExtension;
     69       qulonglong m_uMediumSizeMin;
     70       qulonglong m_uMediumSizeMax;
     71    /** @} */
    7572
    76     /* Widgets: */
    77     QLineEdit *m_pLocationEditor;
    78     QIToolButton *m_pLocationOpenButton;
    79     UIMediumSizeEditor *m_pEditorSize;
     73    /** @name Widgets
     74     * @{ */
     75       QLineEdit *m_pLocationEditor;
     76       QIToolButton *m_pLocationOpenButton;
     77       UIMediumSizeEditor *m_pSizeEditor;
     78       QIRichTextLabel *m_pLocationLabel;
     79       QIRichTextLabel *m_pSizeLabel;
     80    /** @} */
    8081};
    8182
     
    9091public:
    9192
    92     /* Constructor: */
    9393    UIWizardNewVDPageBasic3(const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize);
    9494
    9595protected:
    9696
    97     /* Wrapper to access 'this' from base part: */
     97    /** Wrapper to access 'this' from base part: */
    9898    UIWizardPage* thisImp() { return this; }
    99     /* Wrapper to access 'wizard-field' from base part: */
     99    /** Wrapper to access 'wizard-field' from base part: */
    100100    QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); }
    101101
    102102private slots:
    103103
    104     /* Location editors stuff: */
     104    /** Location editors stuff: */
    105105    void sltSelectLocationButtonClicked();
    106106
    107107private:
    108108
    109     /* Translation stuff: */
    110109    void retranslateUi();
    111 
    112     /* Prepare stuff: */
    113110    void initializePage();
    114 
    115     /* Validation stuff: */
    116111    bool isComplete() const;
    117112    bool validatePage();
    118 
    119     /* Widgets: */
    120     QIRichTextLabel *m_pLocationLabel;
    121     QIRichTextLabel *m_pSizeLabel;
    122113};
    123114
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageExpert.cpp

    r87878 r87891  
    7676            QVBoxLayout *pSizeGroupBoxLayout = new QVBoxLayout(m_pSizeGroupBox);
    7777            {
    78                 m_pEditorSize = new UIMediumSizeEditor;
     78                m_pSizeEditor = new UIMediumSizeEditor;
    7979                {
    80                     pSizeGroupBoxLayout->addWidget(m_pEditorSize);
     80                    pSizeGroupBoxLayout->addWidget(m_pSizeEditor);
    8181                }
    8282            }
     
    129129    connect(m_pLocationOpenButton, &QIToolButton::clicked,
    130130            this, &UIWizardNewVDPageExpert::sltSelectLocationButtonClicked);
    131     connect(m_pEditorSize, &UIMediumSizeEditor::sigSizeChanged,
     131    connect(m_pSizeEditor, &UIMediumSizeEditor::sigSizeChanged,
    132132            this, &UIWizardNewVDPageExpert::completeChanged);
    133133
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic5.cpp

    r87890 r87891  
    2626#include "UIBaseMemoryEditor.h"
    2727#include "UICommon.h"
     28#include "UIMediumSizeEditor.h"
    2829#include "UIVirtualCPUEditor.h"
    2930#include "UIWizardNewVM.h"
     
    3536
    3637UIWizardNewVMPageBasic5::UIWizardNewVMPageBasic5()
     38    : m_fUserSetSize(false)
    3739{
    3840    prepare();
     
    6264    /* Since the medium format is static we can decide widget visibility here: */
    6365    setWidgetVisibility(m_mediumFormat);
     66
     67    retranslateUi();
    6468}
    6569
     
    7579    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    7680    pMainLayout->addWidget(createMediumVariantWidgets(true));
     81
     82    m_pSizeLabel = new QIRichTextLabel;
     83    m_pSizeEditor = new UIMediumSizeEditor;
     84
     85    pMainLayout->addWidget(m_pSizeLabel);
     86
     87    pMainLayout->addWidget(m_pSizeEditor);
     88
    7789    pMainLayout->addStretch();
    7890
    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);
    83 
    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();
     91    createConnections();
    9292}
    9393
    9494void UIWizardNewVMPageBasic5::createConnections()
    9595{
     96    connect(m_pSizeEditor, &UIMediumSizeEditor::sigSizeChanged, this, &UIWizardNewVDPageBasic3::completeChanged);
     97    connect(m_pSizeEditor, &UIMediumSizeEditor::sigSizeChanged, this, &UIWizardNewVMPageBasic5::sltHandleSizeEditorChange);
    9698}
    9799
     
    101103    UIWizardNewVDPage2::retranslateWidgets();
    102104
    103 
    104     //retranslateWidgets();
     105    if (m_pSizeLabel)
     106        m_pSizeLabel->setText(UIWizardNewVM::tr("Select the size of the virtual hard disk in megabytes. "
     107                                                "This size is the limit on the amount of file data "
     108                                                "that a virtual machine will be able to store on the hard disk."));
    105109}
    106110
     
    111115    m_strDefaultName = strDefaultName.isEmpty() ? QString("NewVirtualDisk1") : strDefaultName;
    112116    m_strDefaultPath = fieldImp("machineFolder").toString();
    113     // fieldImp("type").value<CGuestOSType>().GetRecommendedHDD()
    114 
    115     retranslateUi();
     117    if (m_pSizeEditor && !m_fUserSetSize)
     118    {
     119        m_pSizeEditor->blockSignals(true);
     120        setMediumSize(fieldImp("type").value<CGuestOSType>().GetRecommendedHDD());
     121        m_pSizeEditor->blockSignals(false);
     122    }
    116123}
    117124
    118125void UIWizardNewVMPageBasic5::cleanupPage()
    119126{
    120     UIWizardPage::cleanupPage();
     127    /* do not reset fields: */
    121128}
    122129
    123130bool UIWizardNewVMPageBasic5::isComplete() const
    124131{
    125     return true;
     132    return mediumSize() >= m_uMediumSizeMin && mediumSize() <= m_uMediumSizeMax;
    126133}
     134
     135
     136void UIWizardNewVMPageBasic5::sltHandleSizeEditorChange()
     137{
     138    m_fUserSetSize = true;
     139}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic5.h

    r87890 r87891  
    7171private slots:
    7272
     73    void sltHandleSizeEditorChange();
    7374
    7475private:
     
    8384
    8485    bool isComplete() const;
    85 
     86    /** this is set to true when user manually set the size. */
     87    bool m_fUserSetSize;
    8688
    8789    /** For guided new vm wizard VDI is the only format. Thus we have no UI item for it. */
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