Commit ee48796e authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

[DesktopNotifier] Notify change for any link to trash:/

With removal of default Trash and D10684 users can add the Trash link back themselves.
The file name isn't neccessarily "Trash.desktop", though, so check all desktop files for that when trash state changes.

Differential Revision:
parent c91c111e
......@@ -18,6 +18,7 @@
#include "desktopnotifier.h"
#include <KDesktopFile>
#include <KDirWatch>
#include <KPluginFactory>
#include <KPluginLoader>
......@@ -63,9 +64,20 @@ void DesktopNotifier::dirty(const QString &path)
if (path.startsWith(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + '/' + "Trash/files")) {
// Trigger an update of the trash icon
if (QFile::exists(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/trash.desktop"))
org::kde::KDirNotify::emitFilesChanged(QList<QUrl>() << QUrl(QStringLiteral("desktop:/trash.desktop")));
QList<QUrl> trashUrls;
// Check for any .desktop file linking to trash:/ to update its icon
const auto desktopFiles = QDir(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)).entryInfoList({QStringLiteral("*.desktop")});
for (const auto &fi : desktopFiles) {
KDesktopFile df(fi.absoluteFilePath());
if (df.hasLinkType() && df.readUrl() == QLatin1String("trash:/")) {
trashUrls << QUrl(QStringLiteral("desktop:/") + fi.fileName());
if (!trashUrls.isEmpty()) {
} else if (path == QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QStringLiteral("/user-dirs.dirs")){
} else {
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