summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuha Paananen <ext-juha.1.paananen@nokia.com>2010-08-05 13:20:39 +0300
committerJuha Paananen <ext-juha.1.paananen@nokia.com>2010-08-05 13:20:39 +0300
commit9175ae6cec0a6beb75eaf00bfe9961c1464088e5 (patch)
tree12e400c76d777d67da5744ad6cd9a7b3ec944f5c
parentc3942f1e917d68c8132f2672512f251c2f99b111 (diff)
Update quick launch favorites, if favorites directory is changed on disk.emulator
-rw-r--r--library/components/favoritescriptbutton.cpp9
-rw-r--r--library/components/favoritescriptbutton.h5
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