Commit 2e509a94 authored by David Redondo's avatar David Redondo 🏎
Browse files

lnf: Allow setting fonts from global themes

Seems like an an obvious and nice feature to have.
Just piping some strings through.
parent 5824e636
Pipeline #140869 passed with stage
in 5 minutes and 34 seconds
......@@ -112,6 +112,10 @@ KCMLookandFeel::KCMLookandFeel(QObject *parent, const KPluginMetaData &data, con
}
});
connect(m_lnf, &LookAndFeelManager::cursorsChanged, this, &KCMLookandFeel::cursorsChanged);
connect(m_lnf, &LookAndFeelManager::fontsChanged, this, [] {
QDBusMessage message = QDBusMessage::createSignal("/KDEPlatformTheme", "org.kde.KDEPlatformTheme", "refreshFonts");
QDBusConnection::sessionBus().send(message);
});
}
KCMLookandFeel::~KCMLookandFeel()
......
......@@ -40,6 +40,7 @@ LookAndFeelManager::LookAndFeelManager(QObject *parent)
, m_applyLatteLayout(false)
, m_applyWindowDecoration(true)
, m_plasmashellChanged(false)
, m_fontsChanged(false)
{
m_applyLatteLayout = (KService::serviceByDesktopName("org.kde.latte-dock") != nullptr);
}
......@@ -201,6 +202,66 @@ void LookAndFeelManager::setPlasmaTheme(const QString &theme)
writeNewDefaults(QStringLiteral("plasmarc"), QStringLiteral("Theme"), QStringLiteral("name"), theme);
}
void LookAndFeelManager::setGeneralFont(const QString &font)
{
if (font.isEmpty()) {
return;
}
writeNewDefaults(QStringLiteral("kdeglobals"), QStringLiteral("General"), QStringLiteral("font"), font, KConfig::Notify);
m_fontsChanged = true;
}
void LookAndFeelManager::setFixedFont(const QString &font)
{
if (font.isEmpty()) {
return;
}
writeNewDefaults(QStringLiteral("kdeglobals"), QStringLiteral("General"), QStringLiteral("fixed"), font, KConfig::Notify);
m_fontsChanged = true;
}
void LookAndFeelManager::setSmallestReadableFont(const QString &font)
{
if (font.isEmpty()) {
return;
}
writeNewDefaults(QStringLiteral("kdeglobals"), QStringLiteral("General"), QStringLiteral("smallestReadableFont"), font, KConfig::Notify);
m_fontsChanged = true;
}
void LookAndFeelManager::setToolbarFont(const QString &font)
{
if (font.isEmpty()) {
return;
}
writeNewDefaults(QStringLiteral("kdeglobals"), QStringLiteral("General"), QStringLiteral("toolBarFont"), font, KConfig::Notify);
m_fontsChanged = true;
}
void LookAndFeelManager::setMenuFont(const QString &font)
{
if (font.isEmpty()) {
return;
}
writeNewDefaults(QStringLiteral("kdeglobals"), QStringLiteral("General"), QStringLiteral("menuFont"), font, KConfig::Notify);
m_fontsChanged = true;
}
void LookAndFeelManager::setWindowTitleFont(const QString &font)
{
if (font.isEmpty()) {
return;
}
writeNewDefaults(QStringLiteral("kdeglobals"), QStringLiteral("WM"), QStringLiteral("activeFont"), font, KConfig::Notify);
m_fontsChanged = true;
}
void LookAndFeelManager::setResetDefaultLayout(bool reset)
{
if (m_resetDefaultLayout == reset) {
......@@ -399,6 +460,21 @@ void LookAndFeelManager::save(const KPackage::Package &package, const KPackage::
#endif
}
group = KConfigGroup(conf, "kdeglobals");
group = KConfigGroup(&group, "General");
setGeneralFont(group.readEntry("font", QString()));
setFixedFont(group.readEntry("fixed", QString()));
setSmallestReadableFont(group.readEntry("smallestReadableFont", QString()));
setToolbarFont(group.readEntry("toolBarFont", QString()));
setMenuFont(group.readEntry("menuFont", QString()));
group = KConfigGroup(conf, "kdeglobals");
group = KConfigGroup(&group, "WM");
setWindowTitleFont(group.readEntry("activeFont"));
if (m_fontsChanged) {
Q_EMIT fontsChanged();
m_fontsChanged = false;
}
setSplashScreen(m_data->settings()->lookAndFeelPackage());
setLockScreen(m_data->settings()->lookAndFeelPackage());
......
......@@ -58,6 +58,14 @@ public:
void setWindowPlacement(const QString &value);
void setShellPackage(const QString &name);
void setGeneralFont(const QString &font);
void setFixedFont(const QString &font);
void setSmallFont(const QString &font);
void setSmallestReadableFont(const QString &font);
void setToolbarFont(const QString &font);
void setMenuFont(const QString &font);
void setWindowTitleFont(const QString &font);
LookAndFeelSettings *settings() const;
void setApplyWidgetStyle(bool apply)
......@@ -72,6 +80,7 @@ Q_SIGNALS:
void colorsChanged();
void styleChanged(const QString &newStyle);
void cursorsChanged(const QString &newStyle);
void fontsChanged();
void refreshServices(const QStringList &toStop, const KService::List &toStart);
private:
......@@ -107,6 +116,7 @@ private:
bool m_applyWindowDecoration : 1;
bool m_plasmashellChanged : 1;
bool m_fontsChanged : 1;
};
#endif // LOOKANDFEELMANAGER_H
Supports Markdown
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