vcl/inc/qt5/QtInstance.hxx |    1 +
 vcl/qt5/QtInstance.cxx     |    8 ++++++++
 2 files changed, 9 insertions(+)

New commits:
commit c214b1f686526c095c02a32be70f69b437e0151c
Author:     Dan Kingsley <[email protected]>
AuthorDate: Mon Oct 27 10:53:02 2025 +1300
Commit:     Michael Weghorn <[email protected]>
CommitDate: Fri Oct 31 08:29:00 2025 +0100

    Theme update without restart (Linux)
    
    On Linux desktop environments, LibreOffice does not automatically update
    its theme when the system theme changes.
    e.g., from light to dark mode.
    A restart is required for the theme to be applied.
    
    Steps to reproduce:
    1. Open LibreOffice on a Linux desktop environment with Qt 6.5 or later.
    2. Change the system-wide theme from light to dark, or vice-versa.
    (e.g. automatic night time dark mode applies sunset)
    3. The LibreOffice theme does not update to match the new system theme.
    4. After restarting the application, the theme does update.
    
    This change allows the theme to refresh automatically
    when changed, without requiring a full restart.
    
    Change-Id: I3b86975e825b358f00dbbb82e0e741ced93ad509
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192995
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>
    Reviewed-by: Dan Kingsley <[email protected]>

diff --git a/vcl/inc/qt5/QtInstance.hxx b/vcl/inc/qt5/QtInstance.hxx
index 337f15697f67..ed2016df0a89 100644
--- a/vcl/inc/qt5/QtInstance.hxx
+++ b/vcl/inc/qt5/QtInstance.hxx
@@ -98,6 +98,7 @@ private Q_SLOTS:
     bool ImplYield(bool bWait, bool bHandleAllCurrentEvents);
     static void deleteObjectLater(QObject* pObject);
     static void localeChanged();
+    void colorSchemeChanged();
 
     void orientationChanged(Qt::ScreenOrientation);
     void primaryScreenChanged(QScreen*);
diff --git a/vcl/qt5/QtInstance.cxx b/vcl/qt5/QtInstance.cxx
index c3700e51cb7e..8606f52a2ba3 100644
--- a/vcl/qt5/QtInstance.cxx
+++ b/vcl/qt5/QtInstance.cxx
@@ -47,6 +47,7 @@
 #include <QtCore/QLibraryInfo>
 #include <QtCore/QThread>
 #include <QtGui/QScreen>
+#include <QtGui/QStyleHints>
 #include <QtWidgets/QApplication>
 #include <QtWidgets/QWidget>
 #include <QtWidgets/QMessageBox>
@@ -308,6 +309,11 @@ QtInstance::QtInstance(std::unique_ptr<QApplication>& 
pQApp)
     connect(qApp, &QGuiApplication::screenAdded, this, 
&QtInstance::screenAdded);
     connect(qApp, &QGuiApplication::screenRemoved, this, 
&QtInstance::screenRemoved);
 
+#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
+    connect(QGuiApplication::styleHints(), &QStyleHints::colorSchemeChanged, 
this,
+            &QtInstance::colorSchemeChanged);
+#endif
+
 #ifndef EMSCRIPTEN
     m_bSupportsOpenGL = true;
 #elif !HAVE_EMSCRIPTEN_JSPI
@@ -765,6 +771,8 @@ void QtInstance::screenAdded(QScreen* pScreen)
 
 void QtInstance::screenRemoved(QScreen*) { notifyDisplayChanged(); }
 
+void QtInstance::colorSchemeChanged() { UpdateStyle(false); }
+
 void QtInstance::virtualGeometryChanged(const QRect&) { 
notifyDisplayChanged(); }
 
 void QtInstance::AllocFakeCmdlineArgs(std::unique_ptr<char* []>& rFakeArgv,

Reply via email to