VirtualBox

Changeset 108311 in vbox


Ignore:
Timestamp:
Feb 20, 2025 1:29:09 PM (3 weeks ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167655
Message:

FE/Qt: bugref:10814: VBox Manager / Tools pane: Hovered and Selected tokens for Machine tools in widget mode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsItem.cpp

    r108310 r108311  
    747747                                         : highlightColor.darker(110);
    748748
    749             /* Prepare token sub-rect: */
    750             QRect tokenRect(rectangle.topLeft() + QPoint(0, 4),
    751                             QSize(5, rectangle.height() - 8));
    752 
    753             /* Draw gradient token: */
    754             QLinearGradient hlGrad(tokenRect.topLeft(), tokenRect.bottomLeft());
    755             hlGrad.setColorAt(0, highlightColor1);
    756             hlGrad.setColorAt(1, highlightColor2);
    757             pPainter->fillRect(tokenRect, hlGrad);
     749            /* Depending on item class: */
     750            switch (itemClass())
     751            {
     752                case UIToolClass_Global:
     753                {
     754                    /* Prepare token sub-rect: */
     755                    QRect tokenRect(rectangle.topLeft() + QPoint(0, 4),
     756                                    QSize(5, rectangle.height() - 8));
     757
     758                    /* Draw gradient token: */
     759                    QLinearGradient hlGrad(tokenRect.topLeft(), tokenRect.bottomLeft());
     760                    hlGrad.setColorAt(0, highlightColor1);
     761                    hlGrad.setColorAt(1, highlightColor2);
     762                    pPainter->fillRect(tokenRect, hlGrad);
     763                    break;
     764                }
     765                case UIToolClass_Machine:
     766                {
     767                    /* A bit of indentation for Machine tools in widget mode: */
     768                    int iIndent = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * .5;
     769
     770                    /* Prepare token sub-rect: */
     771                    QRect tokenRect(rectangle.topLeft() + QPoint(iIndent, rectangle.height() / 2 - 2),
     772                                    QSize(5, 5));
     773
     774                    /* Restrict painter path: */
     775                    pPainter->save();
     776                    QPainterPath path;
     777                    path.addEllipse(tokenRect);
     778                    pPainter->setClipPath(path);
     779
     780                    /* Draw gradient token: */
     781                    QLinearGradient hlGrad(tokenRect.topLeft(), tokenRect.bottomLeft());
     782                    hlGrad.setColorAt(0, highlightColor1);
     783                    hlGrad.setColorAt(1, highlightColor2);
     784                    pPainter->fillRect(tokenRect, hlGrad);
     785                    pPainter->restore();
     786                    break;
     787                }
     788                default:
     789                    break;
     790            }
    758791        }
    759792
     
    779812#endif /* !VBOX_WS_MAC */
    780813
     814            /* A bit of indentation for Machine tools in widget mode: */
     815            const int iIndent = itemClass() == UIToolClass_Machine
     816                              ? QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * .5 : 0;
     817
    781818            /* Prepare icon sub-rect: */
    782819            QRect subRect;
     
    784821            subRect.setWidth(subRect.height());
    785822#ifdef VBOX_WS_MAC
    786             subRect.moveTopLeft(rectangle.topLeft() + QPoint(2 * iMargin - iPadding, iMargin - iPadding));
     823            subRect.moveTopLeft(rectangle.topLeft() + QPoint(iIndent + 2 * iMargin - iPadding, iMargin - iPadding));
    787824#else
    788             subRect.moveTopLeft(rectangle.topLeft() + QPoint(1.5 * iMargin - iPadding, iMargin - iPadding));
     825            subRect.moveTopLeft(rectangle.topLeft() + QPoint(iIndent + 1.5 * iMargin - iPadding, iMargin - iPadding));
    789826#endif
    790827
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette