chore(plasma_api): use macro for setter/getter generation

This commit is contained in:
Mikhail Zolotukhin 2022-02-15 20:49:24 +03:00 committed by Genda
parent 2d69fe6ee5
commit 75dd01e024
3 changed files with 21 additions and 12 deletions

View File

@ -0,0 +1,18 @@
// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin <mail@genda.life>
// SPDX-License-Identifier: MIT
#pragma once
#define BI_READ_ONLY_PROPERTY(TYPE, NAME) \
TYPE NAME() const \
{ \
return m_kwinImpl->property(#NAME).value<TYPE>(); \
}
#define BI_PROPERTY(TYPE, NAME, SETTER_NAME) \
BI_READ_ONLY_PROPERTY(TYPE, NAME) \
\
void SETTER_NAME(const TYPE &value) \
{ \
m_kwinImpl->setProperty(#NAME, QVariant::fromValue(value)); \
}

View File

@ -44,16 +44,6 @@ void Workspace::wrapSignals()
wrapComplexSignal(SIGNAL(currentDesktopChanged(int, KWin::AbstractClient *)), SLOT(currentDesktopChangedTransformer(int, KWin::AbstractClient *)));
};
int Workspace::currentDesktop()
{
return m_kwinImpl->property("currentDesktop").value<int>();
}
void Workspace::setCurrentDesktop(int desktop)
{
m_kwinImpl->setProperty("currentDesktop", QVariant::fromValue(desktop));
}
void Workspace::currentDesktopChangedTransformer(int desktop, KWin::AbstractClient *kwinClient)
{
// Since we don't know the KWin internal implementation we have to use reinterpret_cast

View File

@ -8,6 +8,8 @@
#include "plasma-api/client.hpp"
#include "utils.hpp"
// Forward declare KWin Classes
namespace KWin
{
@ -23,8 +25,7 @@ public:
Workspace(QQmlEngine *engine);
Workspace(const Workspace &);
int currentDesktop();
void setCurrentDesktop(int desktop);
BI_PROPERTY(int, currentDesktop, setCurrentDesktop);
public Q_SLOTS:
void currentDesktopChangedTransformer(int desktop, KWin::AbstractClient *kwinClient);