9#include "virtualkeyboardwatcher.h"
11#ifdef KIRIGAMI_ENABLE_DBUS
12#include "settings_interface.h"
13#include <QDBusConnection>
14#include <QDBusPendingCallWatcher>
17#include "kirigamiplatform_logging.h"
25Q_GLOBAL_STATIC(VirtualKeyboardWatcher, virtualKeyboardWatcherSelf)
27class KIRIGAMIPLATFORM_NO_EXPORT VirtualKeyboardWatcher::Private
29 static constexpr auto serviceName =
"org.freedesktop.portal.Desktop"_L1;
30 static constexpr auto objectName =
"/org/freedesktop/portal/desktop"_L1;
31 static constexpr auto interfaceName =
"org.kde.kwin.VirtualKeyboard"_L1;
33 static constexpr auto GROUP =
"org.kde.VirtualKeyboard"_L1;
34 static constexpr auto KEY_AVAILABLE =
"available"_L1;
35 static constexpr auto KEY_ENABLED =
"enabled"_L1;
36 static constexpr auto KEY_ACTIVE =
"active"_L1;
37 static constexpr auto KEY_VISIBLE =
"visible"_L1;
38 static constexpr auto KEY_WILL_SHOW_ON_ACTIVE =
"willShowOnActive"_L1;
41 Private(VirtualKeyboardWatcher *qq)
44#ifdef KIRIGAMI_ENABLE_DBUS
45 qDBusRegisterMetaType<VariantMapMap>();
49 &OrgFreedesktopPortalSettingsInterface::SettingChanged,
56 if (key == KEY_AVAILABLE) {
58 Q_EMIT q->availableChanged();
59 }
else if (key == KEY_ENABLED) {
61 Q_EMIT q->enabledChanged();
62 }
else if (key == KEY_ACTIVE) {
64 Q_EMIT q->activeChanged();
65 }
else if (key == KEY_VISIBLE) {
67 Q_EMIT q->visibleChanged();
68 }
else if (key == KEY_WILL_SHOW_ON_ACTIVE) {
77 VirtualKeyboardWatcher *q;
79#ifdef KIRIGAMI_ENABLE_DBUS
80 void getAllProperties();
81 void updateWillShowOnActive();
83 OrgFreedesktopPortalSettingsInterface *settingsInterface =
nullptr;
88 bool available =
false;
92 bool willShowOnActive =
false;
95VirtualKeyboardWatcher::VirtualKeyboardWatcher(
QObject *parent)
97 , d(std::make_unique<Private>(this))
101VirtualKeyboardWatcher::~VirtualKeyboardWatcher() =
default;
103bool VirtualKeyboardWatcher::available()
const
108bool VirtualKeyboardWatcher::enabled()
const
113bool VirtualKeyboardWatcher::active()
const
118bool VirtualKeyboardWatcher::visible()
const
123bool VirtualKeyboardWatcher::willShowOnActive()
const
125#ifdef KIRIGAMI_ENABLE_DBUS
126 d->updateWillShowOnActive();
128 return d->willShowOnActive;
131VirtualKeyboardWatcher *VirtualKeyboardWatcher::self()
133 return virtualKeyboardWatcherSelf();
136#ifdef KIRIGAMI_ENABLE_DBUS
138void VirtualKeyboardWatcher::Private::updateWillShowOnActive()
140 if (willShowOnActiveCall) {
144 willShowOnActiveCall =
new QDBusPendingCallWatcher(settingsInterface->Read(GROUP, KEY_WILL_SHOW_ON_ACTIVE), q);
150 if (reply.
value().toBool() != willShowOnActive) {
151 willShowOnActive = reply.
value().toBool();
152 Q_EMIT q->willShowOnActiveChanged();
156 willShowOnActiveCall =
nullptr;
160void VirtualKeyboardWatcher::Private::getAllProperties()
168 const auto groupValues = reply.
value().value(GROUP);
169 available = groupValues.value(KEY_AVAILABLE).toBool();
170 enabled = groupValues.value(KEY_ENABLED).toBool();
171 active = groupValues.value(KEY_ACTIVE).toBool();
172 visible = groupValues.value(KEY_VISIBLE).toBool();
173 willShowOnActive = groupValues.value(KEY_WILL_SHOW_ON_ACTIVE).toBool();
177 Q_EMIT q->availableChanged();
178 Q_EMIT q->enabledChanged();
179 Q_EMIT q->activeChanged();
180 Q_EMIT q->visibleChanged();
189#include "moc_virtualkeyboardwatcher.cpp"
QDBusConnection sessionBus()
QString message() const const
void finished(QDBusPendingCallWatcher *self)
QDBusError error() const const
bool isError() const const
typename Select< 0 >::Type value() const const
QVariant variant() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
bool toBool() const const