[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [plasma-framework] src/scriptengines/qml/plasmoid: QML appletinterface: add support for actionTriger
From: Davide Bettio <bettio () kde ! org>
Date: 2014-04-22 18:09:59
Message-ID: E1Wcf8p-0003Ob-45 () scm ! kde ! org
[Download RAW message or body]
Git commit e1a2555278d7858283a2410ea2e04ce35673a152 by Davide Bettio.
Committed on 22/04/2014 at 18:08.
Pushed by bettio into branch 'master'.
QML appletinterface: add support for actionTrigered(name) method so we don't have to \
create an action_name method for each contextmenu action.
Signed-off-by: Davide Bettio <bettio@kde.org>
M +7 -1 src/scriptengines/qml/plasmoid/appletinterface.cpp
M +8 -0 src/scriptengines/qml/plasmoid/appletinterface.h
http://commits.kde.org/plasma-framework/e1a2555278d7858283a2410ea2e04ce35673a152
diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp \
b/src/scriptengines/qml/plasmoid/appletinterface.cpp index 7355ef9..dfa1c6d 100644
--- a/src/scriptengines/qml/plasmoid/appletinterface.cpp
+++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp
@@ -501,7 +501,13 @@ QStringList AppletInterface::downloadedFiles() const
void AppletInterface::executeAction(const QString &name)
{
if (qmlObject()->rootObject()) {
- QMetaObject::invokeMethod(qmlObject()->rootObject(), QString("action_" + \
name).toLatin1(), Qt::DirectConnection); + const QMetaObject *metaObj = \
qmlObject()->rootObject()->metaObject(); + QString actionMethodName = \
QString("action_" + name); + if \
(metaObj->indexOfMethod(QMetaObject::normalizedSignature((actionMethodName + \
"()").toLatin1())) != -1){ + \
QMetaObject::invokeMethod(qmlObject()->rootObject(), actionMethodName.toLatin1(), \
Qt::DirectConnection); + }else{
+ QMetaObject::invokeMethod(qmlObject()->rootObject(), "actionTriggered", \
Qt::DirectConnection, Q_ARG(QVariant, name)); + }
}
}
diff --git a/src/scriptengines/qml/plasmoid/appletinterface.h \
b/src/scriptengines/qml/plasmoid/appletinterface.h index 011cf19..31da8ec 100644
--- a/src/scriptengines/qml/plasmoid/appletinterface.h
+++ b/src/scriptengines/qml/plasmoid/appletinterface.h
@@ -189,6 +189,14 @@ public:
Q_INVOKABLE void setConfigurationRequired(bool needsConfiguring, const QString \
&reason = QString());
Q_INVOKABLE void setActionSeparator(const QString &name);
+ /**
+ * Add an action to the Plasmoid contextual menu.
+ * When the action is triggered a function called action_<name> will be called, \
if there is no function with that name actionTriggered(name) will be called instead. \
+ * @param: action name + * @text: user visible displayed text
+ * @icon: user visible optional displayed icon
+ * @shortcut: shortcut to trigger this action
+ */
Q_INVOKABLE void setAction(const QString &name, const QString &text,
const QString &icon = QString(), const QString \
&shortcut = QString());
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic