VirtualBox

Changeset 84918 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jun 23, 2020 1:12:08 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
138789
Message:

FE/Qt: bugref:9515. Painting user name/password line edits to indicate any error.

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

Legend:

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

    r84917 r84918  
    132132    if (m_pUserNameLineEdit && m_pUserNameLineEdit->text().isEmpty())
    133133    {
    134         // mark user name the line edit
     134        markLineEdit(m_pUserNameLineEdit, true);
    135135        return false;
    136136    }
     137    else
     138        markLineEdit(m_pUserNameLineEdit, false);
     139    bool fPasswordOK = true;
    137140    if (m_pPasswordLineEdit && m_pPasswordRepeatLineEdit)
    138141    {
    139142        if (m_pPasswordLineEdit->text() != m_pPasswordRepeatLineEdit->text())
    140         {
    141             // mark password line edits
    142             return false;
    143         }
     143            fPasswordOK = false;
    144144        if (m_pPasswordLineEdit->text().isEmpty())
    145             return false;
    146     }
    147     return true;
     145            fPasswordOK = false;
     146    }
     147    markLineEdit(m_pPasswordLineEdit, !fPasswordOK);
     148    markLineEdit(m_pPasswordRepeatLineEdit, !fPasswordOK);
     149    return fPasswordOK;
    148150}
    149151
     
    188190    connect(pLineEdit, &T::textChanged, this, &UIUserNamePasswordEditor::sigSomeTextChanged);
    189191    return;
     192}
     193
     194void UIUserNamePasswordEditor::markLineEdit(QLineEdit *pLineEdit, bool fError)
     195{
     196    if (!pLineEdit)
     197        return;
     198    QPalette palette = pLineEdit->palette();
     199    if (fError)
     200        palette.setColor(QPalette::Base, QColor(255, 180, 180));
     201    else
     202        palette.setColor(QPalette::Base, m_orginalLineEditBaseColor);
     203    pLineEdit->setPalette(palette);
    190204}
    191205
     
    205219    connect(m_pPasswordRepeatLineEdit, &UIPasswordLineEdit::sigTextVisibilityToggled,
    206220            this, &UIUserNamePasswordEditor::sltHandlePasswordVisibility);
     221    /* Cache the original back color of the line edit to restore it correctly: */
     222    if (m_pUserNameLineEdit)
     223        m_orginalLineEditBaseColor = m_pUserNameLineEdit->palette().color(QPalette::Base);
    207224
    208225    retranslateUi();
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasicInstallSetup.h

    r84917 r84918  
    9292    void retranslateUi();
    9393
     94private slots:
     95
     96    void sltHandlePasswordVisibility(bool fPasswordVisible);
     97
    9498private:
    9599
     
    97101    template <class T>
    98102    void addLineEdit(int &iRow, QLabel *&pLabel, T *&pLineEdit, QGridLayout *pLayout);
     103    /** Changes @p pLineEdit's base color to indicate an error or reverts it to the original color. */
     104    void markLineEdit(QLineEdit *pLineEdit, bool fError);
    99105
    100106    QLineEdit          *m_pUserNameLineEdit;
     
    105111    QLabel *m_pPasswordLabel;
    106112    QLabel *m_pPasswordRepeatLabel;
    107 
    108 private slots:
    109 
    110     void sltHandlePasswordVisibility(bool fPasswordVisible);
     113    QColor m_orginalLineEditBaseColor;
    111114};
    112115
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasicNameType.cpp

    r84917 r84918  
    355355void UIWizardNewVMPageBasicNameType::sltNameChanged(const QString &strNewName)
    356356{
    357     /* Call to base-class: */
    358357    onNameChanged(strNewName);
    359358    composeMachineFilePath();
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