diff --git a/kcms/style/gtkpage.cpp b/kcms/style/gtkpage.cpp index 134cc39e3..4f96836f2 100644 --- a/kcms/style/gtkpage.cpp +++ b/kcms/style/gtkpage.cpp @@ -100,5 +100,11 @@ void GtkPage::defaults() void GtkPage::load() { m_gtkThemesModel->load(); + m_gtkThemesModel->setSelectedTheme(m_gtkConfigInterface.gtkTheme()); Q_EMIT selectGtkThemeInCombobox(gtkThemeFromConfig()); } + +bool GtkPage::isDefaults() const +{ + return m_gtkThemesModel->selectedTheme() == QLatin1String("Breeze"); +} diff --git a/kcms/style/gtkpage.h b/kcms/style/gtkpage.h index eda301a7c..efcdd7259 100644 --- a/kcms/style/gtkpage.h +++ b/kcms/style/gtkpage.h @@ -26,6 +26,7 @@ public: Q_INVOKABLE void load(); void save(); void defaults(); + bool isDefaults() const; public Q_SLOTS: QString gtkThemeFromConfig(); diff --git a/kcms/style/kcmstyle.cpp b/kcms/style/kcmstyle.cpp index 778bdc1b2..545a62192 100644 --- a/kcms/style/kcmstyle.cpp +++ b/kcms/style/kcmstyle.cpp @@ -87,19 +87,18 @@ KCMStyle::KCMStyle(QObject *parent, const KPluginMetaData &data, const QVariantL connect(styleSettings(), &StyleSettings::iconsInMenusChanged, this, [this] { m_effectsDirty = true; }); + + m_gtkPage = new GtkPage(this); + connect(m_gtkPage, &GtkPage::gtkThemeSettingsChanged, this, [this]() { + settingsChanged(); + setNeedsSave(true); + }); } KCMStyle::~KCMStyle() = default; -GtkPage *KCMStyle::gtkPage() +GtkPage *KCMStyle::gtkPage() const { - if (!m_gtkPage) { - m_gtkPage = new GtkPage(this); - connect(m_gtkPage, &GtkPage::gtkThemeSettingsChanged, this, [this]() { - setNeedsSave(true); - }); - } - return m_gtkPage; } @@ -249,9 +248,7 @@ void KCMStyle::load() { checkGtkConfigKdedModuleLoaded(); - if (m_gtkPage) { - m_gtkPage->load(); - } + m_gtkPage->load(); ManagedConfigModule::load(); m_model->load(); @@ -264,9 +261,7 @@ void KCMStyle::load() void KCMStyle::save() { - if (m_gtkPage) { - m_gtkPage->save(); - } + m_gtkPage->save(); // Check whether the new style can actually be loaded before saving it. // Otherwise apps will use the default style despite something else having been written to the config @@ -320,9 +315,7 @@ void KCMStyle::save() void KCMStyle::defaults() { - if (m_gtkPage) { - m_gtkPage->defaults(); - } + m_gtkPage->defaults(); // TODO the old code had a fallback chain but do we actually support not having Breeze for Plasma? // defaultStyle() -> oxygen -> plastique -> windows -> platinum -> motif @@ -341,4 +334,9 @@ void KCMStyle::loadSettingsToModel() setOtherToolBarStyle(static_cast(toolBarStyleEnum.keyToValue(qUtf8Printable(styleSettings()->toolButtonStyleOtherToolbars())))); } +bool KCMStyle::isDefaults() const +{ + return m_gtkPage->isDefaults(); +} + #include "kcmstyle.moc" diff --git a/kcms/style/kcmstyle.h b/kcms/style/kcmstyle.h index 723188d4a..05ed04071 100644 --- a/kcms/style/kcmstyle.h +++ b/kcms/style/kcmstyle.h @@ -52,7 +52,7 @@ public: }; Q_ENUM(ToolBarStyle) - GtkPage *gtkPage(); + GtkPage *gtkPage() const; StylesModel *model() const; @@ -75,6 +75,8 @@ public: void save() override; void defaults() override; + bool isDefaults() const override; + Q_SIGNALS: void showErrorMessage(const QString &message); void styleReconfigured(const QString &styleName);