VirtualBox

Changeset 108690 in vbox


Ignore:
Timestamp:
Mar 21, 2025 1:49:37 PM (4 weeks ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
168106
Message:

FE/Qt: bugref:10814: VBox Manager / Tool-pane: Wipe out popup-mode support.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager
Files:
9 edited

Legend:

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

    r108665 r108690  
    348348
    349349        /* Create tool-menu: */
    350         m_pMenu = new UITools(this, UIToolClass_Invalid, actionPool(), Qt::Widget);
     350        m_pMenu = new UITools(this, UIToolClass_Invalid, actionPool());
    351351        if (toolMenu())
    352352        {
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UITools.cpp

    r108308 r108690  
    55
    66/*
    7  * Copyright (C) 2012-2024 Oracle and/or its affiliates.
     7 * Copyright (C) 2012-2025 Oracle and/or its affiliates.
    88 *
    99 * This file is part of VirtualBox base platform packages, as
     
    4040UITools::UITools(QWidget *pParent,
    4141                 UIToolClass enmClass,
    42                  UIActionPool *pActionPool,
    43                  Qt::WindowFlags theFlags /* = Qt::Popup */)
    44     : QWidget(pParent, theFlags)
     42                 UIActionPool *pActionPool)
     43    : QWidget(pParent, Qt::Widget)
    4544    , m_enmClass(enmClass)
    4645    , m_pActionPool(pActionPool)
    47     , m_fPopup(theFlags == Qt::Popup)
    4846    , m_pMainLayout(0)
    4947    , m_pToolsModel(0)
     
    118116{
    119117    /* Prepare model: */
    120     m_pToolsModel = new UIToolsModel(this, m_pActionPool, m_enmClass, m_fPopup);
     118    m_pToolsModel = new UIToolsModel(this, m_pActionPool, m_enmClass);
    121119    if (m_pToolsModel)
    122120        prepareView();
     
    129127
    130128    /* Prepare view: */
    131     m_pToolsView = new UIToolsView(this, m_pToolsModel, m_fPopup);
     129    m_pToolsView = new UIToolsView(this, m_pToolsModel);
    132130    if (m_pToolsView)
    133131    {
     
    143141{
    144142    /* Model connections: */
    145     connect(m_pToolsModel, &UIToolsModel::sigClose,
    146             this, &UITools::close);
    147143    connect(m_pToolsModel, &UIToolsModel::sigSelectionChanged,
    148144            this, &UITools::sigSelectionChanged);
     
    157153{
    158154    /* Model connections: */
    159     disconnect(m_pToolsModel, &UIToolsModel::sigClose,
    160                this, &UITools::close);
    161155    disconnect(m_pToolsModel, &UIToolsModel::sigSelectionChanged,
    162156               this, &UITools::sigSelectionChanged);
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UITools.h

    r108308 r108690  
    55
    66/*
    7  * Copyright (C) 2012-2024 Oracle and/or its affiliates.
     7 * Copyright (C) 2012-2025 Oracle and/or its affiliates.
    88 *
    99 * This file is part of VirtualBox base platform packages, as
     
    6262    /** Constructs Tools-pane passing @a pParent to the base-class.
    6363      * @param  enmClass     Brings the tools class, it will be fixed one.
    64       * @param  pActionPool  Brings the action-pool reference.
    65       * @param  theFlags     Brings the widget flags. */
     64      * @param  pActionPool  Brings the action-pool reference. */
    6665    UITools(QWidget *pParent,
    6766            UIToolClass enmClass,
    68             UIActionPool *pActionPool,
    69             Qt::WindowFlags theFlags = Qt::Popup);
     67            UIActionPool *pActionPool);
    7068    /** Destructs Tools-pane. */
    7169    virtual ~UITools();
     
    124122        UIActionPool *m_pActionPool;
    125123
    126         /** Holds whether tools represented as popup. */
    127         const bool  m_fPopup;
    128 
    129124        /** Holds the main layout instance. */
    130125        QVBoxLayout  *m_pMainLayout;
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsItem.cpp

    r108606 r108690  
    55
    66/*
    7  * Copyright (C) 2012-2024 Oracle and/or its affiliates.
     7 * Copyright (C) 2012-2025 Oracle and/or its affiliates.
    88 *
    99 * This file is part of VirtualBox base platform packages, as
     
    3131#include <QGraphicsScene>
    3232#include <QPainter>
    33 #include <QPropertyAnimation>
    34 #include <QSignalTransition>
    35 #include <QStateMachine>
    3633#include <QStyle>
    3734#include <QStyleOptionGraphicsItem>
     
    4138/* GUI includes: */
    4239#include "UICommon.h"
    43 #include "UIImageTools.h"
    44 #include "UITools.h"
    4540#include "UIToolsItem.h"
    4641#include "UIToolsModel.h"
     
    193188    , m_enmReason(HidingReason_Null)
    194189    , m_fHovered(false)
    195     , m_pHoveringMachine(0)
    196     , m_pHoveringAnimationForward(0)
    197     , m_pHoveringAnimationBackward(0)
    198     , m_iAnimationDuration(400)
    199     , m_iDefaultValue(0)
    200     , m_iHoveredValue(100)
    201     , m_iAnimatedValue(m_iDefaultValue)
    202     , m_iDefaultLightnessStart(0)
    203     , m_iDefaultLightnessFinal(0)
    204     , m_iHoverLightnessStart(0)
    205     , m_iHoverLightnessFinal(0)
    206     , m_iHighlightLightnessStart(0)
    207     , m_iHighlightLightnessFinal(0)
    208190    , m_iPreviousMinimumWidthHint(0)
    209191    , m_iPreviousMinimumHeightHint(0)
     
    253235}
    254236
    255 void UIToolsItem::setHovered(bool fHovered)
    256 {
    257     m_fHovered = fHovered;
    258     if (m_fHovered)
    259         emit sigHoverEnter();
    260     else
    261         emit sigHoverLeave();
    262 }
    263 
    264237void UIToolsItem::updateGeometry()
    265238{
     
    297270    iProposedWidth += 2 * iMargin;
    298271#ifdef VBOX_WS_MAC
    299     /* Additional 2 margins for widget mode: */
    300     if (!model()->isPopup())
    301         iProposedWidth += 2 * iMargin;
     272    /* Additional 2 margins: */
     273    iProposedWidth += 2 * iMargin;
    302274#else
    303     /* Additional 1 margin for widget mode: */
    304     if (!model()->isPopup())
    305         iProposedWidth += iMargin;
     275    /* Additional 1 margin: */
     276    iProposedWidth += iMargin;
    306277#endif
    307278
     
    309280    iProposedWidth += m_pixmapSize.width();
    310281
    311     /* Add text size for non-Aux tools in popup mode
    312      * or if it is requested for widget mode: */
     282    /* Add text size for non-Aux tools if it is requested: */
    313283    if (   m_enmClass != UIToolClass_Aux
    314         && (   model()->isPopup()
    315             || model()->showItemNames()))
     284        && model()->showItemNames())
    316285    {
    317286        iProposedWidth += m_nameSize.width();
     
    319288        /* Add 1 spacing by default: */
    320289        iProposedWidth += iSpacing;
    321         /* Additional 1 spacing for widget mode: */
    322         if (!model()->isPopup())
    323             iProposedWidth += iSpacing;
     290        /* Additional 1 spacing: */
     291        iProposedWidth += iSpacing;
    324292    }
    325293
     
    370338    {
    371339        m_fHovered = true;
    372         emit sigHoverEnter();
    373340        update();
    374341
    375         /* Show tooltip at the right of item for widget mode: */
    376         if (   !model()->isPopup()
    377             && !model()->showItemNames())
     342        /* Show tooltip if there is no name: */
     343        if (!model()->showItemNames())
    378344        {
    379345            const QPointF posAtScene = mapToScene(rect().topRight() + QPoint(3, -3));
     
    389355    {
    390356        m_fHovered = false;
    391         emit sigHoverLeave();
    392357        update();
    393358
    394359        /* Hide tooltip for good: */
    395         if (!model()->isPopup())
    396             QToolTip::hideText();
     360        QToolTip::hideText();
    397361    }
    398362}
     
    405369    /* Paint background: */
    406370    paintBackground(pPainter, rectangle);
    407     /* Paint frame for popup only: */
    408     if (model()->isPopup())
    409         paintFrame(pPainter, rectangle);
    410371    /* Paint tool info: */
    411372    paintToolInfo(pPainter, rectangle);
     
    426387    /* Install Tools-view item accessibility interface factory: */
    427388    QAccessible::installFactory(UIAccessibilityInterfaceForUIToolsItem::pFactory);
    428 
    429     /* Prepare color tones: */
    430 #if defined(VBOX_WS_MAC)
    431     m_iDefaultLightnessStart = 120;
    432     m_iDefaultLightnessFinal = 110;
    433     m_iHoverLightnessStart = 125;
    434     m_iHoverLightnessFinal = 115;
    435     m_iHighlightLightnessStart = 115;
    436     m_iHighlightLightnessFinal = 105;
    437 #elif defined(VBOX_WS_WIN)
    438     m_iDefaultLightnessStart = 120;
    439     m_iDefaultLightnessFinal = 110;
    440     m_iHoverLightnessStart = 220;
    441     m_iHoverLightnessFinal = 210;
    442     m_iHighlightLightnessStart = 190;
    443     m_iHighlightLightnessFinal = 180;
    444 #else /* !VBOX_WS_MAC && !VBOX_WS_WIN */
    445     m_iDefaultLightnessStart = 110;
    446     m_iDefaultLightnessFinal = 100;
    447     m_iHoverLightnessStart = 125;
    448     m_iHoverLightnessFinal = 115;
    449     m_iHighlightLightnessStart = 110;
    450     m_iHighlightLightnessFinal = 100;
    451 #endif /* !VBOX_WS_MAC && !VBOX_WS_WIN */
    452389
    453390    /* Configure item options: */
     
    457394    setFlag(QGraphicsItem::ItemIsSelectable, false);
    458395
    459     /* Prepare hover animation for popup mode only: */
    460     if (model()->isPopup())
    461         prepareHoverAnimation();
    462396    /* Prepare connections: */
    463397    prepareConnections();
     
    466400    updatePixmap();
    467401    updateNameSize();
    468 }
    469 
    470 void UIToolsItem::prepareHoverAnimation()
    471 {
    472     /* Create hovering animation machine: */
    473     m_pHoveringMachine = new QStateMachine(this);
    474     if (m_pHoveringMachine)
    475     {
    476         /* Create 'default' state: */
    477         QState *pStateDefault = new QState(m_pHoveringMachine);
    478         /* Create 'hovered' state: */
    479         QState *pStateHovered = new QState(m_pHoveringMachine);
    480 
    481         /* Configure 'default' state: */
    482         if (pStateDefault)
    483         {
    484             /* When we entering default state => we assigning animatedValue to m_iDefaultValue: */
    485             pStateDefault->assignProperty(this, "animatedValue", m_iDefaultValue);
    486 
    487             /* Add state transitions: */
    488             QSignalTransition *pDefaultToHovered = pStateDefault->addTransition(this, SIGNAL(sigHoverEnter()), pStateHovered);
    489             if (pDefaultToHovered)
    490             {
    491                 /* Create forward animation: */
    492                 m_pHoveringAnimationForward = new QPropertyAnimation(this, "animatedValue", this);
    493                 if (m_pHoveringAnimationForward)
    494                 {
    495                     m_pHoveringAnimationForward->setDuration(m_iAnimationDuration);
    496                     m_pHoveringAnimationForward->setStartValue(m_iDefaultValue);
    497                     m_pHoveringAnimationForward->setEndValue(m_iHoveredValue);
    498 
    499                     /* Add to transition: */
    500                     pDefaultToHovered->addAnimation(m_pHoveringAnimationForward);
    501                 }
    502             }
    503         }
    504 
    505         /* Configure 'hovered' state: */
    506         if (pStateHovered)
    507         {
    508             /* When we entering hovered state => we assigning animatedValue to m_iHoveredValue: */
    509             pStateHovered->assignProperty(this, "animatedValue", m_iHoveredValue);
    510 
    511             /* Add state transitions: */
    512             QSignalTransition *pHoveredToDefault = pStateHovered->addTransition(this, SIGNAL(sigHoverLeave()), pStateDefault);
    513             if (pHoveredToDefault)
    514             {
    515                 /* Create backward animation: */
    516                 m_pHoveringAnimationBackward = new QPropertyAnimation(this, "animatedValue", this);
    517                 if (m_pHoveringAnimationBackward)
    518                 {
    519                     m_pHoveringAnimationBackward->setDuration(m_iAnimationDuration);
    520                     m_pHoveringAnimationBackward->setStartValue(m_iHoveredValue);
    521                     m_pHoveringAnimationBackward->setEndValue(m_iDefaultValue);
    522 
    523                     /* Add to transition: */
    524                     pHoveredToDefault->addAnimation(m_pHoveringAnimationBackward);
    525                 }
    526             }
    527         }
    528 
    529         /* Initial state is 'default': */
    530         m_pHoveringMachine->setInitialState(pStateDefault);
    531         /* Start state-machine: */
    532         m_pHoveringMachine->start();
    533     }
    534402}
    535403
     
    574442            fnt.setWeight(QFont::Bold);
    575443
    576             /* Make Machine & Management tool font smaller for widget mode: */
    577             if (   !model()->isPopup()
    578                 && (   itemClass() == UIToolClass_Machine
    579                     || itemClass() == UIToolClass_Management))
     444            /* Make Machine & Management tool font smaller: */
     445            if (   itemClass() == UIToolClass_Machine
     446                || itemClass() == UIToolClass_Management)
    580447                fnt.setPointSize(fnt.pointSize() - 1);
    581448
     
    592459void UIToolsItem::updatePixmap()
    593460{
    594     /* Smaller Machine & Management tool icons in widget mode: */
    595     const int iIconMetric =    !model()->isPopup()
    596                             && (   itemClass() == UIToolClass_Machine
    597                                 || itemClass() == UIToolClass_Management)
     461    /* Smaller Machine & Management tool icons: */
     462    const int iIconMetric =    itemClass() == UIToolClass_Machine
     463                            || itemClass() == UIToolClass_Management
    598464                          ? QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize)
    599465                          : QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * 1.5;
     
    638504    const QPalette pal = QApplication::palette();
    639505
    640     /* For popup: */
    641     if (model()->isPopup())
    642     {
    643         /* Selection background: */
    644         if (model()->currentItem(itemClass()) == this)
     506    /* Selection background: */
     507    if (model()->currentItem(itemClass()) == this)
     508    {
     509        /* Acquire background color: */
     510#ifdef VBOX_WS_MAC
     511        const QColor selectionColor = uiCommon().isInDarkMode()
     512                                    ? pal.color(QPalette::Active, QPalette::Button).lighter(150)
     513                                    : pal.color(QPalette::Active, QPalette::Button).darker(150);
     514#else
     515        const QColor selectionColor = uiCommon().isInDarkMode()
     516                                    ? pal.color(QPalette::Active, QPalette::Accent)
     517                                    : pal.color(QPalette::Active, QPalette::Accent);
     518#endif
     519        QColor selectionColor1 = selectionColor;
     520        QColor selectionColor2 = selectionColor;
     521        selectionColor1.setAlpha(100);
     522        selectionColor2.setAlpha(110);
     523
     524        /* Acquire token color: */
     525        const QColor highlightColor = isEnabled()
     526                                    ? pal.color(QPalette::Active, QPalette::Highlight)
     527                                    : pal.color(QPalette::Disabled, QPalette::Highlight);
     528        const QColor highlightColor1 = uiCommon().isInDarkMode()
     529                                     ? highlightColor.lighter(160)
     530                                     : highlightColor.darker(160);
     531        const QColor highlightColor2 = uiCommon().isInDarkMode()
     532                                     ? highlightColor.lighter(140)
     533                                     : highlightColor.darker(140);
     534
     535        /* Depending on item class: */
     536        switch (itemClass())
    645537        {
    646             /* Prepare color: */
    647             const QColor backgroundColor = isEnabled()
    648                                          ? pal.color(QPalette::Active, QPalette::Highlight)
    649                                          : pal.color(QPalette::Disabled, QPalette::Window);
    650             /* Draw gradient: */
    651             QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft());
    652             bgGrad.setColorAt(0, backgroundColor.lighter(m_iHighlightLightnessStart));
    653             bgGrad.setColorAt(1, backgroundColor.lighter(m_iHighlightLightnessFinal));
    654             pPainter->fillRect(rectangle, bgGrad);
    655 
    656             if (isEnabled() && isHovered())
     538            case UIToolClass_Global:
    657539            {
    658                 /* Prepare color: */
    659                 QColor animationColor1 = QColor(Qt::white);
    660                 QColor animationColor2 = QColor(Qt::white);
     540                /* Draw gradient background: */
     541                QLinearGradient bgGrad(rectangle.topLeft(), rectangle.topRight());
     542                bgGrad.setColorAt(0, selectionColor1);
     543                bgGrad.setColorAt(1, selectionColor2);
     544                pPainter->fillRect(rectangle, bgGrad);
     545
     546                /* Draw gradient token: */
     547                QRect tokenRect(rectangle.topLeft(), QSize(5, rectangle.height()));
     548                QLinearGradient tkGrad(tokenRect.topLeft(), tokenRect.bottomLeft());
     549                tkGrad.setColorAt(0, highlightColor1);
     550                tkGrad.setColorAt(1, highlightColor2);
     551                pPainter->fillRect(tokenRect, tkGrad);
     552                break;
     553            }
     554            case UIToolClass_Machine:
     555            case UIToolClass_Management:
     556            {
     557                /* Draw gradient background: */
     558                QRect backgroundRect(rectangle.topLeft() + QPoint(5, 0), QSize(rectangle.width() - 5, rectangle.height()));
     559                QLinearGradient bgGrad(backgroundRect.topLeft(), backgroundRect.topRight());
     560                bgGrad.setColorAt(0, selectionColor1);
     561                bgGrad.setColorAt(1, selectionColor2);
     562                pPainter->fillRect(backgroundRect, bgGrad);
     563
     564                /* Draw gradient token: */
     565                QRect tokenRect(rectangle.topRight() - QPoint(5, 0), QSize(5, rectangle.height()));
     566                QLinearGradient hlGrad(tokenRect.topLeft(), tokenRect.bottomLeft());
     567                hlGrad.setColorAt(0, highlightColor1);
     568                hlGrad.setColorAt(1, highlightColor2);
     569                pPainter->fillRect(tokenRect, hlGrad);
     570                break;
     571            }
     572            default:
     573                break;
     574        }
     575    }
     576
     577    /* Hovering background for widget: */
     578    else if (m_fHovered)
     579    {
     580        /* Prepare variables: */
     581        const int iMargin = data(ToolsItemData_Margin).toInt();
     582        const int iPadding = data(ToolsItemData_Padding).toInt();
     583
     584        /* Configure painter: */
     585        pPainter->setRenderHint(QPainter::Antialiasing, true);
     586        /* Acquire background color: */
    661587#ifdef VBOX_WS_MAC
    662                 animationColor1.setAlpha(90);
     588        const QColor backgroundColor = pal.color(QPalette::Active, QPalette::Window);
     589#else /* !VBOX_WS_MAC */
     590        const QColor windowColor = pal.color(QPalette::Active, QPalette::Window);
     591        const QColor accentColor = pal.color(QPalette::Active, QPalette::Accent);
     592        const int iRed = iShift30(windowColor.red(), accentColor.red());
     593        const int iGreen = iShift30(windowColor.green(), accentColor.green());
     594        const int iBlue = iShift30(windowColor.blue(), accentColor.blue());
     595        const QColor backgroundColor = QColor(qRgb(iRed, iGreen, iBlue));
     596#endif /* !VBOX_WS_MAC */
     597
     598        /* A bit of indentation for Machine & Management tools in widget mode: */
     599        const int iIndent = itemClass() == UIToolClass_Machine || itemClass() == UIToolClass_Management
     600                          ? QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * .5 : 0;
     601
     602        /* Prepare icon sub-rect: */
     603        QRect subRect;
     604        subRect.setHeight(m_pixmap.height() / m_pixmap.devicePixelRatio() + iPadding * 2);
     605        subRect.setWidth(subRect.height());
     606#ifdef VBOX_WS_MAC
     607        subRect.moveTopLeft(rectangle.topLeft() + QPoint(iIndent + 2 * iMargin - iPadding, iMargin - iPadding));
    663608#else
    664                 animationColor1.setAlpha(30);
     609        subRect.moveTopLeft(rectangle.topLeft() + QPoint(iIndent + 1.5 * iMargin - iPadding, iMargin - iPadding));
    665610#endif
    666                 animationColor2.setAlpha(0);
    667                 /* Draw hovering animated gradient: */
    668                 QRect animatedRect = rectangle;
    669                 animatedRect.setWidth(animatedRect.height());
    670                 const int iLength = 2 * animatedRect.width() + rectangle.width();
    671                 const int iShift = - animatedRect.width() + iLength * animatedValue() / 100;
    672                 animatedRect.moveLeft(iShift);
    673                 QLinearGradient bgAnimatedGrad(animatedRect.topLeft(), animatedRect.bottomRight());
    674                 bgAnimatedGrad.setColorAt(0,   animationColor2);
    675                 bgAnimatedGrad.setColorAt(0.1, animationColor2);
    676                 bgAnimatedGrad.setColorAt(0.5, animationColor1);
    677                 bgAnimatedGrad.setColorAt(0.9, animationColor2);
    678                 bgAnimatedGrad.setColorAt(1,   animationColor2);
    679                 pPainter->fillRect(rectangle, bgAnimatedGrad);
    680             }
    681         }
    682         /* Hovering background: */
    683         else if (isHovered())
    684         {
    685             /* Prepare color: */
    686             const QColor backgroundColor = isEnabled()
    687                                          ? pal.color(QPalette::Active, QPalette::Highlight)
    688                                          : pal.color(QPalette::Disabled, QPalette::Window);
    689             /* Draw gradient: */
    690             QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft());
    691             bgGrad.setColorAt(0, backgroundColor.lighter(m_iHoverLightnessStart));
    692             bgGrad.setColorAt(1, backgroundColor.lighter(m_iHoverLightnessFinal));
    693             pPainter->fillRect(rectangle, bgGrad);
    694 
    695             if (isEnabled())
    696             {
    697                 /* Prepare color: */
    698                 QColor animationColor1 = QColor(Qt::white);
    699                 QColor animationColor2 = QColor(Qt::white);
     611
     612        /* Paint icon frame: */
     613        QPainterPath painterPath;
     614        painterPath.addRoundedRect(subRect, iPadding, iPadding);
    700615#ifdef VBOX_WS_MAC
    701                 animationColor1.setAlpha(120);
    702 #else
    703                 animationColor1.setAlpha(50);
    704 #endif
    705                 animationColor2.setAlpha(0);
    706                 /* Draw hovering animated gradient: */
    707                 QRect animatedRect = rectangle;
    708                 animatedRect.setWidth(animatedRect.height());
    709                 const int iLength = 2 * animatedRect.width() + rectangle.width();
    710                 const int iShift = - animatedRect.width() + iLength * animatedValue() / 100;
    711                 animatedRect.moveLeft(iShift);
    712                 QLinearGradient bgAnimatedGrad(animatedRect.topLeft(), animatedRect.bottomRight());
    713                 bgAnimatedGrad.setColorAt(0,   animationColor2);
    714                 bgAnimatedGrad.setColorAt(0.1, animationColor2);
    715                 bgAnimatedGrad.setColorAt(0.5, animationColor1);
    716                 bgAnimatedGrad.setColorAt(0.9, animationColor2);
    717                 bgAnimatedGrad.setColorAt(1,   animationColor2);
    718                 pPainter->fillRect(rectangle, bgAnimatedGrad);
    719             }
    720         }
    721         /* Default background: */
    722         else
    723         {
    724             /* Prepare color: */
    725             const QColor backgroundColor = isEnabled()
    726                                          ? pal.color(QPalette::Active, QPalette::Window)
    727                                          : pal.color(QPalette::Disabled, QPalette::Window);
    728             /* Draw gradient: */
    729             QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft());
    730             bgGrad.setColorAt(0, backgroundColor.lighter(m_iDefaultLightnessStart));
    731             bgGrad.setColorAt(1, backgroundColor.lighter(m_iDefaultLightnessFinal));
    732             pPainter->fillRect(rectangle, bgGrad);
    733         }
    734     }
    735     /* For widget: */
    736     else
    737     {
    738         /* Selection background: */
    739         if (model()->currentItem(itemClass()) == this)
    740         {
    741             /* Acquire background color: */
     616        const QColor backgroundColor1 = uiCommon().isInDarkMode()
     617                                      ? backgroundColor.lighter(220)
     618                                      : backgroundColor.darker(140);
     619#else /* !VBOX_WS_MAC */
     620        const QColor backgroundColor1 = uiCommon().isInDarkMode()
     621                                      ? backgroundColor.lighter(140)
     622                                      : backgroundColor.darker(120);
     623#endif /* !VBOX_WS_MAC */
     624        pPainter->setPen(QPen(backgroundColor1, 2, Qt::SolidLine, Qt::RoundCap));
     625        pPainter->drawPath(QPainterPathStroker().createStroke(painterPath));
     626
     627        /* Fill icon body: */
     628        pPainter->setClipPath(painterPath);
    742629#ifdef VBOX_WS_MAC
    743             const QColor selectionColor = uiCommon().isInDarkMode()
    744                                         ? pal.color(QPalette::Active, QPalette::Button).lighter(150)
    745                                         : pal.color(QPalette::Active, QPalette::Button).darker(150);
    746 #else
    747             const QColor selectionColor = uiCommon().isInDarkMode()
    748                                         ? pal.color(QPalette::Active, QPalette::Accent)
    749                                         : pal.color(QPalette::Active, QPalette::Accent);
    750 #endif
    751             QColor selectionColor1 = selectionColor;
    752             QColor selectionColor2 = selectionColor;
    753             selectionColor1.setAlpha(100);
    754             selectionColor2.setAlpha(110);
    755 
    756             /* Acquire token color: */
    757             const QColor highlightColor = isEnabled()
    758                                         ? pal.color(QPalette::Active, QPalette::Highlight)
    759                                         : pal.color(QPalette::Disabled, QPalette::Highlight);
    760             const QColor highlightColor1 = uiCommon().isInDarkMode()
    761                                          ? highlightColor.lighter(160)
    762                                          : highlightColor.darker(160);
    763             const QColor highlightColor2 = uiCommon().isInDarkMode()
    764                                          ? highlightColor.lighter(140)
    765                                          : highlightColor.darker(140);
    766 
    767             /* Depending on item class: */
    768             switch (itemClass())
    769             {
    770                 case UIToolClass_Global:
    771                 {
    772                     /* Draw gradient background: */
    773                     QLinearGradient bgGrad(rectangle.topLeft(), rectangle.topRight());
    774                     bgGrad.setColorAt(0, selectionColor1);
    775                     bgGrad.setColorAt(1, selectionColor2);
    776                     pPainter->fillRect(rectangle, bgGrad);
    777 
    778                     /* Draw gradient token: */
    779                     QRect tokenRect(rectangle.topLeft(), QSize(5, rectangle.height()));
    780                     QLinearGradient tkGrad(tokenRect.topLeft(), tokenRect.bottomLeft());
    781                     tkGrad.setColorAt(0, highlightColor1);
    782                     tkGrad.setColorAt(1, highlightColor2);
    783                     pPainter->fillRect(tokenRect, tkGrad);
    784                     break;
    785                 }
    786                 case UIToolClass_Machine:
    787                 case UIToolClass_Management:
    788                 {
    789                     /* Draw gradient background: */
    790                     QRect backgroundRect(rectangle.topLeft() + QPoint(5, 0), QSize(rectangle.width() - 5, rectangle.height()));
    791                     QLinearGradient bgGrad(backgroundRect.topLeft(), backgroundRect.topRight());
    792                     bgGrad.setColorAt(0, selectionColor1);
    793                     bgGrad.setColorAt(1, selectionColor2);
    794                     pPainter->fillRect(backgroundRect, bgGrad);
    795 
    796                     /* Draw gradient token: */
    797                     QRect tokenRect(rectangle.topRight() - QPoint(5, 0), QSize(5, rectangle.height()));
    798                     QLinearGradient hlGrad(tokenRect.topLeft(), tokenRect.bottomLeft());
    799                     hlGrad.setColorAt(0, highlightColor1);
    800                     hlGrad.setColorAt(1, highlightColor2);
    801                     pPainter->fillRect(tokenRect, hlGrad);
    802                     break;
    803                 }
    804                 default:
    805                     break;
    806             }
    807         }
    808 
    809         /* Hovering background for widget: */
    810         else if (isHovered())
    811         {
    812             /* Prepare variables: */
    813             const int iMargin = data(ToolsItemData_Margin).toInt();
    814             const int iPadding = data(ToolsItemData_Padding).toInt();
    815 
    816             /* Configure painter: */
    817             pPainter->setRenderHint(QPainter::Antialiasing, true);
    818             /* Acquire background color: */
    819 #ifdef VBOX_WS_MAC
    820             const QColor backgroundColor = pal.color(QPalette::Active, QPalette::Window);
     630        const QColor backgroundColor2 = uiCommon().isInDarkMode()
     631                                      ? backgroundColor.lighter(160)
     632                                      : backgroundColor.darker(120);
    821633#else /* !VBOX_WS_MAC */
    822             const QColor windowColor = pal.color(QPalette::Active, QPalette::Window);
    823             const QColor accentColor = pal.color(QPalette::Active, QPalette::Accent);
    824             const int iRed = iShift30(windowColor.red(), accentColor.red());
    825             const int iGreen = iShift30(windowColor.green(), accentColor.green());
    826             const int iBlue = iShift30(windowColor.blue(), accentColor.blue());
    827             const QColor backgroundColor = QColor(qRgb(iRed, iGreen, iBlue));
     634        const QColor backgroundColor2 = uiCommon().isInDarkMode()
     635                                      ? backgroundColor.lighter(105)
     636                                      : backgroundColor.darker(105);
    828637#endif /* !VBOX_WS_MAC */
    829 
    830             /* A bit of indentation for Machine & Management tools in widget mode: */
    831             const int iIndent = itemClass() == UIToolClass_Machine || itemClass() == UIToolClass_Management
    832                               ? QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * .5 : 0;
    833 
    834             /* Prepare icon sub-rect: */
    835             QRect subRect;
    836             subRect.setHeight(m_pixmap.height() / m_pixmap.devicePixelRatio() + iPadding * 2);
    837             subRect.setWidth(subRect.height());
    838 #ifdef VBOX_WS_MAC
    839             subRect.moveTopLeft(rectangle.topLeft() + QPoint(iIndent + 2 * iMargin - iPadding, iMargin - iPadding));
    840 #else
    841             subRect.moveTopLeft(rectangle.topLeft() + QPoint(iIndent + 1.5 * iMargin - iPadding, iMargin - iPadding));
    842 #endif
    843 
    844             /* Paint icon frame: */
    845             QPainterPath painterPath;
    846             painterPath.addRoundedRect(subRect, iPadding, iPadding);
    847 #ifdef VBOX_WS_MAC
    848             const QColor backgroundColor1 = uiCommon().isInDarkMode()
    849                                           ? backgroundColor.lighter(220)
    850                                           : backgroundColor.darker(140);
    851 #else /* !VBOX_WS_MAC */
    852             const QColor backgroundColor1 = uiCommon().isInDarkMode()
    853                                           ? backgroundColor.lighter(140)
    854                                           : backgroundColor.darker(120);
    855 #endif /* !VBOX_WS_MAC */
    856             pPainter->setPen(QPen(backgroundColor1, 2, Qt::SolidLine, Qt::RoundCap));
    857             pPainter->drawPath(QPainterPathStroker().createStroke(painterPath));
    858 
    859             /* Fill icon body: */
    860             pPainter->setClipPath(painterPath);
    861 #ifdef VBOX_WS_MAC
    862             const QColor backgroundColor2 = uiCommon().isInDarkMode()
    863                                           ? backgroundColor.lighter(160)
    864                                           : backgroundColor.darker(120);
    865 #else /* !VBOX_WS_MAC */
    866             const QColor backgroundColor2 = uiCommon().isInDarkMode()
    867                                           ? backgroundColor.lighter(105)
    868                                           : backgroundColor.darker(105);
    869 #endif /* !VBOX_WS_MAC */
    870             pPainter->fillRect(subRect, backgroundColor2);
    871         }
    872     }
    873 
    874     /* Restore painter: */
    875     pPainter->restore();
    876 }
    877 
    878 void UIToolsItem::paintFrame(QPainter *pPainter, const QRect &rectangle) const
    879 {
    880     /* Don't paint frame for disabled items: */
    881     if (!isEnabled())
    882         return;
    883 
    884     /* Save painter: */
    885     pPainter->save();
    886 
    887     /* Prepare colors: */
    888     const QPalette pal = QApplication::palette();
    889     QColor strokeColor;
    890 
    891     /* Selection frame: */
    892     if (model()->currentItem(itemClass()) == this)
    893         strokeColor = pal.color(QPalette::Active, QPalette::Highlight).lighter(m_iHighlightLightnessStart - 40);
    894     /* Hovering frame: */
    895     else if (isHovered())
    896         strokeColor = pal.color(QPalette::Active, QPalette::Highlight).lighter(m_iHoverLightnessStart - 40);
    897     /* Default frame: */
    898     else
    899         strokeColor = pal.color(QPalette::Active, QPalette::Window).lighter(m_iDefaultLightnessStart);
    900 
    901     /* Create/assign pen: */
    902     QPen pen(strokeColor);
    903     pen.setWidth(0);
    904     pPainter->setPen(pen);
    905 
    906     /* Draw borders: */
    907     pPainter->drawLine(rectangle.topLeft(),    rectangle.topRight());
    908     pPainter->drawLine(rectangle.bottomLeft(), rectangle.bottomRight());
    909     pPainter->drawLine(rectangle.topLeft(),    rectangle.bottomLeft());
    910     pPainter->drawLine(rectangle.topRight(),   rectangle.bottomRight());
     638        pPainter->fillRect(subRect, backgroundColor2);
     639    }
    911640
    912641    /* Restore painter: */
     
    922651    const QPalette pal = QApplication::palette();
    923652
    924     /* Selected or hovered item foreground for popup mode: */
    925     if (   model()->isPopup()
    926         && (model()->currentItem(itemClass()) == this || isHovered()))
    927     {
    928         /* Get background color: */
    929         const QColor highlight = pal.color(QPalette::Active, QPalette::Highlight);
    930         const QColor background = model()->currentItem(itemClass()) == this
    931                                 ? highlight.lighter(m_iHighlightLightnessStart)
    932                                 : highlight.lighter(m_iHoverLightnessStart);
    933 
    934         /* Gather foreground color for background one: */
    935         const QColor foreground = suitableForegroundColor(pal, background);
    936         pPainter->setPen(foreground);
    937     }
    938653    /* Default item foreground: */
    939     else
    940     {
    941         const QColor foreground = isEnabled()
    942                                 ? pal.color(QPalette::Active, QPalette::Text)
    943                                 : pal.color(QPalette::Disabled, QPalette::Text);
    944         pPainter->setPen(foreground);
    945     }
     654    const QColor foreground = isEnabled()
     655                            ? pal.color(QPalette::Active, QPalette::Text)
     656                            : pal.color(QPalette::Disabled, QPalette::Text);
     657    pPainter->setPen(foreground);
    946658
    947659    /* Paint left column: */
     
    949661        /* Prepare variables: */
    950662#ifdef VBOX_WS_MAC
    951         int iPixmapX = model()->isPopup() ? iMargin : 2 * iMargin;
     663        int iPixmapX = 2 * iMargin;
    952664#else
    953         int iPixmapX = model()->isPopup() ? iMargin : 1.5 * iMargin;
     665        int iPixmapX = 1.5 * iMargin;
    954666#endif
    955667
    956         /* A bit of indentation for Machine & Management tools in widget mode: */
    957         if (   !model()->isPopup()
    958             && (   itemClass() == UIToolClass_Machine
    959                 || itemClass() == UIToolClass_Management))
     668        /* A bit of indentation for Machine & Management tools: */
     669        if (   itemClass() == UIToolClass_Machine
     670            || itemClass() == UIToolClass_Management)
    960671            iPixmapX += QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * .5;
    961672
     
    975686        /* Prepare variables: */
    976687#ifdef VBOX_WS_MAC
    977         int iNameX = model()->isPopup() ? iMargin + m_pixmapSize.width() + iSpacing
    978                                         : 2 * iMargin + m_pixmapSize.width() + 2 * iSpacing;
     688        int iNameX = 2 * iMargin + m_pixmapSize.width() + 2 * iSpacing;
    979689#else
    980         int iNameX = model()->isPopup() ? iMargin + m_pixmapSize.width() + iSpacing
    981                                         : 1.5 * iMargin + m_pixmapSize.width() + 2 * iSpacing;
     690        int iNameX = 1.5 * iMargin + m_pixmapSize.width() + 2 * iSpacing;
    982691#endif
    983692
    984         /* A bit of indentation for Machine & Management tools in widget mode: */
    985         if (   !model()->isPopup()
    986             && (   itemClass() == UIToolClass_Machine
    987                 || itemClass() == UIToolClass_Management))
     693        /* A bit of indentation for Machine & Management tools: */
     694        if (   itemClass() == UIToolClass_Machine
     695            || itemClass() == UIToolClass_Management)
    988696            iNameX += QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * .5;
    989697
    990698        const int iNameY = (iFullHeight - m_nameSize.height()) / 2;
    991         /* Paint name (always for popup mode, if requested otherwise): */
    992         if (   model()->isPopup()
    993             || model()->showItemNames())
     699        /* Paint name if requested: */
     700        if (model()->showItemNames())
    994701            paintText(/* Painter: */
    995702                      pPainter,
     
    1001708                      model()->paintDevice(),
    1002709                      /* Text to paint: */
    1003                       m_strName,
    1004                       /* Text for popup mode? */
    1005                       model()->isPopup());
     710                      m_strName);
    1006711    }
    1007712}
     
    1018723void UIToolsItem::paintText(QPainter *pPainter, QPoint point,
    1019724                            const QFont &font, QPaintDevice *pPaintDevice,
    1020                             const QString &strText,
    1021                             bool fPopup)
     725                            const QString &strText)
    1022726{
    1023727    /* Save painter: */
     
    1032736
    1033737    /* Draw text: */
    1034     if (fPopup)
    1035         pPainter->drawText(point, strText);
    1036     else
    1037     {
    1038         QPainterPath textPath;
    1039         textPath.addText(0, 0, font, strText);
    1040         textPath.translate(point);
    1041         pPainter->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
    1042         pPainter->setPen(QPen(uiCommon().isInDarkMode() ? Qt::black : Qt::white, 2, Qt::SolidLine, Qt::RoundCap));
    1043         pPainter->drawPath(QPainterPathStroker().createStroke(textPath));
    1044         pPainter->setBrush(uiCommon().isInDarkMode() ? Qt::white: Qt::black);
    1045         pPainter->setPen(Qt::NoPen);
    1046         pPainter->drawPath(textPath);
    1047     }
     738    QPainterPath textPath;
     739    textPath.addText(0, 0, font, strText);
     740    textPath.translate(point);
     741    pPainter->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
     742    pPainter->setPen(QPen(uiCommon().isInDarkMode() ? Qt::black : Qt::white, 2, Qt::SolidLine, Qt::RoundCap));
     743    pPainter->drawPath(QPainterPathStroker().createStroke(textPath));
     744    pPainter->setBrush(uiCommon().isInDarkMode() ? Qt::white: Qt::black);
     745    pPainter->setPen(Qt::NoPen);
     746    pPainter->drawPath(textPath);
    1048747
    1049748    /* Restore painter: */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsItem.h

    r108619 r108690  
    55
    66/*
    7  * Copyright (C) 2012-2024 Oracle and/or its affiliates.
     7 * Copyright (C) 2012-2025 Oracle and/or its affiliates.
    88 *
    99 * This file is part of VirtualBox base platform packages, as
     
    3434/* Qt includes: */
    3535#include <QIcon>
    36 #include <QMimeData>
    3736#include <QPixmap>
    38 #include <QRectF>
    3937#include <QString>
    4038
     
    4442
    4543/* Forward declaration: */
    46 class QPropertyAnimation;
    4744class QGraphicsScene;
    48 class QGraphicsSceneDragDropEvent;
    4945class QGraphicsSceneHoverEvent;
    50 class QGraphicsSceneMouseEvent;
    51 class QStateMachine;
    52 class UIActionPool;
    53 class UIToolsItemGroup;
    54 class UIToolsItemGlobal;
    55 class UIToolsItemMachine;
    5646class UIToolsModel;
    5747
     
    6151{
    6252    Q_OBJECT;
    63     Q_PROPERTY(int animatedValue READ animatedValue WRITE setAnimatedValue);
    6453
    6554signals:
    66 
    67     /** @name Item stuff.
    68       * @{ */
    69         /** Notifies listeners about hover enter. */
    70         void sigHoverEnter();
    71         /** Notifies listeners about hover leave. */
    72         void sigHoverLeave();
    73     /** @} */
    7455
    7556    /** @name Layout stuff.
     
    122103        /** Defines whether item is @a fHidden by the @a enmReason. */
    123104        void setHiddenByReason(bool fHidden, HidingReason enmReason);
    124 
    125         /** Returns whether item is hovered. */
    126         bool isHovered() const { return m_fHovered; }
    127         /** Defines whether item is @a fHovered. */
    128         void setHovered(bool fHovered);
    129105    /** @} */
    130106
     
    184160        /** Prepares all. */
    185161        void prepare();
    186         /** Prepares hover animation. */
    187         void prepareHoverAnimation();
    188162        /** Prepares connections. */
    189163        void prepareConnections();
     
    197171        /** Returns abstractly stored data value for certain @a iKey. */
    198172        QVariant data(int iKey) const;
    199 
    200         /** Defines item's default animation @a iValue. */
    201         void setDefaultValue(int iValue) { m_iDefaultValue = iValue; update(); }
    202         /** Returns item's default animation value. */
    203         int defaultValue() const { return m_iDefaultValue; }
    204 
    205         /** Defines item's hovered animation @a iValue. */
    206         void setHoveredValue(int iValue) { m_iHoveredValue = iValue; update(); }
    207         /** Returns item's hovered animation value. */
    208         int hoveredValue() const { return m_iHoveredValue; }
    209 
    210         /** Defines item's animated @a iValue. */
    211         void setAnimatedValue(int iValue) { m_iAnimatedValue = iValue; update(); }
    212         /** Returns item's animated value. */
    213         int animatedValue() const { return m_iAnimatedValue; }
    214173    /** @} */
    215174
     
    227186          * @param  rectangle  Brings the rectangle to fill with background. */
    228187        void paintBackground(QPainter *pPainter, const QRect &rectangle) const;
    229         /** Paints frame using using passed @a pPainter.
    230           * @param  rectangle  Brings the rectangle to stroke with frame. */
    231         void paintFrame(QPainter *pPainter, const QRect &rectangle) const;
    232188        /** Paints tool info using using passed @a pPainter.
    233189          * @param  rectangle  Brings the rectangle to limit painting with. */
     
    241197          * @param  point         Brings upper-left corner pixmap should be mapped to.
    242198          * @param  font          Brings the text font.
    243           * @param  pPaintDevice  Brings the paint-device reference to initilize painting from.
    244           * @param  fPopup        Brings whether it's a text for popup mode, widget mode otherwise. */
     199          * @param  pPaintDevice  Brings the paint-device reference to initilize painting from. */
    245200        static void paintText(QPainter *pPainter, QPoint point,
    246201                              const QFont &font, QPaintDevice *pPaintDevice,
    247                               const QString &strText,
    248                               bool fPopup);
     202                              const QString &strText);
    249203
    250204#ifndef VBOX_WS_MAC
     
    274228
    275229        /** Holds whether item is hovered. */
    276         bool                m_fHovered;
    277         /** Holds the hovering animation machine instance. */
    278         QStateMachine      *m_pHoveringMachine;
    279         /** Holds the forward hovering animation instance. */
    280         QPropertyAnimation *m_pHoveringAnimationForward;
    281         /** Holds the backward hovering animation instance. */
    282         QPropertyAnimation *m_pHoveringAnimationBackward;
    283         /** Holds the animation duration. */
    284         int                 m_iAnimationDuration;
    285         /** Holds the default animation value. */
    286         int                 m_iDefaultValue;
    287         /** Holds the hovered animation value. */
    288         int                 m_iHoveredValue;
    289         /** Holds the animated value. */
    290         int                 m_iAnimatedValue;
    291 
    292         /** Holds start default lightness tone. */
    293         int  m_iDefaultLightnessStart;
    294         /** Holds final default lightness tone. */
    295         int  m_iDefaultLightnessFinal;
    296         /** Holds start hover lightness tone. */
    297         int  m_iHoverLightnessStart;
    298         /** Holds final hover lightness tone. */
    299         int  m_iHoverLightnessFinal;
    300         /** Holds start highlight lightness tone. */
    301         int  m_iHighlightLightnessStart;
    302         /** Holds final highlight lightness tone. */
    303         int  m_iHighlightLightnessFinal;
     230        bool  m_fHovered;
    304231    /** @} */
    305232
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsModel.cpp

    r108619 r108690  
    363363*********************************************************************************************************************************/
    364364
    365 UIToolsModel::UIToolsModel(QObject *pParent, UIActionPool *pActionPool, UIToolClass enmClass, bool fPopup)
     365UIToolsModel::UIToolsModel(QObject *pParent, UIActionPool *pActionPool, UIToolClass enmClass)
    366366    : QObject(pParent)
    367367    , m_pActionPool(pActionPool)
    368368    , m_enmClass(enmClass)
    369     , m_fPopup(fPopup)
    370369    , m_pView(0)
    371370    , m_pScene(0)
     
    513512    }
    514513    return QVariant();
    515 }
    516 
    517 void UIToolsModel::close()
    518 {
    519     emit sigClose();
    520514}
    521515
     
    846840                            {
    847841                                setCurrentItem(pClickedItem);
    848                                 /* Close the widget in popup mode only: */
    849                                 if (isPopup())
    850                                     close();
    851842                                return true;
    852843                            }
     
    10241015void UIToolsModel::prepareAnimationEngine()
    10251016{
    1026     if (!isPopup() && m_enmClass == UIToolClass_Invalid)
     1017    if (m_enmClass == UIToolClass_Invalid)
    10271018        m_pAnimationEngine = new UIToolsAnimationEngine(this);
    10281019}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsModel.h

    r108619 r108690  
    5858signals:
    5959
    60     /** @name General stuff.
    61       * @{ */
    62         /** Notifies about closing request. */
    63         void sigClose();
    64     /** @} */
    65 
    6660    /** @name Selection stuff.
    6761      * @{ */
     
    9185    /** Constructs Tools-model passing @a pParent to the base-class.
    9286      * @param  pActionPool  Brings the action-pool reference.
    93       * @param  enmClass     Brings the tools class, it will be const one.
    94       * @param  fPopup       Brings whether tools represented as popup. */
    95     UIToolsModel(QObject *pParent, UIActionPool *pActionPool, UIToolClass enmClass, bool fPopup);
     87      * @param  enmClass     Brings the tools class, it will be const one. */
     88    UIToolsModel(QObject *pParent, UIActionPool *pActionPool, UIToolClass enmClass);
    9689    /** Destructs Tools-model. */
    9790    virtual ~UIToolsModel() RT_OVERRIDE;
     
    10497        /** Returns the action-pool reference. */
    10598        UIActionPool *actionPool() const { return m_pActionPool; }
    106         /** Returns whether tools represented as popup. */
    107         bool isPopup() const { return m_fPopup; }
    10899
    109100        /** Returns the scene reference. */
     
    140131        /** Returns abstractly stored data value for certain @a iKey. */
    141132        QVariant data(int iKey) const;
    142 
    143         /** Asks parent to close. */
    144         void close();
    145133    /** @} */
    146134
     
    256244        const UIToolClass  m_enmClass;
    257245
    258         /** Holds whether tools represented as popup. */
    259         const bool  m_fPopup;
    260 
    261246        /** Holds the view reference. */
    262247        UIToolsView    *m_pView;
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsView.cpp

    r108223 r108690  
    55
    66/*
    7  * Copyright (C) 2012-2024 Oracle and/or its affiliates.
     7 * Copyright (C) 2012-2025 Oracle and/or its affiliates.
    88 *
    99 * This file is part of VirtualBox base platform packages, as
     
    115115
    116116
    117 UIToolsView::UIToolsView(QWidget *pParent, UIToolsModel *pModel, bool fPopup)
     117UIToolsView::UIToolsView(QWidget *pParent, UIToolsModel *pModel)
    118118    : QIGraphicsView(pParent)
    119119    , m_pModel(pModel)
    120     , m_fPopup(fPopup)
    121120    , m_iMinimumWidthHint(0)
    122121    , m_iMinimumHeightHint(0)
     
    199198    model()->setView(this);
    200199
    201     /* No minimum size-hint for widget mode: */
    202     if (!isPopup())
    203         setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
     200    /* No minimum size-hint: */
     201    setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    204202
    205203    /* Setup frame: */
     
    223221    QColor backgroundColorActive = pal.color(QPalette::Active, QPalette::Window);
    224222    QColor backgroundColorInactive = pal.color(QPalette::Inactive, QPalette::Window);
    225     if (!isPopup())
    226     {
    227         backgroundColorActive = uiCommon().isInDarkMode()
    228                               ? backgroundColorActive.lighter(120)
    229                               : backgroundColorActive.darker(108);
    230         backgroundColorInactive = uiCommon().isInDarkMode()
    231                                 ? backgroundColorInactive.lighter(120)
    232                                 : backgroundColorInactive.darker(108);
    233     }
     223    backgroundColorActive = uiCommon().isInDarkMode()
     224                          ? backgroundColorActive.lighter(120)
     225                          : backgroundColorActive.darker(108);
     226    backgroundColorInactive = uiCommon().isInDarkMode()
     227                            ? backgroundColorInactive.lighter(120)
     228                            : backgroundColorInactive.darker(108);
    234229    pal.setColor(QPalette::Active, QPalette::Base, backgroundColorActive);
    235230    pal.setColor(QPalette::Inactive, QPalette::Base, backgroundColorInactive);
     
    237232#else /* !VBOX_WS_MAC */
    238233
    239     if (isPopup())
    240     {
    241         /* Same as on macOS for now, will go away soon: */
    242         QColor backgroundColorActive = pal.color(QPalette::Active, QPalette::Window);
    243         QColor backgroundColorInactive = pal.color(QPalette::Inactive, QPalette::Window);
    244         if (!isPopup())
    245         {
    246             backgroundColorActive = uiCommon().isInDarkMode()
    247                                   ? backgroundColorActive.lighter(120)
    248                                   : backgroundColorActive.darker(108);
    249             backgroundColorInactive = uiCommon().isInDarkMode()
    250                                     ? backgroundColorInactive.lighter(120)
    251                                     : backgroundColorInactive.darker(108);
    252         }
    253         pal.setColor(QPalette::Active, QPalette::Base, backgroundColorActive);
    254         pal.setColor(QPalette::Inactive, QPalette::Base, backgroundColorInactive);
    255     }
    256     else
    257     {
    258         /* Blending Window color to 10% of Accent color: */
    259         const QColor backgroundColor = pal.color(QPalette::Active, QPalette::Window);
    260         const QColor accentColor = pal.color(QPalette::Active, QPalette::Accent);
    261         const int iRed = iShift10(backgroundColor.red(), accentColor.red());
    262         const int iGreen = iShift10(backgroundColor.green(), accentColor.green());
    263         const int iBlue = iShift10(backgroundColor.blue(), accentColor.blue());
    264         const QColor blendColor = QColor(qRgb(iRed, iGreen, iBlue));
    265         pal.setColor(QPalette::Active, QPalette::Base, blendColor);
    266         pal.setColor(QPalette::Inactive, QPalette::Base, blendColor);
    267     }
     234    /* Blending Window color to 10% of Accent color: */
     235    const QColor backgroundColor = pal.color(QPalette::Active, QPalette::Window);
     236    const QColor accentColor = pal.color(QPalette::Active, QPalette::Accent);
     237    const int iRed = iShift10(backgroundColor.red(), accentColor.red());
     238    const int iGreen = iShift10(backgroundColor.green(), accentColor.green());
     239    const int iBlue = iShift10(backgroundColor.blue(), accentColor.blue());
     240    const QColor blendColor = QColor(qRgb(iRed, iGreen, iBlue));
     241    pal.setColor(QPalette::Active, QPalette::Base, blendColor);
     242    pal.setColor(QPalette::Inactive, QPalette::Base, blendColor);
    268243
    269244#endif /* !VBOX_WS_MAC */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsView.h

    r108223 r108690  
    55
    66/*
    7  * Copyright (C) 2012-2024 Oracle and/or its affiliates.
     7 * Copyright (C) 2012-2025 Oracle and/or its affiliates.
    88 *
    99 * This file is part of VirtualBox base platform packages, as
     
    4646
    4747    /** Constructs a Tools-view passing @a pParent to the base-class.
    48       * @param  pModel  Brings the tools model reference.
    49       * @param  fPopup  Brings whether tools represented as popup. */
    50     UIToolsView(QWidget *pParent, UIToolsModel *pModel, bool fPopup);
     48      * @param  pModel  Brings the tools model reference. */
     49    UIToolsView(QWidget *pParent, UIToolsModel *pModel);
    5150    /** Destructs a Tools-view. */
    5251    virtual ~UIToolsView();
     
    103102    /** @name General stuff.
    104103      * @{ */
    105         /** Returns whether tools represented as popup. */
    106         bool isPopup() const { return m_fPopup; }
    107 
    108104        /** Updates scene rectangle. */
    109105        void updateSceneRect();
     
    119115        /** Holds the tools model reference. */
    120116        UIToolsModel *m_pModel;
    121 
    122         /** Holds whether tools represented as popup. */
    123         const bool  m_fPopup;
    124117    /** @} */
    125118
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