summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2010-04-14 11:18:33 +0200
committerChristian Kamm <christian.d.kamm@nokia.com>2010-04-14 11:18:33 +0200
commite550b1b135d8ac5f5a904ce061254ab52154afc1 (patch)
treea15187ffed982d640f3c7fca60de9e9ef0f622ac
parentdf42322a0cd1454bef4def257380d92bd8b66c5c (diff)
Add a new component: the favorite script button.
It allows easy access to scripts in a given directory. Reviewed-by: owolff
-rw-r--r--library/components/component.qrc1
-rw-r--r--library/components/favoritescriptbutton.cpp66
-rw-r--r--library/components/favoritescriptbutton.h57
-rw-r--r--library/components/images/favoriteScripts.pngbin0 -> 516 bytes
-rw-r--r--library/remotecontrolwidget.pro2
5 files changed, 126 insertions, 0 deletions
diff --git a/library/components/component.qrc b/library/components/component.qrc
index 26b2a8a..c36f7cf 100644
--- a/library/components/component.qrc
+++ b/library/components/component.qrc
@@ -17,5 +17,6 @@
<file>images/networkstatus3.png</file>
<file>images/networkstatus4.png</file>
<file>images/networkstatus5.png</file>
+ <file>images/favoriteScripts.png</file>
</qresource>
</RCC>
diff --git a/library/components/favoritescriptbutton.cpp b/library/components/favoritescriptbutton.cpp
new file mode 100644
index 0000000..3e0a157
--- /dev/null
+++ b/library/components/favoritescriptbutton.cpp
@@ -0,0 +1,66 @@
+/**************************************************************************
+**
+** This file is part of Remote Control Widget
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+#include "favoritescriptbutton.h"
+
+#include <QtCore/QSignalMapper>
+#include <QtCore/QDir>
+#include <QtGui/QMenu>
+#include <QtGui/QIcon>
+
+FavoriteScriptButton::FavoriteScriptButton(QWidget *parent)
+ : QToolButton(parent)
+{
+ setPopupMode(QToolButton::InstantPopup);
+ setIcon(QIcon(":/components/images/favoriteScripts.png"));
+ setProperty("noArrow", true);
+
+ mMenu = new QMenu(this);
+ mActionToPath = new QSignalMapper(mMenu);
+ connect(mActionToPath, SIGNAL(mapped(QString)), SIGNAL(scriptSelected(QString)));
+
+ setMenu(mMenu);
+}
+
+FavoriteScriptButton::~FavoriteScriptButton()
+{
+}
+
+void FavoriteScriptButton::setPath(const QString &path)
+{
+ mMenu->clear();
+
+ QDir dir(path);
+ QStringList scriptPatterns;
+ scriptPatterns << "*.js" << "*.qs";
+ foreach (const QFileInfo &file, dir.entryInfoList(scriptPatterns, QDir::Files)) {
+ QAction *action = mMenu->addAction(file.baseName(), mActionToPath, SLOT(map()));
+ mActionToPath->setMapping(action, file.filePath());
+ }
+}
diff --git a/library/components/favoritescriptbutton.h b/library/components/favoritescriptbutton.h
new file mode 100644
index 0000000..45d7091
--- /dev/null
+++ b/library/components/favoritescriptbutton.h
@@ -0,0 +1,57 @@
+/**************************************************************************
+**
+** This file is part of Remote Control Widget
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+#ifndef FAVORITESCRIPTBUTTON_H
+#define FAVORITESCRIPTBUTTON_H
+
+#include "remotecontrolwidget_global.h"
+
+#include <QtGui/QToolButton>
+
+class QMenu;
+class QSignalMapper;
+
+class REMOTECONTROLWIDGETSHARED_EXPORT FavoriteScriptButton : public QToolButton
+{
+ Q_OBJECT
+public:
+ explicit FavoriteScriptButton(QWidget *parent = 0);
+ virtual ~FavoriteScriptButton();
+
+ void setPath(const QString &path);
+
+signals:
+ void scriptSelected(const QString &fileName);
+
+private:
+ QMenu *mMenu;
+ QSignalMapper *mActionToPath;
+};
+
+#endif //FAVORITESCRIPTBUTTON_H
diff --git a/library/components/images/favoriteScripts.png b/library/components/images/favoriteScripts.png
new file mode 100644
index 0000000..1348354
--- /dev/null
+++ b/library/components/images/favoriteScripts.png
Binary files differ
diff --git a/library/remotecontrolwidget.pro b/library/remotecontrolwidget.pro
index 2ea3ebb..ad036bd 100644
--- a/library/remotecontrolwidget.pro
+++ b/library/remotecontrolwidget.pro
@@ -32,6 +32,7 @@ SOURCES += \
components/batterybutton.cpp \
components/networkmodebutton.cpp \
components/signalstrengthbutton.cpp \
+ components/favoritescriptbutton.cpp \
components/scriptui.cpp
PUBLIC_HEADERS += \
@@ -45,6 +46,7 @@ PUBLIC_HEADERS += \
components/batterybutton.h \
components/networkmodebutton.h \
components/signalstrengthbutton.h \
+ components/favoritescriptbutton.h \
components/scriptui.h
HEADERS += $$PUBLIC_HEADERS \