Changeset 108001 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jan 31, 2025 11:58:03 AM (3 months ago)
- svn:sync-xref-src-repo-rev:
- 167273
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsItem.cpp
r107981 r108001 40 40 41 41 /* GUI includes: */ 42 #include "UICommon.h" 42 43 #include "UIImageTools.h" 43 44 #include "UITools.h" … … 186 187 187 188 UIToolsItem::UIToolsItem(QGraphicsScene *pScene, const QIcon &icon, 188 UIToolClass enmClass, UIToolType enmType) 189 UIToolClass enmClass, UIToolType enmType, 190 bool fExtraButton /* = false */) 189 191 : m_pScene(pScene) 190 192 , m_icon(icon) 191 193 , m_enmClass(enmClass) 192 194 , m_enmType(enmType) 195 , m_fExtraButton(fExtraButton) 193 196 , m_fHovered(false) 194 197 , m_pHoveringMachine(0) … … 379 382 /* Paint tool info: */ 380 383 paintToolInfo(pPainter, rectangle); 384 /* Paint extra-button if requested: */ 385 if (m_fExtraButton) 386 paintExtraButton(pPainter, rectangle); 381 387 } 382 388 … … 822 828 } 823 829 830 void UIToolsItem::paintExtraButton(QPainter *pPainter, const QRect &rectangle) const 831 { 832 /* Save painter: */ 833 pPainter->save(); 834 835 /* Configure painter: */ 836 pPainter->setRenderHint(QPainter::Antialiasing, true); 837 /* Acquire background color: */ 838 const QPalette pal = QApplication::palette(); 839 QColor backgroundColor = pal.color(QPalette::Window); 840 841 /* Prepare button sub-rect: */ 842 QRect subRect; 843 subRect.setWidth(rectangle.width() / 6); 844 subRect.setHeight(rectangle.height() / 2); 845 subRect.moveTopLeft(QPoint(rectangle.right() - subRect.width() - 2, 846 rectangle.bottom() - 3 * rectangle.height() / 4 + 1)); 847 848 /* Paint button frame: */ 849 QPainterPath painterPath; 850 painterPath.addRoundedRect(subRect, 4, 4); 851 QColor backgroundColor1 = uiCommon().isInDarkMode() 852 ? backgroundColor.lighter(110) 853 : backgroundColor.darker(110); 854 pPainter->setPen(QPen(backgroundColor1, 2, Qt::SolidLine, Qt::RoundCap)); 855 pPainter->drawPath(QPainterPathStroker().createStroke(painterPath)); 856 857 /* Fill button body: */ 858 pPainter->setClipPath(painterPath); 859 QColor backgroundColor2 = uiCommon().isInDarkMode() 860 ? backgroundColor.lighter(150) 861 : backgroundColor.darker(150); 862 pPainter->fillRect(subRect, backgroundColor2); 863 864 /* Paint arrow: */ 865 pPainter->drawLine(subRect.topLeft() + QPoint(3, 3), QPoint(subRect.right() - 2, subRect.center().y())); 866 pPainter->drawLine(subRect.bottomLeft() + QPoint(3, -3), QPoint(subRect.right() - 2, subRect.center().y())); 867 868 /* Restore painter: */ 869 pPainter->restore(); 870 } 871 824 872 /* static */ 825 873 void UIToolsItem::paintPixmap(QPainter *pPainter, const QPoint &point, -
trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsItem.h
r107981 r108001 84 84 85 85 /** Constructs item on the basis of passed arguments. 86 * @param pScene Brings the scene reference to add item to. 87 * @param icon Brings the item icon. 88 * @param enmClass Brings the item class. 89 * @param enmType Brings the item type. */ 86 * @param pScene Brings the scene reference to add item to. 87 * @param icon Brings the item icon. 88 * @param enmClass Brings the item class. 89 * @param enmType Brings the item type. 90 * @param fExtraButton Brings whether item should have extra-button. */ 90 91 UIToolsItem(QGraphicsScene *pScene, const QIcon &icon, 91 UIToolClass enmClass, UIToolType enmType); 92 UIToolClass enmClass, UIToolType enmType, 93 bool fExtraButton = false); 92 94 /** Destructs item. */ 93 95 virtual ~UIToolsItem() RT_OVERRIDE; … … 223 225 * @param rectangle Brings the rectangle to limit painting with. */ 224 226 void paintToolInfo(QPainter *pPainter, const QRect &rectangle) const; 227 /** Paints extra-button using using passed @a pPainter. 228 * @param rectangle Brings the rectangle to limit painting with. */ 229 void paintExtraButton(QPainter *pPainter, const QRect &rectangle) const; 225 230 226 231 /** Paints @a pixmap using passed @a pPainter. … … 249 254 /** Holds the item type. */ 250 255 UIToolType m_enmType; 256 /** Holds whether item should have extra-button. */ 257 bool m_fExtraButton; 251 258 252 259 /** Holds the item pixmap. */
Note:
See TracChangeset
for help on using the changeset viewer.