kdeconnect-kde/plugins/mousepad/mousepadplugin.cpp

75 lines
1.8 KiB
C++
Raw Normal View History

/**
* 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>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "mousepadplugin.h"
#include <KLocalizedString>
#include <KPluginFactory>
2018-04-09 17:23:54 +01:00
#include <QGuiApplication>
#if defined(Q_OS_WIN)
#include "windowsremoteinput.h"
#elif defined(Q_OS_MACOS)
#include "macosremoteinput.h"
#else
#include "waylandremoteinput.h"
#if WITH_X11
#include "x11remoteinput.h"
#endif
#endif
2019-06-12 21:16:54 +01:00
K_PLUGIN_CLASS_WITH_JSON(MousepadPlugin, "kdeconnect_mousepad.json")
MousepadPlugin::MousepadPlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
, m_impl(nullptr)
{
#if defined(Q_OS_WIN)
m_impl = new WindowsRemoteInput(this);
#elif defined(Q_OS_APPLE)
m_impl = new MacOSRemoteInput(this);
#else
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
m_impl = new WaylandRemoteInput(this);
}
#if WITH_X11
if (QGuiApplication::platformName() == QLatin1String("xcb")) {
m_impl = new X11RemoteInput(this);
}
#endif
#endif
if (!m_impl) {
qDebug() << "KDE Connect was built without" << QGuiApplication::platformName() << "support";
}
}
2014-07-02 00:39:38 +01:00
MousepadPlugin::~MousepadPlugin()
{
delete m_impl;
}
bool MousepadPlugin::receivePacket(const NetworkPacket &np)
{
if (m_impl) {
return m_impl->handlePacket(np);
} else {
return false;
}
}
void MousepadPlugin::connected()
{
NetworkPacket np(PACKET_TYPE_MOUSEPAD_KEYBOARDSTATE);
if (m_impl) {
np.set<bool>(QStringLiteral("state"), m_impl->hasKeyboardSupport());
}
sendPacket(np);
}
2014-07-02 00:39:38 +01:00
#include "mousepadplugin.moc"