Changeset 104979 in vbox
- Timestamp:
- Jun 20, 2024 1:19:45 PM (9 months ago)
- svn:sync-xref-src-repo-rev:
- 163589
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/extensions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILineEdit.cpp
r104978 r104979 30 30 #include <QClipboard> 31 31 #include <QContextMenuEvent> 32 #include <QHBoxLayout>33 32 #include <QLabel> 34 33 #include <QMenu> … … 39 38 #include "UIDesktopWidgetWatchdog.h" 40 39 #include "UIIconPool.h" 41 42 /* Other VBox includes: */43 #include "iprt/assert.h"44 40 45 41 … … 50 46 , m_fMarkable(false) 51 47 , m_fMarkForError(false) 52 , m_p IconLabel(0)48 , m_pLabelIcon(0) 53 49 , m_iIconMargin(0) 54 50 { … … 62 58 , m_fMarkable(false) 63 59 , m_fMarkForError(false) 64 , m_p IconLabel(0)60 , m_pLabelIcon(0) 65 61 , m_iIconMargin(0) 66 62 { … … 85 81 void QILineEdit::setMarkable(bool fMarkable) 86 82 { 83 /* Sanity check: */ 87 84 if (m_fMarkable == fMarkable) 88 85 return; 86 87 /* Save new value, show/hide label accordingly: */ 89 88 m_fMarkable = fMarkable; 90 89 update(); … … 93 92 void QILineEdit::mark(bool fError, const QString &strErrorMessage, const QString &strNoErrorMessage) 94 93 { 95 AssertPtrReturnVoid(m_pIconLabel); 96 if (!m_fMarkable) 94 /* Sanity check: */ 95 if ( !m_pLabelIcon 96 || !m_fMarkable) 97 97 return; 98 98 99 /* Assign corresponding icon: */ 99 100 const QIcon icon = fError ? UIIconPool::iconSet(":/status_error_16px.png") : UIIconPool::iconSet(":/status_check_16px.png"); 100 101 const int iIconMetric = qMin((int)(QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * .625), height()); 101 const qreal fDevicePixelRatio = gpDesktop->devicePixelRatio(m_p IconLabel);102 const qreal fDevicePixelRatio = gpDesktop->devicePixelRatio(m_pLabelIcon); 102 103 const QString strToolTip = fError ? strErrorMessage : strNoErrorMessage; 103 104 const QPixmap iconPixmap = icon.pixmap(QSize(iIconMetric, iIconMetric), fDevicePixelRatio); 104 m_p IconLabel->setPixmap(iconPixmap);105 m_p IconLabel->resize(m_pIconLabel->minimumSizeHint());106 m_p IconLabel->setToolTip(strToolTip);107 m_iIconMargin = (height() - m_p IconLabel->height()) / 2;105 m_pLabelIcon->setPixmap(iconPixmap); 106 m_pLabelIcon->resize(m_pLabelIcon->minimumSizeHint()); 107 m_pLabelIcon->setToolTip(strToolTip); 108 m_iIconMargin = (height() - m_pLabelIcon->height()) / 2; 108 109 update(); 109 110 } … … 111 112 bool QILineEdit::event(QEvent *pEvent) 112 113 { 114 /* Depending on event type: */ 113 115 switch (pEvent->type()) 114 116 { … … 131 133 break; 132 134 } 135 136 /* Call to base-class: */ 133 137 return QLineEdit::event(pEvent); 134 138 } … … 140 144 if (m_fMarkable) 141 145 { 142 m_p IconLabel->resize(m_pIconLabel->minimumSizeHint());143 m_iIconMargin = (height() - m_p IconLabel->height()) / 2;146 m_pLabelIcon->resize(m_pLabelIcon->minimumSizeHint()); 147 m_iIconMargin = (height() - m_pLabelIcon->height()) / 2; 144 148 moveIconLabel(); 145 149 } … … 174 178 175 179 /* Prepare icon label: */ 176 m_p IconLabel= new QLabel(this);180 m_pLabelIcon = new QLabel(this); 177 181 } 178 182 … … 199 203 void QILineEdit::moveIconLabel() 200 204 { 201 AssertPtrReturnVoid(m_pIconLabel); 202 m_pIconLabel->move(width() - m_pIconLabel->width() - m_iIconMargin, m_iIconMargin); 203 } 205 /* Sanity check: */ 206 if ( !m_pLabelIcon 207 || !m_fMarkable) 208 return; 209 210 /* We do it cause we have manual layout for the label: */ 211 m_pLabelIcon->move(width() - m_pLabelIcon->width() - m_iIconMargin, m_iIconMargin); 212 } -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILineEdit.h
r104978 r104979 33 33 34 34 /* Qt includes */ 35 #include <QIcon>36 35 #include <QLineEdit> 37 36 … … 39 38 #include "UILibraryDefs.h" 40 39 40 /* Forward declarations: */ 41 41 class QLabel; 42 42 … … 104 104 bool m_fMarkForError; 105 105 /** Holds the icon label instance. */ 106 QLabel *m_p IconLabel;106 QLabel *m_pLabelIcon; 107 107 /** Holds last error message. */ 108 108 QString m_strErrorMessage;
Note:
See TracChangeset
for help on using the changeset viewer.