VirtualBox

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


Ignore:
Timestamp:
Dec 7, 2023 3:04:57 PM (14 months ago)
Author:
vboxsync
Message:

FE/Qt: Windows: Extend UICommon with public API to determine whether host OS is in Dark mode.

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

Legend:

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

    r102518 r102524  
    10091009}
    10101010
     1011#ifdef VBOX_WS_WIN
     1012bool UICommon::isWindowsInDarkMode() const
     1013{
     1014    /* Load saved color theme: */
     1015    UIColorThemeType enmColorTheme = gEDataManager->colorTheme();
     1016
     1017    /* Check whether we have dark system theme requested: */
     1018    if (enmColorTheme == UIColorThemeType_Auto)
     1019    {
     1020        QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
     1021                           QSettings::NativeFormat);
     1022        if (settings.value("AppsUseLightTheme") == 0)
     1023            enmColorTheme = UIColorThemeType_Dark;
     1024    }
     1025
     1026    /* Return result: */
     1027    return enmColorTheme == UIColorThemeType_Dark;
     1028}
     1029#endif /* VBOX_WS_WIN */
     1030
    10111031void UICommon::loadColorTheme()
    10121032{
     
    10741094#elif defined(VBOX_WS_WIN)
    10751095
    1076     /* Load saved color theme: */
    1077     UIColorThemeType enmColorTheme = gEDataManager->colorTheme();
    1078 
    1079     /* Check whether we have dark system theme requested: */
    1080     if (enmColorTheme == UIColorThemeType_Auto)
    1081     {
    1082         QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
    1083                            QSettings::NativeFormat);
    1084         if (settings.value("AppsUseLightTheme") == 0)
    1085             enmColorTheme = UIColorThemeType_Dark;
    1086     }
    1087 
    1088     /* Check whether dark theme was requested by any means: */
    1089     if (enmColorTheme == UIColorThemeType_Dark)
     1096    /* For the Dark mode! */
     1097    if (isWindowsInDarkMode())
    10901098    {
    10911099        qApp->setStyle(QStyleFactory::create("Fusion"));
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h

    r102518 r102524  
    236236        QString hostOperatingSystem() const;
    237237
     238#ifdef VBOX_WS_WIN
     239        /** Returns whether Windows host is in Dark mode. */
     240        bool isWindowsInDarkMode() const;
     241#endif
     242
    238243        /** Loads the color theme. */
    239244        void loadColorTheme();
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