Commit 640042ce authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

[AppMenu Applet] Support actions without menu

Applications could place actions in the main menu bar that do not have a menu.
Also restore the checked binding when clicked to avoid it highlighting even though there is no menu.
This might also fix some spurious highlighting that I've seen when switching between windows.

Differential Revision: https://phabricator.kde.org/D11168
parent b10f5bc7
......@@ -228,7 +228,13 @@ void AppMenuApplet::trigger(QQuickItem *ctx, int idx)
// FIXME TODO connect only once
connect(actionMenu, &QMenu::aboutToHide, this, &AppMenuApplet::onMenuAboutToHide, Qt::UniqueConnection);
return;
} else { // is it just an action without a menu?
const QVariant data = m_model->index(idx, 0).data(AppMenuModel::ActionRole);
QAction *action = static_cast<QAction *>(data.value<void *>());
if (action) {
Q_ASSERT(!action->menu());
action->trigger();
}
}
}
......
......@@ -124,6 +124,10 @@ Item {
visible: text !== ""
onClicked: {
plasmoid.nativeInterface.trigger(this, index)
checked = Qt.binding(function() {
return plasmoid.nativeInterface.currentIndex === index;
});
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment