1 /* This file is part of the KDE Project
2 Copyright (C) 2008 Fredrik Höglund <fredrik@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
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
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
19 #include "desktopnotifier.h"
23 #include <KGlobalSettings>
24 #include <KPluginFactory>
25 #include <KPluginLoader>
26 #include <KStandardDirs>
28 #include <kdirnotify.h>
31 K_PLUGIN_FACTORY(DesktopNotifierFactory
, registerPlugin
<DesktopNotifier
>();)
32 K_EXPORT_PLUGIN(DesktopNotifierFactory("kio_desktop"))
35 DesktopNotifier::DesktopNotifier(QObject
*parent
, const QList
<QVariant
> &)
38 KDirWatch
*dirWatch
= new KDirWatch(this);
39 dirWatch
->addDir(KGlobalSettings::desktopPath());
40 dirWatch
->addDir(KGlobal::dirs()->localxdgdatadir() + "Trash/files");
42 connect(dirWatch
, SIGNAL(dirty(QString
)), SLOT(dirty(QString
)));
45 void DesktopNotifier::dirty(const QString
&path
)
49 if (path
.startsWith(KGlobal::dirs()->localxdgdatadir() + "Trash/files")) {
50 // Trigger an update of the trash icon
51 if (QFile::exists(KGlobalSettings::desktopPath() + "/trash.desktop"))
52 org::kde::KDirNotify::emitFilesChanged(QStringList() << "desktop:/trash.desktop");
54 // Emitting FilesAdded forces a re-read of the dir
55 org::kde::KDirNotify::emitFilesAdded("desktop:/");