Commit 8936b4db authored by Alexander Lohnau's avatar Alexander Lohnau 💬 Committed by Kurt Hindenburg
Browse files

Port away from deprecated KNSCore::DownloadManager

We can just remove the files on disk and with the RemoveDeadEntries
option set to true KNS will check if the files still exist. If
not the entry will be marked as not installed.
parent 9e28c446
......@@ -4,3 +4,4 @@ Categories=Konsole Color Schemes
......@@ -29,7 +29,7 @@
#include <KIconDialog>
#include <KLocalizedString>
#include <KMessageBox>
#include <KNSCore/DownloadManager>
#include <KNSCore/Engine>
#include <KWindowSystem>
#include <kconfigwidgets_version.h>
......@@ -1152,51 +1152,15 @@ void EditProfileDialog::updateFontPreview(QFont font)
void EditProfileDialog::removeColorScheme()
QModelIndexList selected = _appearanceUi->colorSchemeList->selectionModel()->selectedIndexes();
const QModelIndexList selected = _appearanceUi->colorSchemeList->selectionModel()->selectedIndexes();
if (selected.isEmpty()) {
// The actual delete runs async because we need to on-demand query
// files managed by KNS. Deleting files managed by KNS screws up the
// KNS states (entry gets shown as installed when in fact we deleted it).
auto *manager = new KNSCore::DownloadManager(QStringLiteral("konsole.knsrc"), this);
connect(manager, &KNSCore::DownloadManager::searchResult,
this, [=](const KNSCore::EntryInternal::List &entries) {
const QString &name = selected.first().data(Qt::UserRole + 1).value<const ColorScheme *>()->name();
bool uninstalled = false;
// Check if the theme was installed by KNS, if so uninstall it through
// there and unload it.
for (auto &entry : entries) {
for (const auto &file : entry.installedFiles()) {
if (ColorSchemeManager::colorSchemeNameFromPath(file) != name) {
// Make sure the manager can unload it before uninstalling it.
if (ColorSchemeManager::instance()->unloadColorScheme(file)) {
uninstalled = true;
if (uninstalled) {
// If KNS wasn't able to remove it is a custom theme and we'll drop
// it manually.
if (!uninstalled) {
uninstalled = ColorSchemeManager::instance()->deleteColorScheme(name);
if (uninstalled) {
if (ColorSchemeManager::instance()->deleteColorScheme(name)) {
void EditProfileDialog::gotNewColorSchemes(const KNS3::Entry::List &changedEntries)
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