KWin
Loading...
Searching...
No Matches
Public Slots | Public Member Functions | List of all members
KWin::Script Class Reference

#include <scripting.h>

Inheritance diagram for KWin::Script:
KWin::AbstractScript

Public Slots

void run () override
 
- Public Slots inherited from KWin::AbstractScript
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.
 
- Public Member Functions inherited from KWin::AbstractScript
 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

- Signals inherited from KWin::AbstractScript
void runningChanged (bool)
 
- Protected Member Functions inherited from KWin::AbstractScript
void setRunning (bool running)
 

Detailed Description

Definition at line 103 of file scripting.h.

Constructor & Destructor Documentation

◆ Script()

KWin::Script::Script ( int id,
QString scriptName,
QString pluginName,
QObject * parent = nullptr )

Definition at line 132 of file scripting.cpp.

◆ ~Script()

KWin::Script::~Script ( )
virtual

Definition at line 160 of file scripting.cpp.

Member Function Documentation

◆ actionsForUserActionMenu()

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:

{
title: "My Menu Entry",
checkable: true,
checked: false,
triggered: function (action) {
// callback when the menu entry is triggered with the QAction as argument
}
}

To construct a complete Menu the JavaScript object looks like the following:

{
title: "My Menu Title",
items: [{...}, {...}, ...] // list of menu entries as described above
}

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.

Parameters
cThe Client for which the menu is invoked, passed to the callback
parentThe Parent for the created Menus or Actions
Returns
QList< QAction* > List of QActions obtained from asking the registered callbacks
See also
registerUseractionsMenuCallback

Definition at line 468 of file scripting.cpp.

◆ callDBus()

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.

◆ readConfig()

QVariant KWin::Script::readConfig ( const QString & key,
const QVariant & defaultValue = QVariant() )

Definition at line 294 of file scripting.cpp.

◆ registerScreenEdge()

bool KWin::Script::registerScreenEdge ( int edge,
const QJSValue & callback )

Definition at line 395 of file scripting.cpp.

◆ registerShortcut()

bool KWin::Script::registerShortcut ( const QString & objectName,
const QString & text,
const QString & keySequence,
const QJSValue & callback )

Definition at line 374 of file scripting.cpp.

◆ registerTouchScreenEdge()

bool KWin::Script::registerTouchScreenEdge ( int edge,
const QJSValue & callback )

Definition at line 425 of file scripting.cpp.

◆ registerUserActionsMenu()

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.

Parameters
callbackScript method to execute when the UserActionsMenu is about to be shown.
Returns
void
See also
actionsForUserActionMenu

Definition at line 459 of file scripting.cpp.

◆ run

void KWin::Script::run ( )
overrideslot

Definition at line 164 of file scripting.cpp.

◆ unregisterScreenEdge()

bool KWin::Script::unregisterScreenEdge ( int edge)

Definition at line 412 of file scripting.cpp.

◆ unregisterTouchScreenEdge()

bool KWin::Script::unregisterTouchScreenEdge ( int edge)

Definition at line 446 of file scripting.cpp.


The documentation for this class was generated from the following files: