File indexing completed on 2024-04-14 04:51:48
0001 /** 0002 * SPDX-FileCopyrightText: 2017 Holger Kaelberer <holger.k@elberer.de> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <QDBusInterface> 0010 #include <QVariantMap> 0011 #include <core/kdeconnectplugin.h> 0012 0013 struct FakeKey; 0014 0015 #define PACKET_TYPE_MOUSEPAD_REQUEST QLatin1String("kdeconnect.mousepad.request") 0016 #define PACKET_TYPE_MOUSEPAD_ECHO QLatin1String("kdeconnect.mousepad.echo") 0017 #define PACKET_TYPE_MOUSEPAD_KEYBOARDSTATE QLatin1String("kdeconnect.mousepad.keyboardstate") 0018 0019 class RemoteKeyboardPlugin : public KdeConnectPlugin 0020 { 0021 Q_OBJECT 0022 Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.remotekeyboard") 0023 Q_PROPERTY(bool remoteState READ remoteState NOTIFY remoteStateChanged) 0024 0025 private: 0026 bool m_remoteState; 0027 0028 public: 0029 explicit RemoteKeyboardPlugin(QObject *parent, const QVariantList &args); 0030 0031 void receivePacket(const NetworkPacket &np) override; 0032 QString dbusPath() const override; 0033 0034 bool remoteState() const 0035 { 0036 return m_remoteState; 0037 } 0038 0039 Q_SCRIPTABLE void sendKeyPress(const QString &key, int specialKey = 0, bool shift = false, bool ctrl = false, bool alt = false, bool sendAck = true) const; 0040 Q_SCRIPTABLE void sendQKeyEvent(const QVariantMap &keyEvent, bool sendAck = true) const; 0041 Q_SCRIPTABLE int translateQtKey(int qtKey) const; 0042 0043 Q_SIGNALS: 0044 Q_SCRIPTABLE void keyPressReceived(const QString &key, int specialKey = 0, bool shift = false, bool ctrl = false, bool alt = false); 0045 Q_SCRIPTABLE void remoteStateChanged(bool state); 0046 };