VirtualBox

Changeset 108106 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Feb 6, 2025 5:20:30 PM (3 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167404
Message:

FE/Qt: bugref:10814: VBox Manager / Tools pane: Adjusting widget mode colors for item frame and extra button on non-macOS hosts.

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

    r108102 r108106  
    748748            pPainter->setRenderHint(QPainter::Antialiasing, true);
    749749            /* Acquire background color: */
    750             const QColor backgroundColor = pal.color(QPalette::Window);
     750#ifdef VBOX_WS_MAC
     751            const QColor backgroundColor = pal.color(QPalette::Active, QPalette::Window);
     752#else /* !VBOX_WS_MAC */
     753            const QColor windowColor = pal.color(QPalette::Active, QPalette::Window);
     754            const QColor accentColor = pal.color(QPalette::Active, QPalette::Accent);
     755            const int iRed = iShift30(windowColor.red(), accentColor.red());
     756            const int iGreen = iShift30(windowColor.green(), accentColor.green());
     757            const int iBlue = iShift30(windowColor.blue(), accentColor.blue());
     758            const QColor backgroundColor = QColor(qRgb(iRed, iGreen, iBlue));
     759#endif /* !VBOX_WS_MAC */
    751760
    752761            /* Prepare icon sub-rect: */
     
    759768            QPainterPath painterPath;
    760769            painterPath.addRoundedRect(subRect, iPadding, iPadding);
     770#ifdef VBOX_WS_MAC
    761771            const QColor backgroundColor1 = uiCommon().isInDarkMode()
    762772                                          ? backgroundColor.lighter(220)
    763773                                          : backgroundColor.darker(140);
     774#else /* !VBOX_WS_MAC */
     775            const QColor backgroundColor1 = uiCommon().isInDarkMode()
     776                                          ? backgroundColor.lighter(140)
     777                                          : backgroundColor.darker(120);
     778#endif /* !VBOX_WS_MAC */
    764779            pPainter->setPen(QPen(backgroundColor1, 2, Qt::SolidLine, Qt::RoundCap));
    765780            pPainter->drawPath(QPainterPathStroker().createStroke(painterPath));
     
    767782            /* Fill icon body: */
    768783            pPainter->setClipPath(painterPath);
     784#ifdef VBOX_WS_MAC
    769785            const QColor backgroundColor2 = uiCommon().isInDarkMode()
    770786                                          ? backgroundColor.lighter(160)
    771787                                          : backgroundColor.darker(120);
     788#else /* !VBOX_WS_MAC */
     789            const QColor backgroundColor2 = uiCommon().isInDarkMode()
     790                                          ? backgroundColor.lighter(105)
     791                                          : backgroundColor.darker(105);
     792#endif /* !VBOX_WS_MAC */
    772793            pPainter->fillRect(subRect, backgroundColor2);
    773794        }
     
    896917    /* Acquire background color: */
    897918    const QPalette pal = QApplication::palette();
    898     QColor backgroundColor = pal.color(QPalette::Window);
     919#ifdef VBOX_WS_MAC
     920    const QColor backgroundColor = pal.color(QPalette::Active, QPalette::Window);
     921#else /* !VBOX_WS_MAC */
     922    const QColor windowColor = pal.color(QPalette::Active, QPalette::Window);
     923    const QColor accentColor = pal.color(QPalette::Active, QPalette::Accent);
     924    const int iRed = iShift30(windowColor.red(), accentColor.red());
     925    const int iGreen = iShift30(windowColor.green(), accentColor.green());
     926    const int iBlue = iShift30(windowColor.blue(), accentColor.blue());
     927    const QColor backgroundColor = QColor(qRgb(iRed, iGreen, iBlue));
     928#endif /* !VBOX_WS_MAC */
    899929
    900930    /* Prepare button sub-rect: */
     
    907937    QPainterPath painterPath;
    908938    painterPath.addRoundedRect(m_extraButtonRect, iPadding, iPadding);
    909     QColor backgroundColor1 = uiCommon().isInDarkMode()
    910                             ? backgroundColor.lighter(220)
    911                             : backgroundColor.darker(140);
     939#ifdef VBOX_WS_MAC
     940    const QColor backgroundColor1 = uiCommon().isInDarkMode()
     941                                  ? backgroundColor.lighter(220)
     942                                  : backgroundColor.darker(140);
     943#else /* !VBOX_WS_MAC */
     944    const QColor backgroundColor1 = uiCommon().isInDarkMode()
     945                                  ? backgroundColor.lighter(140)
     946                                  : backgroundColor.darker(120);
     947#endif /* !VBOX_WS_MAC */
    912948    pPainter->setPen(QPen(backgroundColor1, 2, Qt::SolidLine, Qt::RoundCap));
    913949    pPainter->drawPath(QPainterPathStroker().createStroke(painterPath));
     
    915951    /* Fill button body: */
    916952    pPainter->setClipPath(painterPath);
    917     QColor backgroundColor2 = uiCommon().isInDarkMode()
    918                             ? backgroundColor.lighter(160)
    919                             : backgroundColor.darker(120);
     953#ifdef VBOX_WS_MAC
     954    const QColor backgroundColor2 = uiCommon().isInDarkMode()
     955                                  ? backgroundColor.lighter(160)
     956                                  : backgroundColor.darker(120);
     957#else /* !VBOX_WS_MAC */
     958    const QColor backgroundColor2 = uiCommon().isInDarkMode()
     959                                  ? backgroundColor.lighter(105)
     960                                  : backgroundColor.darker(105);
     961#endif /* !VBOX_WS_MAC */
    920962    pPainter->fillRect(m_extraButtonRect, backgroundColor2);
    921963
     
    9691011    pPainter->restore();
    9701012}
     1013
     1014#ifndef VBOX_WS_MAC
     1015/* static */
     1016int UIToolsItem::iShift30(int i1, int i2)
     1017{
     1018    const int iMin = qMin(i1, i2);
     1019    const int iMax = qMax(i1, i2);
     1020    const int iDiff = iMax - iMin;
     1021    const int iDiff10 = iDiff * 0.3;
     1022
     1023    int iResult = 0;
     1024    if (i1 > i2)
     1025        iResult = i1 - iDiff10;
     1026    else
     1027        iResult = i1 + iDiff10;
     1028
     1029    return qMin(255, iResult);
     1030}
     1031#endif /* !VBOX_WS_MAC */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsItem.h

    r108061 r108106  
    248248                              const QFont &font, QPaintDevice *pPaintDevice,
    249249                              const QString &strText);
     250
     251#ifndef VBOX_WS_MAC
     252        /** Returns a number shifter per 10% from @a i1 to @a i2. */
     253        static int iShift30(int i1, int i2);
     254#endif
    250255    /** @} */
    251256
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