KWin
|
#include <scripting.h>
Public Slots | |
void | run () override |
![]() | |
void | stop () |
virtual void | run ()=0 |
Public Member Functions | |
Script (int id, QString scriptName, QString pluginName, QObject *parent=nullptr) | |
virtual | ~Script () |
Q_INVOKABLE QVariant | readConfig (const QString &key, const QVariant &defaultValue=QVariant()) |
Q_INVOKABLE void | callDBus (const QString &service, const QString &path, const QString &interface, const QString &method, const QJSValue &arg1=QJSValue(), const QJSValue &arg2=QJSValue(), const QJSValue &arg3=QJSValue(), const QJSValue &arg4=QJSValue(), const QJSValue &arg5=QJSValue(), const QJSValue &arg6=QJSValue(), const QJSValue &arg7=QJSValue(), const QJSValue &arg8=QJSValue(), const QJSValue &arg9=QJSValue()) |
Q_INVOKABLE bool | registerShortcut (const QString &objectName, const QString &text, const QString &keySequence, const QJSValue &callback) |
Q_INVOKABLE bool | registerScreenEdge (int edge, const QJSValue &callback) |
Q_INVOKABLE bool | unregisterScreenEdge (int edge) |
Q_INVOKABLE bool | registerTouchScreenEdge (int edge, const QJSValue &callback) |
Q_INVOKABLE bool | unregisterTouchScreenEdge (int edge) |
Q_INVOKABLE void | registerUserActionsMenu (const QJSValue &callback) |
Registers the given callback to be invoked whenever the UserActionsMenu is about to be showed. In the callback the script can create a further sub menu or menu entry to be added to the UserActionsMenu. | |
QList< QAction * > | actionsForUserActionMenu (Window *client, QMenu *parent) |
Creates actions for the UserActionsMenu by invoking the registered callbacks. | |
![]() | |
AbstractScript (int id, QString scriptName, QString pluginName, QObject *parent=nullptr) | |
~AbstractScript () override | |
int | scriptId () const |
QString | fileName () const |
const QString & | pluginName () |
bool | running () const |
KConfigGroup | config () const |
Additional Inherited Members | |
![]() | |
void | runningChanged (bool) |
![]() | |
void | setRunning (bool running) |
Definition at line 103 of file scripting.h.
KWin::Script::Script | ( | int | id, |
QString | scriptName, | ||
QString | pluginName, | ||
QObject * | parent = nullptr ) |
Definition at line 132 of file scripting.cpp.
|
virtual |
Definition at line 160 of file scripting.cpp.
QList< QAction * > KWin::Script::actionsForUserActionMenu | ( | KWin::Window * | client, |
QMenu * | parent ) |
Creates actions for the UserActionsMenu by invoking the registered callbacks.
This method invokes all the callbacks previously registered with registerUseractionsMenuCallback. The Client c
is passed in as an argument to the invoked method.
The invoked method is supposed to return a JavaScript object containing either the menu or menu entry to be added. In case the callback returns a null or undefined or any other invalid value, it is not considered for adding to the menu.
The JavaScript object structure for a menu entry looks like the following:
To construct a complete Menu the JavaScript object looks like the following:
The returned JavaScript object is introspected and for a menu entry a QAction is created, while for a menu a QMenu is created and QActions for the individual entries. Of course it is allowed to have nested structures.
All created objects are (grand) children to the passed in parent
menu, so that they get deleted whenever the menu is destroyed.
c | The Client for which the menu is invoked, passed to the callback |
parent | The Parent for the created Menus or Actions |
Definition at line 468 of file scripting.cpp.
void KWin::Script::callDBus | ( | const QString & | service, |
const QString & | path, | ||
const QString & | interface, | ||
const QString & | method, | ||
const QJSValue & | arg1 = QJSValue(), | ||
const QJSValue & | arg2 = QJSValue(), | ||
const QJSValue & | arg3 = QJSValue(), | ||
const QJSValue & | arg4 = QJSValue(), | ||
const QJSValue & | arg5 = QJSValue(), | ||
const QJSValue & | arg6 = QJSValue(), | ||
const QJSValue & | arg7 = QJSValue(), | ||
const QJSValue & | arg8 = QJSValue(), | ||
const QJSValue & | arg9 = QJSValue() ) |
Definition at line 299 of file scripting.cpp.
QVariant KWin::Script::readConfig | ( | const QString & | key, |
const QVariant & | defaultValue = QVariant() ) |
Definition at line 294 of file scripting.cpp.
bool KWin::Script::registerScreenEdge | ( | int | edge, |
const QJSValue & | callback ) |
Definition at line 395 of file scripting.cpp.
bool KWin::Script::registerShortcut | ( | const QString & | objectName, |
const QString & | text, | ||
const QString & | keySequence, | ||
const QJSValue & | callback ) |
Definition at line 374 of file scripting.cpp.
bool KWin::Script::registerTouchScreenEdge | ( | int | edge, |
const QJSValue & | callback ) |
Definition at line 425 of file scripting.cpp.
void KWin::Script::registerUserActionsMenu | ( | const QJSValue & | callback | ) |
Registers the given callback
to be invoked whenever the UserActionsMenu is about to be showed. In the callback the script can create a further sub menu or menu entry to be added to the UserActionsMenu.
callback | Script method to execute when the UserActionsMenu is about to be shown. |
Definition at line 459 of file scripting.cpp.
|
overrideslot |
Definition at line 164 of file scripting.cpp.
bool KWin::Script::unregisterScreenEdge | ( | int | edge | ) |
Definition at line 412 of file scripting.cpp.
bool KWin::Script::unregisterTouchScreenEdge | ( | int | edge | ) |
Definition at line 446 of file scripting.cpp.