| Summary: | Allow Scripts to add menus to useractions menu | ||
|---|---|---|---|
| Product: | [Plasma] kwin | Reporter: | Martin Flöser <mgraesslin> |
| Component: | scripting | Assignee: | Martin Flöser <mgraesslin> |
| Status: | RESOLVED FIXED | ||
| Severity: | wishlist | CC: | kwin-bugs-null |
| Priority: | NOR | Flags: | mgraesslin:
ReviewRequest+
|
| Version First Reported In: | git master | ||
| Target Milestone: | 4.10 | ||
| Platform: | unspecified | ||
| OS: | Linux | ||
| URL: | https://git.reviewboard.kde.org/r/106285/ | ||
| Latest Commit: | http://commits.kde.org/kde-workspace/846715c278582f17deb501eade3b2641c70d6b4f | Version Fixed In: | 4.10 |
| Sentry Crash Report: | |||
|
Description
Martin Flöser
2012-07-18 17:21:13 UTC
Git commit 846715c278582f17deb501eade3b2641c70d6b4f by Martin Gräßlin.
Committed on 31/08/2012 at 13:28.
Pushed by graesslin into branch 'master'.
Allow Scripts to add menus to the UserActionsMenu
A script can register a callback through registerUserActionsMenu to be
informed when the UserActionsMenu is about to be shown. This menu calls
the Scripting component to gather actions to add to a Scripts submenu.
The Scripting component now asks all scripts for the actions, which will
invoke the registered callbacks with the Client for which the menu is to
be shown as argument.
The callback is supposed to return a JSON structure describing how the
menu should look like. The returned object can either be a menu item or
a complete menu. If multiple menu items or menus are supposed to be added
by the script it should just register multiple callbacks.
The structure for an item looks like the following:
{
text: "My caption",
checkable: true,
checked: false,
triggered: function (action) {
print("The triggered action as parameter");
}
}
The structure for a complete menu looks quite similar:
{
text: "My menu caption",
items: [
{...}, {...} // items as described above
]
}
The C++ part of the script parses the returned object and generates
either QAction or QMenu from it. All objects become children of the
scripts QMenu provided by the UserActionsMenu.
Before the menu is shown again the existing menu is deleted to ensure
that no outdated values from no longer existing scripts are around. This
means the scripts are queried each time the menu is shown.
FIXED-IN: 4.10
REVIEW: 106285
M +7 -0 kwin/scripting/documentation-global.xml
M +116 -0 kwin/scripting/scripting.cpp
M +108 -0 kwin/scripting/scripting.h
M +30 -1 kwin/scripting/scriptingutils.h
M +31 -0 kwin/useractions.cpp
M +4 -0 kwin/useractions.h
M +6 -0 kwin/workspace.h
http://commits.kde.org/kde-workspace/846715c278582f17deb501eade3b2641c70d6b4f
|