Changeset 109005 in vbox
- Timestamp:
- Apr 16, 2025 2:46:44 PM (4 days ago)
- svn:sync-xref-src-repo-rev:
- 168528
- 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
r109002 r109005 342 342 { 343 343 m_fHovered = true; 344 update();345 344 346 345 /* Show tooltip for all tools … … 359 358 } 360 359 } 360 361 update(); 361 362 } 362 363 … … 593 594 : pal.color(QPalette::Active, QPalette::Window); 594 595 595 /* Prepare icon sub-rect: */596 /* Prepare button sub-rect: */ 596 597 QRect subRect; 597 598 subRect.setHeight(m_pixmap.height() / m_pixmap.devicePixelRatio() + iPadding * 2); … … 603 604 #endif 604 605 605 /* Paint icon frame: */ 606 QPainterPath painterPath; 607 painterPath.addRoundedRect(subRect, iPadding, iPadding); 608 #ifdef VBOX_WS_MAC 609 const QColor backgroundColor1 = uiCommon().isInDarkMode() 610 ? backgroundColor.lighter(220) 611 : backgroundColor.darker(140); 612 #else /* !VBOX_WS_MAC */ 613 const QColor backgroundColor1 = uiCommon().isInDarkMode() 614 ? backgroundColor.lighter(140) 615 : backgroundColor.darker(120); 616 #endif /* !VBOX_WS_MAC */ 617 pPainter->setPen(QPen(backgroundColor1, 2, Qt::SolidLine, Qt::RoundCap)); 618 pPainter->drawPath(QPainterPathStroker().createStroke(painterPath)); 619 620 /* Fill icon body: */ 621 pPainter->setClipPath(painterPath); 622 #ifdef VBOX_WS_MAC 623 const QColor backgroundColor2 = uiCommon().isInDarkMode() 624 ? backgroundColor.lighter(160) 625 : backgroundColor.darker(120); 626 #else /* !VBOX_WS_MAC */ 627 const QColor backgroundColor2 = uiCommon().isInDarkMode() 628 ? backgroundColor.lighter(105) 629 : backgroundColor.darker(105); 630 #endif /* !VBOX_WS_MAC */ 631 pPainter->fillRect(subRect, backgroundColor2); 606 /* Prepare mouse cursor position: */ 607 const QPoint cursorPosInView = model()->view()->mapFromGlobal(QCursor::pos()); 608 const QPointF cursorPosInScene = model()->view()->mapToScene(cursorPosInView); 609 const QPointF cursorPosInItem = mapFromScene(cursorPosInScene); 610 611 /* Paint button finally: */ 612 paintRoundedButton(pPainter, subRect, cursorPosInItem, backgroundColor, iPadding); 632 613 } 633 614 … … 737 718 pPainter->restore(); 738 719 } 720 721 /* static */ 722 void UIToolsItem::paintRoundedButton(QPainter *pPainter, 723 const QRect &rectangle, 724 const QPointF &cursorPosition, 725 const QColor &color, 726 int iPadding) 727 { 728 /* Save painter: */ 729 pPainter->save(); 730 731 /* Paint icon frame: */ 732 QPainterPath painterPath; 733 painterPath.addRoundedRect(rectangle, iPadding, iPadding); 734 const QColor frameColor = uiCommon().isInDarkMode() 735 ? color.lighter(220) 736 : color.darker(120); 737 pPainter->setPen(QPen(frameColor, 2, Qt::SolidLine, Qt::RoundCap)); 738 pPainter->drawPath(QPainterPathStroker().createStroke(painterPath)); 739 740 /* Fill icon body: */ 741 pPainter->setClipPath(painterPath); 742 const QColor backgroundColor = uiCommon().isInDarkMode() 743 ? color.lighter(180) 744 : color.darker(105); 745 pPainter->fillRect(rectangle, backgroundColor); 746 747 /* Paint active background: */ 748 QRadialGradient grad(rectangle.center(), rectangle.width(), cursorPosition); 749 const QColor color1 = uiCommon().isInDarkMode() 750 ? backgroundColor.lighter(180) 751 : backgroundColor.lighter(120); 752 const QColor color2 = uiCommon().isInDarkMode() 753 ? backgroundColor.darker(180) 754 : backgroundColor.darker(120); 755 grad.setColorAt(0, color1); 756 grad.setColorAt(1, color2); 757 pPainter->fillRect(rectangle, grad); 758 759 /* Restore painter: */ 760 pPainter->restore(); 761 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsItem.h
r109001 r109005 200 200 const QFont &font, QPaintDevice *pPaintDevice, 201 201 const QString &strText); 202 203 /** Paints rounded button which moves light focus according to @a cursorPosition using passed @a pPainter. 204 * @param rectangle Brings the button's rectangle. 205 * @param color Brings the base color to work with. 206 * @param iPadding Brings the button rounded padding. */ 207 static void paintRoundedButton(QPainter *pPainter, 208 const QRect &rectangle, 209 const QPointF &cursorPosition, 210 const QColor &color, 211 int iPadding); 202 212 /** @} */ 203 213
Note:
See TracChangeset
for help on using the changeset viewer.