VirtualBox

Ignore:
Timestamp:
Jul 8, 2020 8:48:27 AM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9515. Enabling disabling unatteded related widgets correctly

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

Legend:

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

    r85052 r85104  
    333333    /* Unlock the signals of m_pComboType: */
    334334    m_pComboType->blockSignals(false);
     335
     336    /* Notify listeners about this change: */
     337    emit sigOSFamilyChanged();
    335338}
    336339
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.h

    r85052 r85104  
    6464    /** Notifies listeners about VM OS type change. */
    6565    void sigOsTypeChanged();
     66    /** Notifies listeners about VM OS family change. */
     67    void sigOSFamilyChanged();
    6668
    6769public:
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.h

    r85090 r85104  
    128128class UIWizardNewVMPageBasic1 : public UIWizardPage, public UIWizardNewVMPage1
    129129{
     130
    130131    Q_OBJECT;
    131132    Q_PROPERTY(QString machineFilePath READ machineFilePath WRITE setMachineFilePath);
     
    137138    Q_PROPERTY(bool startHeadless READ startHeadless);
    138139    Q_PROPERTY(QString detectedOSTypeId READ detectedOSTypeId);
    139 
    140140
    141141public:
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic2.cpp

    r85090 r85104  
    285285        QWidget *pProductKeyWidget = m_pToolBox->widget(ToolBoxItems_ProductKey);
    286286        if (pProductKeyWidget)
    287             pProductKeyWidget->setEnabled(isProductKeyWidgetVisible());
     287            pProductKeyWidget->setEnabled(isProductKeyWidgetEnabled());
    288288    }
    289289    UIWizardPage::showEvent(pEvent);
     
    305305}
    306306
    307 bool UIWizardNewVMPageBasic2::isProductKeyWidgetVisible() const
     307bool UIWizardNewVMPageBasic2::isProductKeyWidgetEnabled() const
    308308{
    309309    UIWizardNewVM *pWizard = qobject_cast<UIWizardNewVM*>(wizard());
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic2.h

    r85090 r85104  
    123123    bool isComplete() const;
    124124    /** Returns true if we show the widgets for guest os product key. */
    125     bool isProductKeyWidgetVisible() const;
     125    bool isProductKeyWidgetEnabled() const;
    126126
    127127    QIRichTextLabel *m_pLabel;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp

    r85090 r85104  
    5555        QGridLayout *pNameContainerLayout = new QGridLayout(m_pNameAndSystemContainer);
    5656        createNameOSTypeWidgets(pNameContainerLayout, false);
     57        m_pGAInstallContainer = createGAInstallWidgets();
     58        m_pUsernameHostnameContainer = createUserNameHostNameWidgets();
     59
    5760        m_pToolBox->insertItem(ExpertToolboxItems_NameAndOSType, m_pNameAndSystemContainer, "");
    58         m_pToolBox->insertItem(ExpertToolboxItems_UsernameHostname, createUserNameHostNameWidgets(), "");
    59         m_pToolBox->insertItem(ExpertToolboxItems_GAInstall, createGAInstallWidgets(), "");
     61        m_pToolBox->insertItem(ExpertToolboxItems_UsernameHostname, m_pUsernameHostnameContainer, "");
     62        m_pToolBox->insertItem(ExpertToolboxItems_GAInstall, m_pGAInstallContainer, "");
    6063        m_pToolBox->insertItem(ExpertToolboxItems_ProductKey, createProductKeyWidgets(), "");
    6164        m_pToolBox->insertItem(ExpertToolboxItems_Disk, createDiskWidgets(), "");
     
    143146void UIWizardNewVMPageExpert::sltUnattendedCheckBoxToggle()
    144147{
    145     const bool fEnabled = m_pButtonUnattended->isChecked();
    146     if (m_pISOSelectorLabel)
    147         m_pISOSelectorLabel->setEnabled(fEnabled);
    148     if (m_pISOFilePathSelector)
    149         m_pISOFilePathSelector->setEnabled(fEnabled);
    150     if (m_pStartHeadlessLabel)
    151         m_pStartHeadlessLabel->setEnabled(fEnabled);
    152     if (m_pStartHeadlessCheckBox)
    153         m_pStartHeadlessCheckBox->setEnabled(fEnabled);
     148    if (m_pButtonUnattended)
     149        disableEnableUnattendedRelatedWidgets(m_pButtonUnattended->isChecked());
    154150    emit completeChanged();
    155151}
     
    175171    Q_UNUSED(strPath);
    176172    emit completeChanged();
     173}
     174
     175void UIWizardNewVMPageExpert::sltOSFamilyTypeChanged()
     176{
     177    if (m_pProductKeyLabel)
     178        m_pProductKeyLabel->setEnabled(isProductKeyWidgetEnabled());
     179    if (m_pProductKeyLineEdit)
     180        m_pProductKeyLineEdit->setEnabled(isProductKeyWidgetEnabled());
    177181}
    178182
     
    238242{
    239243    /* Connections for Name, OS Type, and unattended install stuff: */
    240     connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigNameChanged,
    241             this, &UIWizardNewVMPageExpert::sltNameChanged);
    242     connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigPathChanged,
    243             this, &UIWizardNewVMPageExpert::sltPathChanged);
    244     connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged,
    245             this, &UIWizardNewVMPageExpert::sltOsTypeChanged);
    246     connect(m_pButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked),
    247             this, &UIWizardNewVMPageExpert::sltUnattendedCheckBoxToggle);
    248     connect(m_pISOFilePathSelector, &UIFilePathSelector::pathChanged,
    249             this, &UIWizardNewVMPageExpert::sltISOPathChanged);
     244    if (m_pNameAndSystemEditor)
     245    {
     246        connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigNameChanged,
     247                this, &UIWizardNewVMPageExpert::sltNameChanged);
     248        connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigPathChanged,
     249                this, &UIWizardNewVMPageExpert::sltPathChanged);
     250        connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged,
     251                this, &UIWizardNewVMPageExpert::sltOsTypeChanged);
     252        connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOSFamilyChanged,
     253                this, &UIWizardNewVMPageExpert::sltOSFamilyTypeChanged);
     254    }
     255    if (m_pButtonGroup)
     256        connect(m_pButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked),
     257                this, &UIWizardNewVMPageExpert::sltUnattendedCheckBoxToggle);
     258    if (m_pISOFilePathSelector)
     259        connect(m_pISOFilePathSelector, &UIFilePathSelector::pathChanged,
     260                this, &UIWizardNewVMPageExpert::sltISOPathChanged);
    250261
    251262    /* Connections for username, password, and hostname: */
    252     connect(m_pUserNamePasswordEditor, &UIUserNamePasswordEditor::sigSomeTextChanged,
    253             this, &UIWizardNewVMPageExpert::completeChanged);
    254     connect(m_pInstallGACheckBox, &QCheckBox::toggled, this,
    255             &UIWizardNewVMPageExpert::sltInstallGACheckBoxToggle);
    256     connect(m_pISOFilePathSelector, &UIFilePathSelector::pathChanged,
    257             this, &UIWizardNewVMPageExpert::sltGAISOPathChanged);
     263    if (m_pUserNamePasswordEditor)
     264        connect(m_pUserNamePasswordEditor, &UIUserNamePasswordEditor::sigSomeTextChanged,
     265                this, &UIWizardNewVMPageExpert::completeChanged);
     266    if (m_pInstallGACheckBox)
     267        connect(m_pInstallGACheckBox, &QCheckBox::toggled, this,
     268                &UIWizardNewVMPageExpert::sltInstallGACheckBoxToggle);
     269    if (m_pGAISOFilePathSelector)
     270        connect(m_pGAISOFilePathSelector, &UIFilePathSelector::pathChanged,
     271                this, &UIWizardNewVMPageExpert::sltGAISOPathChanged);
    258272
    259273    /* Connections for disk and hardware stuff: */
    260     connect(m_pDiskSkip, &QRadioButton::toggled,
    261             this, &UIWizardNewVMPageExpert::sltVirtualDiskSourceChanged);
    262     connect(m_pDiskCreate, &QRadioButton::toggled,
    263             this, &UIWizardNewVMPageExpert::sltVirtualDiskSourceChanged);
    264     connect(m_pDiskPresent, &QRadioButton::toggled,
    265             this, &UIWizardNewVMPageExpert::sltVirtualDiskSourceChanged);
    266     connect(m_pDiskSelector, static_cast<void(UIMediaComboBox::*)(int)>(&UIMediaComboBox::currentIndexChanged),
    267             this, &UIWizardNewVMPageExpert::sltVirtualDiskSourceChanged);
    268     connect(m_pVMMButton, &QIToolButton::clicked,
    269             this, &UIWizardNewVMPageExpert::sltGetWithFileOpenDialog);
     274    if (m_pDiskSkip)
     275        connect(m_pDiskSkip, &QRadioButton::toggled,
     276                this, &UIWizardNewVMPageExpert::sltVirtualDiskSourceChanged);
     277    if (m_pDiskCreate)
     278        connect(m_pDiskCreate, &QRadioButton::toggled,
     279                this, &UIWizardNewVMPageExpert::sltVirtualDiskSourceChanged);
     280    if (m_pDiskPresent)
     281        connect(m_pDiskPresent, &QRadioButton::toggled,
     282                this, &UIWizardNewVMPageExpert::sltVirtualDiskSourceChanged);
     283    if (m_pDiskSelector)
     284        connect(m_pDiskSelector, static_cast<void(UIMediaComboBox::*)(int)>(&UIMediaComboBox::currentIndexChanged),
     285                this, &UIWizardNewVMPageExpert::sltVirtualDiskSourceChanged);
     286    if (m_pVMMButton)
     287        connect(m_pVMMButton, &QIToolButton::clicked,
     288                this, &UIWizardNewVMPageExpert::sltGetWithFileOpenDialog);
    270289}
    271290
     
    301320    if (m_pDiskSelector)
    302321        m_pDiskSelector->setCurrentIndex(0);
     322
     323    if (m_pButtonUnattended)
     324        disableEnableUnattendedRelatedWidgets(m_pButtonUnattended->isChecked());
     325    m_pProductKeyLabel->setEnabled(isProductKeyWidgetEnabled());
     326    m_pProductKeyLineEdit->setEnabled(isProductKeyWidgetEnabled());
    303327}
    304328
     
    356380    return fResult;
    357381}
     382
     383bool UIWizardNewVMPageExpert::isProductKeyWidgetEnabled() const
     384{
     385    UIWizardNewVM *pWizard = qobject_cast<UIWizardNewVM*>(wizard());
     386    if (!pWizard || !pWizard->isUnattendedInstallEnabled() || !pWizard->isGuestOSTypeWindows())
     387        return false;
     388    return true;
     389}
     390
     391void UIWizardNewVMPageExpert::disableEnableUnattendedRelatedWidgets(bool fEnabled)
     392{
     393    if (m_pISOSelectorLabel)
     394        m_pISOSelectorLabel->setEnabled(fEnabled);
     395    if (m_pISOFilePathSelector)
     396        m_pISOFilePathSelector->setEnabled(fEnabled);
     397    if (m_pStartHeadlessLabel)
     398        m_pStartHeadlessLabel->setEnabled(fEnabled);
     399    if (m_pStartHeadlessCheckBox)
     400        m_pStartHeadlessCheckBox->setEnabled(fEnabled);
     401    if (m_pGAInstallContainer)
     402        m_pGAInstallContainer->setEnabled(fEnabled);
     403    if (m_pUsernameHostnameContainer)
     404        m_pUsernameHostnameContainer->setEnabled(fEnabled);
     405    if (m_pProductKeyLabel)
     406        m_pProductKeyLabel->setEnabled(isProductKeyWidgetEnabled());
     407    if (m_pProductKeyLineEdit)
     408        m_pProductKeyLineEdit->setEnabled(isProductKeyWidgetEnabled());
     409}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.h

    r85090 r85104  
    8383    void sltInstallGACheckBoxToggle(bool fChecked);
    8484    void sltGAISOPathChanged(const QString &strPath);
     85    void sltOSFamilyTypeChanged();
    8586
    8687private:
     
    107108    bool validatePage();
    108109
     110    bool isProductKeyWidgetEnabled() const;
     111    void disableEnableUnattendedRelatedWidgets(bool fEnabled);
     112
    109113    /** Widgets. */
    110114    QWidget *m_pNameAndSystemContainer;
     115    QWidget *m_pGAInstallContainer;
     116    QWidget *m_pUsernameHostnameContainer;
    111117    QToolBox  *m_pToolBox;
    112118};
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