From e0f97946afb058ba1a2e90dca4452d6c36e86228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 27 Mar 2012 22:21:06 +0200 Subject: [PATCH] Add QML specific export of ClientList Sometimes Qt is surprising. Apparently QML has problems with a QList and wants to have a QList which cannot be used in QtScript. There ends my dream of having one API for both JavaScript and QML. So with QtScript it is: workspace.clientList() and in QML it is: workspace.getClientList() --- scripting/workspace_wrapper.cpp | 9 +++++++++ scripting/workspace_wrapper.h | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/scripting/workspace_wrapper.cpp b/scripting/workspace_wrapper.cpp index c0de0783e2..e99d9b0d9b 100644 --- a/scripting/workspace_wrapper.cpp +++ b/scripting/workspace_wrapper.cpp @@ -186,6 +186,15 @@ QString WorkspaceWrapper::supportInformation() const return Workspace::self()->supportInformation(); } +QList< QObject* > WorkspaceWrapper::getClientList() const +{ + QList list; + foreach (Client* client, Workspace::self()->clientList()) { + list << client; + } + return list; +} + void WorkspaceWrapper::setupClientConnections(KWin::Client *client) { connect(client, SIGNAL(clientMinimized(KWin::Client*,bool)), SIGNAL(clientMinimized(KWin::Client*))); diff --git a/scripting/workspace_wrapper.h b/scripting/workspace_wrapper.h index c4ea8f68f6..de2ce9075d 100644 --- a/scripting/workspace_wrapper.h +++ b/scripting/workspace_wrapper.h @@ -136,6 +136,15 @@ void setter( rettype val ); int activeScreen() const; int numScreens() const; + /** + * List of Clients currently managed by KWin. + * Use this method in QML scripts. + **/ + Q_INVOKABLE QList< QObject* > getClientList() const; + /** + * List of Clients currently managed by KWin. + * Use this method in JavaScript scripts. + **/ Q_INVOKABLE QList< KWin::Client* > clientList() const; /** * Returns the geometry a Client can use with the specified option.