Changeset View
Changeset View
Standalone View
Standalone View
kioslave/desktop/desktopnotifier.cpp
Show All 12 Lines | 1 | /* This file is part of the KDE Project | |||
---|---|---|---|---|---|
13 | You should have received a copy of the GNU Library General Public License | 13 | You should have received a copy of the GNU Library General Public License | ||
14 | along with this library; see the file COPYING.LIB. If not, write to | 14 | along with this library; see the file COPYING.LIB. If not, write to | ||
15 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 15 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
16 | Boston, MA 02110-1301, USA. | 16 | Boston, MA 02110-1301, USA. | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | #include "desktopnotifier.h" | 19 | #include "desktopnotifier.h" | ||
20 | 20 | | |||
21 | #include <KDesktopFile> | ||||
21 | #include <KDirWatch> | 22 | #include <KDirWatch> | ||
22 | #include <KPluginFactory> | 23 | #include <KPluginFactory> | ||
23 | #include <KPluginLoader> | 24 | #include <KPluginLoader> | ||
24 | 25 | | |||
25 | #include <kdirnotify.h> | 26 | #include <kdirnotify.h> | ||
26 | 27 | | |||
27 | #include <QStandardPaths> | 28 | #include <QStandardPaths> | ||
28 | #include <QFile> | 29 | #include <QFile> | ||
Show All 29 Lines | 56 | { | |||
58 | } | 59 | } | ||
59 | } | 60 | } | ||
60 | 61 | | |||
61 | void DesktopNotifier::dirty(const QString &path) | 62 | void DesktopNotifier::dirty(const QString &path) | ||
62 | { | 63 | { | ||
63 | Q_UNUSED(path) | 64 | Q_UNUSED(path) | ||
64 | 65 | | |||
65 | if (path.startsWith(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + '/' + "Trash/files")) { | 66 | if (path.startsWith(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + '/' + "Trash/files")) { | ||
66 | // Trigger an update of the trash icon | 67 | QList<QUrl> trashUrls; | ||
67 | if (QFile::exists(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/trash.desktop")) | 68 | | ||
68 | org::kde::KDirNotify::emitFilesChanged(QList<QUrl>() << QUrl(QStringLiteral("desktop:/trash.desktop"))); | 69 | // Check for any .desktop file linking to trash:/ to update its icon | ||
70 | const auto desktopFiles = QDir(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)).entryInfoList({QStringLiteral("*.desktop")}); | ||||
71 | for (const auto &fi : desktopFiles) { | ||||
72 | KDesktopFile df(fi.absoluteFilePath()); | ||||
73 | if (df.hasLinkType() && df.readUrl() == QLatin1String("trash:/")) { | ||||
74 | trashUrls << QUrl(QStringLiteral("desktop:/") + fi.fileName()); | ||||
75 | } | ||||
76 | } | ||||
77 | | ||||
78 | if (!trashUrls.isEmpty()) { | ||||
79 | org::kde::KDirNotify::emitFilesChanged(trashUrls); | ||||
80 | } | ||||
69 | } else if (path == QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QStringLiteral("/user-dirs.dirs")){ | 81 | } else if (path == QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QStringLiteral("/user-dirs.dirs")){ | ||
70 | checkDesktopLocation(); | 82 | checkDesktopLocation(); | ||
71 | } else { | 83 | } else { | ||
72 | // Emitting FilesAdded forces a re-read of the dir | 84 | // Emitting FilesAdded forces a re-read of the dir | ||
73 | QUrl url; | 85 | QUrl url; | ||
74 | url.setScheme(QStringLiteral("desktop")); | 86 | url.setScheme(QStringLiteral("desktop")); | ||
75 | const auto relativePath = QDir(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)).relativeFilePath(path); | 87 | const auto relativePath = QDir(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)).relativeFilePath(path); | ||
76 | url.setPath(QStringLiteral("%1/%2").arg(url.path(), relativePath)); | 88 | url.setPath(QStringLiteral("%1/%2").arg(url.path(), relativePath)); | ||
Show All 16 Lines |