Commit 5b886878 authored by Jan Blackquill's avatar Jan Blackquill 🌈

Implement smallFont in Kirigami plugin

Test Plan: {F8273961} {F8273893}

Reviewers: #kirigami, mart

Reviewed By: #kirigami, mart

Subscribers: filipf, ngraham, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D29307
parent aa8cb14b
......@@ -32,7 +32,7 @@ include(KDEInstallDirs)
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)
......
......@@ -13,6 +13,7 @@ target_link_libraries(org.kde.desktop
Qt5::Core
KF5::Kirigami2
PRIVATE
Qt5::DBus
Qt5::Qml
Qt5::Quick
KF5::ConfigWidgets
......
......@@ -14,6 +14,8 @@
#include <KIconLoader>
#include <KColorScheme>
#include <KConfigGroup>
#include <QDBusConnection>
class IconLoaderSingleton
{
......@@ -156,8 +158,17 @@ 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();
connect(this, &PlasmaDesktopTheme::colorSetChanged,
this, &PlasmaDesktopTheme::syncColors);
......@@ -172,6 +183,21 @@ PlasmaDesktopTheme::PlasmaDesktopTheme(QObject *parent)
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();
......
......@@ -53,6 +53,9 @@ public:
Q_SIGNALS:
void colorsChanged();
protected Q_SLOTS:
void configurationChanged();
private:
QPointer<QQuickItem> m_parentItem;
QPointer<QWindow> m_window;
......
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