Commit 0276d06d authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Port deprecated KNSCore::DownloadManager usage

Using the RemoveDeadEntries KNewStuff will check
if the files of the entry still exist, if not
the entry is marked as deleted.
parent 1a115f22
......@@ -13,7 +13,7 @@ set(KONVERSATION_VERSION "${KONVERSATION_BASE_VERSION}.${RELEASE_SERVICE_COMPACT
project(konversation VERSION ${KONVERSATION_VERSION})
set (QT_MIN_VERSION "5.12.0")
set(KF5_MIN_VERSION "5.71.0")
set(KF5_MIN_VERSION "5.74.0")
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH})
......
......@@ -3,3 +3,4 @@ ProvidersUrl=https://autoconfig.kde.org/ocs/providers.xml
Categories=Konversation Nicklist Themes
TargetDir=konversation/themes
Uncompress=always
RemoveDeadEntries=true
......@@ -299,41 +299,10 @@ void Theme_Config::removeTheme()
}
dir.chop(QLatin1String("index.desktop").size());
// Check if theme was installed by KNS, if so uninstall via KNS, otherwise manually
auto *manager = new KNSCore::DownloadManager(QStringLiteral("konversation_nicklist_theme.knsrc"), this);
connect(manager, &KNSCore::DownloadManager::searchResult,
this, [=](const KNSCore::EntryInternal::List &entries) {
bool isUninstalledByKNS = false;
for (auto &entry : entries) {
const QStringList installedFiles = entry.installedFiles();
for (const QString &file : installedFiles) {
// file strings are of pattern "[...]/konversation/themes/simpleminded/*"
if (file.startsWith(dir)) {
// uninstall via KNS and be done
manager->uninstallEntry(entry);
isUninstalledByKNS = true;
break;
}
}
if (isUninstalledByKNS) {
break;
}
}
if (isUninstalledByKNS) {
loadSettings();
} else {
// manually installed, so delete manually
KIO::DeleteJob* job = KIO::del(QUrl::fromLocalFile(dir));
connect(job, &KIO::DeleteJob::result, this, &Theme_Config::postRemoveTheme);
}
manager->deleteLater();
});
manager->checkForInstalled();
// delete the files, the RemoveDeadEntries entry in the
// knsrc file takes care of marking the KNS entry is as deleted
KIO::DeleteJob* job = KIO::del(QUrl::fromLocalFile(dir));
connect(job, &KIO::DeleteJob::result, this, &Theme_Config::postRemoveTheme);
}
void Theme_Config::postRemoveTheme(KJob* /* delete_job */)
......
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