aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel/src/unitymenumodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libqmenumodel/src/unitymenumodel.cpp')
-rw-r--r--libqmenumodel/src/unitymenumodel.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp
index 70412a4..6e9a5f7 100644
--- a/libqmenumodel/src/unitymenumodel.cpp
+++ b/libqmenumodel/src/unitymenumodel.cpp
@@ -715,6 +715,40 @@ void UnityMenuModel::activate(int index, const QVariant& parameter)
}
}
+static QVariant parseVariantString(const QString& string)
+{
+ QVariant qvariant;
+ GVariant *gvariant;
+ GError *error = NULL;
+
+ if (string.isEmpty()) {
+ return qvariant;
+ }
+
+ gvariant = g_variant_parse (NULL, string.toStdString().c_str(), NULL, NULL, &error);
+
+ if (error) {
+ qWarning() << "Impossible to parse" << string << "as variant string:"<< error->message;
+ g_error_free (error);
+ return qvariant;
+ }
+
+ qvariant = Converter::toQVariant(gvariant);
+ g_variant_unref (gvariant);
+
+ return qvariant;
+}
+
+void UnityMenuModel::activateByVariantString(int index, const QString& parameter)
+{
+ activate(index, parseVariantString(parameter));
+}
+
+void UnityMenuModel::changeStateByVariantString(int index, const QString& parameter)
+{
+ changeState(index, parseVariantString(parameter));
+}
+
void UnityMenuModel::changeState(int index, const QVariant& parameter)
{
GSequenceIter *it;