Commit f8e56a22 authored by Marco Martin's avatar Marco Martin

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
parent b246c63d
......@@ -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();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment