- Timestamp:
- Feb 12, 2021 11:00:29 AM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
-
Makefile.kmk (modified) (1 diff)
-
src/widgets/UIUserNamePasswordEditor.cpp (modified) (10 diffs)
-
src/widgets/UIUserNamePasswordEditor.h (modified) (3 diffs)
-
src/wizards/newvm/UIWizardNewVMPageBasic2.cpp (modified) (1 diff)
-
src/wizards/newvm/UIWizardNewVMPageExpert.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r87656 r87731 956 956 src/widgets/UIMenuToolBar.cpp \ 957 957 src/widgets/UITabBar.cpp \ 958 src/widgets/UIUserNamePasswordEditor.cpp \ 958 959 src/widgets/graphics/UIGraphicsScrollBar.cpp \ 959 960 src/wizards/importappliance/UIWizardImportApp.cpp -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIUserNamePasswordEditor.cpp
r87348 r87731 19 19 #include <QGridLayout> 20 20 #include <QLabel> 21 #include <QLineEdit> 21 22 #include <QStyle> 22 23 #include <QVBoxLayout> … … 30 31 #include "UIWizardNewVM.h" 31 32 33 /********************************************************************************************************************************* 34 * UIPasswordLineEdit definition. * 35 *********************************************************************************************************************************/ 36 37 class UIPasswordLineEdit : public QLineEdit 38 { 39 Q_OBJECT; 40 41 signals: 42 43 void sigTextVisibilityToggled(bool fTextVisible); 44 45 public: 46 47 UIPasswordLineEdit(QWidget *pParent = 0); 48 void toggleTextVisibility(bool fTextVisible); 49 void mark(bool fError, const QString &strErrorToolTip); 50 51 protected: 52 53 virtual void resizeEvent(QResizeEvent *pEvent) /* override */; 54 virtual void paintEvent(QPaintEvent *pPaintEvent) /* override */; 55 56 private slots: 57 58 void sltHandleTextVisibilityChange(); 59 60 private: 61 62 void prepare(); 63 void adjustTextVisibilityButtonGeometry(); 64 65 QIToolButton *m_pTextVisibilityButton; 66 QIcon m_markIcon; 67 QLabel *m_pErrorIconLabel; 68 QString m_strErrorToolTip; 69 /** When true the line edit is marked with some icon to indicate some error. */ 70 bool m_fMarkForError; 71 }; 72 73 74 /********************************************************************************************************************************* 75 * UIPasswordLineEdit implementation. * 76 *********************************************************************************************************************************/ 77 32 78 UIPasswordLineEdit::UIPasswordLineEdit(QWidget *pParent /*= 0 */) 33 79 : QLineEdit(pParent) 34 80 , m_pTextVisibilityButton(0) 81 , m_pErrorIconLabel(0) 82 , m_fMarkForError(false) 35 83 { 36 84 prepare(); … … 55 103 } 56 104 105 void UIPasswordLineEdit::mark(bool fError, const QString &strErrorToolTip) 106 { 107 if (m_fMarkForError == fError && m_strErrorToolTip == strErrorToolTip) 108 return; 109 m_fMarkForError = fError; 110 m_strErrorToolTip = strErrorToolTip; 111 update(); 112 } 113 57 114 void UIPasswordLineEdit::prepare() 58 115 { 116 m_markIcon = UIIconPool::iconSet(":/status_error_16px.png"); 59 117 /* Prepare text visibility button: */ 60 118 m_pTextVisibilityButton = new QIToolButton(this); … … 67 125 connect(m_pTextVisibilityButton, &QToolButton::clicked, this, &UIPasswordLineEdit::sltHandleTextVisibilityChange); 68 126 } 69 127 m_pErrorIconLabel = new QLabel(this); 70 128 toggleTextVisibility(false); 71 129 adjustTextVisibilityButtonGeometry(); … … 96 154 /* Call to base-class: */ 97 155 QLineEdit::resizeEvent(pEvent); 98 99 156 adjustTextVisibilityButtonGeometry(); 157 } 158 159 void UIPasswordLineEdit::paintEvent(QPaintEvent *pPaintEvent) 160 { 161 QLineEdit::paintEvent(pPaintEvent); 162 if (m_fMarkForError) 163 { 164 const int iIconMargin = 0.5 * QApplication::style()->pixelMetric(QStyle::PM_LayoutTopMargin); 165 int iIconSize = height() - 2 * iIconMargin; 166 if (!m_pErrorIconLabel) 167 m_pErrorIconLabel = new QLabel(this); 168 m_pErrorIconLabel->setPixmap(m_markIcon.pixmap(windowHandle(), QSize(iIconSize, iIconSize))); 169 int iIconX = width() - iIconSize - iIconMargin; 170 if (m_pTextVisibilityButton) 171 iIconX -= m_pTextVisibilityButton->width() - iIconMargin; 172 m_pErrorIconLabel->move(iIconX, iIconMargin); 173 m_pErrorIconLabel->setToolTip(m_strErrorToolTip); 174 m_pErrorIconLabel->show(); 175 } 176 else 177 { 178 if (m_pErrorIconLabel) 179 m_pErrorIconLabel->hide(); 180 } 100 181 } 101 182 … … 110 191 emit sigTextVisibilityToggled(fTextVisible); 111 192 } 193 194 195 /********************************************************************************************************************************* 196 * UIUserNamePasswordEditor implementation. * 197 *********************************************************************************************************************************/ 112 198 113 199 UIUserNamePasswordEditor::UIUserNamePasswordEditor(QWidget *pParent /* = 0 */) … … 170 256 if (m_pPasswordLineEdit->text().isEmpty()) 171 257 fPasswordOK = false; 172 } 173 markLineEdit(m_pPasswordLineEdit, !fPasswordOK); 174 markLineEdit(m_pPasswordRepeatLineEdit, !fPasswordOK); 258 259 m_pPasswordLineEdit->mark(!fPasswordOK, m_strPasswordError); 260 m_pPasswordRepeatLineEdit->mark(!fPasswordOK, m_strPasswordError); 261 } 175 262 return fPasswordOK; 176 263 } … … 211 298 void UIUserNamePasswordEditor::retranslateUi() 212 299 { 213 QString strPassword = UI WizardNewVM::tr("Password:");214 QString strRepeatPassword = UI WizardNewVM::tr("Repeat Password:");215 QString strUsername = UI WizardNewVM::tr("Username:");300 QString strPassword = UIUserNamePasswordEditor::tr("Password"); 301 QString strRepeatPassword = UIUserNamePasswordEditor::tr("Repeat Password"); 302 QString strUsername = UIUserNamePasswordEditor::tr("Username"); 216 303 if (m_pUserNameLabel) 217 304 { 218 m_pUserNameLabel->setText( strUsername);219 m_pUserNameLabel->setToolTip(UI WizardNewVM::tr("Type the user name which will be used in attended install:"));305 m_pUserNameLabel->setText(QString("%1%2").arg(strUsername).arg(":")); 306 m_pUserNameLabel->setToolTip(UIUserNamePasswordEditor::tr("Type the user name which will be used in attended install:")); 220 307 221 308 } 222 309 if (m_pPasswordLabel) 223 310 { 224 m_pPasswordLabel->setText( strPassword);225 m_pPasswordLabel->setToolTip(UI WizardNewVM::tr("Type the password for the user name"));311 m_pPasswordLabel->setText(QString("%1%2").arg(strPassword).arg(":")); 312 m_pPasswordLabel->setToolTip(UIUserNamePasswordEditor::tr("Type the password for the user name")); 226 313 227 314 } 228 315 if (m_pPasswordRepeatLabel) 229 316 { 230 m_pPasswordRepeatLabel->setText( strRepeatPassword);231 m_pPasswordRepeatLabel->setToolTip(UI WizardNewVM::tr("Retype the password:"));317 m_pPasswordRepeatLabel->setText(QString("%1%2").arg(strRepeatPassword).arg(":")); 318 m_pPasswordRepeatLabel->setToolTip(UIUserNamePasswordEditor::tr("Retype the password:")); 232 319 } 233 320 … … 250 337 m_pPasswordRepeatLineEdit->setPlaceholderText(QString()); 251 338 } 339 m_strPasswordError = UIUserNamePasswordEditor::tr("Invalid password pair"); 252 340 } 253 341 … … 326 414 emit sigSomeTextChanged(); 327 415 } 416 417 #include "UIUserNamePasswordEditor.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIUserNamePasswordEditor.h
r87348 r87731 23 23 24 24 /* Qt includes: */ 25 #include <Q LineEdit>25 #include <QIcon> 26 26 #include <QWidget> 27 27 … … 32 32 class QGridLayout; 33 33 class QLabel; 34 class QIToolButton; 35 36 class UIPasswordLineEdit : public QLineEdit 37 { 38 Q_OBJECT; 39 40 signals: 41 42 void sigTextVisibilityToggled(bool fTextVisible); 43 44 public: 45 46 UIPasswordLineEdit(QWidget *pParent = 0); 47 void toggleTextVisibility(bool fTextVisible); 48 49 protected: 50 51 virtual void resizeEvent(QResizeEvent *pEvent) /* override */; 52 53 private: 54 55 void prepare(); 56 void adjustTextVisibilityButtonGeometry(); 57 58 QIToolButton *m_pTextVisibilityButton; 59 60 private slots: 61 62 void sltHandleTextVisibilityChange(); 63 }; 34 class QLineEdit; 35 class UIPasswordLineEdit; 64 36 65 37 class UIUserNamePasswordEditor : public QIWithRetranslateUI<QWidget> … … 124 96 bool m_fShowPlaceholderText; 125 97 bool m_fLabelsVisible; 98 99 QString m_strPasswordError; 126 100 }; 127 101 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic2.cpp
r87592 r87731 22 22 #include <QGroupBox> 23 23 #include <QLabel> 24 #include <QLineEdit> 24 25 #include <QSpacerItem> 25 26 #include <QToolBox> -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp
r87724 r87731 23 23 #include <QHBoxLayout> 24 24 #include <QLabel> 25 #include <QLineEdit> 25 26 #include <QRadioButton> 26 27 #include <QSpinBox>
Note:
See TracChangeset
for help on using the changeset viewer.

