From 19b8bac2aa59d02968c33ac6f83c66907d5ab94c Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Sat, 2 Sep 2023 10:37:47 +0200 Subject: tdf#149611 qt: Make auto-selection of dark app colors work Rename the newly introduced method `QtFrame::isUsingDarkColorScheme` to detect whether a dark color scheme is in use from Change-Id I8f347c6e7f775cc55377c5c84481de3051c3cf24 tdf#156894 qt: Prefer dark icon theme in dark mode and let it override `SalFrame::GetUseDarkMode`. This gets used (via `MiscSettings::GetUseDarkMode`) in `ColorConfig::GetDefaultColor` to determine what application colors to use. With this, setting "Tools" -> "Options" -> "LibreOfficeDev" -> "Application Colors" -> "Automatic" to "System Theme" will now automatically switch to dark application colors (like a dark doc background instead of white) for kf5/qt6 when a dark global theme is active (e.g. because "Breeze Dark" has been selected in Plasma system settings). Change-Id: I151e7eb35a94a9c525452a7d90b24283f6226904 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156467 Tested-by: Jenkins Reviewed-by: Michael Weghorn --- vcl/inc/qt5/QtFrame.hxx | 2 +- vcl/qt5/QtFrame.cxx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'vcl') diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx index ecedc3ae2e29..b5ae7508a506 100644 --- a/vcl/inc/qt5/QtFrame.hxx +++ b/vcl/inc/qt5/QtFrame.hxx @@ -128,7 +128,6 @@ class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public SalFrame bool isWindow() const; QWindow* windowHandle() const; QScreen* screen() const; - static bool isUsingDarkColorScheme(); bool isMinimized() const; bool isMaximized() const; void SetWindowStateImpl(Qt::WindowStates eState); @@ -215,6 +214,7 @@ public: virtual void SetScreenNumber(unsigned int) override; virtual void SetApplicationID(const OUString&) override; virtual void ResolveWindowHandle(SystemEnvData& rData) const override; + virtual bool GetUseDarkMode() const override; virtual bool GetUseReducedAnimation() const override; inline bool CallCallback(SalEvent nEvent, const void* pEvent) const; diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx index ff7edb9fd7b2..49d542a64909 100644 --- a/vcl/qt5/QtFrame.cxx +++ b/vcl/qt5/QtFrame.cxx @@ -354,7 +354,7 @@ QScreen* QtFrame::screen() const #endif } -bool QtFrame::isUsingDarkColorScheme() +bool QtFrame::GetUseDarkMode() const { #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) const QStyleHints* pStyleHints = QApplication::styleHints(); @@ -1234,7 +1234,7 @@ void QtFrame::UpdateSettings(AllSettings& rSettings) style.SetMenuFont(aFont); // Icon theme - const bool bPreferDarkTheme = isUsingDarkColorScheme(); + const bool bPreferDarkTheme = GetUseDarkMode(); style.SetPreferredIconTheme(toOUString(QIcon::themeName()), bPreferDarkTheme); // Scroll bar size -- cgit