From 9175ae6cec0a6beb75eaf00bfe9961c1464088e5 Mon Sep 17 00:00:00 2001 From: Juha Paananen Date: Thu, 5 Aug 2010 13:20:39 +0300 Subject: Update quick launch favorites, if favorites directory is changed on disk. --- library/components/favoritescriptbutton.cpp | 9 +++++++++ library/components/favoritescriptbutton.h | 5 +++++ 2 files changed, 14 insertions(+) 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 #include #include +#include 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); } @@ -54,6 +57,12 @@ FavoriteScriptButton::~FavoriteScriptButton() } void FavoriteScriptButton::setPath(const QString &path) +{ + mFSWatcher->addPath(path); + refreshFileList(path); +} + +void FavoriteScriptButton::refreshFileList(const QString &path) { mMenu->clear(); 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 -- cgit v1.2.3