VirtualBox

Changeset 102482 in vbox


Ignore:
Timestamp:
Dec 5, 2023 4:10:24 PM (16 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
160625
Message:

FE/Qt: macOS: Hardcode native Window colors as Qt has them far far away from the native apps.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/globals
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp

    r102476 r102482  
    319319    m_fDarkMode = UICocoaApplication::instance()->isDarkMode();
    320320#endif
    321 #ifdef VBOX_WS_WIN
    322321    /* Load color theme: */
    323322    loadColorTheme();
    324 #endif
    325323
    326324    /* Load translation based on the user settings: */
     
    957955}
    958956
    959 #ifdef VBOX_WS_WIN
    960 /* static */
    961957void UICommon::loadColorTheme()
    962958{
     959#if defined (VBOX_WS_MAC)
     960    /* macOS has Window color hardcoded somewhere inside, Qt has no access to it,
     961     * moreover these colors are influenced by window background blending,
     962     * making Qt default colors incredibly inconsistent with native macOS apps. */
     963    QPalette pal = qApp->palette();
     964    if (isInDarkMode())
     965    {
     966        pal.setColor(QPalette::Active, QPalette::Window, QColor("#252328"));
     967        pal.setColor(QPalette::Inactive, QPalette::Window, QColor("#2A2630"));
     968    }
     969    else
     970    {
     971        pal.setColor(QPalette::Active, QPalette::Window, QColor("#E1DEE4"));
     972        pal.setColor(QPalette::Inactive, QPalette::Window, QColor("#EEE8E9"));
     973    }
     974    qApp->setPalette(pal);
     975
     976#elif defined(VBOX_WS_WIN)
     977
    963978    /* Load saved color theme: */
    964979    UIColorThemeType enmColorTheme = gEDataManager->colorTheme();
     
    10021017        qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #2b2b2b; border: 1px solid #737373; }");
    10031018    }
    1004 }
    10051019#endif /* VBOX_WS_WIN */
     1020}
    10061021
    10071022bool UICommon::processArgs()
     
    27462761        {
    27472762            m_fDarkMode = fDarkMode;
     2763            loadColorTheme();
    27482764            emit sigThemeChange();
    27492765        }
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h

    r102476 r102482  
    176176        /** Returns whether UICommon instance cleanup is in progress. */
    177177        bool isCleaningUp() const { return m_fCleaningUp; }
     178
     179#ifdef VBOX_WS_MAC
     180        /** Returns whether macOS is in Dark mode. */
     181        bool isInDarkMode() const { return m_fDarkMode; }
     182#endif
    178183    /** @} */
    179184
     
    213218    /** @name Host OS stuff.
    214219     * @{ */
    215 #ifdef VBOX_WS_WIN
    216220        /** Loads the color theme. */
    217         static void loadColorTheme();
    218 #endif
     221        void loadColorTheme();
    219222
    220223#ifdef VBOX_WS_NIX
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