Commit 9eed27b5 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Fix window decorations not being uninstallable

BUG: 414570
FIXED-IN: 5.79
parent 5dddcdee
/*
This file is part of the KDE libraries
SPDX-FileCopyrightText: 2016 Aleix Pol Gonzalez <aleixpol@kde.org>
SPDX-FileCopyrightText: 2021 Alexander Lohnau <alexander.lohnau@gmx.de>
SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
......@@ -12,6 +13,7 @@
#include <QDebug>
#include <QStandardPaths>
#include <QFile>
#include <QFileInfo>
#include <KLocalizedString>
......@@ -22,8 +24,37 @@
#include "knshandlerversion.h"
/**
* Unfortunately there are two knsrc files for the window decorations, but only one is used in the KCM.
* But both are used by third parties, consequently we can not remove one. To solve this we create a symlink
* which links the old cache file to the new cache file, which is exposed on the GUI.
* This way users can again remove window decorations that are installed as a dependency of a global theme.
* BUG: 414570
*/
void createSymlinkForWindowDecorations()
{
QFileInfo info(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/knewstuff3/aurorae.knsregistry"));
// If we have created the symbolic link already we can exit the function here
if (info.isSymbolicLink()) {
return;
}
// Delete this file, it the KNS entries are not exposed in any GUI
if (info.exists()) {
QFile::remove(info.absoluteFilePath());
}
QFileInfo newFileInfo(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/knewstuff3/window-decorations.knsregistry"));
QFile file(newFileInfo.absoluteFilePath());
// Make sure that the file exists
if (!newFileInfo.exists()) {
file.open(QFile::WriteOnly);
file.close();
}
file.link(info.absoluteFilePath());
}
int main(int argc, char** argv)
{
createSymlinkForWindowDecorations();
QCoreApplication app(argc, argv);
app.setApplicationName(QLatin1String("kpackage-knshandler"));
app.setApplicationVersion(knshandlerversion);
......
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