From f8e56a22721057107bccdf319da36ff82ca2a804 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 7 Sep 2020 09:52:57 +0000 Subject: [PATCH] move the dbus connection in the singleton connecting to dbus is expensive, do it only once in the singleton the theme instance will only connecto to the signal forwarded by the singleton --- .../plasmadesktoptheme.cpp | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/kirigami-plasmadesktop-integration/plasmadesktoptheme.cpp b/kirigami-plasmadesktop-integration/plasmadesktoptheme.cpp index babb433..ff046eb 100644 --- a/kirigami-plasmadesktop-integration/plasmadesktoptheme.cpp +++ b/kirigami-plasmadesktop-integration/plasmadesktoptheme.cpp @@ -45,6 +45,14 @@ public: { connect(qGuiApp, &QGuiApplication::paletteChanged, this, &StyleSingleton::refresh); + + // Use DBus in order to listen for kdeglobals changes directly, as the + // QApplication doesn't expose the font variants we're looking for, + // namely smallFont. + QDBusConnection::sessionBus().connect( QString(), + QStringLiteral( "/KGlobalSettings" ), + QStringLiteral( "org.kde.KGlobalSettings" ), + QStringLiteral( "notifyChange" ), this, SIGNAL(configurationChanged())); } void refresh() @@ -125,6 +133,7 @@ public: KColorScheme viewScheme; Q_SIGNALS: + void configurationChanged(); void paletteChanged(); private: @@ -161,14 +170,6 @@ PlasmaDesktopTheme::PlasmaDesktopTheme(QObject *parent) }); } - // Use DBus in order to listen for kdeglobals changes directly, as the - // QApplication doesn't expose the font variants we're looking for, - // namely smallFont. - QDBusConnection::sessionBus().connect( QString(), - QStringLiteral( "/KGlobalSettings" ), - QStringLiteral( "org.kde.KGlobalSettings" ), - QStringLiteral( "notifyChange" ), this, SLOT(configurationChanged())); - //TODO: correct? depends from https://codereview.qt-project.org/206889 connect(qGuiApp, &QGuiApplication::fontDatabaseChanged, this, [this]() {setDefaultFont(qApp->font());}); configurationChanged(); @@ -181,6 +182,9 @@ PlasmaDesktopTheme::PlasmaDesktopTheme(QObject *parent) connect(s_style->data(), &StyleSingleton::paletteChanged, this, &PlasmaDesktopTheme::syncColors); + connect(s_style->data(), &StyleSingleton::configurationChanged, + this, &PlasmaDesktopTheme::configurationChanged); + syncColors(); } -- GitLab