Changeset 72871 in vbox
- Timestamp:
- Jul 4, 2018 12:02:36 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIStatusBarEditorWindow.cpp
r72026 r72871 88 88 protected: 89 89 90 /** Handles any Qt @a pEvent. */ 91 virtual bool event(QEvent *pEvent) /* override */; 92 90 93 /** Handles translation event. */ 91 94 virtual void retranslateUi() /* override */; … … 106 109 107 110 private: 111 112 /** Prepares all. */ 113 void prepare(); 114 115 /** Updates pixmap. */ 116 void updatePixmap(); 108 117 109 118 /** Holds the button type. */ … … 207 216 , m_fHovered(false) 208 217 { 209 /* Track mouse events: */ 210 setMouseTracking(true); 211 212 /* Prepare icon for assigned type: */ 213 const QIcon icon = gpConverter->toIcon(m_enmType); 214 const QStyle *pStyle = QApplication::style(); 215 const int iIconMetric = pStyle->pixelMetric(QStyle::PM_SmallIconSize); 216 m_pixmapSize = QSize(iIconMetric, iIconMetric); 217 m_pixmap = icon.pixmap(m_pixmapSize); 218 219 /* Cache button size-hint: */ 220 QStyleOptionButton option; 221 option.initFrom(this); 222 const QRect minRect = QApplication::style()->subElementRect(QStyle::SE_CheckBoxIndicator, &option); 223 m_size = m_pixmapSize.expandedTo(minRect.size()); 224 225 /* Translate finally: */ 226 retranslateUi(); 218 prepare(); 227 219 } 228 220 … … 238 230 /* Update: */ 239 231 update(); 232 } 233 234 bool UIStatusBarEditorButton::event(QEvent *pEvent) 235 { 236 /* Handle know event types: */ 237 switch (pEvent->type()) 238 { 239 case QEvent::Show: 240 case QEvent::ScreenChangeInternal: 241 { 242 /* Update pixmap: */ 243 updatePixmap(); 244 break; 245 } 246 default: 247 break; 248 } 249 250 /* Call to base-class: */ 251 return QIWithRetranslateUI<QWidget>::event(pEvent); 240 252 } 241 253 … … 347 359 pDrag->setPixmap(m_pixmap); 348 360 pDrag->exec(); 361 } 362 363 void UIStatusBarEditorButton::prepare() 364 { 365 /* Track mouse events: */ 366 setMouseTracking(true); 367 368 /* Calculate icon size: */ 369 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize); 370 m_pixmapSize = QSize(iIconMetric, iIconMetric); 371 372 /* Cache button size-hint: */ 373 QStyleOptionButton option; 374 option.initFrom(this); 375 const QRect minRect = QApplication::style()->subElementRect(QStyle::SE_CheckBoxIndicator, &option); 376 m_size = m_pixmapSize.expandedTo(minRect.size()); 377 378 /* Update pixmap: */ 379 updatePixmap(); 380 381 /* Translate finally: */ 382 retranslateUi(); 383 } 384 385 void UIStatusBarEditorButton::updatePixmap() 386 { 387 /* Recache pixmap for assigned type: */ 388 const QIcon icon = gpConverter->toIcon(m_enmType); 389 if (window()) 390 m_pixmap = icon.pixmap(window()->windowHandle(), m_pixmapSize); 391 else 392 m_pixmap = icon.pixmap(m_pixmapSize); 349 393 } 350 394
Note:
See TracChangeset
for help on using the changeset viewer.

