VirtualBox

Changeset 90033 in vbox


Ignore:
Timestamp:
Jul 5, 2021 3:38:36 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9996. Refactoring unattended install page of the new vm wizard.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.cpp

    r88239 r90033  
    386386
    387387    /* Notify listeners about this change: */
    388     emit sigOSFamilyChanged();
     388    emit sigOSFamilyChanged(m_strFamilyId);
    389389}
    390390
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.h

    r88150 r90033  
    7070    void sigOsTypeChanged();
    7171    /** Notifies listeners about VM OS family change. */
    72     void sigOSFamilyChanged();
     72    void sigOSFamilyChanged(const QString &strFamilyId);
    7373
    7474public:
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp

    r90018 r90033  
    6161    , m_iSASCount(0)
    6262    , m_iUSBCount(0)
     63    , m_fInstallGuestAdditions(false)
    6364{
    6465#ifndef VBOX_WS_MAC
     
    714715}
    715716
     717const QString &UIWizardNewVM::guestOSFamilyId() const
     718{
     719    return m_strGuestOSFamilyId;
     720}
     721
     722void UIWizardNewVM::setGuestOSFamilyId(const QString &strGuestOSFamilyId)
     723{
     724    m_strGuestOSFamilyId = strGuestOSFamilyId;
     725}
     726
     727bool UIWizardNewVM::installGuestAdditions() const
     728{
     729    return m_fInstallGuestAdditions;
     730}
     731
     732void UIWizardNewVM::setInstallGuestAdditions(bool fInstallGA)
     733{
     734    m_fInstallGuestAdditions = fInstallGA;
     735}
     736
    716737const UIUnattendedInstallData &UIWizardNewVM::unattendedInstallData() const
    717738{
     
    746767}
    747768
    748 // bool UIWizardNewVM::isGuestOSTypeWindows() const
    749 // {
    750 //     return getStringFieldValue("guestOSFamiyId").contains("windows", Qt::CaseInsensitive);
    751 // }
     769bool UIWizardNewVM::isGuestOSTypeWindows() const
     770{
     771    return m_strGuestOSFamilyId.contains("windows", Qt::CaseInsensitive);
     772}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.h

    r90018 r90033  
    8383    const UIUnattendedInstallData &unattendedInstallData() const;
    8484    bool isUnattendedEnabled() const;
    85     //bool isGuestOSTypeWindows() const;
     85    bool isGuestOSTypeWindows() const;
    8686    CMedium &virtualDisk();
    8787    void setVirtualDisk(const CMedium &medium);
     
    105105    void setDetectedOSTypeId(const QString &strDetectedOSTypeId);
    106106
     107    const QString &guestOSFamilyId() const;
     108    void setGuestOSFamilyId(const QString &strGuestOSFamilyId);
     109
     110    bool installGuestAdditions() const;
     111    void setInstallGuestAdditions(bool fInstallGA);
     112
    107113protected:
    108114
     
    116122    void configureVM(const QString &strGuestTypeId, const CGuestOSType &comGuestType);
    117123    bool attachDefaultDevices(const CGuestOSType &comGuestType);
    118 
    119     friend class UIWizardNewVMPageDisk;
    120     friend class UIWizardNewVMPageExpert;
    121124
    122125private slots:
     
    165168    /** Type Id od the OS detected from the ISO file by IUnattended. */
    166169    QString m_strDetectedOSTypeId;
     170
     171    /** Holds the VM OS family ID. */
     172    QString  m_strGuestOSFamilyId;
     173
     174    /** True if guest additions are to be installed during unattended install. */
     175    bool m_fInstallGuestAdditions;
    167176};
    168177
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMNameOSTypePageBasic.cpp

    r90019 r90033  
    293293// }
    294294
    295 // QString UIWizardNewVMNameOSTypePage::guestOSFamiyId() const
    296 // {
    297 //     if (!m_pNameAndSystemEditor)
    298 //         return QString();
    299 //     return m_pNameAndSystemEditor->familyId();
    300 // }
    301 
    302295
    303296// QString UIWizardNewVMNameOSTypePage::ISOFilePath() const
     
    392385        connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged, this, &UIWizardNewVMNameOSTypePageBasic::sltOsTypeChanged);
    393386        connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigImageChanged, this, &UIWizardNewVMNameOSTypePageBasic::sltISOPathChanged);
     387        connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOSFamilyChanged, this, &UIWizardNewVMNameOSTypePageBasic::sltGuestOSFamilChanged);
    394388    }
    395389}
     
    405399void UIWizardNewVMNameOSTypePageBasic::sltNameChanged(const QString &strNewName)
    406400{
    407     Q_UNUSED(strNewName);
    408401    UIWizardNewVMNameOSTypePage::onNameChanged(m_pNameAndSystemEditor, strNewName);
    409402    UIWizardNewVMNameOSTypePage::composeMachineFilePath(m_pNameAndSystemEditor, m_pWizard);
     
    451444    if (m_pNameAndSystemEditor)
    452445        m_pNameAndSystemEditor->setFocus();
    453     //setSkipCheckBoxEnable();
    454 }
    455 
    456 void UIWizardNewVMNameOSTypePageBasic::cleanupPage()
    457 {
    458     // cleanupMachineFolder();
    459     // /* Call to base-class: */
    460     // UIWizardPage::cleanupPage();
    461 }
     446    setSkipCheckBoxEnable();
     447}
     448
     449// void UIWizardNewVMNameOSTypePageBasic::cleanupPage()
     450// {
     451//    cleanupMachineFolder();
     452//    /* Call to base-class: */
     453//    UIWizardPage::cleanupPage();
     454// }
    462455
    463456bool UIWizardNewVMNameOSTypePageBasic::validatePage()
     
    476469    if (fileInfo.exists() && fileInfo.isReadable())
    477470        uiCommon().updateRecentlyUsedMediumListAndFolder(UIMediumDeviceType_DVD, strPath);
    478     // setSkipCheckBoxEnable();
    479     // emit completeChanged();
     471    setSkipCheckBoxEnable();
     472    emit completeChanged();
     473}
     474
     475void UIWizardNewVMNameOSTypePageBasic::sltGuestOSFamilChanged(const QString &strGuestOSFamilyId)
     476{
     477    if (m_pWizard)
     478        m_pWizard->setGuestOSFamilyId(strGuestOSFamilyId);
    480479}
    481480
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMNameOSTypePageBasic.h

    r90018 r90033  
    102102    void sltOsTypeChanged();
    103103    void sltISOPathChanged(const QString &strPath);
     104    void sltGuestOSFamilChanged(const QString &strGuestOSFamilyId);
    104105
    105106private:
     
    112113    void createConnections();
    113114    void initializePage();
    114     void cleanupPage();
     115    //void cleanupPage();
    115116    QWidget *createNameOSTypeWidgets();
    116117    void markWidgets() const;
    117118    void setSkipCheckBoxEnable();
    118119    bool isUnattendedEnabled() const;
    119 
    120120
    121121    UIWizardNewVM *m_pWizard;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMUnattendedPageBasic.cpp

    r90003 r90033  
    8484// }
    8585
    86 // bool UIWizardNewVMUnattendedPage::installGuestAdditions() const
    87 // {
    88 //     if (!m_pGAInstallationISOContainer)
    89 //         return false;
    90 //     return m_pGAInstallationISOContainer->isChecked();
    91 // }
    9286
    9387// void UIWizardNewVMUnattendedPage::setInstallGuestAdditions(bool fInstallGA)
     
    118112
    119113
    120 // bool UIWizardNewVMUnattendedPage::checkGAISOFile() const
    121 // {
    122 //     if (!m_pGAISOFilePathSelector)
    123 //         return false;
    124 //     /* GA ISO selector should not be empty since GA install check box is checked at this point: */
    125 //     const QString &strPath = m_pGAISOFilePathSelector->path();
    126 //     if (strPath.isNull() || strPath.isEmpty())
    127 //         return false;
    128 //     QFileInfo fileInfo(strPath);
    129 //     if (!fileInfo.exists() || !fileInfo.isReadable())
    130 //         return false;
    131 //     return true;
    132 // }
    133 
    134 // void UIWizardNewVMUnattendedPage::markWidgets() const
    135 // {
    136 //     if (installGuestAdditions())
    137 //         m_pGAISOFilePathSelector->mark(!checkGAISOFile());
    138 // }
    139 
    140 
    141 // void UIWizardNewVMUnattendedPage::disableEnableGAWidgets(bool fEnabled)
    142 // {
    143 //     if (m_pGAISOPathLabel)
    144 //         m_pGAISOPathLabel->setEnabled(fEnabled);
    145 //     if (m_pGAISOFilePathSelector)
    146 //         m_pGAISOFilePathSelector->setEnabled(fEnabled);
    147 // }
    148 
    149 // void UIWizardNewVMUnattendedPage::disableEnableProductKeyWidgets(bool fEnabled)
    150 // {
    151 //     if (m_pProductKeyLabel)
    152 //         m_pProductKeyLabel->setEnabled(fEnabled);
    153 //     if (m_pProductKeyLineEdit)
    154 //         m_pProductKeyLineEdit->setEnabled(fEnabled);
    155 // }
     114bool UIWizardNewVMUnattendedPage::checkGAISOFile(UIFilePathSelector *pGAISOFilePathSelector)
     115{
     116    if (!pGAISOFilePathSelector)
     117        return false;
     118    /* GA ISO selector should not be empty since GA install check box is checked at this point: */
     119    const QString &strPath = pGAISOFilePathSelector->path();
     120    if (strPath.isNull() || strPath.isEmpty())
     121        return false;
     122    QFileInfo fileInfo(strPath);
     123    if (!fileInfo.exists() || !fileInfo.isReadable())
     124        return false;
     125    return true;
     126}
     127
     128
    156129
    157130// bool UIWizardNewVMUnattendedPage::startHeadless() const
     
    162135// }
    163136
    164 
    165 // bool UIWizardNewVMUnattendedPage::isGAInstallEnabled() const
    166 // {
    167 //     if (m_pGAInstallationISOContainer && m_pGAInstallationISOContainer->isChecked())
    168 //         return true;
    169 //     return false;
    170 // }
    171137
    172138UIWizardNewVMUnattendedPageBasic::UIWizardNewVMUnattendedPageBasic()
     
    184150    , m_pProductKeyLabel(0)
    185151{
     152    m_pWizard = qobject_cast<UIWizardNewVM*>(wizard());
    186153    prepare();
    187154}
     
    199166    pMainLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding), 3, 0, 1, 2);
    200167
    201 
    202     // createConnections();
     168     createConnections();
    203169}
    204170
    205171void UIWizardNewVMUnattendedPageBasic::createConnections()
    206172{
    207     // if (m_pUserNamePasswordEditor)
    208     //     connect(m_pUserNamePasswordEditor, &UIUserNamePasswordEditor::sigSomeTextChanged,
    209     //             this, &UIWizardNewVMUnattendedPageBasic::completeChanged);
    210     // if (m_pGAISOFilePathSelector)
    211     //     connect(m_pGAISOFilePathSelector, &UIFilePathSelector::pathChanged,
    212     //             this, &UIWizardNewVMUnattendedPageBasic::sltGAISOPathChanged);
    213     // if (m_pGAISOFilePathSelector)
    214     //     connect(m_pGAInstallationISOContainer, &QGroupBox::toggled,
    215     //             this, &UIWizardNewVMUnattendedPageBasic::sltInstallGACheckBoxToggle);
     173    if (m_pUserNamePasswordEditor)
     174        connect(m_pUserNamePasswordEditor, &UIUserNamePasswordEditor::sigSomeTextChanged,
     175                this, &UIWizardNewVMUnattendedPageBasic::completeChanged);
     176    if (m_pGAISOFilePathSelector)
     177        connect(m_pGAISOFilePathSelector, &UIFilePathSelector::pathChanged,
     178                this, &UIWizardNewVMUnattendedPageBasic::sltGAISOPathChanged);
     179    if (m_pGAISOFilePathSelector)
     180        connect(m_pGAInstallationISOContainer, &QGroupBox::toggled,
     181                this, &UIWizardNewVMUnattendedPageBasic::sltInstallGACheckBoxToggle);
    216182}
    217183
     
    254220void UIWizardNewVMUnattendedPageBasic::initializePage()
    255221{
    256     // disableEnableProductKeyWidgets(isProductKeyWidgetEnabled());
    257     // disableEnableGAWidgets(m_pGAInstallationISOContainer ? m_pGAInstallationISOContainer->isChecked() : false);
    258     // retranslateUi();
     222    disableEnableProductKeyWidgets(isProductKeyWidgetEnabled());
     223    disableEnableGAWidgets(m_pGAInstallationISOContainer ? m_pGAInstallationISOContainer->isChecked() : false);
     224    retranslateUi();
    259225}
    260226
    261227bool UIWizardNewVMUnattendedPageBasic::isComplete() const
    262228{
    263 //     markWidgets();
    264 //     if (isGAInstallEnabled() && !checkGAISOFile())
    265 //         return false;
    266 // //     bool fIsComplete = true;
    267 // //     if (!checkGAISOFile())
    268 // //     {
    269 // //         m_pToolBox->setItemIcon(ToolBoxItems_GAInstall, UIIconPool::iconSet(":/status_error_16px.png"));
    270 // //         fIsComplete = false;
    271 // //     }
    272 //     if (m_pUserNamePasswordEditor && !m_pUserNamePasswordEditor->isComplete())
    273 //         return false;
    274 // //     {
    275 // //         m_pToolBox->setItemIcon(ToolBoxItems_UserNameHostname, UIIconPool::iconSet(":/status_error_16px.png"));
    276 // //         fIsComplete = false;
    277 // //     }
    278 // //     return fIsComplete;
     229    markWidgets();
     230    if (m_pWizard && m_pWizard->installGuestAdditions() &&
     231        !UIWizardNewVMUnattendedPage::checkGAISOFile(m_pGAISOFilePathSelector))
     232        return false;
     233    if (m_pUserNamePasswordEditor && !m_pUserNamePasswordEditor->isComplete())
     234        return false;
    279235    return true;
    280236}
     
    286242void UIWizardNewVMUnattendedPageBasic::showEvent(QShowEvent *pEvent)
    287243{
    288     Q_UNUSED(pEvent);
    289     // if (m_pToolBox)
    290     //     m_pToolBox->setItemEnabled(ToolBoxItems_ProductKey, isProductKeyWidgetEnabled());
    291     //UIWizardPage::showEvent(pEvent);
     244    UINativeWizardPage::showEvent(pEvent);
    292245}
    293246
    294247void UIWizardNewVMUnattendedPageBasic::sltInstallGACheckBoxToggle(bool fEnabled)
    295248{
    296     Q_UNUSED(fEnabled);
    297     // disableEnableGAWidgets(fEnabled);
    298     // emit completeChanged();
     249    disableEnableGAWidgets(fEnabled);
     250    if (m_pWizard)
     251        m_pWizard->setInstallGuestAdditions(fEnabled);
     252    emit completeChanged();
    299253}
    300254
     
    302256{
    303257    Q_UNUSED(strPath);
    304     // emit completeChanged();
     258    emit completeChanged();
    305259}
    306260
    307261bool UIWizardNewVMUnattendedPageBasic::isProductKeyWidgetEnabled() const
    308262{
    309     // UIWizardNewVM *pWizard = qobject_cast<UIWizardNewVM*>(wizard());
    310     // if (!pWizard || !pWizard->isUnattendedEnabled() || !pWizard->isGuestOSTypeWindows())
    311     //     return false;
     263    if (!m_pWizard || !m_pWizard->isUnattendedEnabled() || !m_pWizard->isGuestOSTypeWindows())
     264        return false;
    312265    return true;
    313266}
     
    419372    return m_pGAInstallationISOContainer;
    420373}
     374
     375void UIWizardNewVMUnattendedPageBasic::disableEnableGAWidgets(bool fEnabled)
     376{
     377    if (m_pGAISOPathLabel)
     378        m_pGAISOPathLabel->setEnabled(fEnabled);
     379    if (m_pGAISOFilePathSelector)
     380        m_pGAISOFilePathSelector->setEnabled(fEnabled);
     381}
     382
     383void UIWizardNewVMUnattendedPageBasic::disableEnableProductKeyWidgets(bool fEnabled)
     384{
     385    if (m_pProductKeyLabel)
     386        m_pProductKeyLabel->setEnabled(fEnabled);
     387    if (m_pProductKeyLineEdit)
     388        m_pProductKeyLineEdit->setEnabled(fEnabled);
     389}
     390
     391void UIWizardNewVMUnattendedPageBasic::markWidgets() const
     392{
     393    if (m_pWizard && m_pWizard->installGuestAdditions())
     394        m_pGAISOFilePathSelector->mark(!UIWizardNewVMUnattendedPage::checkGAISOFile(m_pGAISOFilePathSelector));
     395}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMUnattendedPageBasic.h

    r90003 r90033  
    3232class QLabel;
    3333class QLineEdit;
    34 class QToolBox;
    3534class QIRichTextLabel;
    3635class UIFilePathSelector;
    3736class UIUserNamePasswordEditor;
     37class UIWizardNewVM;
    3838struct UIUnattendedInstallData;
    3939
    4040
    41 // class UIWizardNewVMUnattendedPage : public UIWizardPageBase
    42 // {
    43 // public:
    44 
     41namespace UIWizardNewVMUnattendedPage
     42{
     43    bool checkGAISOFile(UIFilePathSelector *pGAISOFilePathSelector);
    4544//     UIWizardNewVMUnattendedPage();
    4645
     
    5352//         QString hostname() const;
    5453//         void setHostname(const QString &strHostName);
    55 //         bool installGuestAdditions() const;
    56 //         void setInstallGuestAdditions(bool fInstallGA);
    5754//         QString guestAdditionsISOPath() const;
    5855//         void setGuestAdditionsISOPath(const QString &strISOPath);
     
    6057//     /** @} */
    6158
    62 // protected:
    63 //     enum
    64 //     {
    65 //         ToolBoxItems_UserNameHostname,
    66 //         ToolBoxItems_GAInstall,
    67 //         ToolBoxItems_ProductKey
    68 //     };
    69 
    7059
    7160//     /** Returns false if ISO path selector is non empty but has invalid file path. */
    7261//     bool checkGAISOFile() const;
    73 //     void markWidgets() const;
     62
    7463//     void retranslateWidgets();
    75 //     void disableEnableGAWidgets(bool fEnabled);
    76 //     void disableEnableProductKeyWidgets(bool fEnabled);
     64
    7765
    7866//     bool startHeadless() const;
    7967
    80 //     bool isGAInstallEnabled() const;
    8168
    82 
    83 // private:
    84 
    85 //     friend class UIWizardNewVM;
    86 // };
     69}
    8770
    8871class UIWizardNewVMUnattendedPageBasic : public UINativeWizardPage
     
    118101    /** Returns true if we show the widgets for guest os product key. */
    119102    bool isProductKeyWidgetEnabled() const;
     103    void disableEnableProductKeyWidgets(bool fEnabled);
     104    void disableEnableGAWidgets(bool fEnabled);
     105    void markWidgets() const;
    120106
    121     QIRichTextLabel *m_pLabel;
     107    UIWizardNewVM *m_pWizard;
    122108
    123109    /** @name Widgets
    124110      * @{ */
     111        QIRichTextLabel *m_pLabel;
    125112        QGroupBox *m_pUserNameContainer;
    126113        QGroupBox *m_pAdditionalOptionsContainer;
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