Changeset 104575 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- May 10, 2024 1:35:32 PM (12 months ago)
- svn:sync-xref-src-repo-rev:
- 163114
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/extensions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILineEdit.cpp
r104546 r104575 207 207 } 208 208 209 210 209 void UIMarkableLineEdit::mark(bool fError, const QString &strErrorMessage, const QString &strNoErrorMessage) 211 210 { 211 AssertPtrReturnVoid(m_pIconLabel); 212 212 const QIcon icon = fError ? UIIconPool::iconSet(":/status_error_16px.png") : UIIconPool::iconSet(":/status_check_16px.png"); 213 const int iIconMetric = qMin((int)(QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * .625), height()); 214 const qreal fDevicePixelRatio = gpDesktop->devicePixelRatio(m_pIconLabel); 213 215 const QString strToolTip = fError ? strErrorMessage : strNoErrorMessage; 214 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize); 215 const qreal fDevicePixelRatio = gpDesktop->devicePixelRatio(m_pIconLabel); 216 QPixmap iconPixmap = icon.pixmap(QSize(iIconMetric, iIconMetric), fDevicePixelRatio); 217 m_iIconMargin = QApplication::style()->pixelMetric(QStyle::PM_LayoutTopMargin); 218 int iHeight = height() - m_iIconMargin; 219 iconPixmap = iconPixmap.scaledToHeight(iHeight, Qt::SmoothTransformation); 216 const QPixmap iconPixmap = icon.pixmap(QSize(iIconMetric, iIconMetric), fDevicePixelRatio); 220 217 m_pIconLabel->setPixmap(iconPixmap); 218 m_pIconLabel->resize(m_pIconLabel->minimumSizeHint()); 221 219 m_pIconLabel->setToolTip(strToolTip); 222 220 m_iIconMargin = (height() - m_pIconLabel->height()) / 2; 223 221 update(); 224 222 } 225 223 226 void UIMarkableLineEdit::paintEvent(QPaintEvent *pEvent)227 {228 QLineEdit::paintEvent(pEvent);229 moveIconLabel();230 }231 224 void UIMarkableLineEdit::moveIconLabel() 232 225 { 233 226 AssertPtrReturnVoid(m_pIconLabel); 234 m_pIconLabel->setVisible(true); 235 int iHeight = height() - m_iIconMargin; 236 m_pIconLabel->setGeometry(width() - iHeight - 0.5 * m_iIconMargin, 0.5 * m_iIconMargin, iHeight, iHeight); 227 m_pIconLabel->move(width() - m_pIconLabel->width() - m_iIconMargin, m_iIconMargin); 237 228 } 238 229 … … 241 232 /* Call to base-class: */ 242 233 QLineEdit::resizeEvent(pResizeEvent); 234 moveIconLabel(); 235 } 236 237 void UIMarkableLineEdit::showEvent(QShowEvent *pShowEvent) 238 { 239 /* Call to base-class: */ 240 QLineEdit::showEvent(pShowEvent); 243 241 moveIconLabel(); 244 242 } -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILineEdit.h
r104546 r104575 118 118 119 119 /** Handles resize @a pEvent. */ 120 virtual void resizeEvent(QResizeEvent *pResizeEvent) RT_OVERRIDE; 121 virtual void paintEvent(QPaintEvent *pEvent) RT_OVERRIDE; 120 virtual void resizeEvent(QResizeEvent *pEvent) RT_OVERRIDE; 121 /** Handles show @a pEvent. */ 122 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE; 122 123 void moveIconLabel(); 123 124 void prepare();
Note:
See TracChangeset
for help on using the changeset viewer.