Commit 803a5d8b authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Only show delete button for themes that were manually or through KNS installed

Rather than just hardcoding breeze, we check if the theme was installed using the sddmthemeinstaller.
In case that was done, we have an entry in the config file with the file path.

BUG: 454874
parent 05e82d72
Pipeline #190248 passed with stage
in 1 minute and 48 seconds
......@@ -88,6 +88,7 @@ KCM.GridViewKCM {
iconName: "edit-delete"
tooltip: i18nc("@info:tooltip", "Delete")
onTriggered: kcm.removeTheme(view.model.index(index, 0))
enabled: model.deletable
}
]
onClicked: kcm.sddmSettings.current = model.id
......
......@@ -22,6 +22,7 @@ ThemesModel::ThemesModel(QObject *parent)
: QAbstractListModel(parent)
{
populate();
m_customInstalledThemes = KSharedConfig::openConfig(QStringLiteral("sddmthemeinstallerrc"))->group("DownloadedThemes").entryMap().values();
}
ThemesModel::~ThemesModel()
......@@ -52,6 +53,7 @@ QHash<int, QByteArray> ThemesModel::roleNames() const
{PathRole, QByteArrayLiteral("path")},
{ConfigFileRole, QByteArrayLiteral("configFile")},
{CurrentBackgroundRole, QByteArrayLiteral("currentBackground")},
{DeletableRole, QByteArrayLiteral("deletable")},
};
}
......@@ -94,6 +96,8 @@ QVariant ThemesModel::data(const QModelIndex &index, int role) const
if (metadata.supportsBackground()) {
return m_currentWallpapers[metadata.themeid()];
}
case DeletableRole:
return m_customInstalledThemes.contains(metadata.path().chopped(1)); // Chop the trailing /
}
return QVariant();
......
......@@ -31,6 +31,7 @@ public:
ThemeApiRole,
ConfigFileRole,
CurrentBackgroundRole,
DeletableRole,
};
Q_ENUM(Roles)
......@@ -58,6 +59,7 @@ private:
int m_currentIndex;
QList<ThemeMetadata> mThemeList;
QHash<QString, QString> m_currentWallpapers;
QList<QString> m_customInstalledThemes;
};
#endif // THEMESMODEL_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