2014-06-27 14:41:47 +01:00
|
|
|
/**
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-FileCopyrightText: 2018 Albert Vaca Cintora <albertvaka@gmail.com>
|
|
|
|
* SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
* SPDX-FileCopyrightText: 2014 Ahmed I. Khalil <ahmedibrahimkhali@gmail.com>
|
2014-06-27 14:41:47 +01:00
|
|
|
*
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
2014-06-27 14:41:47 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "mousepadplugin.h"
|
2015-07-03 08:25:34 +01:00
|
|
|
#include <KLocalizedString>
|
2022-09-10 22:23:52 +01:00
|
|
|
#include <KPluginFactory>
|
2018-04-09 17:23:54 +01:00
|
|
|
#include <QGuiApplication>
|
2016-05-31 16:16:01 +01:00
|
|
|
|
2023-07-19 18:08:03 +01:00
|
|
|
#if defined(Q_OS_WIN)
|
2022-09-10 22:23:52 +01:00
|
|
|
#include "windowsremoteinput.h"
|
2023-07-19 18:08:03 +01:00
|
|
|
#elif defined(Q_OS_MACOS)
|
2022-09-10 22:23:52 +01:00
|
|
|
#include "macosremoteinput.h"
|
2018-04-02 19:20:24 +01:00
|
|
|
#else
|
2022-09-10 22:23:52 +01:00
|
|
|
#include "waylandremoteinput.h"
|
2023-07-19 18:08:03 +01:00
|
|
|
#if WITH_X11
|
|
|
|
#include "x11remoteinput.h"
|
2022-09-10 22:23:52 +01:00
|
|
|
#endif
|
2016-05-31 16:16:01 +01:00
|
|
|
#endif
|
2015-07-03 08:25:34 +01:00
|
|
|
|
2019-06-12 21:16:54 +01:00
|
|
|
K_PLUGIN_CLASS_WITH_JSON(MousepadPlugin, "kdeconnect_mousepad.json")
|
2014-06-27 14:41:47 +01:00
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
MousepadPlugin::MousepadPlugin(QObject *parent, const QVariantList &args)
|
2016-05-31 16:16:01 +01:00
|
|
|
: KdeConnectPlugin(parent, args)
|
2018-04-08 18:20:51 +01:00
|
|
|
, m_impl(nullptr)
|
2014-06-29 16:21:54 +01:00
|
|
|
{
|
2023-07-19 18:08:03 +01:00
|
|
|
#if defined(Q_OS_WIN)
|
2018-04-02 19:20:24 +01:00
|
|
|
m_impl = new WindowsRemoteInput(this);
|
2023-07-31 22:03:38 +01:00
|
|
|
#elif defined(Q_OS_MACOS)
|
2019-07-21 23:49:07 +01:00
|
|
|
m_impl = new MacOSRemoteInput(this);
|
2018-04-02 19:20:24 +01:00
|
|
|
#else
|
2018-04-08 18:20:51 +01:00
|
|
|
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
|
2018-04-02 19:20:24 +01:00
|
|
|
m_impl = new WaylandRemoteInput(this);
|
2016-09-29 09:54:33 +01:00
|
|
|
}
|
2023-07-19 18:08:03 +01:00
|
|
|
#if WITH_X11
|
|
|
|
if (QGuiApplication::platformName() == QLatin1String("xcb")) {
|
|
|
|
m_impl = new X11RemoteInput(this);
|
|
|
|
}
|
2022-09-10 22:23:52 +01:00
|
|
|
#endif
|
2016-09-29 09:54:33 +01:00
|
|
|
#endif
|
2018-04-08 18:20:51 +01:00
|
|
|
|
|
|
|
if (!m_impl) {
|
|
|
|
qDebug() << "KDE Connect was built without" << QGuiApplication::platformName() << "support";
|
|
|
|
}
|
2014-06-27 14:41:47 +01:00
|
|
|
}
|
2014-07-02 00:39:38 +01:00
|
|
|
|
2018-04-02 19:20:24 +01:00
|
|
|
MousepadPlugin::~MousepadPlugin()
|
2015-07-03 08:25:34 +01:00
|
|
|
{
|
2018-04-02 19:20:24 +01:00
|
|
|
delete m_impl;
|
2015-07-03 08:25:34 +01:00
|
|
|
}
|
|
|
|
|
2023-07-31 08:25:45 +01:00
|
|
|
void MousepadPlugin::receivePacket(const NetworkPacket &np)
|
2015-07-03 08:25:34 +01:00
|
|
|
{
|
2018-04-08 18:20:51 +01:00
|
|
|
if (m_impl) {
|
2023-07-31 08:25:45 +01:00
|
|
|
m_impl->handlePacket(np);
|
2018-04-08 18:20:51 +01:00
|
|
|
}
|
2015-07-03 08:25:34 +01:00
|
|
|
}
|
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
void MousepadPlugin::connected()
|
|
|
|
{
|
2018-05-12 16:51:55 +01:00
|
|
|
NetworkPacket np(PACKET_TYPE_MOUSEPAD_KEYBOARDSTATE);
|
2018-07-12 15:14:32 +01:00
|
|
|
if (m_impl) {
|
|
|
|
np.set<bool>(QStringLiteral("state"), m_impl->hasKeyboardSupport());
|
|
|
|
}
|
2018-05-12 16:51:55 +01:00
|
|
|
sendPacket(np);
|
|
|
|
}
|
|
|
|
|
2023-07-26 09:15:11 +01:00
|
|
|
#include "moc_mousepadplugin.cpp"
|
2014-07-02 00:39:38 +01:00
|
|
|
#include "mousepadplugin.moc"
|