Changeset 87724 in vbox for trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILineEdit.cpp
- Timestamp:
- Feb 11, 2021 3:21:12 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 142770
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILineEdit.cpp
r87460 r87724 20 20 #include <QClipboard> 21 21 #include <QContextMenuEvent> 22 #include <QLabel> 22 23 #include <QMenu> 23 24 #include <QPalette> … … 26 27 /* GUI includes: */ 27 28 #include "QILineEdit.h" 28 29 #include "UIIconPool.h" 29 30 30 31 QILineEdit::QILineEdit(QWidget *pParent /* = 0 */) … … 32 33 , m_fAllowToCopyContentsWhenDisabled(false) 33 34 , m_pCopyAction(0) 35 , m_pIconLabel(0) 36 , m_fMarkForError(false) 34 37 { 35 38 prepare(); … … 40 43 , m_fAllowToCopyContentsWhenDisabled(false) 41 44 , m_pCopyAction(0) 45 , m_pIconLabel(0) 46 , m_fMarkForError(false) 42 47 { 43 48 prepare(); … … 61 66 void QILineEdit::mark(bool fError) 62 67 { 63 QPalette newPalette = palette(); 64 if (fError) 65 newPalette.setColor(QPalette::Base, QColor(255, 180, 180)); 66 else 67 newPalette.setColor(QPalette::Base, m_originalBaseColor); 68 setPalette(newPalette); 68 if (fError == m_fMarkForError) 69 return; 70 m_fMarkForError = fError; 71 update(); 69 72 } 70 73 … … 94 97 } 95 98 99 void QILineEdit::paintEvent(QPaintEvent *pPaintEvent) 100 { 101 QLineEdit::paintEvent(pPaintEvent); 102 103 if (m_fMarkForError) 104 { 105 const int iIconMargin = 0.5 * QApplication::style()->pixelMetric(QStyle::PM_LayoutTopMargin); 106 int iIconSize = height() - 2 * iIconMargin; 107 if (!m_pIconLabel) 108 m_pIconLabel = new QLabel(this); 109 m_pIconLabel->setPixmap(m_markIcon.pixmap(windowHandle(), QSize(iIconSize, iIconSize))); 110 m_pIconLabel->move(width() - iIconSize - iIconMargin, iIconMargin); 111 m_pIconLabel->show(); 112 } 113 else 114 { 115 if (m_pIconLabel) 116 m_pIconLabel->hide(); 117 } 118 } 119 96 120 void QILineEdit::copy() 97 121 { … … 103 127 void QILineEdit::prepare() 104 128 { 129 m_markIcon = UIIconPool::iconSet(":/status_error_16px.png"); 105 130 /* Prepare original base color: */ 106 131 m_originalBaseColor = palette().color(QPalette::Base);
Note:
See TracChangeset
for help on using the changeset viewer.