VirtualBox

Changeset 85078 in vbox


Ignore:
Timestamp:
Jul 7, 2020 6:45:08 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
138983
Message:

FE/Qt: bugref:9515. Making the widget creation a bit more modular in page1. we will need this in expert mode.

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

Legend:

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

    r85066 r85078  
    281281}
    282282
     283void UIWizardNewVMPage1::createWidgets(QGridLayout *pGridLayout)
     284{
     285    if (pGridLayout)
     286    {
     287        m_pLabel1 = new QIRichTextLabel;
     288        if (m_pLabel1)
     289            pGridLayout->addWidget(m_pLabel1, 0, 0, 1, 3);
     290
     291        m_pButtonGroup = new QButtonGroup;
     292        if (m_pButtonGroup)
     293        {
     294            m_pButtonSimple = new QRadioButton;
     295            if (m_pButtonSimple)
     296            {
     297                m_pButtonSimple->setChecked(true);
     298                pGridLayout->addWidget(m_pButtonSimple, 1, 0, 1, 3);
     299            }
     300            m_pButtonUnattended = new QRadioButton;
     301            if (m_pButtonUnattended)
     302            {
     303                QStyleOptionButton options;
     304                options.initFrom(m_pButtonUnattended);
     305                const int iWidth = m_pButtonUnattended->style()->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth,
     306                                                                             &options, m_pButtonUnattended);
     307                pGridLayout->setColumnMinimumWidth(0, iWidth);
     308                pGridLayout->addWidget(m_pButtonUnattended, 2, 0, 1, 3);
     309            }
     310
     311            m_pButtonGroup->addButton(m_pButtonSimple);
     312            m_pButtonGroup->addButton(m_pButtonUnattended);
     313        }
     314
     315        m_pISOSelectorLabel = new QLabel;
     316        if (m_pISOSelectorLabel)
     317        {
     318            m_pISOSelectorLabel->setAlignment(Qt::AlignRight);
     319            m_pISOSelectorLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     320            m_pISOSelectorLabel->setEnabled(false);
     321            pGridLayout->addWidget(m_pISOSelectorLabel, 3, 1);
     322        }
     323        m_pISOFilePathSelector = new UIFilePathSelector;
     324        if (m_pISOFilePathSelector)
     325        {
     326            m_pISOFilePathSelector->setResetEnabled(false);
     327            m_pISOFilePathSelector->setMode(UIFilePathSelector::Mode_File_Open);
     328            m_pISOFilePathSelector->setFileDialogFilters("*.iso *.ISO");
     329            m_pISOFilePathSelector->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     330            m_pISOFilePathSelector->setEnabled(false);
     331            pGridLayout->addWidget(m_pISOFilePathSelector, 3, 2);
     332        }
     333
     334        m_pStartHeadlessLabel = new QLabel;
     335        if (m_pStartHeadlessLabel)
     336        {
     337            m_pStartHeadlessLabel->setAlignment(Qt::AlignRight);
     338            m_pStartHeadlessLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     339            m_pStartHeadlessLabel->setEnabled(false);
     340            pGridLayout->addWidget(m_pStartHeadlessLabel, 4, 1);
     341        }
     342        m_pStartHeadlessCheckBox = new QCheckBox;
     343        if (m_pStartHeadlessCheckBox)
     344        {
     345            m_pStartHeadlessCheckBox->setEnabled(false);
     346            pGridLayout->addWidget(m_pStartHeadlessCheckBox, 4, 2);
     347        }
     348
     349        m_pLabel2 = new QIRichTextLabel;
     350        if (m_pLabel2)
     351            pGridLayout->addWidget(m_pLabel2, 5, 0, 1, 3);
     352
     353        m_pNameAndSystemEditor = new UINameAndSystemEditor(0, true, true, true);
     354        if (m_pNameAndSystemEditor)
     355        {
     356            pGridLayout->addWidget(m_pNameAndSystemEditor, 6, 1, 1, 2);
     357        }
     358    }
     359}
     360
    283361bool UIWizardNewVMPage1::createMachineFolder()
    284362{
     
    409487void UIWizardNewVMPageBasic1::prepare()
    410488{
    411     QGridLayout *pMainLayout = new QGridLayout(this);
    412     if (pMainLayout)
    413     {
    414         m_pLabel1 = new QIRichTextLabel(this);
    415         if (m_pLabel1)
    416             pMainLayout->addWidget(m_pLabel1, 0, 0, 1, 3);
    417 
    418         QButtonGroup *pButtonGroup = new QButtonGroup(this);
    419         if (pButtonGroup)
    420         {
    421             m_pButtonSimple = new QRadioButton(this);
    422             if (m_pButtonSimple)
    423             {
    424                 m_pButtonSimple->setChecked(true);
    425                 pMainLayout->addWidget(m_pButtonSimple, 1, 0, 1, 3);
    426             }
    427             m_pButtonUnattended = new QRadioButton(this);
    428             if (m_pButtonUnattended)
    429             {
    430                 QStyleOptionButton options;
    431                 options.initFrom(m_pButtonUnattended);
    432                 const int iWidth = m_pButtonUnattended->style()->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth,
    433                                                                              &options, m_pButtonUnattended);
    434                 pMainLayout->setColumnMinimumWidth(0, iWidth);
    435                 pMainLayout->addWidget(m_pButtonUnattended, 2, 0, 1, 3);
    436             }
    437 
    438             pButtonGroup->addButton(m_pButtonSimple);
    439             pButtonGroup->addButton(m_pButtonUnattended);
    440             connect(pButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked),
    441                     this, &UIWizardNewVMPageBasic1::sltUnattendedCheckBoxToggle);
    442         }
    443 
    444         m_pISOSelectorLabel = new QLabel;
    445         if (m_pISOSelectorLabel)
    446         {
    447             m_pISOSelectorLabel->setAlignment(Qt::AlignRight);
    448             m_pISOSelectorLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    449             m_pISOSelectorLabel->setEnabled(false);
    450             pMainLayout->addWidget(m_pISOSelectorLabel, 3, 1);
    451         }
    452         m_pISOFilePathSelector = new UIFilePathSelector;
    453         if (m_pISOFilePathSelector)
    454         {
    455             m_pISOFilePathSelector->setResetEnabled(false);
    456             m_pISOFilePathSelector->setMode(UIFilePathSelector::Mode_File_Open);
    457             m_pISOFilePathSelector->setFileDialogFilters("*.iso *.ISO");
    458             m_pISOFilePathSelector->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    459             m_pISOFilePathSelector->setEnabled(false);
    460             connect(m_pISOFilePathSelector, &UIFilePathSelector::pathChanged, this, &UIWizardNewVMPageBasic1::sltISOPathChanged);
    461             pMainLayout->addWidget(m_pISOFilePathSelector, 3, 2);
    462         }
    463 
    464         m_pStartHeadlessLabel = new QLabel;
    465         if (m_pStartHeadlessLabel)
    466         {
    467             m_pStartHeadlessLabel->setAlignment(Qt::AlignRight);
    468             m_pStartHeadlessLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    469             m_pStartHeadlessLabel->setEnabled(false);
    470             pMainLayout->addWidget(m_pStartHeadlessLabel, 4, 1);
    471         }
    472         m_pStartHeadlessCheckBox = new QCheckBox;
    473         if (m_pStartHeadlessCheckBox)
    474         {
    475             m_pStartHeadlessCheckBox->setEnabled(false);
    476             pMainLayout->addWidget(m_pStartHeadlessCheckBox, 4, 2);
    477         }
    478 
    479         m_pLabel2 = new QIRichTextLabel(this);
    480         if (m_pLabel2)
    481             pMainLayout->addWidget(m_pLabel2, 5, 0, 1, 3);
    482 
    483         m_pNameAndSystemEditor = new UINameAndSystemEditor(this, true, true, true);
    484         if (m_pNameAndSystemEditor)
    485         {
    486             connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigNameChanged, this, &UIWizardNewVMPageBasic1::sltNameChanged);
    487             connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigPathChanged, this, &UIWizardNewVMPageBasic1::sltPathChanged);
    488             connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged, this, &UIWizardNewVMPageBasic1::sltOsTypeChanged);
    489             pMainLayout->addWidget(m_pNameAndSystemEditor, 6, 1, 1, 2);
    490         }
    491 
    492         /* Register fields: */
    493         registerField("name*", m_pNameAndSystemEditor, "name", SIGNAL(sigNameChanged(const QString &)));
    494         registerField("type", m_pNameAndSystemEditor, "type", SIGNAL(sigOsTypeChanged()));
    495         registerField("machineFilePath", this, "machineFilePath");
    496         registerField("machineFolder", this, "machineFolder");
    497         registerField("machineBaseName", this, "machineBaseName");
    498         registerField("guestOSFamiyId", this, "guestOSFamiyId");
    499         registerField("ISOFilePath", this, "ISOFilePath");
    500         registerField("isUnattendedEnabled", this, "isUnattendedEnabled");
    501         registerField("startHeadless", this, "startHeadless");
    502         registerField("detectedOSTypeId", this, "detectedOSTypeId");
    503     }
     489    QGridLayout *pMainLayout = new QGridLayout(this);;
     490    createWidgets(pMainLayout);
     491    void createConnections();
     492    /* Register fields: */
     493    registerField("name*", m_pNameAndSystemEditor, "name", SIGNAL(sigNameChanged(const QString &)));
     494    registerField("type", m_pNameAndSystemEditor, "type", SIGNAL(sigOsTypeChanged()));
     495    registerField("machineFilePath", this, "machineFilePath");
     496    registerField("machineFolder", this, "machineFolder");
     497    registerField("machineBaseName", this, "machineBaseName");
     498    registerField("guestOSFamiyId", this, "guestOSFamiyId");
     499    registerField("ISOFilePath", this, "ISOFilePath");
     500    registerField("isUnattendedEnabled", this, "isUnattendedEnabled");
     501    registerField("startHeadless", this, "startHeadless");
     502    registerField("detectedOSTypeId", this, "detectedOSTypeId");
     503}
     504
     505void UIWizardNewVMPageBasic1::createConnections()
     506{
     507    connect(m_pButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked),
     508            this, &UIWizardNewVMPageBasic1::sltUnattendedCheckBoxToggle);
     509    connect(m_pISOFilePathSelector, &UIFilePathSelector::pathChanged, this, &UIWizardNewVMPageBasic1::sltISOPathChanged);
     510    connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigNameChanged, this, &UIWizardNewVMPageBasic1::sltNameChanged);
     511    connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigPathChanged, this, &UIWizardNewVMPageBasic1::sltPathChanged);
     512    connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged, this, &UIWizardNewVMPageBasic1::sltOsTypeChanged);
    504513}
    505514
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.h

    r85055 r85078  
    2727/* Forward declarations: */
    2828class QCheckBox;
     29class QGridLayout;
    2930class QLabel;
    3031class QRadioButton;
     
    3233class UIFilePathSelector;
    3334class UINameAndSystemEditor;
     35class QButtonGroup;
    3436
    3537/* 1st page of the New Virtual Machine wizard (base part): */
     
    7476    void composeMachineFilePath();
    7577    bool checkISOFile() const;
     78    /** Creates the page widgets and adds them into the @p pGridLayout. */
     79    void createWidgets(QGridLayout *pGridLayout);
    7680
    7781    /** Holds the simple variant button instance. */
     
    9296    /** Provides a path selector and a line edit field for path and name entry. */
    9397    UINameAndSystemEditor *m_pNameAndSystemEditor;
     98    /* Widgets: */
     99    QIRichTextLabel *m_pLabel1;
     100    QIRichTextLabel *m_pLabel2;
     101    QButtonGroup *m_pButtonGroup;
    94102    QString m_strDetectedOSTypeId;
    95103
     
    154162private:
    155163
    156     void prepare();
    157164    /* Translation stuff: */
    158165    void retranslateUi();
    159166
    160167    /* Prepare stuff: */
     168    void prepare();
     169    void createConnections();
    161170    void initializePage();
    162171    void cleanupPage();
     
    165174    virtual bool validatePage() /* override */;
    166175
    167     /* Widgets: */
    168     QIRichTextLabel *m_pLabel1;
    169     QIRichTextLabel *m_pLabel2;
    170176};
    171177
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