Commit 11092af7 authored by Benjamin Port's avatar Benjamin Port
Browse files

KCM Fonts ConfigModule to ManagedConfigModule

Reviewers: #plasma, ervin

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26228
parent 5b98466e
......@@ -497,7 +497,7 @@ bool FontAASettings::State::operator!=(const State& other) const
/**** KFonts ****/
KFonts::KFonts(QObject *parent, const QVariantList &args)
: KQuickAddons::ConfigModule(parent, args)
: KQuickAddons::ManagedConfigModule(parent, args)
, m_settings(new FontsSettings(this))
, m_fontAASettings(new FontAASettings(this))
{
......@@ -514,14 +514,6 @@ KFonts::KFonts(QObject *parent, const QVariantList &args)
setNeedsSave(m_fontAASettings->needsSave());
};
connect(m_settings, &FontsSettings::configChanged, this, &KFonts::updateNeedsSave);
connect(m_settings, &FontsSettings::fontChanged, this, &KFonts::updateNeedsSave);
connect(m_settings, &FontsSettings::fixedChanged, this, &KFonts::updateNeedsSave);
connect(m_settings, &FontsSettings::smallestReadableFontChanged, this, &KFonts::updateNeedsSave);
connect(m_settings, &FontsSettings::toolBarFontChanged, this, &KFonts::updateNeedsSave);
connect(m_settings, &FontsSettings::menuFontChanged, this, &KFonts::updateNeedsSave);
connect(m_settings, &FontsSettings::activeFontChanged, this, &KFonts::updateNeedsSave);
connect(m_fontAASettings, &FontAASettings::subPixelCurrentIndexChanged, this, updateState);
connect(m_fontAASettings, &FontAASettings::hintingCurrentIndexChanged, this, updateState);
connect(m_fontAASettings, &FontAASettings::excludeChanged, this, updateState);
......@@ -543,7 +535,7 @@ FontsSettings *KFonts::fontsSettings() const
void KFonts::defaults()
{
m_settings->setDefaults();
ManagedConfigModule::defaults();
m_fontAASettings->defaults();
}
......@@ -560,7 +552,7 @@ void KFonts::setNearestExistingFonts()
void KFonts::load()
{
// first load all the settings
m_settings->load();
ManagedConfigModule::load();
m_fontAASettings->load();
// Then set the existing fonts based on those settings
......@@ -572,12 +564,13 @@ void KFonts::load()
// previews
engine()->addImageProvider("preview", new PreviewImageProvider(m_settings->font()));
setNeedsSave(false);
// reload state after loading by emiting a settings signal
emit m_settings->activeFontChanged();
}
void KFonts::save()
{
m_settings->save();
ManagedConfigModule::save();
KConfig _cfgfonts("kcmfonts");
KConfigGroup cfgfonts(&_cfgfonts, "General");
......@@ -601,12 +594,11 @@ void KFonts::save()
runRdb(KRdbExportXftSettings | KRdbExportGtkTheme);
emit fontsHaveChanged();
setNeedsSave(false);
}
void KFonts::updateNeedsSave()
bool KFonts::isSaveNeeded() const
{
setNeedsSave(m_settings->isSaveNeeded() || m_fontAASettings->needsSave());
return m_fontAASettings->needsSave();
}
void KFonts::adjustAllFonts()
......
......@@ -31,7 +31,7 @@
#include <QAbstractItemModel>
#include <QStandardItemModel>
#include <KQuickAddons/ConfigModule>
#include <KQuickAddons/ManagedConfigModule>
#include "kxftconfig.h"
......@@ -134,7 +134,7 @@ private:
/**
* The Desktop/fonts tab in kcontrol.
*/
class KFonts : public KQuickAddons::ConfigModule
class KFonts : public KQuickAddons::ManagedConfigModule
{
Q_OBJECT
Q_PROPERTY(FontsSettings *fontsSettings READ fontsSettings CONSTANT)
......@@ -158,7 +158,7 @@ Q_SIGNALS:
void fontsHaveChanged();
private:
void updateNeedsSave();
bool isSaveNeeded() const override ;
QFont applyFontDiff(const QFont &fnt, const QFont &newFont, int fontDiffFlags);
void setNearestExistingFonts();
......
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