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

[Colors KCM] Correctly report whether saving is needed

Summary:
Previously the kcm always reported that a save is needed once a scheme had been
marked for deletion. The correct way is to check if there are schemes that are
currently marked for deletion. Also we don't need the firstTime workaround.

Test Plan: Mark a scheme for deletion and undo that action

Reviewers: #plasma, mart

Reviewed By: #plasma, mart

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26526
parent 946e6d8e
......@@ -74,9 +74,7 @@ KCMColors::KCMColors(QObject *parent, const QVariantList &args)
about->addAuthor(i18n("Kai Uwe Broulik"), QString(), QStringLiteral("kde@privat.broulik.de"));
setAboutData(about);
connect(m_model, &ColorsModel::pendingDeletionsChanged, this, [this] {
setNeedsSave(true);
});
connect(m_model, &ColorsModel::pendingDeletionsChanged, this, &KCMColors::settingsChanged);
connect(m_model, &ColorsModel::selectedSchemeChanged, this, [this](const QString &scheme) {
m_selectedSchemeDirty = true;
......@@ -303,6 +301,12 @@ void KCMColors::editScheme(const QString &schemeName, QQuickItem *ctx)
m_editDialogProcess->start(QStringLiteral("kcolorschemeeditor"), args);
}
bool KCMColors::isSaveNeeded() const
{
return !m_model->match(m_model->index(0, 0), ColorsModel::PendingDeletionRole, true).isEmpty();
}
void KCMColors::load()
{
ManagedConfigModule::load();
......
......@@ -92,6 +92,8 @@ Q_SIGNALS:
void showSchemeNotInstalledWarning(const QString &schemeName);
private:
bool isSaveNeeded() const override;
void saveColors();
void processPendingDeletions();
......
......@@ -123,12 +123,9 @@ void ColorsModel::setSelectedScheme(const QString &scheme)
return;
}
const bool firstTime = m_selectedScheme.isNull();
m_selectedScheme = scheme;
if (!firstTime) {
emit selectedSchemeChanged(scheme);
}
emit selectedSchemeChanged(scheme);
emit selectedSchemeIndexChanged();
}
......
......@@ -40,12 +40,9 @@ void FilterProxyModel::setSelectedScheme(const QString &scheme)
return;
}
const bool firstTime = m_selectedScheme.isNull();
m_selectedScheme = scheme;
if (!firstTime) {
emit selectedSchemeChanged();
}
emit selectedSchemeChanged();
emit selectedSchemeIndexChanged();
}
......
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