diff options
Diffstat (limited to 'libqmenumodel/src/unitymenumodel.cpp')
-rw-r--r-- | libqmenumodel/src/unitymenumodel.cpp | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp index 658fdca..d9dc542 100644 --- a/libqmenumodel/src/unitymenumodel.cpp +++ b/libqmenumodel/src/unitymenumodel.cpp @@ -289,7 +289,7 @@ UnityMenuModel::UnityMenuModel(QObject *parent): priv = new UnityMenuModelPrivate(this); } -UnityMenuModel::UnityMenuModel(const UnityMenuModelPrivate& other, QObject *parent): +UnityMenuModel::UnityMenuModel(const UnityMenuModelPrivate& other, UnityMenuModel *parent): QAbstractListModel(parent) { priv = new UnityMenuModelPrivate(other, this); @@ -729,6 +729,47 @@ void UnityMenuModel::activate(int index, const QVariant& parameter) } } +void UnityMenuModel::aboutToShow(int index) +{ + GSequenceIter *it = g_sequence_get_iter_at_pos (priv->items, index); + if (g_sequence_iter_is_end (it)) { + return; + } + + auto item = static_cast<GtkMenuTrackerItem*>(g_sequence_get(it)); + if (!item) { + return; + } + + quint64 actionTag; + if (gtk_menu_tracker_item_get_attribute (item, "qtubuntu-tag", "t", &actionTag)) { + // Child UnityMenuModel have priv->connection null, so climb to the parent until we find a non null one + UnityMenuModelPrivate *privToUse = priv; + while (privToUse && !privToUse->connection) { + auto pModel = dynamic_cast<UnityMenuModel*>(privToUse->model->QObject::parent()); + if (pModel) { + privToUse = pModel->priv; + } else { + privToUse = nullptr; + } + } + if (privToUse) { + g_dbus_connection_call (privToUse->connection, + privToUse->busName, + privToUse->menuObjectPath, + "qtubuntu.actions.extra", + "aboutToShow", + g_variant_new("(t)", actionTag), + nullptr, + G_DBUS_CALL_FLAGS_NO_AUTO_START, + G_MAXINT, + nullptr, + nullptr, + nullptr); + } + } +} + void UnityMenuModel::activateByVariantString(int index, const QString& parameter) { activate(index, Converter::toQVariantFromVariantString(parameter)); |