diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ include(KDECMakeSettings) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) -find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Gui Widgets QuickControls2) +find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Gui Widgets QuickControls2 DBus) find_package(KF5 ${KF5_DEP_VERSION} REQUIRED COMPONENTS Config Kirigami2) diff --git a/kirigami-plasmadesktop-integration/CMakeLists.txt b/kirigami-plasmadesktop-integration/CMakeLists.txt --- a/kirigami-plasmadesktop-integration/CMakeLists.txt +++ b/kirigami-plasmadesktop-integration/CMakeLists.txt @@ -13,6 +13,7 @@ Qt5::Core KF5::Kirigami2 PRIVATE + Qt5::DBus Qt5::Qml Qt5::Quick KF5::ConfigWidgets diff --git a/kirigami-plasmadesktop-integration/plasmadesktoptheme.h b/kirigami-plasmadesktop-integration/plasmadesktoptheme.h --- a/kirigami-plasmadesktop-integration/plasmadesktoptheme.h +++ b/kirigami-plasmadesktop-integration/plasmadesktoptheme.h @@ -53,6 +53,9 @@ Q_SIGNALS: void colorsChanged(); +protected Q_SLOTS: + void configurationChanged(); + private: QPointer m_parentItem; QPointer m_window; diff --git a/kirigami-plasmadesktop-integration/plasmadesktoptheme.cpp b/kirigami-plasmadesktop-integration/plasmadesktoptheme.cpp --- a/kirigami-plasmadesktop-integration/plasmadesktoptheme.cpp +++ b/kirigami-plasmadesktop-integration/plasmadesktoptheme.cpp @@ -14,6 +14,8 @@ #include #include +#include +#include class IconLoaderSingleton { @@ -156,8 +158,17 @@ }); } + // 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(); connect(this, &PlasmaDesktopTheme::colorSetChanged, this, &PlasmaDesktopTheme::syncColors); @@ -172,6 +183,21 @@ PlasmaDesktopTheme::~PlasmaDesktopTheme() = default; +void PlasmaDesktopTheme::configurationChanged() +{ + KSharedConfigPtr ptr = KSharedConfig::openConfig(); + KConfigGroup general( ptr->group("general") ); + setSmallFont(general.readEntry("smallestReadableFont", []() { + auto smallFont = qApp->font(); + if (smallFont.pixelSize() != -1) { + smallFont.setPixelSize(smallFont.pixelSize()-2); + } else { + smallFont.setPointSize(smallFont.pointSize()-2); + } + return smallFont; + }())); +} + QIcon PlasmaDesktopTheme::iconFromTheme(const QString &name, const QColor &customColor) { QPalette pal = palette();