Commit cf45e112 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Rework deletion of Yakuake skins

- Remove usage of DownloadManager
- Use RemoveDeadEntries option, otherwise removed/invalid entries would still show up as installed
- Allow deletion of KNS entries, with the mentioned option set KNS will realize that the
entries were manually uninstalled. It also more intuitive to click the remove button
instead of the "Get New..." button if you want to uninstall entries.
parent 529db2de
......@@ -31,7 +31,6 @@
#include <KTar>
#include <knewstuff_version.h>
#include <downloadmanager.h>
#if KNEWSTUFF_VERSION < QT_VERSION_CHECK(5, 78, 0)
#include <downloaddialog.h>
#else
......@@ -73,7 +72,6 @@ AppearanceSettings::AppearanceSettings(QWidget* parent) : QWidget(parent)
ghnsButton->setIcon(QIcon::fromTheme(QStringLiteral("get-hot-new-stuff")));
m_knsConfigFileName = QLatin1String("yakuake.knsrc");
m_knsDownloadManager = new KNSCore::DownloadManager(m_knsConfigFileName);
connect(ghnsButton, &QPushButton::clicked, this, &AppearanceSettings::getNewSkins);
......@@ -394,31 +392,12 @@ void AppearanceSettings::updateRemoveSkinButton()
return;
}
QString skinDir;
QVariant value = skinList->currentIndex().data(SkinDir);
if (value.isValid())
skinDir = value.toString();
value = skinList->currentIndex().data(SkinInstalledWithKns);
bool isKnsSkin = value.toBool();
// We don't allow the user to remove the default skin
// or any skin which was installed through KNS3.
if (skinDir.isEmpty() || isKnsSkin)
{
removeButton->setEnabled(false);
return;
const QString skinDir = skinList->currentIndex().data(SkinDir).toString();
bool enabled = false;
if (!skinDir.isEmpty()) {
enabled == QFileInfo(skinDir + QStringLiteral("/title.skin")).isWritable();
}
QFile titleSkin(skinDir + QStringLiteral("/title.skin"));
if (!titleSkin.open(QIODevice::ReadWrite))
removeButton->setEnabled(false);
else
removeButton->setEnabled(true);
titleSkin.close();
removeButton->setEnabled(enabled);
}
void AppearanceSettings::removeSelectedSkin()
......@@ -534,7 +513,18 @@ void AppearanceSettings::getNewSkins()
invalidSkinText += QString(QStringLiteral("<li>%1</li>")).arg(entry.name());
// Then remove the skin.
m_knsDownloadManager->uninstallEntry(entry);
const QStringList files = entry.installedFiles();
for (const QString &file : files) {
QFileInfo info(QString(file).remove(QStringLiteral("/*")));
if (!info.exists()) {
continue;
}
if (info.isDir()) {
QDir(info.absoluteFilePath()).removeRecursively();
} else {
QFile::remove(info.absoluteFilePath());
}
}
}
}
......
......@@ -35,12 +35,6 @@ class SkinListDelegate;
class QStandardItem;
class QStandardItemModel;
namespace KNSCore
{
class DownloadManager;
}
class AppearanceSettings : public QWidget, private Ui::AppearanceSettings
{
Q_OBJECT
......@@ -135,7 +129,6 @@ class AppearanceSettings : public QWidget, private Ui::AppearanceSettings
QStringList m_installSkinFileList;
QString m_knsConfigFileName;
KNSCore::DownloadManager* m_knsDownloadManager;
};
#endif
......@@ -2,3 +2,5 @@
Categories=Yakuake Skin
Uncompress=always
TargetDir=yakuake/kns_skins
# In case the entries are invalid or the user uninstalls them manually
RemoveDeadEntries=true
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