mirror of
https://github.com/Bismuth-Forge/bismuth.git
synced 2024-09-11 00:15:37 +03:00
chore(plasma_api): use macro for setter/getter generation
This commit is contained in:
parent
2d69fe6ee5
commit
75dd01e024
18
src/core/plasma-api/utils.hpp
Normal file
18
src/core/plasma-api/utils.hpp
Normal 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)); \
|
||||
}
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user