Add property for number of desktops to scripting

Adding macros to define the wraping code.
This commit is contained in:
Martin Gräßlin 2012-01-26 08:22:54 +01:00
parent 7b3c58280b
commit 26d069981d
2 changed files with 28 additions and 0 deletions

View file

@ -33,11 +33,24 @@ WorkspaceWrapper::WorkspaceWrapper(QObject* parent) : QObject(parent)
connect(ws, SIGNAL(clientAdded(KWin::Client*)), SLOT(setupClientConnections(KWin::Client*)));
connect(ws, SIGNAL(clientRemoved(KWin::Client*)), SIGNAL(clientRemoved(KWin::Client*)));
connect(ws, SIGNAL(clientActivated(KWin::Client*)), SIGNAL(clientActivated(KWin::Client*)));
connect(ws, SIGNAL(numberDesktopsChanged(int)), SIGNAL(numberDesktopsChanged(int)));
foreach (KWin::Client *client, ws->clientList()) {
setupClientConnections(client);
}
}
#define GETTERSETTER( rettype, getterName, setterName ) \
rettype WorkspaceWrapper::getterName( ) const { \
return Workspace::self()->getterName(); \
} \
void WorkspaceWrapper::setterName( rettype val ) { \
Workspace::self()->setterName( val ); \
}
GETTERSETTER(int, numberOfDesktops, setNumberOfDesktops)
#undef GETTERSETTER
QList< KWin::Client* > WorkspaceWrapper::clientList() const
{
return KWin::Workspace::self()->clientList();

View file

@ -42,6 +42,10 @@ class WorkspaceWrapper : public QObject
Q_PROPERTY(int workspaceWidth READ workspaceWidth)
Q_PROPERTY(int workspaceHeight READ workspaceHeight)
Q_PROPERTY(QSize workspaceSize READ workspaceSize)
/**
* The number of desktops currently used. Minimum number of desktops is 1, maximum 20.
**/
Q_PROPERTY(int desktops READ numberOfDesktops WRITE setNumberOfDesktops NOTIFY numberDesktopsChanged)
private:
Q_DISABLE_COPY(WorkspaceWrapper)
@ -60,9 +64,20 @@ signals:
void clientActivated(KWin::Client*);
void clientFullScreenSet(KWin::Client*, bool, bool);
void clientSetKeepAbove(KWin::Client*, bool);
/**
* Signal emitted whenever the number of desktops changed.
* To get the current number of desktops use the property desktops.
* @param oldNumberOfDesktops The previous number of desktops.
**/
void numberDesktopsChanged(int oldNumberOfDesktops);
public:
WorkspaceWrapper(QObject* parent = 0);
#define GETTERSETTERDEF( rettype, getter, setter ) \
rettype getter() const; \
void setter( rettype val );
GETTERSETTERDEF(int, numberOfDesktops, setNumberOfDesktops)
#undef GETTERSETTERDEF
int currentDesktop() const;
void setCurrentDesktop(int desktop);
KWin::Client *activeClient();