- Timestamp:
- Aug 12, 2021 6:47:02 AM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
-
extensions/QILineEdit.cpp (modified) (5 diffs)
-
extensions/QILineEdit.h (modified) (1 diff)
-
wizards/editors/UIUserNamePasswordEditor.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILineEdit.cpp
r90641 r90642 24 24 #include <QPalette> 25 25 #include <QStyleOptionFrame> 26 #include <QTime>27 26 28 27 /* GUI includes: */ … … 67 66 void QILineEdit::mark(bool fError, const QString &strErrorMessage /* = QString() */) 68 67 { 68 /* Check if something really changed: */ 69 69 if (fError == m_fMarkForError && m_strErrorMessage == strErrorMessage) 70 70 return; 71 72 /* Save new values: */ 71 73 m_fMarkForError = fError; 72 74 m_strErrorMessage = strErrorMessage; 73 update(); 75 76 /* Update accordingly: */ 77 if (m_fMarkForError) 78 { 79 /* Create label if absent: */ 80 if (!m_pIconLabel) 81 m_pIconLabel = new QLabel(this); 82 83 /* Update label content, visibility & position: */ 84 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * .625; 85 const int iShift = height() > iIconMetric ? (height() - iIconMetric) / 2 : 0; 86 m_pIconLabel->setPixmap(m_markIcon.pixmap(windowHandle(), QSize(iIconMetric, iIconMetric))); 87 m_pIconLabel->setToolTip(m_strErrorMessage); 88 m_pIconLabel->move(width() - iIconMetric - iShift, iShift); 89 m_pIconLabel->show(); 90 } 91 else 92 { 93 /* Hide label: */ 94 if (m_pIconLabel) 95 m_pIconLabel->hide(); 96 } 74 97 } 75 98 … … 99 122 } 100 123 101 void QILineEdit:: paintEvent(QPaintEvent *pPaintEvent)124 void QILineEdit::resizeEvent(QResizeEvent *pResizeEvent) 102 125 { 103 QLineEdit::paintEvent(pPaintEvent); 126 /* Call to base-class: */ 127 QLineEdit::resizeEvent(pResizeEvent); 104 128 105 if (m_fMarkForError) 129 /* Update error label position: */ 130 if (m_pIconLabel) 106 131 { 107 if (!m_pIconLabel) 108 m_pIconLabel = new QLabel(this); 109 110 if (m_pIconLabel && m_pIconLabel->isHidden()) 111 { 112 const int iIconMargin = 1. * QApplication::style()->pixelMetric(QStyle::PM_LayoutTopMargin); 113 int iIconSize = height() - 2 * iIconMargin; 114 m_pIconLabel->setPixmap(m_markIcon.pixmap(windowHandle(), QSize(iIconSize, iIconSize))); 115 m_pIconLabel->setToolTip(m_strErrorMessage); 116 m_pIconLabel->move(width() - iIconSize - iIconMargin, iIconMargin); 117 m_pIconLabel->show(); 118 } 119 } 120 else 121 { 122 if (m_pIconLabel && m_pIconLabel->isVisible()) 123 m_pIconLabel->hide(); 132 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * .625; 133 const int iShift = height() > iIconMetric ? (height() - iIconMetric) / 2 : 0; 134 m_pIconLabel->move(width() - iIconMetric - iShift, iShift); 124 135 } 125 136 } … … 134 145 void QILineEdit::prepare() 135 146 { 136 m_markIcon = UIIconPool::iconSet(":/status_error_16px.png");137 138 147 /* Prepare invisible copy action: */ 139 148 m_pCopyAction = new QAction(this); … … 145 154 addAction(m_pCopyAction); 146 155 } 156 157 /* Prepare warning icon: */ 158 m_markIcon = UIIconPool::iconSet(":/status_error_16px.png"); 147 159 } 148 160 -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILineEdit.h
r88860 r90642 59 59 /** Handles any Qt @a pEvent. */ 60 60 virtual bool event(QEvent *pEvent) /* override */; 61 virtual void paintEvent(QPaintEvent *pPaintEvent) /* override */; 61 62 /** Handles resize @a pEvent. */ 63 virtual void resizeEvent(QResizeEvent *pResizeEvent) /* override */; 62 64 63 65 private slots: -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIUserNamePasswordEditor.cpp
r90193 r90642 53 53 54 54 virtual void resizeEvent(QResizeEvent *pEvent) /* override */; 55 virtual void paintEvent(QPaintEvent *pPaintEvent) /* override */;56 55 57 56 private slots: … … 106 105 void UIPasswordLineEdit::mark(bool fError, const QString &strErrorToolTip) 107 106 { 107 /* Check if something really changed: */ 108 108 if (m_fMarkForError == fError && m_strErrorToolTip == strErrorToolTip) 109 109 return; 110 111 /* Save new values: */ 110 112 m_fMarkForError = fError; 111 113 m_strErrorToolTip = strErrorToolTip; 112 update(); 114 115 /* Update accordingly: */ 116 if (m_fMarkForError) 117 { 118 /* Create label if absent: */ 119 if (!m_pErrorIconLabel) 120 m_pErrorIconLabel = new QLabel(this); 121 122 /* Update label content, visibility & position: */ 123 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * .625; 124 const int iShift = height() > iIconMetric ? (height() - iIconMetric) / 2 : 0; 125 m_pErrorIconLabel->setPixmap(m_markIcon.pixmap(windowHandle(), QSize(iIconMetric, iIconMetric))); 126 m_pErrorIconLabel->setToolTip(m_strErrorToolTip); 127 int iIconX = width() - iIconMetric - iShift; 128 if (m_pTextVisibilityButton) 129 iIconX -= m_pTextVisibilityButton->width() - iShift; 130 m_pErrorIconLabel->move(iIconX, iShift); 131 m_pErrorIconLabel->show(); 132 } 133 else 134 { 135 /* Hide label: */ 136 if (m_pErrorIconLabel) 137 m_pErrorIconLabel->hide(); 138 } 113 139 } 114 140 … … 156 182 QLineEdit::resizeEvent(pEvent); 157 183 adjustTextVisibilityButtonGeometry(); 158 } 159 160 void UIPasswordLineEdit::paintEvent(QPaintEvent *pPaintEvent) 161 { 162 QLineEdit::paintEvent(pPaintEvent); 163 if (m_fMarkForError) 164 { 165 const int iIconMargin = 1. * QApplication::style()->pixelMetric(QStyle::PM_LayoutTopMargin); 166 int iIconSize = height() - 2 * iIconMargin; 167 if (!m_pErrorIconLabel) 168 m_pErrorIconLabel = new QLabel(this); 169 m_pErrorIconLabel->setPixmap(m_markIcon.pixmap(windowHandle(), QSize(iIconSize, iIconSize))); 170 int iIconX = width() - iIconSize - iIconMargin; 184 185 /* Update error label position: */ 186 if (m_pErrorIconLabel) 187 { 188 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * .625; 189 const int iShift = height() > iIconMetric ? (height() - iIconMetric) / 2 : 0; 190 int iIconX = width() - iIconMetric - iShift; 171 191 if (m_pTextVisibilityButton) 172 iIconX -= m_pTextVisibilityButton->width() - iIconMargin; 173 m_pErrorIconLabel->move(iIconX, iIconMargin); 174 m_pErrorIconLabel->setToolTip(m_strErrorToolTip); 175 m_pErrorIconLabel->show(); 176 } 177 else 178 { 179 if (m_pErrorIconLabel) 180 m_pErrorIconLabel->hide(); 192 iIconX -= m_pTextVisibilityButton->width() - iShift; 193 m_pErrorIconLabel->move(iIconX, iShift); 181 194 } 182 195 }
Note:
See TracChangeset
for help on using the changeset viewer.

