clipboard: make new Wayland implementation build on non-Apple unices only

This commit is contained in:
Piyush Aggarwal 2021-04-07 15:50:25 +05:30
parent 389a47b088
commit 80178b8ff8
2 changed files with 25 additions and 10 deletions

View file

@ -1,6 +1,8 @@
if(UNIX AND NOT APPLE)
find_package(QtWaylandScanner REQUIRED)
find_package(Wayland 1.15 COMPONENTS Client)
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS WaylandClient)
endif()
set(debug_file_SRCS)
ecm_qt_declare_logging_category(
@ -8,22 +10,27 @@ ecm_qt_declare_logging_category(
IDENTIFIER KDECONNECT_PLUGIN_CLIPBOARD CATEGORY_NAME kdeconnect.plugin.clipboard
DEFAULT_SEVERITY Warning
EXPORT kdeconnect-kde DESCRIPTION "kdeconnect (plugin clipboard)")
set(kdeconnect_clipboard_SRCS
clipboardplugin.cpp
clipboardlistener.cpp
datacontrol.cpp
${debug_file_SRCS}
)
if(UNIX AND NOT APPLE)
list(APPEND kdeconnect_clipboard_SRCS datacontrol.cpp)
ecm_add_qtwayland_client_protocol(kdeconnect_clipboard_SRCS
PROTOCOL wlr-data-control-unstable-v1.xml
BASENAME wlr-data-control-unstable-v1
)
set(kdeconnect_clipboard_WL_LINK_LIBS Qt5::GuiPrivate # for native interface to get wl_seat
Wayland::Client Qt::WaylandClient)
endif()
kdeconnect_add_plugin(kdeconnect_clipboard JSON kdeconnect_clipboard.json SOURCES ${kdeconnect_clipboard_SRCS})
target_link_libraries(kdeconnect_clipboard kdeconnectcore
Qt5::Gui
Qt5::GuiPrivate # for native interface to get wl_seat
Wayland::Client Qt::WaylandClient
${kdeconnect_clipboard_WL_LINK_LIBS}
)

View file

@ -8,7 +8,9 @@
#include <QDebug>
#include <QMimeData>
#if !defined(Q_OS_WIN) && !defined(Q_OS_MAC)
#include "datacontrol.h"
#endif
ClipboardListener::ClipboardListener()
{}
@ -27,11 +29,15 @@ ClipboardListener* ClipboardListener::instance()
{
static ClipboardListener* me = nullptr;
if (!me) {
#if !defined(Q_OS_WIN) && !defined(Q_OS_MAC)
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
me = new WaylandClipboardListener();
} else {
#endif
me = new QClipboardListener();
#if !defined(Q_OS_WIN) && !defined(Q_OS_MAC)
}
#endif
}
return me;
}
@ -72,6 +78,7 @@ void QClipboardListener::setText(const QString& content)
clipboard->setText(content);
}
#if !defined(Q_OS_WIN) && !defined(Q_OS_MAC)
WaylandClipboardListener::WaylandClipboardListener()
: m_dataControl(new DataControl(this))
{
@ -105,3 +112,4 @@ void WaylandClipboardListener::refresh(const QMimeData *mime)
refreshContent(content);
Q_EMIT clipboardChanged(content);
}
#endif