VirtualBox

Changeset 108568 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Mar 17, 2025 11:18:04 AM (5 weeks ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167973
Message:

FE/Qt: bugref:10867. Some refactoring.

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

Legend:

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

    r108567 r108568  
    2727
    2828/* Qt includes: */
     29#include <QCheckBox>
    2930#include <QVBoxLayout>
    3031
     
    3536#include "UIGlobalSession.h"
    3637#include "UIGuestOSType.h"
     38#include "UIMediumSizeEditor.h"
     39#include "UITranslationEventListener.h"
    3740#include "UIVirtualCPUEditor.h"
    3841#include "UIWizardNewVM.h"
    39 #include "UIWizardNewVMEditors.h"
    4042#include "UIWizardNewVMHardwarePage.h"
    4143
     
    4648    : UINativeWizardPage(strHelpKeyword)
    4749    , m_pLabel(0)
    48     , m_pHardwareWidgetContainer(0)
     50    , m_pBaseMemoryEditor(0)
     51    , m_pVirtualCPUEditor(0)
     52    , m_pEFICheckBox(0)
     53    , m_pMediumSizeEditor(0)
    4954    , m_fVDIFormatFound(false)
    5055    , m_uMediumSizeMin(_4M)
     
    6166    m_pLabel = new QIRichTextLabel(this);
    6267    pMainLayout->addWidget(m_pLabel);
    63     m_pHardwareWidgetContainer = new UINewVMHardwareContainer(this, true /* with medium size editor */);
    64     AssertReturnVoid(m_pHardwareWidgetContainer);
    65     pMainLayout->addWidget(m_pHardwareWidgetContainer);
     68    QWidget *pHardwareWidgetContainer = new QWidget(this);
     69    AssertReturnVoid(pHardwareWidgetContainer);
     70
     71    QGridLayout *pContainerLayout = new QGridLayout(pHardwareWidgetContainer);
     72    pContainerLayout->setContentsMargins(0, 0, 0, 0);
     73
     74    m_pBaseMemoryEditor = new UIBaseMemoryEditor;
     75    m_pVirtualCPUEditor = new UIVirtualCPUEditor;
     76    m_pMediumSizeEditor = new UIMediumSizeEditor;
     77    m_pEFICheckBox      = new QCheckBox;
     78    pContainerLayout->addWidget(m_pBaseMemoryEditor, 0, 0, 1, 4);
     79    pContainerLayout->addWidget(m_pVirtualCPUEditor, 1, 0, 1, 4);
     80    pContainerLayout->addWidget(m_pMediumSizeEditor, 2, 0, 1, 4);
     81    pContainerLayout->addWidget(m_pEFICheckBox, 3, 0, 1, 1);
     82
     83    pMainLayout->addWidget(pHardwareWidgetContainer);
    6684
    6785    pMainLayout->addStretch();
     
    7189void UIWizardNewVMHardwarePage::createConnections()
    7290{
    73     if (m_pHardwareWidgetContainer)
    74     {
    75         connect(m_pHardwareWidgetContainer, &UINewVMHardwareContainer::sigMemorySizeChanged,
     91    if (m_pBaseMemoryEditor)
     92        connect(m_pBaseMemoryEditor, &UIBaseMemoryEditor::sigValueChanged,
    7693                this, &UIWizardNewVMHardwarePage::sltMemorySizeChanged);
    77         connect(m_pHardwareWidgetContainer, &UINewVMHardwareContainer::sigCPUCountChanged,
     94    if (m_pVirtualCPUEditor)
     95        connect(m_pVirtualCPUEditor, &UIVirtualCPUEditor::sigValueChanged,
    7896                this, &UIWizardNewVMHardwarePage::sltCPUCountChanged);
    79         connect(m_pHardwareWidgetContainer, &UINewVMHardwareContainer::sigEFIEnabledChanged,
     97    if (m_pEFICheckBox)
     98        connect(m_pEFICheckBox, &QCheckBox::toggled,
    8099                this, &UIWizardNewVMHardwarePage::sltEFIEnabledChanged);
    81         connect(m_pHardwareWidgetContainer, &UINewVMHardwareContainer::sigSizeChanged,
     100    if (m_pMediumSizeEditor)
     101        connect(m_pMediumSizeEditor, &UIMediumSizeEditor::sigSizeChanged,
    82102                this, &UIWizardNewVMHardwarePage::sltHandleSizeEditorChange);
    83     }
     103
     104    connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
     105            this, &UIWizardNewVMHardwarePage::sltRetranslateUI);
    84106}
    85107
     
    97119
    98120    UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
    99     if (pWizard && m_pHardwareWidgetContainer)
    100     {
    101         const QString &strTypeId = pWizard->guestOSTypeId();
    102 
    103         m_pHardwareWidgetContainer->blockSignals(true);
    104         if (!m_userModifiedParameters.contains("MemorySize"))
    105         {
    106             ULONG recommendedRam = gpGlobalSession->guestOSTypeManager().getRecommendedRAM(strTypeId);
    107             m_pHardwareWidgetContainer->setMemorySize(recommendedRam);
    108             pWizard->setMemorySize(recommendedRam);
    109         }
    110         if (!m_userModifiedParameters.contains("CPUCount"))
    111         {
    112             ULONG recommendedCPUs = gpGlobalSession->guestOSTypeManager().getRecommendedCPUCount(strTypeId);
    113             m_pHardwareWidgetContainer->setCPUCount(recommendedCPUs);
    114             pWizard->setCPUCount(recommendedCPUs);
    115         }
    116         if (!m_userModifiedParameters.contains("EFIEnabled"))
    117         {
    118             KFirmwareType fwType = gpGlobalSession->guestOSTypeManager().getRecommendedFirmware(strTypeId);
    119             m_pHardwareWidgetContainer->setEFIEnabled(fwType != KFirmwareType_BIOS);
    120             pWizard->setEFIEnabled(fwType != KFirmwareType_BIOS);
    121         }
    122         m_pHardwareWidgetContainer->blockSignals(false);
    123     }
     121    const QString &strTypeId = pWizard->guestOSTypeId();
     122
     123    if (m_pBaseMemoryEditor && !m_userModifiedParameters.contains("MemorySize"))
     124    {
     125        m_pBaseMemoryEditor->blockSignals(true);
     126        ULONG recommendedRam = gpGlobalSession->guestOSTypeManager().getRecommendedRAM(strTypeId);
     127        m_pBaseMemoryEditor->setValue(recommendedRam);
     128        pWizard->setMemorySize(recommendedRam);
     129        m_pBaseMemoryEditor->blockSignals(false);
     130    }
     131    if (m_pVirtualCPUEditor && !m_userModifiedParameters.contains("CPUCount"))
     132    {
     133        m_pVirtualCPUEditor->blockSignals(true);
     134        ULONG recommendedCPUs = gpGlobalSession->guestOSTypeManager().getRecommendedCPUCount(strTypeId);
     135        m_pVirtualCPUEditor->setValue(recommendedCPUs);
     136        pWizard->setCPUCount(recommendedCPUs);
     137        m_pVirtualCPUEditor->blockSignals(false);
     138    }
     139    if (m_pEFICheckBox && !m_userModifiedParameters.contains("EFIEnabled"))
     140    {
     141        m_pEFICheckBox->blockSignals(true);
     142        KFirmwareType fwType = gpGlobalSession->guestOSTypeManager().getRecommendedFirmware(strTypeId);
     143        m_pEFICheckBox->setChecked(fwType != KFirmwareType_BIOS);
     144        pWizard->setEFIEnabled(fwType != KFirmwareType_BIOS);
     145        m_pEFICheckBox->blockSignals(false);
     146    }
     147
    124148    initializeVirtualHardDiskParameters();
    125149}
     
    174198
    175199    /* 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);
     200    if (m_pMediumSizeEditor && !m_userModifiedParameters.contains("MediumSize"))
     201    {
     202        m_pMediumSizeEditor->blockSignals(true);
     203        m_pMediumSizeEditor->setMediumSize(iRecommendedSize);
     204        m_pMediumSizeEditor->blockSignals(false);
    181205        pWizard->setMediumSize(iRecommendedSize);
    182206    }
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMHardwarePage.h

    r108567 r108568  
    3939
    4040/* Forward declarations: */
     41class QCheckBox;
    4142class QIRichTextLabel;
    42 class UINewVMHardwareContainer;
     43class UIBaseMemoryEditor;
     44class UIVirtualCPUEditor;
     45class UIMediumSizeEditor;
    4346
    4447class UIWizardNewVMHardwarePage : public UINativeWizardPage
     
    6972      * @{ */
    7073        QIRichTextLabel    *m_pLabel;
    71         UINewVMHardwareContainer *m_pHardwareWidgetContainer;
     74        UIBaseMemoryEditor *m_pBaseMemoryEditor;
     75        UIVirtualCPUEditor *m_pVirtualCPUEditor;
     76        QCheckBox          *m_pEFICheckBox;
     77        UIMediumSizeEditor *m_pMediumSizeEditor;
    7278    /** @} */
    7379    bool m_fVDIFormatFound;
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