VirtualBox

Changeset 87907 in vbox for trunk


Ignore:
Timestamp:
Mar 2, 2021 8:58:03 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9950. Merging hdd pages. part 1

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic1.cpp

    r87859 r87907  
    147147void UIWizardNewVDPage1::retranslateWidgets()
    148148{
    149     QList<QAbstractButton*> buttons = m_pFormatButtonGroup->buttons();
    150     for (int i = 0; i < buttons.size(); ++i)
    151     {
    152         QAbstractButton *pButton = buttons[i];
    153         UIMediumFormat enmFormat = gpConverter->fromInternalString<UIMediumFormat>(m_formatNames[m_pFormatButtonGroup->id(pButton)]);
    154         pButton->setText(gpConverter->toString(enmFormat));
     149    if (m_pFormatButtonGroup)
     150    {
     151        QList<QAbstractButton*> buttons = m_pFormatButtonGroup->buttons();
     152        for (int i = 0; i < buttons.size(); ++i)
     153        {
     154            QAbstractButton *pButton = buttons[i];
     155            UIMediumFormat enmFormat = gpConverter->fromInternalString<UIMediumFormat>(m_formatNames[m_pFormatButtonGroup->id(pButton)]);
     156            pButton->setText(gpConverter->toString(enmFormat));
     157        }
    155158    }
    156159}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp

    r87887 r87907  
    8686            setPage(Page2, new UIWizardNewVMPageBasic2);
    8787            setPage(Page4, new UIWizardNewVMPageBasic4);
    88             setPage(Page5, new UIWizardNewVMPageBasic5);
    8988            setPage(Page8, new UIWizardNewVMPageBasic8);
    9089
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic4.cpp

    r87903 r87907  
    3030#include "UIMedium.h"
    3131#include "UIMediumSelector.h"
     32#include "UIMediumSizeEditor.h"
    3233#include "UIMessageCenter.h"
    3334#include "UIWizardNewVD.h"
    3435#include "UIWizardNewVMPageBasic4.h"
     36
     37/* COM includes: */
     38#include "CGuestOSType.h"
     39#include "CSystemProperties.h"
    3540
    3641UIWizardNewVMPage4::UIWizardNewVMPage4()
     
    179184UIWizardNewVMPageBasic4::UIWizardNewVMPageBasic4()
    180185    : m_pLabel(0)
     186    , m_fUserSetSize(false)
     187
    181188{
    182189    prepare();
     
    185192    registerField("virtualDisk", this, "virtualDisk");
    186193    registerField("selectedDiskSource", this, "selectedDiskSource");
     194
     195    registerField("mediumFormat", this, "mediumFormat");
     196    registerField("mediumVariant" /* KMediumVariant */, this, "mediumVariant");
     197    registerField("mediumPath", this, "mediumPath");
     198    registerField("mediumSize", this, "mediumSize");
     199
     200    /* We do not have any UI elements for HDD format selection since we default to VDI in case of guided wizard mode: */
     201    bool fFoundVDI = false;
     202    CSystemProperties properties = uiCommon().virtualBox().GetSystemProperties();
     203    const QVector<CMediumFormat> &formats = properties.GetMediumFormats();
     204    foreach (const CMediumFormat &format, formats)
     205    {
     206        if (format.GetName() == "VDI")
     207        {
     208            m_mediumFormat = format;
     209            fFoundVDI = true;
     210        }
     211    }
     212    if (!fFoundVDI)
     213        AssertMsgFailed(("No medium format corresponding to VDI could be found!"));
     214
     215    m_strDefaultExtension =  defaultExtension(m_mediumFormat);
     216
     217    /* Since the medium format is static we can decide widget visibility here: */
     218    setWidgetVisibility(m_mediumFormat);
     219}
     220
     221CMediumFormat UIWizardNewVMPageBasic4::mediumFormat() const
     222{
     223    return m_mediumFormat;
     224}
     225
     226QString UIWizardNewVMPageBasic4::mediumPath() const
     227{
     228    return absoluteFilePath(toFileName(m_strDefaultName, m_strDefaultExtension), m_strDefaultPath);
    187229}
    188230
     
    204246    pMainLayout->addStretch();
    205247    setEnableDiskSelectionWidgets(m_enmSelectedDiskSource == SelectedDiskSource_Existing);
     248
     249
     250    pMainLayout->addWidget(createMediumVariantWidgets(true));
     251
     252    m_pSizeLabel = new QIRichTextLabel;
     253    m_pSizeEditor = new UIMediumSizeEditor;
     254
     255    pMainLayout->addWidget(m_pSizeLabel);
     256    pMainLayout->addWidget(m_pSizeEditor);
     257
    206258    createConnections();
    207259}
     
    215267    connect(m_pDiskSelectionButton, &QIToolButton::clicked,
    216268            this, &UIWizardNewVMPageBasic4::sltGetWithFileOpenDialog);
     269    connect(m_pSizeEditor, &UIMediumSizeEditor::sigSizeChanged,
     270            this, &UIWizardNewVMPageBasic4::completeChanged);
     271    connect(m_pSizeEditor, &UIMediumSizeEditor::sigSizeChanged,
     272            this, &UIWizardNewVMPageBasic4::sltHandleSizeEditorChange);
    217273}
    218274
     
    259315                          .arg(strRecommendedHDD));
    260316
    261     retranslateWidgets();
     317    UIWizardNewVMPage4::retranslateWidgets();
     318    UIWizardNewVDPage1::retranslateWidgets();
     319    UIWizardNewVDPage2::retranslateWidgets();
     320    UIWizardNewVDPage3::retranslateWidgets();
    262321}
    263322
     
    291350    if (m_pDiskSelector)
    292351        m_pDiskSelector->setCurrentIndex(0);
     352
     353    /* We set the medium name and path according to machine name/path and do let user change these in the guided mode: */
     354    QString strDefaultName = fieldImp("machineBaseName").toString();
     355    m_strDefaultName = strDefaultName.isEmpty() ? QString("NewVirtualDisk1") : strDefaultName;
     356    m_strDefaultPath = fieldImp("machineFolder").toString();
     357    if (m_pSizeEditor && !m_fUserSetSize)
     358    {
     359        m_pSizeEditor->blockSignals(true);
     360        setMediumSize(fieldImp("type").value<CGuestOSType>().GetRecommendedHDD());
     361        m_pSizeEditor->blockSignals(false);
     362    }
     363
    293364}
    294365
     
    320391    return fResult;
    321392}
     393
     394void UIWizardNewVMPageBasic4::sltHandleSizeEditorChange()
     395{
     396    m_fUserSetSize = true;
     397}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic4.h

    r87903 r87907  
    2727/* GUI includes: */
    2828#include "UIWizardPage.h"
     29#include "UIWizardNewVDPageBasic1.h"
     30#include "UIWizardNewVDPageBasic2.h"
     31#include "UIWizardNewVDPageBasic3.h"
    2932#include "UIWizardNewVM.h"
    3033
     
    8588};
    8689
    87 class UIWizardNewVMPageBasic4 : public UIWizardPage, public UIWizardNewVMPage4
     90class UIWizardNewVMPageBasic4 : public UIWizardPage,
     91                                public UIWizardNewVMPage4,
     92                                public UIWizardNewVDPage1,
     93                                public UIWizardNewVDPage2,
     94                                public UIWizardNewVDPage3
    8895{
    8996    Q_OBJECT;
    9097    Q_PROPERTY(CMedium virtualDisk READ virtualDisk WRITE setVirtualDisk);
    9198    Q_PROPERTY(SelectedDiskSource selectedDiskSource READ selectedDiskSource WRITE setSelectedDiskSource);
     99    Q_PROPERTY(CMediumFormat mediumFormat READ mediumFormat);
     100    Q_PROPERTY(qulonglong mediumVariant READ mediumVariant WRITE setMediumVariant);
     101    Q_PROPERTY(QString mediumPath READ mediumPath);
     102    Q_PROPERTY(qulonglong mediumSize READ mediumSize WRITE setMediumSize);
    92103
    93104public:
    94105
    95     /** Constructor. */
    96106    UIWizardNewVMPageBasic4();
     107    /** For the guide wizard mode medium path, name and extention is static and we have
     108      * no UI element for this. thus override. */
     109    virtual QString mediumPath() const /*override */;
    97110    virtual int nextId() const /* override */;
     111    CMediumFormat mediumFormat() const;
    98112
    99113protected:
     
    111125    void sltVirtualSelectedDiskSourceChanged();
    112126    void sltGetWithFileOpenDialog();
     127    void sltHandleSizeEditorChange();
    113128
    114129private:
     
    125140
    126141    QIRichTextLabel *m_pLabel;
     142
     143    /** This is set to true when user manually set the size. */
     144    bool m_fUserSetSize;
     145    /** For guided new vm wizard VDI is the only format. Thus we have no UI item for it. */
     146    CMediumFormat m_mediumFormat;
    127147};
    128148
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic5.h

    r87901 r87907  
    4545                                public UIWizardNewVDPage2,
    4646                                public UIWizardNewVDPage3
    47 
    4847{
    4948
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