VirtualBox

Changeset 87348 in vbox


Ignore:
Timestamp:
Jan 21, 2021 12:09:05 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
142324
Message:

FE/Qt: bugref:9515. Redesigning unattended page

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

Legend:

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

    r87318 r87348  
    6767    int titleHeight() const;
    6868    int pageWidgetHeight() const;
     69    void setTitleIcon(const QIcon &icon);
    6970
    7071protected:
     
    8384    QWidget     *m_pTitleContainerWidget;
    8485    QLabel      *m_pTitleLabel;
     86    QLabel      *m_pIconLabel;
    8587    QCheckBox   *m_pEnableCheckBox;
    8688
     
    98100    , m_pTitleContainerWidget(0)
    99101    , m_pTitleLabel(0)
     102    , m_pIconLabel(0)
    100103    , m_pEnableCheckBox(0)
    101104    , m_pWidget(0)
     
    118121
    119122    m_pTitleContainerWidget = new QWidget;
     123    m_pTitleContainerWidget->installEventFilter(this);
    120124    QHBoxLayout *pTitleLayout = new QHBoxLayout(m_pTitleContainerWidget);
    121125    pTitleLayout->setContentsMargins(qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin),
     
    133137    m_pTitleLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    134138
    135     m_pTitleLabel->installEventFilter(this);
    136139    pTitleLayout->addWidget(m_pTitleLabel);
     140    m_pIconLabel = new QLabel;
     141    pTitleLayout->addWidget(m_pIconLabel, Qt::AlignLeft);
     142    pTitleLayout->addStretch();
    137143    m_pTitleContainerWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    138144    m_pLayout->addWidget(m_pTitleContainerWidget);
     
    183189}
    184190
     191void UIToolBoxPage::setTitleIcon(const QIcon &icon)
     192{
     193    if (!m_pIconLabel)
     194        return;
     195    if (icon.isNull())
     196    {
     197        m_pIconLabel->setPixmap(QPixmap());
     198        return;
     199    }
     200    const int iMetricSmall = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
     201    m_pIconLabel->setPixmap(icon.pixmap(windowHandle(), QSize(iMetricSmall, iMetricSmall)));
     202}
     203
    185204int UIToolBoxPage::titleHeight() const
    186205{
     
    199218bool UIToolBoxPage::eventFilter(QObject *pWatched, QEvent *pEvent)
    200219{
    201     if (pWatched == m_pTitleLabel && pEvent->type() == QEvent::MouseButtonPress)
    202         emit sigShowPageWidget();
     220    if (pWatched == m_pTitleContainerWidget)
     221    {
     222        if (pEvent->type() == QEvent::MouseButtonPress)
     223            emit sigShowPageWidget();
     224    }
    203225    return QWidget::eventFilter(pWatched, pEvent);
    204226
     
    237259
    238260    const QPalette pal = palette();
    239     QColor tabBackgroundColor = pal.color(QPalette::Active, QPalette::Highlight).lighter(110);
     261    QColor tabBackgroundColor = pal.color(QPalette::Active, QPalette::Highlight).lighter(130);
    240262    pNewPage->setTitleBackgroundColor(tabBackgroundColor);
    241263
     
    278300void UIToolBox::setItemIcon(int iIndex, const QIcon &icon)
    279301{
    280     Q_UNUSED(iIndex);
    281     Q_UNUSED(icon);
     302    QMap<int, UIToolBoxPage*>::iterator iterator = m_pages.find(iIndex);
     303    if (iterator == m_pages.end())
     304        return;
     305    iterator.value()->setTitleIcon(icon);
    282306}
    283307
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIUserNamePasswordEditor.cpp

    r87249 r87348  
    120120    , m_pPasswordRepeatLabel(0)
    121121    , m_fForceUnmark(false)
     122    , m_fShowPlaceholderText(true)
     123    , m_fLabelsVisible(true)
    122124{
    123125    prepare();
     
    188190}
    189191
     192void UIUserNamePasswordEditor::setPlaceholderTextEnabled(bool fEnabled)
     193{
     194    if (m_fShowPlaceholderText == fEnabled)
     195        return;
     196    m_fShowPlaceholderText = fEnabled;
     197    retranslateUi();
     198}
     199
     200void UIUserNamePasswordEditor::setLabelsVisible(bool fVisible)
     201{
     202    if (m_fLabelsVisible == fVisible)
     203        return;
     204    m_fLabelsVisible = fVisible;
     205    m_pUserNameLabel->setVisible(fVisible);
     206    m_pPasswordLabel->setVisible(fVisible);
     207    m_pPasswordRepeatLabel->setVisible(fVisible);
     208
     209}
     210
    190211void UIUserNamePasswordEditor::retranslateUi()
    191212{
     213    QString strPassword = UIWizardNewVM::tr("Password:");
     214    QString strRepeatPassword = UIWizardNewVM::tr("Repeat Password:");
     215    QString strUsername = UIWizardNewVM::tr("Username:");
    192216    if (m_pUserNameLabel)
    193217    {
    194         m_pUserNameLabel->setText(UIWizardNewVM::tr("User Name:"));
     218        m_pUserNameLabel->setText(strUsername);
    195219        m_pUserNameLabel->setToolTip(UIWizardNewVM::tr("Type the user name which will be used in attended install:"));
    196220
     
    198222    if (m_pPasswordLabel)
    199223    {
    200         m_pPasswordLabel->setText(UIWizardNewVM::tr("Password:"));
     224        m_pPasswordLabel->setText(strPassword);
    201225        m_pPasswordLabel->setToolTip(UIWizardNewVM::tr("Type the password for the user name"));
    202226
     
    204228    if (m_pPasswordRepeatLabel)
    205229    {
    206         m_pPasswordRepeatLabel->setText(UIWizardNewVM::tr("Repeat Password:"));
     230        m_pPasswordRepeatLabel->setText(strRepeatPassword);
    207231        m_pPasswordRepeatLabel->setToolTip(UIWizardNewVM::tr("Retype the password:"));
     232    }
     233
     234    if (m_fShowPlaceholderText)
     235    {
     236        if(m_pUserNameLineEdit)
     237            m_pUserNameLineEdit->setPlaceholderText(strUsername);
     238        if (m_pPasswordLineEdit)
     239            m_pPasswordLineEdit->setPlaceholderText(strPassword);
     240        if (m_pPasswordRepeatLineEdit)
     241            m_pPasswordRepeatLineEdit->setPlaceholderText(strRepeatPassword);
     242    }
     243    else
     244    {
     245        if(m_pUserNameLineEdit)
     246            m_pUserNameLineEdit->setPlaceholderText(QString());
     247        if (m_pPasswordLineEdit)
     248            m_pPasswordLineEdit->setPlaceholderText(QString());
     249        if (m_pPasswordRepeatLineEdit)
     250            m_pPasswordRepeatLineEdit->setPlaceholderText(QString());
    208251    }
    209252}
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIUserNamePasswordEditor.h

    r85150 r87348  
    8888    void setForceUnmark(bool fForceUnmark);
    8989
     90    /** When fEnabled true place holder texts for the line edits are shown. */
     91    void setPlaceholderTextEnabled(bool fEnabled);
     92    void setLabelsVisible(bool fVisible);
     93
    9094protected:
    9195
     
    118122    /** When true line edits are not marked even if they have to be. */
    119123    bool m_fForceUnmark;
     124    bool m_fShowPlaceholderText;
     125    bool m_fLabelsVisible;
    120126};
    121127
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.cpp

    r87322 r87348  
    448448bool UIWizardNewVMPage1::isUnattendedEnabled() const
    449449{
    450     if (m_pISOFilePathSelector)
    451         return m_pISOFilePathSelector->isValid();
    452     return false;
     450    if (!m_pISOFilePathSelector)
     451        return false;
     452    const QString &strPath = m_pISOFilePathSelector->path();
     453    if (strPath.isNull() || strPath.isEmpty())
     454        return false;
     455    return true;
    453456}
    454457
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic2.cpp

    r87322 r87348  
    115115    QWidget *pContainer = new QWidget;
    116116    QGridLayout *pGridLayout = new QGridLayout(pContainer);
     117    pGridLayout->setContentsMargins(0, 0, 0, 0);
    117118
    118119    m_pUserNamePasswordEditor = new UIUserNamePasswordEditor;
     
    159160    QWidget *pContainer = new QWidget;
    160161    QGridLayout *pGridLayout = new QGridLayout(pContainer);
    161 
     162    pGridLayout->setContentsMargins(0, 0, 0, 0);
    162163    m_pProductKeyLabel = new QLabel;
    163164    m_pProductKeyLabel->setAlignment(Qt::AlignRight);
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp

    r87322 r87348  
    2020#include <QCheckBox>
    2121#include <QGridLayout>
     22#include <QGroupBox>
    2223#include <QHBoxLayout>
    2324#include <QLabel>
     
    4546    : UIWizardNewVMPage1(strGroup)
    4647    , m_pToolBox(0)
     48    , m_pInstallationISOContainer(0)
     49    , m_pUserNameContainer(0)
     50    , m_pAdditionalOptionsContainer(0)
     51    , m_pGAInstallationISOContainer(0)
    4752{
    4853    /* Create widgets: */
     
    181186void UIWizardNewVMPageExpert::sltOSFamilyTypeChanged()
    182187{
    183     if (m_pToolBox)
    184         m_pToolBox->setItemEnabled(ExpertToolboxItems_ProductKey, isProductKeyWidgetEnabled());
     188    disableEnableProductKeyWidgets(isProductKeyWidgetEnabled());
    185189}
    186190
     
    190194    UIWizardNewVMPage2::retranslateWidgets();
    191195    UIWizardNewVMPage3::retranslateWidgets();
    192 
     196    if (m_pInstallationISOContainer)
     197        m_pInstallationISOContainer->setTitle(UIWizardNewVM::tr("Installation medium (ISO)"));
     198    if (m_pUserNameContainer)
     199        m_pUserNameContainer->setTitle(UIWizardNewVM::tr("User name and password"));
     200    if (m_pAdditionalOptionsContainer)
     201        m_pAdditionalOptionsContainer->setTitle(UIWizardNewVM::tr("Additional options"));
     202    if (m_pGAInstallationISOContainer)
     203        m_pGAInstallationISOContainer->setTitle(UIWizardNewVM::tr("Guest Additions Installation Medium (ISO)"));
    193204    if (m_pToolBox)
    194205    {
    195206        m_pToolBox->setItemText(ExpertToolboxItems_NameAndOSType, QString(UIWizardNewVM::tr("Name and operating system")));
    196         m_pToolBox->setItemText(ExpertToolboxItems_UsernameHostname, UIWizardNewVM::tr("Username and hostname"));
    197207        m_pToolBox->setItemText(ExpertToolboxItems_Unattended, UIWizardNewVM::tr("Unattended Install"));
    198         m_pToolBox->setItemText(ExpertToolboxItems_GAInstall, UIWizardNewVM::tr("Guest additions install"));
    199         m_pToolBox->setItemText(ExpertToolboxItems_ProductKey, UIWizardNewVM::tr("Product key"));
    200208        m_pToolBox->setItemText(ExpertToolboxItems_Disk, UIWizardNewVM::tr("Hard disk"));
    201209        m_pToolBox->setItemText(ExpertToolboxItems_Hardware, UIWizardNewVM::tr("Hardware"));
     
    311319    int iRow = 0;
    312320
    313     m_pISOSelectorLabel = new QLabel;
    314     if (m_pISOSelectorLabel)
    315     {
    316         m_pISOSelectorLabel->setAlignment(Qt::AlignRight);
    317         m_pISOSelectorLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
    318         pLayout->addWidget(m_pISOSelectorLabel, iRow, 0, 1, 1);
    319     }
    320 
    321     m_pISOFilePathSelector = new UIFilePathSelector;
    322     if (m_pISOFilePathSelector)
    323     {
    324         m_pISOFilePathSelector->setResetEnabled(false);
    325         m_pISOFilePathSelector->setMode(UIFilePathSelector::Mode_File_Open);
    326         m_pISOFilePathSelector->setFileDialogFilters("*.iso *.ISO");
    327         pLayout->addWidget(m_pISOFilePathSelector, iRow++, 1, 1, 4);
    328     }
    329 
    330     m_pStartHeadlessCheckBox = new QCheckBox;
    331     if (m_pStartHeadlessCheckBox)
    332         pLayout->addWidget(m_pStartHeadlessCheckBox, iRow++, 0, 1, 5);
    333 
    334     pLayout->addWidget(createUserNameHostNameWidgets(), iRow, 0, 4, 5);
    335     iRow += 4;
    336     pLayout->addWidget(createGAInstallWidgets(), iRow, 0, 2, 5);
    337     iRow += 2;
    338     pLayout->addWidget(createProductKeyWidgets(), iRow, 0, 1, 5);
    339 
    340 
     321    /* Installation medium selector etc: */
     322    {
     323        m_pInstallationISOContainer = new QGroupBox;
     324        QHBoxLayout *pInstallationISOContainerLayout = new QHBoxLayout(m_pInstallationISOContainer);
     325
     326        m_pISOFilePathSelector = new UIFilePathSelector;
     327        if (m_pISOFilePathSelector)
     328        {
     329            m_pISOFilePathSelector->setResetEnabled(false);
     330            m_pISOFilePathSelector->setMode(UIFilePathSelector::Mode_File_Open);
     331            m_pISOFilePathSelector->setFileDialogFilters("*.iso *.ISO");
     332            pInstallationISOContainerLayout->addWidget(m_pISOFilePathSelector);
     333        }
     334        pLayout->addWidget(m_pInstallationISOContainer, iRow++, 0, 1, 4);
     335    }
     336
     337    /* Username selector: */
     338    {
     339        m_pUserNameContainer = new QGroupBox;
     340        QVBoxLayout *pUserNameContainerLayout = new QVBoxLayout(m_pUserNameContainer);
     341        m_pUserNamePasswordEditor = new UIUserNamePasswordEditor;
     342        if (m_pUserNamePasswordEditor)
     343        {
     344            m_pUserNamePasswordEditor->setLabelsVisible(true);
     345            pUserNameContainerLayout->addWidget(m_pUserNamePasswordEditor);
     346        }
     347        pLayout->addWidget(m_pUserNameContainer, iRow, 0, 1, 2);
     348    }
     349
     350    /* Additional options: */
     351    {
     352        m_pAdditionalOptionsContainer = new QGroupBox;
     353        QGridLayout *pAdditionalOptionsContainerLayout = new QGridLayout(m_pAdditionalOptionsContainer);
     354        m_pStartHeadlessCheckBox = new QCheckBox;
     355        if (m_pStartHeadlessCheckBox)
     356            pAdditionalOptionsContainerLayout->addWidget(m_pStartHeadlessCheckBox, 0, 0, 1, 4);
     357
     358        m_pProductKeyLabel = new QLabel;
     359        if (m_pProductKeyLabel)
     360        {
     361            m_pProductKeyLabel->setAlignment(Qt::AlignRight);
     362            m_pProductKeyLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
     363            pAdditionalOptionsContainerLayout->addWidget(m_pProductKeyLabel, 1, 0, 1, 1);
     364        }
     365        m_pProductKeyLineEdit = new QLineEdit;
     366        if (m_pProductKeyLineEdit)
     367        {
     368            m_pProductKeyLineEdit->setInputMask(">NNNNN-NNNNN-NNNNN-NNNNN-NNNNN;#");
     369            pAdditionalOptionsContainerLayout->addWidget(m_pProductKeyLineEdit, 1, 1, 1, 3);
     370        }
     371
     372        m_pHostnameLabel = new QLabel;
     373        if (m_pHostnameLabel)
     374        {
     375            m_pHostnameLabel->setAlignment(Qt::AlignRight);
     376            m_pHostnameLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
     377            pAdditionalOptionsContainerLayout->addWidget(m_pHostnameLabel, 2, 0, 1, 1);
     378        }
     379
     380        m_pHostnameLineEdit = new QLineEdit;
     381        if (m_pHostnameLineEdit)
     382            pAdditionalOptionsContainerLayout->addWidget(m_pHostnameLineEdit, 2, 1, 1, 3);
     383
     384        // pAdditionalOptionsContainerLayout->addWidget(createHostNameWidgets());
     385
     386        // pAdditionalOptionsContainerLayout->addStretch();
     387        pLayout->addWidget(m_pAdditionalOptionsContainer, iRow, 2, 1, 2);
     388    }
     389    ++iRow;
     390    /* Guest additions installation: */
     391    {
     392        m_pGAInstallationISOContainer = new QGroupBox;
     393        QHBoxLayout *pGAInstallationISOContainer = new QHBoxLayout(m_pGAInstallationISOContainer);
     394        m_pGAISOFilePathSelector = new UIFilePathSelector;
     395        {
     396            m_pGAISOFilePathSelector->setResetEnabled(false);
     397            m_pGAISOFilePathSelector->setMode(UIFilePathSelector::Mode_File_Open);
     398            m_pGAISOFilePathSelector->setFileDialogFilters("*.iso *.ISO");
     399            m_pGAISOFilePathSelector->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
     400            pGAInstallationISOContainer->addWidget(m_pGAISOFilePathSelector);
     401        }
     402        pLayout->addWidget(m_pGAInstallationISOContainer, iRow, 0, 1, 4);
     403    }
    341404    return pContainerWidget;
    342405}
     
    347410    bool fIsComplete = true;
    348411    m_pToolBox->setItemIcon(ExpertToolboxItems_NameAndOSType, QIcon());
     412    m_pToolBox->setItemIcon(ExpertToolboxItems_Unattended, QIcon());
    349413    m_pToolBox->setItemIcon(ExpertToolboxItems_Disk, QIcon());
    350414    m_pToolBox->setItemIcon(ExpertToolboxItems_Hardware, QIcon());
    351     m_pToolBox->setItemIcon(ExpertToolboxItems_UsernameHostname, QIcon());
    352     m_pToolBox->setItemIcon(ExpertToolboxItems_GAInstall, QIcon());
    353     m_pToolBox->setItemIcon(ExpertToolboxItems_ProductKey, QIcon());
    354415
    355416    if (!UIWizardPage::isComplete())
     
    370431    {
    371432        /* Check the installation medium: */
    372         // if (!isISOFileSelectorComplete())
    373         // {
    374         //     m_pToolBox->setItemIcon(ExpertToolboxItems_NameAndOSType,
    375         //                             UIIconPool::iconSet(":/status_error_16px.png"));
    376         //     fIsComplete = false;
    377         // }
     433        if (!isISOFileSelectorComplete())
     434        {
     435            m_pToolBox->setItemIcon(ExpertToolboxItems_Unattended,
     436                                    UIIconPool::iconSet(":/status_error_16px.png"));
     437            fIsComplete = false;
     438        }
    378439        /* Check the GA installation medium: */
    379440        if (!checkGAISOFile())
    380441        {
    381             m_pToolBox->setItemIcon(ExpertToolboxItems_GAInstall,
    382                                     UIIconPool::iconSet(":/status_error_16px.png"));
     442            // m_pToolBox->setItemIcon(ExpertToolboxItems_Unattended,
     443            //                         UIIconPool::iconSet(":/status_error_16px.png"));
    383444            fIsComplete = false;
    384445        }
     
    387448            if (!m_pUserNamePasswordEditor->isComplete())
    388449            {
    389                 m_pToolBox->setItemIcon(ExpertToolboxItems_UsernameHostname,
     450                m_pToolBox->setItemIcon(ExpertToolboxItems_Unattended,
    390451                                        UIIconPool::iconSet(":/status_error_16px.png"));
    391452                fIsComplete = false;
     
    444505void UIWizardNewVMPageExpert::disableEnableUnattendedRelatedWidgets(bool fEnabled)
    445506{
    446     if (m_pStartHeadlessCheckBox)
    447         m_pStartHeadlessCheckBox->setEnabled(fEnabled);
    448 }
     507    if (m_pUserNameContainer)
     508        m_pUserNameContainer->setEnabled(fEnabled);
     509    if (m_pAdditionalOptionsContainer)
     510        m_pAdditionalOptionsContainer->setEnabled(fEnabled);
     511    if (m_pGAInstallationISOContainer)
     512        m_pGAInstallationISOContainer->setEnabled(fEnabled);
     513    disableEnableProductKeyWidgets(isProductKeyWidgetEnabled());
     514}
     515
     516void UIWizardNewVMPageExpert::disableEnableProductKeyWidgets(bool fEnabled)
     517{
     518    if (m_pProductKeyLabel)
     519        m_pProductKeyLabel->setEnabled(fEnabled);
     520    if (m_pProductKeyLineEdit)
     521        m_pProductKeyLineEdit->setEnabled(fEnabled);
     522}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.h

    r87322 r87348  
    2828
    2929/* Forward declarations: */
     30class QGroupBox;
    3031class UIToolBox;
    3132
     
    9192        ExpertToolboxItems_Disk,
    9293        ExpertToolboxItems_Hardware,
    93         ExpertToolboxItems_UsernameHostname,
    94         ExpertToolboxItems_GAInstall,
    95         ExpertToolboxItems_ProductKey
    9694    };
    9795    /** Translation stuff. */
     
    109107    bool isProductKeyWidgetEnabled() const;
    110108    void disableEnableUnattendedRelatedWidgets(bool fEnabled);
     109    void disableEnableProductKeyWidgets(bool fEnabled);
    111110    void markWidgets() const;
    112111    QWidget *createUnattendedWidgets();
    113112
    114 
    115113    UIToolBox  *m_pToolBox;
     114    QGroupBox *m_pInstallationISOContainer;
     115    QGroupBox *m_pUserNameContainer;
     116    QGroupBox *m_pAdditionalOptionsContainer;
     117    QGroupBox *m_pGAInstallationISOContainer;
    116118};
    117119
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