VirtualBox

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


Ignore:
Timestamp:
May 26, 2021 3:32:54 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10003: UICommon: Dark theme support for Windows; No real-time changes, restart is required for now.

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

Legend:

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

    r89296 r89298  
    4040#ifdef VBOX_WS_WIN
    4141# include <QEventLoop>
     42# include <QStyleFactory>
    4243#endif
    4344#ifdef VBOX_WS_X11
     
    723724}
    724725
     726#ifdef VBOX_WS_WIN
     727/* static */
     728void UICommon::loadColorTheme()
     729{
     730    /* Load saved color theme: */
     731    UIColorThemeType enmColorTheme = gEDataManager->colorTheme();
     732
     733    /* Check whether we have dark system theme requested: */
     734    if (enmColorTheme == UIColorThemeType_Auto)
     735    {
     736        QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
     737                           QSettings::NativeFormat);
     738        if (settings.value("AppsUseLightTheme") == 0)
     739            enmColorTheme = UIColorThemeType_Dark;
     740    }
     741
     742    /* Check whether dark theme was requested by any means: */
     743    if (enmColorTheme == UIColorThemeType_Dark)
     744    {
     745        qApp->setStyle(QStyleFactory::create("Fusion"));
     746        QPalette darkPalette;
     747        QColor windowColor1 = QColor(59, 60, 61);
     748        QColor windowColor2 = QColor(63, 64, 65);
     749        QColor baseColor1 = QColor(46, 47, 48);
     750        QColor baseColor2 = QColor(56, 57, 58);
     751        QColor disabledColor = QColor(113, 114, 115);
     752        darkPalette.setColor(QPalette::Window, windowColor1);
     753        darkPalette.setColor(QPalette::WindowText, Qt::white);
     754        darkPalette.setColor(QPalette::Disabled, QPalette::WindowText, disabledColor);
     755        darkPalette.setColor(QPalette::Base, baseColor1);
     756        darkPalette.setColor(QPalette::AlternateBase, baseColor2);
     757        darkPalette.setColor(QPalette::PlaceholderText, disabledColor);
     758        darkPalette.setColor(QPalette::Text, Qt::white);
     759        darkPalette.setColor(QPalette::Disabled, QPalette::Text, disabledColor);
     760        darkPalette.setColor(QPalette::Button, windowColor2);
     761        darkPalette.setColor(QPalette::ButtonText, Qt::white);
     762        darkPalette.setColor(QPalette::Disabled, QPalette::ButtonText, disabledColor);
     763        darkPalette.setColor(QPalette::BrightText, Qt::red);
     764        darkPalette.setColor(QPalette::Link, QColor(179, 214, 242));
     765        darkPalette.setColor(QPalette::Highlight, QColor(29, 84, 92));
     766        darkPalette.setColor(QPalette::HighlightedText, Qt::white);
     767        darkPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, disabledColor);
     768        qApp->setPalette(darkPalette);
     769        qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #2b2b2b; border: 1px solid #737373; }");
     770    }
     771}
     772#endif /* VBOX_WS_WIN */
     773
    725774/* static */
    726775void UICommon::loadLanguage(const QString &strLangId)
     
    41474196    m_pThreadPoolCloud = new UIThreadPool(2 /* worker count */, 1000 /* worker timeout */);
    41484197
     4198#ifdef VBOX_WS_WIN
     4199    /* Load color theme: */
     4200    loadColorTheme();
     4201#endif
     4202
    41494203    /* Load translation based on the user settings: */
    41504204    QString sLanguageId = gEDataManager->languageId();
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h

    r88678 r89298  
    55
    66/*
    7  * Copyright (C) 2006-2020 Oracle Corporation
     7 * Copyright (C) 2006-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    315315        /** Returns the system language ID. */
    316316        static QString systemLanguageId();
     317
     318#ifdef VBOX_WS_WIN
     319        /** Loads the color theme. */
     320        static void loadColorTheme();
     321#endif
    317322
    318323        /** Loads the language by language ID.
Note: See TracChangeset for help on using the changeset viewer.

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