Commit 05f21f51 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

[kcms/style] Consider GTK theme setting when computing default state

The GTK theme name is not managed by KConfigXT, we need to manually track that when determining whether the Defaults button is enabled

BUG: 458292
parent 01be1382
Pipeline #224523 passed with stage
in 11 minutes and 41 seconds
......@@ -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");
}
......@@ -26,6 +26,7 @@ public:
Q_INVOKABLE void load();
void save();
void defaults();
bool isDefaults() const;
public Q_SLOTS:
QString gtkThemeFromConfig();
......
......@@ -86,19 +86,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;
}
......@@ -248,9 +247,7 @@ void KCMStyle::load()
{
checkGtkConfigKdedModuleLoaded();
if (m_gtkPage) {
m_gtkPage->load();
}
m_gtkPage->load();
ManagedConfigModule::load();
m_model->load();
......@@ -263,9 +260,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
......@@ -319,9 +314,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
......@@ -340,4 +333,9 @@ void KCMStyle::loadSettingsToModel()
setOtherToolBarStyle(static_cast<ToolBarStyle>(toolBarStyleEnum.keyToValue(qUtf8Printable(styleSettings()->toolButtonStyleOtherToolbars()))));
}
bool KCMStyle::isDefaults() const
{
return m_gtkPage->isDefaults();
}
#include "kcmstyle.moc"
......@@ -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);
......
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