VirtualBox

Changeset 108567 in vbox


Ignore:
Timestamp:
Mar 17, 2025 10:48:45 AM (8 weeks ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167972
Message:

FE/Qt: bugref:10867. Adding the medium size widget to the hardware page.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardNewVMEditors.cpp

    r108376 r108567  
    3636#include "UIFilePathSelector.h"
    3737#include "UIHostnameDomainNameEditor.h"
     38#include "UIMediumSizeEditor.h"
    3839#include "UIMediumTools.h"
    3940#include "UITranslationEventListener.h"
     
    323324*********************************************************************************************************************************/
    324325
    325 UINewVMHardwareContainer::UINewVMHardwareContainer(QWidget *pParent /* = 0 */)
     326UINewVMHardwareContainer::UINewVMHardwareContainer(QWidget *pParent, bool fWithMediumSizeEditor)
    326327    : QWidget(pParent)
    327328    , m_pBaseMemoryEditor(0)
    328329    , m_pVirtualCPUEditor(0)
    329330    , m_pEFICheckBox(0)
     331    , m_pMediumSizeEditor(0)
     332    , m_fWithMediumSizeEditor(fWithMediumSizeEditor)
    330333{
    331334    prepare();
     
    350353}
    351354
     355void UINewVMHardwareContainer::setMediumSize(qulonglong uSize)
     356{
     357    if (m_pMediumSizeEditor)
     358        m_pMediumSizeEditor->setMediumSize(uSize);
     359}
     360
    352361void UINewVMHardwareContainer::prepare()
    353362{
     
    357366    m_pBaseMemoryEditor = new UIBaseMemoryEditor;
    358367    m_pVirtualCPUEditor = new UIVirtualCPUEditor;
     368    if (m_fWithMediumSizeEditor)
     369        m_pMediumSizeEditor = new UIMediumSizeEditor;
    359370    m_pEFICheckBox      = new QCheckBox;
    360371    pHardwareLayout->addWidget(m_pBaseMemoryEditor, 0, 0, 1, 4);
    361372    pHardwareLayout->addWidget(m_pVirtualCPUEditor, 1, 0, 1, 4);
    362     pHardwareLayout->addWidget(m_pEFICheckBox, 2, 0, 1, 1);
     373    if (m_pMediumSizeEditor)
     374    {
     375        pHardwareLayout->addWidget(m_pMediumSizeEditor, 2, 0, 1, 4);
     376        pHardwareLayout->addWidget(m_pEFICheckBox, 3, 0, 1, 1);
     377    }
     378    else
     379        pHardwareLayout->addWidget(m_pEFICheckBox, 2, 0, 1, 1);
    363380
    364381
     
    372389        connect(m_pEFICheckBox, &QCheckBox::toggled,
    373390                this, &UINewVMHardwareContainer::sigEFIEnabledChanged);
     391    if (m_pMediumSizeEditor)
     392        connect(m_pMediumSizeEditor, &UIMediumSizeEditor::sigSizeChanged,
     393                this, &UINewVMHardwareContainer::sigSizeChanged);
    374394
    375395    sltRetranslateUI();
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardNewVMEditors.h

    r108376 r108567  
    4545class UIHostnameDomainNameEditor;
    4646class UIPasswordLineEdit;
     47class UIMediumSizeEditor;
    4748class UIUserNamePasswordEditor;
    4849class UIVirtualCPUEditor;
     
    166167    void sigCPUCountChanged(int iCount);
    167168    void sigEFIEnabledChanged(bool fEnabled);
    168 
    169 public:
    170 
    171     UINewVMHardwareContainer(QWidget *pParent = 0);
    172 
    173     /** @name Wrappers for UIFilePathSelector
     169    void sigSizeChanged(qulonglong uSize);
     170
     171public:
     172
     173    UINewVMHardwareContainer(QWidget *pParent, bool fWithMediumSizeEditor);
     174
     175    /** @name Wrappers for members
    174176      * @{ */
    175177        void setMemorySize(int iSize);
    176178        void setCPUCount(int iCount);
    177179        void setEFIEnabled(bool fEnabled);
     180        void setMediumSize(qulonglong uSize);
    178181    /** @} */
    179182
     
    192195    UIVirtualCPUEditor *m_pVirtualCPUEditor;
    193196    QCheckBox *m_pEFICheckBox;
     197    UIMediumSizeEditor *m_pMediumSizeEditor;
     198    bool m_fWithMediumSizeEditor;
    194199};
    195200
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp

    r108376 r108567  
    114114            setUnattendedPageVisible(false);
    115115            addPage(new UIWizardNewVMHardwarePage("create-vm-wizard-hardware" /* help keyword*/));
    116             addPage(new UIWizardNewVMDiskPage(m_pActionPool, "create-vm-wizard-virtual-hard-disk" /* help keyword*/));
    117116            addPage(new UIWizardNewVMSummaryPage);
    118117            break;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMDiskPage.cpp

    r108548 r108567  
    201201    }
    202202
    203     /* Initialize medium variant parameter of the wizard (only if user has not touched the checkbox yet): */
    204     if (!m_userModifiedParameters.contains("MediumVariant"))
    205     {
    206         pWizard->setMediumVariant((qulonglong)KMediumVariant_Standard);
    207     }
     203    pWizard->setMediumVariant((qulonglong)KMediumVariant_Standard);
    208204}
    209205
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMExpertPage.cpp

    r108389 r108567  
    8181        m_pToolBox->insertPage(ExpertToolboxItems_NameAndOSType, createNameOSTypeWidgets(), "");
    8282        m_pToolBox->insertPage(ExpertToolboxItems_Unattended, createUnattendedWidgets(), "");
    83         m_pHardwareWidgetContainer = new UINewVMHardwareContainer;
     83        m_pHardwareWidgetContainer = new UINewVMHardwareContainer(this, false /* without medium size editor */);
    8484        m_pToolBox->insertPage(ExpertToolboxItems_Hardware, m_pHardwareWidgetContainer, "");
    8585        m_pToolBox->insertPage(ExpertToolboxItems_Disk, createDiskWidgets(), "");
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMHardwarePage.cpp

    r108162 r108567  
    3232#include "QIRichTextLabel.h"
    3333#include "UIBaseMemoryEditor.h"
     34#include "UIWizardDiskEditors.h"
    3435#include "UIGlobalSession.h"
    3536#include "UIGuestOSType.h"
     
    3940#include "UIWizardNewVMHardwarePage.h"
    4041
     42/* COM includes: */
     43#include "CSystemProperties.h"
    4144
    4245UIWizardNewVMHardwarePage::UIWizardNewVMHardwarePage(const QString strHelpKeyword /* = QString() */)
     
    4447    , m_pLabel(0)
    4548    , m_pHardwareWidgetContainer(0)
     49    , m_fVDIFormatFound(false)
     50    , m_uMediumSizeMin(_4M)
     51    , m_uMediumSizeMax(gpGlobalSession->virtualBox().GetSystemProperties().GetInfoVDSize())
    4652{
    4753    prepare();
     
    5561    m_pLabel = new QIRichTextLabel(this);
    5662    pMainLayout->addWidget(m_pLabel);
    57     m_pHardwareWidgetContainer = new UINewVMHardwareContainer;
     63    m_pHardwareWidgetContainer = new UINewVMHardwareContainer(this, true /* with medium size editor */);
    5864    AssertReturnVoid(m_pHardwareWidgetContainer);
    5965    pMainLayout->addWidget(m_pHardwareWidgetContainer);
     
    7379        connect(m_pHardwareWidgetContainer, &UINewVMHardwareContainer::sigEFIEnabledChanged,
    7480                this, &UIWizardNewVMHardwarePage::sltEFIEnabledChanged);
     81        connect(m_pHardwareWidgetContainer, &UINewVMHardwareContainer::sigSizeChanged,
     82                this, &UIWizardNewVMHardwarePage::sltHandleSizeEditorChange);
    7583    }
    7684}
     
    114122        m_pHardwareWidgetContainer->blockSignals(false);
    115123    }
     124    initializeVirtualHardDiskParameters();
     125}
     126
     127void UIWizardNewVMHardwarePage::initializeVirtualHardDiskParameters()
     128{
     129    UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
     130    AssertReturnVoid(pWizard);
     131
     132    LONG64 iRecommendedSize = 0;
     133
     134    if (!m_userModifiedParameters.contains("SelectedDiskSource"))
     135    {
     136        iRecommendedSize = gpGlobalSession->guestOSTypeManager().getRecommendedHDD(pWizard->guestOSTypeId());
     137        if (iRecommendedSize != 0)
     138        {
     139            pWizard->setDiskSource(SelectedDiskSource_New);
     140            pWizard->setEmptyDiskRecommended(false);
     141        }
     142        else
     143        {
     144            pWizard->setDiskSource(SelectedDiskSource_Empty);
     145            pWizard->setEmptyDiskRecommended(true);
     146        }
     147    }
     148
     149    if (!m_fVDIFormatFound)
     150    {
     151        /* We do not have any UI elements for HDD format selection since we default to VDI in case of guided wizard mode: */
     152        CSystemProperties properties = gpGlobalSession->virtualBox().GetSystemProperties();
     153        const QVector<CMediumFormat> &formats = properties.GetMediumFormats();
     154        foreach (const CMediumFormat &format, formats)
     155        {
     156            if (format.GetName() == "VDI")
     157            {
     158                pWizard->setMediumFormat(format);
     159                m_fVDIFormatFound = true;
     160            }
     161        }
     162        if (!m_fVDIFormatFound)
     163            AssertMsgFailed(("No medium format corresponding to VDI could be found!"));
     164    }
     165    QString strDefaultExtension =  UIWizardDiskEditors::defaultExtension(pWizard->mediumFormat(), KDeviceType_HardDisk);
     166
     167    /* We set the medium name and path according to machine name/path and do not allow user change these in the guided mode: */
     168    QString strDefaultName = pWizard->machineFileName().isEmpty() ? QString("NewVirtualDisk1") : pWizard->machineFileName();
     169    const QString &strMachineFolder = pWizard->machineFolder();
     170    QString strMediumPath =
     171        UIWizardDiskEditors::constructMediumFilePath(UIWizardDiskEditors::appendExtension(strDefaultName,
     172                                                                                          strDefaultExtension), strMachineFolder);
     173    pWizard->setMediumPath(strMediumPath);
     174
     175    /* Set the recommended disk size if user has already not done so: */
     176    if (m_pHardwareWidgetContainer && !m_userModifiedParameters.contains("MediumSize"))
     177    {
     178        m_pHardwareWidgetContainer->blockSignals(true);
     179        m_pHardwareWidgetContainer->setMediumSize(iRecommendedSize);
     180        m_pHardwareWidgetContainer->blockSignals(false);
     181        pWizard->setMediumSize(iRecommendedSize);
     182    }
     183
     184    pWizard->setMediumVariant((qulonglong)KMediumVariant_Standard);
    116185}
    117186
    118187bool UIWizardNewVMHardwarePage::isComplete() const
    119188{
    120     return true;
     189   UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
     190   AssertReturn(pWizard, false);
     191
     192   const qulonglong uSize = pWizard->mediumSize();
     193   if (pWizard->diskSource() == SelectedDiskSource_New)
     194       return uSize >= m_uMediumSizeMin && uSize <= m_uMediumSizeMax;
     195   return true;
    121196}
    122197
     
    141216    m_userModifiedParameters << "EFIEnabled";
    142217}
     218
     219void UIWizardNewVMHardwarePage::sltHandleSizeEditorChange(qulonglong uSize)
     220{
     221    AssertReturnVoid(wizardWindow<UIWizardNewVM>());
     222    wizardWindow<UIWizardNewVM>()->setMediumSize(uSize);
     223    m_userModifiedParameters << "MediumSize";
     224    emit completeChanged();
     225}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMHardwarePage.h

    r107002 r108567  
    5555    void sltCPUCountChanged(int iCount);
    5656    void sltEFIEnabledChanged(bool fEnabled);
     57    void sltHandleSizeEditorChange(qulonglong uSize);
    5758    virtual void sltRetranslateUI() RT_OVERRIDE RT_FINAL;
    5859
     
    6465    virtual void initializePage() RT_OVERRIDE RT_FINAL;
    6566    virtual bool isComplete() const RT_OVERRIDE RT_FINAL;
    66 
     67    void initializeVirtualHardDiskParameters();
    6768    /** @name Widgets
    6869      * @{ */
     
    7071        UINewVMHardwareContainer *m_pHardwareWidgetContainer;
    7172    /** @} */
     73    bool m_fVDIFormatFound;
     74    qulonglong m_uMediumSizeMin;
     75    qulonglong m_uMediumSizeMax;
    7276    /** This set is used to decide if we have to set wizard's parameters
    7377      * some default values or not. When user modifies a value through a widget we
Note: See TracChangeset for help on using the changeset viewer.

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