VirtualBox

Changeset 90169 in vbox


Ignore:
Timestamp:
Jul 13, 2021 4:16:35 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9996. Using UIGAInstallationGroupBox

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

Legend:

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

    r90165 r90169  
    1717
    1818/* Qt includes: */
     19#include <QLabel>
    1920#include <QVBoxLayout>
    2021
    2122/* GUI includes: */
     23#include "UICommon.h"
     24#include "UIFilePathSelector.h"
    2225#include "UIUserNamePasswordEditor.h"
     26#include "UIWizardNewVM.h"
    2327#include "UIWizardNewVMEditors.h"
    2428
     
    2630#include "iprt/assert.h"
    2731
     32/*********************************************************************************************************************************
     33*   UIUserNamePasswordGroupBox implementation.                                                                                           *
     34*********************************************************************************************************************************/
     35
    2836UIUserNamePasswordGroupBox::UIUserNamePasswordGroupBox(QWidget *pParent /* = 0 */)
    2937    :QGroupBox(pParent)
     38    , m_pUserNamePasswordEditor(0)
    3039{
    3140    prepare();
     
    8594        m_pUserNamePasswordEditor->setLabelsVisible(fVisible);
    8695}
     96
     97/*********************************************************************************************************************************
     98*   UIUserNamePasswordGroupBox implementation.                                                                                           *
     99*********************************************************************************************************************************/
     100
     101UIGAInstallationGroupBox::UIGAInstallationGroupBox(QWidget *pParent /* = 0 */)
     102    : QIWithRetranslateUI<QGroupBox>(pParent)
     103    , m_pGAISOPathLabel(0)
     104    , m_pGAISOFilePathSelector(0)
     105
     106{
     107    prepare();
     108}
     109
     110void UIGAInstallationGroupBox::prepare()
     111{
     112    setCheckable(true);
     113
     114    QHBoxLayout *pGAInstallationISOLayout = new QHBoxLayout(this);
     115    AssertReturnVoid(pGAInstallationISOLayout);
     116    m_pGAISOPathLabel = new QLabel;
     117    AssertReturnVoid(m_pGAISOPathLabel);
     118    m_pGAISOPathLabel->setAlignment(Qt::AlignRight);
     119    m_pGAISOPathLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     120
     121    pGAInstallationISOLayout->addWidget(m_pGAISOPathLabel);
     122
     123    m_pGAISOFilePathSelector = new UIFilePathSelector;
     124    AssertReturnVoid(m_pGAISOFilePathSelector);
     125
     126    m_pGAISOFilePathSelector->setResetEnabled(false);
     127    m_pGAISOFilePathSelector->setMode(UIFilePathSelector::Mode_File_Open);
     128    m_pGAISOFilePathSelector->setFileDialogFilters("ISO Images(*.iso *.ISO)");
     129    m_pGAISOFilePathSelector->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     130    m_pGAISOFilePathSelector->setInitialPath(uiCommon().defaultFolderPathForType(UIMediumDeviceType_DVD));
     131    if (m_pGAISOPathLabel)
     132        m_pGAISOPathLabel->setBuddy(m_pGAISOFilePathSelector);
     133
     134    pGAInstallationISOLayout->addWidget(m_pGAISOFilePathSelector);
     135
     136    connect(m_pGAISOFilePathSelector, &UIFilePathSelector::pathChanged,
     137            this, &UIGAInstallationGroupBox::sigPathChanged);
     138    connect(this, &UIGAInstallationGroupBox::toggled,
     139            this, &UIGAInstallationGroupBox::sltToggleWidgetsEnabled);
     140    retranslateUi();
     141}
     142
     143void UIGAInstallationGroupBox::retranslateUi()
     144{
     145    if (m_pGAISOFilePathSelector)
     146        m_pGAISOFilePathSelector->setToolTip(UIWizardNewVM::tr("Please select an installation medium (ISO file)"));
     147    if (m_pGAISOPathLabel)
     148        m_pGAISOPathLabel->setText(UIWizardNewVM::tr("GA I&nstallation ISO:"));
     149    setTitle(UIWizardNewVM::tr("Gu&est Additions"));
     150    setToolTip(UIWizardNewVM::tr("<p>When checked the guest additions will be installed "
     151                                                                    "after the OS install.</p>"));
     152}
     153
     154QString UIGAInstallationGroupBox::path() const
     155{
     156    if (m_pGAISOFilePathSelector)
     157        return m_pGAISOFilePathSelector->path();
     158    return QString();
     159}
     160
     161void UIGAInstallationGroupBox::setPath(const QString &strPath, bool fRefreshText /* = true */)
     162{
     163    if (m_pGAISOFilePathSelector)
     164        m_pGAISOFilePathSelector->setPath(strPath, fRefreshText);
     165}
     166
     167void UIGAInstallationGroupBox::mark(bool fError, const QString &strErrorMessage /* = QString() */)
     168{
     169    if (m_pGAISOFilePathSelector)
     170        m_pGAISOFilePathSelector->mark(fError, strErrorMessage);
     171}
     172
     173
     174void UIGAInstallationGroupBox::sltToggleWidgetsEnabled(bool fEnabled)
     175{
     176    if (m_pGAISOPathLabel)
     177        m_pGAISOPathLabel->setEnabled(fEnabled);
     178
     179    if (m_pGAISOFilePathSelector)
     180        m_pGAISOFilePathSelector->setEnabled(m_pGAISOFilePathSelector);
     181}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardNewVMEditors.h

    r90165 r90169  
    3333class QLabel;
    3434class QILineEdit;
     35class UIFilePathSelector;
    3536class UIPasswordLineEdit;
    3637class UIUserNamePasswordEditor;
     
    6768};
    6869
     70
     71class UIGAInstallationGroupBox : public QIWithRetranslateUI<QGroupBox>
     72{
     73    Q_OBJECT;
     74
     75signals:
     76
     77    void sigPathChanged(const QString &strPath);
     78
     79public:
     80
     81    UIGAInstallationGroupBox(QWidget *pParent = 0);
     82
     83    /** @name Wrappers for UIFilePathSelector
     84     * @{ */
     85       QString path() const;
     86       void setPath(const QString &strPath, bool fRefreshText = true);
     87       void mark(bool fError, const QString &strErrorMessage = QString());
     88    /** @} */
     89
     90public slots:
     91
     92    void sltToggleWidgetsEnabled(bool fEnabled);
     93
     94private:
     95
     96    virtual void retranslateUi() /* override final */;
     97    void prepare();
     98
     99    QLabel *m_pGAISOPathLabel;
     100    UIFilePathSelector *m_pGAISOFilePathSelector;
     101
     102};
     103
    69104#endif /* !FEQT_INCLUDED_SRC_wizards_editors_UIWizardNewVMEditors_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp

    r90165 r90169  
    7070    , m_pStartHeadlessCheckBox(0)
    7171    , m_pGAInstallationISOContainer(0)
    72     , m_pGAISOPathLabel(0)
    73     , m_pGAISOFilePathSelector(0)
    7472    , m_pUserNameContainer(0)
    7573{
     
    195193        m_pProductKeyLabel->setText(UIWizardNewVM::tr("&Product Key:"));
    196194
    197     if (m_pGAISOPathLabel)
    198         m_pGAISOPathLabel->setText(UIWizardNewVM::tr("GA I&nstallation ISO:"));
    199     if (m_pGAISOFilePathSelector)
    200         m_pGAISOFilePathSelector->setToolTip(UIWizardNewVM::tr("Please select an installation medium (ISO file)"));
    201     if (m_pGAInstallationISOContainer)
    202     {
    203         m_pGAInstallationISOContainer->setTitle(UIWizardNewVM::tr("Gu&est Additions"));
    204         m_pGAInstallationISOContainer->setToolTip(UIWizardNewVM::tr("<p>When checked the guest additions will be installed "
    205                                                                     "after the OS install.</p>"));
    206     }
    207 
    208195    if (m_pUserNameContainer)
    209196        m_pUserNameContainer->setTitle(UIWizardNewVM::tr("Username and Password"));
     
    412399    ++iRow;
    413400    /* Guest additions installation: */
    414     pLayout->addWidget(createGAInstallWidgets(), iRow, 0, 1, 4);
     401    m_pGAInstallationISOContainer = new UIGAInstallationGroupBox;
     402
     403    pLayout->addWidget(m_pGAInstallationISOContainer, iRow, 0, 1, 4);
    415404
    416405    return pContainerWidget;
     
    897886    return m_pAdditionalOptionsContainer;
    898887}
    899 
    900 QWidget *UIWizardNewVMPageExpert::createGAInstallWidgets()
    901 {
    902     if (m_pGAInstallationISOContainer)
    903         return m_pGAInstallationISOContainer;
    904 
    905     m_pGAInstallationISOContainer = new QGroupBox;
    906     if (m_pGAInstallationISOContainer)
    907     {
    908         m_pGAInstallationISOContainer->setCheckable(true);
    909 
    910         QHBoxLayout *pGAInstallationISOLayout = new QHBoxLayout(m_pGAInstallationISOContainer);
    911         if (pGAInstallationISOLayout)
    912         {
    913             m_pGAISOPathLabel = new QLabel;
    914             if (m_pGAISOPathLabel)
    915             {
    916                 m_pGAISOPathLabel->setAlignment(Qt::AlignRight);
    917                 m_pGAISOPathLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    918 
    919                 pGAInstallationISOLayout->addWidget(m_pGAISOPathLabel);
    920             }
    921             m_pGAISOFilePathSelector = new UIFilePathSelector;
    922             {
    923                 m_pGAISOFilePathSelector->setResetEnabled(false);
    924                 m_pGAISOFilePathSelector->setMode(UIFilePathSelector::Mode_File_Open);
    925                 m_pGAISOFilePathSelector->setFileDialogFilters("ISO Images(*.iso *.ISO)");
    926                 m_pGAISOFilePathSelector->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    927                 m_pGAISOFilePathSelector->setInitialPath(uiCommon().defaultFolderPathForType(UIMediumDeviceType_DVD));
    928                 if (m_pGAISOPathLabel)
    929                     m_pGAISOPathLabel->setBuddy(m_pGAISOFilePathSelector);
    930 
    931                 pGAInstallationISOLayout->addWidget(m_pGAISOFilePathSelector);
    932             }
    933         }
    934     }
    935 
    936     return m_pGAInstallationISOContainer;
    937 }
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.h

    r90165 r90169  
    3939class QVBoxLayout;
    4040class UIFilePathSelector;
     41class UIGAInstallationGroupBox;
    4142class UIHostnameDomainNameEditor;
    4243class UIMediumSizeEditor;
     
    115116    QWidget *createNameOSTypeWidgets();
    116117    QWidget *createAdditionalOptionsWidgets();
    117     QWidget *createGAInstallWidgets();
    118118
    119119    void updateVirtualDiskPathFromMachinePathName();
     
    147147
    148148    QCheckBox *m_pStartHeadlessCheckBox;
    149     QGroupBox *m_pGAInstallationISOContainer;
    150     QLabel *m_pGAISOPathLabel;
    151     UIFilePathSelector *m_pGAISOFilePathSelector;
     149    UIGAInstallationGroupBox *m_pGAInstallationISOContainer;
    152150    QGroupBox *m_pUserNameContainer;
    153151    UIUserNamePasswordGroupBox *m_pUserNamePasswordGroupBox;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMUnattendedPageBasic.cpp

    r90165 r90169  
    4141#include "CUnattended.h"
    4242
    43 bool UIWizardNewVMUnattendedPage::checkGAISOFile(UIFilePathSelector *pGAISOFilePathSelector)
    44 {
    45     if (!pGAISOFilePathSelector)
    46         return false;
    47     /* GA ISO selector should not be empty since GA install check box is checked at this point: */
    48     const QString &strPath = pGAISOFilePathSelector->path();
     43bool UIWizardNewVMUnattendedPage::checkGAISOFile(const QString &strPath)
     44{
    4945    if (strPath.isNull() || strPath.isEmpty())
    5046        return false;
     
    6258    , m_pUserNamePasswordGroupBox(0)
    6359    , m_pHostnameDomainNameEditor(0)
    64     , m_pGAISOPathLabel(0)
    65     , m_pGAISOFilePathSelector(0)
    6660    , m_pProductKeyLineEdit(0)
    6761    , m_pProductKeyLabel(0)
     
    8175    pMainLayout->addWidget(m_pUserNamePasswordGroupBox, 1, 0, 1, 1);
    8276    pMainLayout->addWidget(createAdditionalOptionsWidgets(), 1, 1, 1, 1);
    83     pMainLayout->addWidget(createGAInstallWidgets(), 2, 0, 1, 2);
     77    m_pGAInstallationISOContainer = new UIGAInstallationGroupBox;
     78    pMainLayout->addWidget(m_pGAInstallationISOContainer, 2, 0, 1, 2);
    8479    pMainLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding), 3, 0, 1, 2);
    8580
     
    9691                this, &UIWizardNewVMUnattendedPageBasic::sltUserNameChanged);
    9792    }
    98     if (m_pGAISOFilePathSelector)
    99         connect(m_pGAISOFilePathSelector, &UIFilePathSelector::pathChanged,
     93    if (m_pGAInstallationISOContainer)
     94    {
     95        connect(m_pGAInstallationISOContainer, &UIGAInstallationGroupBox::toggled,
     96                this, &UIWizardNewVMUnattendedPageBasic::sltInstallGACheckBoxToggle);
     97        connect(m_pGAInstallationISOContainer, &UIGAInstallationGroupBox::sigPathChanged,
    10098                this, &UIWizardNewVMUnattendedPageBasic::sltGAISOPathChanged);
    101     if (m_pGAISOFilePathSelector)
    102         connect(m_pGAInstallationISOContainer, &QGroupBox::toggled,
    103                 this, &UIWizardNewVMUnattendedPageBasic::sltInstallGACheckBoxToggle);
     99    }
    104100    if (m_pHostnameDomainNameEditor)
    105101        connect(m_pHostnameDomainNameEditor, &UIHostnameDomainNameEditor::sigHostnameDomainNameChanged,
     
    121117                                            "hostname. Additionally you can enable guest additions install. "
    122118                                            "For Microsoft Windows guests it is possible to provide a product key.</p>"));
    123     if (m_pGAISOPathLabel)
    124         m_pGAISOPathLabel->setText(UIWizardNewVM::tr("GA I&nstallation ISO:"));
    125     if (m_pGAISOFilePathSelector)
    126         m_pGAISOFilePathSelector->setToolTip(UIWizardNewVM::tr("Please select an installation medium (ISO file)"));
    127     if (m_pGAInstallationISOContainer)
    128     {
    129         m_pGAInstallationISOContainer->setTitle(UIWizardNewVM::tr("Gu&est Additions"));
    130         m_pGAInstallationISOContainer->setToolTip(UIWizardNewVM::tr("<p>When checked the guest additions will be installed "
    131                                                                     "after the OS install.</p>"));
    132     }
    133119    if (m_pProductKeyLabel)
    134120        m_pProductKeyLabel->setText(UIWizardNewVM::tr("&Product Key:"));
     
    149135{
    150136    disableEnableProductKeyWidgets(isProductKeyWidgetEnabled());
    151     disableEnableGAWidgets(m_pGAInstallationISOContainer ? m_pGAInstallationISOContainer->isChecked() : false);
     137    if (m_pGAInstallationISOContainer)
     138        m_pGAInstallationISOContainer->sltToggleWidgetsEnabled(m_pGAInstallationISOContainer->isChecked());
    152139    retranslateUi();
    153140
     
    185172    }
    186173
    187     if (m_pGAISOFilePathSelector && !m_userModifiedParameters.contains("GuestAdditionsISOPath"))
    188     {
    189         m_pGAISOFilePathSelector->blockSignals(true);
    190         m_pGAISOFilePathSelector->setPath(pWizard->guestAdditionsISOPath());
    191         m_pGAISOFilePathSelector->blockSignals(false);
     174    if (m_pGAInstallationISOContainer && !m_userModifiedParameters.contains("GuestAdditionsISOPath"))
     175    {
     176        m_pGAInstallationISOContainer->blockSignals(true);
     177        m_pGAInstallationISOContainer->setPath(pWizard->guestAdditionsISOPath());
     178        m_pGAInstallationISOContainer->blockSignals(false);
    192179    }
    193180}
     
    198185    UIWizardNewVM *pWizard = qobject_cast<UIWizardNewVM*>(wizard());
    199186    if (pWizard && pWizard->installGuestAdditions() &&
    200         !UIWizardNewVMUnattendedPage::checkGAISOFile(m_pGAISOFilePathSelector))
     187        m_pGAInstallationISOContainer &&
     188        !UIWizardNewVMUnattendedPage::checkGAISOFile(m_pGAInstallationISOContainer->path()))
    201189        return false;
    202190    if (m_pUserNamePasswordGroupBox && !m_pUserNamePasswordGroupBox->isComplete())
     
    218206void UIWizardNewVMUnattendedPageBasic::sltInstallGACheckBoxToggle(bool fEnabled)
    219207{
    220     disableEnableGAWidgets(fEnabled);
     208    if (m_pGAInstallationISOContainer)
     209        m_pGAInstallationISOContainer->sltToggleWidgetsEnabled(fEnabled);
    221210    newVMWizardPropertySet(InstallGuestAdditions, fEnabled);
    222211    m_userModifiedParameters << "InstallGuestAdditions";
     
    307296}
    308297
    309 QWidget *UIWizardNewVMUnattendedPageBasic::createGAInstallWidgets()
    310 {
    311     if (m_pGAInstallationISOContainer)
    312         return m_pGAInstallationISOContainer;
    313 
    314     /* Prepare GA Installation ISO container: */
    315     m_pGAInstallationISOContainer = new QGroupBox;
    316     if (m_pGAInstallationISOContainer)
    317     {
    318         m_pGAInstallationISOContainer->setCheckable(true);
    319 
    320         /* Prepare GA Installation ISO layout: */
    321         QHBoxLayout *pGAInstallationISOLayout = new QHBoxLayout(m_pGAInstallationISOContainer);
    322         if (pGAInstallationISOLayout)
    323         {
    324             /* Prepare GA ISO path label: */
    325             m_pGAISOPathLabel = new QLabel;
    326             if (m_pGAISOPathLabel)
    327             {
    328                 m_pGAISOPathLabel->setAlignment(Qt::AlignRight);
    329                 m_pGAISOPathLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    330 
    331                 pGAInstallationISOLayout->addWidget(m_pGAISOPathLabel);
    332             }
    333             /* Prepare GA ISO path editor: */
    334             m_pGAISOFilePathSelector = new UIFilePathSelector;
    335             {
    336                 m_pGAISOFilePathSelector->setResetEnabled(false);
    337                 m_pGAISOFilePathSelector->setMode(UIFilePathSelector::Mode_File_Open);
    338                 m_pGAISOFilePathSelector->setFileDialogFilters("ISO Images(*.iso *.ISO)");
    339                 m_pGAISOFilePathSelector->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    340                 m_pGAISOFilePathSelector->setInitialPath(uiCommon().defaultFolderPathForType(UIMediumDeviceType_DVD));
    341                 if (m_pGAISOPathLabel)
    342                     m_pGAISOPathLabel->setBuddy(m_pGAISOFilePathSelector);
    343 
    344                 pGAInstallationISOLayout->addWidget(m_pGAISOFilePathSelector);
    345             }
    346         }
    347     }
    348 
    349     return m_pGAInstallationISOContainer;
    350 }
    351 
    352 void UIWizardNewVMUnattendedPageBasic::disableEnableGAWidgets(bool fEnabled)
    353 {
    354     if (m_pGAISOPathLabel)
    355         m_pGAISOPathLabel->setEnabled(fEnabled);
    356     if (m_pGAISOFilePathSelector)
    357         m_pGAISOFilePathSelector->setEnabled(fEnabled);
    358 }
    359 
    360298void UIWizardNewVMUnattendedPageBasic::disableEnableProductKeyWidgets(bool fEnabled)
    361299{
     
    369307{
    370308    UIWizardNewVM *pWizard = qobject_cast<UIWizardNewVM*>(wizard());
    371     if (pWizard && pWizard->installGuestAdditions())
    372         m_pGAISOFilePathSelector->mark(!UIWizardNewVMUnattendedPage::checkGAISOFile(m_pGAISOFilePathSelector));
    373 }
     309    if (pWizard && pWizard->installGuestAdditions() && m_pGAInstallationISOContainer)
     310        m_pGAInstallationISOContainer->mark(!UIWizardNewVMUnattendedPage::checkGAISOFile(m_pGAInstallationISOContainer->path()));
     311}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMUnattendedPageBasic.h

    r90165 r90169  
    3333class QLineEdit;
    3434class QIRichTextLabel;
     35class UIGAInstallationGroupBox;
    3536class UIFilePathSelector;
    3637class UIUserNamePasswordGroupBox;
     
    4243{
    4344    /** Returns false if ISO path selector is non empty but has invalid file path. */
    44     bool checkGAISOFile(UIFilePathSelector *pGAISOFilePathSelector);
     45    bool checkGAISOFile(const QString &strPatho);
    4546}
    4647
     
    7475    void createConnections();
    7576    QWidget *createAdditionalOptionsWidgets();
    76     QWidget *createGAInstallWidgets();
    7777
    7878    void retranslateUi();
     
    8282    bool isProductKeyWidgetEnabled() const;
    8383    void disableEnableProductKeyWidgets(bool fEnabled);
    84     void disableEnableGAWidgets(bool fEnabled);
    8584    void markWidgets() const;
    8685
     
    8988        QIRichTextLabel *m_pLabel;
    9089        QGroupBox *m_pAdditionalOptionsContainer;
    91         QGroupBox *m_pGAInstallationISOContainer;
     90        UIGAInstallationGroupBox *m_pGAInstallationISOContainer;
    9291        QCheckBox *m_pStartHeadlessCheckBox;
    9392        UIUserNamePasswordGroupBox *m_pUserNamePasswordGroupBox;
    9493        UIHostnameDomainNameEditor *m_pHostnameDomainNameEditor;
    95         QLabel    *m_pGAISOPathLabel;
    96         UIFilePathSelector *m_pGAISOFilePathSelector;
    9794        /** Product key stuff. */
    9895        QLineEdit *m_pProductKeyLineEdit;
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