diff options
author | Juha Paananen <ext-juha.1.paananen@nokia.com> | 2010-08-05 13:20:39 +0300 |
---|---|---|
committer | Christian Kamm <christian.d.kamm@nokia.com> | 2010-11-08 13:49:44 +0100 |
commit | 26cd5e1601f85983a17ff082124eccf38683c9c3 (patch) | |
tree | cde6fcbdd477d2d7338654b067bb960df8c1dcd7 | |
parent | db1f7663b82019b16fb06e2ed7d7263d0b4a7149 (diff) |
Update quick launch favorites, if favorites directory is changed on disk.
(cherry picked from commit 9175ae6cec0a6beb75eaf00bfe9961c1464088e5)
-rw-r--r-- | library/components/favoritescriptbutton.cpp | 9 | ||||
-rw-r--r-- | library/components/favoritescriptbutton.h | 5 |
2 files changed, 14 insertions, 0 deletions
diff --git a/library/components/favoritescriptbutton.cpp b/library/components/favoritescriptbutton.cpp index cc87eba..7552c2b 100644 --- a/library/components/favoritescriptbutton.cpp +++ b/library/components/favoritescriptbutton.cpp @@ -33,6 +33,7 @@ #include <QtCore/QDir> #include <QtGui/QMenu> #include <QtGui/QIcon> +#include <QFileSystemWatcher> FavoriteScriptButton::FavoriteScriptButton(QWidget *parent) : QToolButton(parent) @@ -42,9 +43,11 @@ FavoriteScriptButton::FavoriteScriptButton(QWidget *parent) setToolTip(tr("Run script")); setProperty("noArrow", true); + mFSWatcher = new QFileSystemWatcher(this); mMenu = new QMenu(this); mActionToPath = new QSignalMapper(mMenu); connect(mActionToPath, SIGNAL(mapped(QString)), SIGNAL(scriptSelected(QString))); + connect(mFSWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(refreshFileList(QString))); setMenu(mMenu); } @@ -55,6 +58,12 @@ FavoriteScriptButton::~FavoriteScriptButton() void FavoriteScriptButton::setPath(const QString &path) { + mFSWatcher->addPath(path); + refreshFileList(path); +} + +void FavoriteScriptButton::refreshFileList(const QString &path) +{ mMenu->clear(); QDir dir(path); diff --git a/library/components/favoritescriptbutton.h b/library/components/favoritescriptbutton.h index 45d7091..b04d507 100644 --- a/library/components/favoritescriptbutton.h +++ b/library/components/favoritescriptbutton.h @@ -36,6 +36,7 @@ class QMenu; class QSignalMapper; +class QFileSystemWatcher; class REMOTECONTROLWIDGETSHARED_EXPORT FavoriteScriptButton : public QToolButton { @@ -49,9 +50,13 @@ public: signals: void scriptSelected(const QString &fileName); +private slots: + void refreshFileList(const QString &path); + private: QMenu *mMenu; QSignalMapper *mActionToPath; + QFileSystemWatcher* mFSWatcher; }; #endif //FAVORITESCRIPTBUTTON_H |