VirtualBox

Changeset 102476 in vbox


Ignore:
Timestamp:
Dec 5, 2023 1:44:42 PM (12 months ago)
Author:
vboxsync
Message:

FE/Qt: UICommon is now able to notify listeners about theme changes; For now the change is only triggered on macOS host as an example.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
4 edited

Legend:

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

    r102474 r102476  
    8383#include "UIWizardNewVD.h"
    8484#ifdef VBOX_WS_MAC
     85# include "UICocoaApplication.h"
    8586# include "UIMachineWindowFullscreen.h"
    8687# include "UIMachineWindowSeamless.h"
     
    190191    , m_fDataCommitted(false)
    191192#endif
     193#ifdef VBOX_WS_MAC
     194    , m_fDarkMode(false)
     195#endif
    192196#ifdef VBOX_WS_NIX
    193197    , m_enmWindowManagerType(X11WMType_Unknown)
     
    311315    m_pThreadPoolCloud = new UIThreadPool(2 /* worker count */, 1000 /* worker timeout */);
    312316
     317#ifdef VBOX_WS_MAC
     318    /* Load whether macOS is in Dark mode: */
     319    m_fDarkMode = UICocoaApplication::instance()->isDarkMode();
     320#endif
    313321#ifdef VBOX_WS_WIN
    314322    /* Load color theme: */
     
    27292737    }
    27302738
     2739#ifdef VBOX_WS_MAC
     2740    /* Handle application palette change event: */
     2741    if (   pEvent->type() == QEvent::ApplicationPaletteChange
     2742        && pObject == windowManager().mainWindowShown())
     2743    {
     2744        const bool fDarkMode = UICocoaApplication::instance()->isDarkMode();
     2745        if (m_fDarkMode != fDarkMode)
     2746        {
     2747            m_fDarkMode = fDarkMode;
     2748            emit sigThemeChange();
     2749        }
     2750    }
     2751#endif
     2752
    27312753    /* Call to base-class: */
    27322754    return QObject::eventFilter(pObject, pEvent);
    27332755}
    2734 
    27352756
    27362757void UICommon::sltHandleFontScaleFactorChanged(int iFontScaleFactor)
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h

    r102363 r102476  
    9494    /** @} */
    9595
     96    /** @name Theme stuff.
     97     * @{ */
     98        /** Notifies listeners about theme change. */
     99        void sigThemeChange();
     100    /** @} */
     101
    96102    /** @name COM: Extension Pack stuff.
    97103     * @{ */
     
    634640        bool  m_fDataCommitted;
    635641#endif
     642
     643#ifdef VBOX_WS_MAC
     644        /** Holds whether macOS is in Dark mode. */
     645        bool  m_fDarkMode;
     646#endif
    636647    /** @} */
    637648
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/UICocoaApplication.h

    r98103 r102476  
    7777    bool isActive() const;
    7878
     79    /** Returns whether app is in Dark mode. */
     80    bool isDarkMode() const;
     81
    7982    /** Hides the application. */
    8083    void hide();
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/UICocoaApplication.mm

    r98103 r102476  
    329329}
    330330
     331bool UICocoaApplication::isDarkMode() const
     332{
     333    NativeNSStringRef pstrInterfaceMode = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"];
     334    return [pstrInterfaceMode isEqualToString :@"Dark"];
     335}
     336
    331337void UICocoaApplication::hide()
    332338{
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