kf.guiaddons: Could not init WaylandClipboard, falling back to QtClipboard.
Hello, Thanks for Developing this library. I am try to use ksystemclipbord to get the clipboard content from background but it fails,
kf.guiaddons: Could not init WaylandClipboard, falling back to QtClipboard.
I have installed all the required libraries with this script,
git clone https://github.com/KDE/extra-cmake-modules.git
cd extra-cmake-modules
git checkout v6.2.0
cmake -B ./build -DCMAKE_INSTALL_PREFIX="/opt/kderoot" -DCMAKE_BUILD_TYPE=Release -DQT_MAJOR_VERSION=6 -DCMAKE_PREFIX_PATH="${QT_CMAKE_DIR}"
cmake --build ./build --config Release --target install
cd build
make
sudo make install
cd ../..
rm -rf extra-cmake-modules
git clone https://github.com/KDE/plasma-wayland-protocols.git
cd plasma-wayland-protocols
cmake -B ./build -DCMAKE_INSTALL_PREFIX="/opt/kderoot" -DCMAKE_BUILD_TYPE=Release -DQT_MAJOR_VERSION=6 -DCMAKE_PREFIX_PATH="${QT_CMAKE_DIR}"
cmake --build ./build --config Release --target install
cd build
make
sudo make install
cd ../..
rm -rf plasma-wayland-protocols
git clone https://github.com/KDE/kguiaddons.git
cd kguiaddons
git checkout v6.2.0
cmake -B ./build -DCMAKE_INSTALL_PREFIX="/opt/kderoot" -DCMAKE_BUILD_TYPE=Release -DQT_MAJOR_VERSION=6 -DCMAKE_PREFIX_PATH="${QT_CMAKE_DIR}"
cmake --build ./build --config Release --target install
cd build
make
sudo make install
cd ../..
rm -rf kguiaddons
and In cmake I include like this,
if(WIN32 OR APPLE)
find_package(Bonjour REQUIRED)
elseif(UNIX AND NOT APPLE)
find_package(KF6GuiAddons REQUIRED)
find_package(Avahi REQUIRED)
else()
message(FATAL_ERROR "Platform not supported")
endif()
...
if(UNIX AND NOT APPLE)
target_link_libraries(clipbird PRIVATE KF6::GuiAddons)
target_include_directories(clipbird PUBLIC ${Avahi_INCLUDE_DIRS})
target_link_libraries(clipbird PUBLIC ${Avahi_LIBRARIES})
target_include_directories(clipbird PUBLIC ${DBUS_INCLUDE_DIRS})
target_link_libraries(clipbird PUBLIC ${DBUS_LIBRARIES})
target_include_directories(clipbird PUBLIC ${LIBNOTIFY_INCLUDE_DIRS})
target_link_libraries(clipbird PUBLIC ${LIBNOTIFY_LIBRARIES})
add_definitions(-D__linux__)
endif()
In C++,
#pragma once // Header guard see https://en.wikipedia.org/wiki/Include_guard
// Copyright (c) 2023 Sri Lakshmi Kanthan P
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
// Qt header
#include <QApplication>
#include <QBuffer>
#include <QByteArray>
#include <QClipboard>
#include <QIODevice>
#include <QImage>
#include <QImageReader>
#include <QList>
#include <QMimeData>
#include <QObject>
#include <QPair>
#include <QString>
#include <QUrl>
#include <QVector>
#include <QtConcurrent>
// KSystem Clipboard header
#include <KSystemClipboard>
// project header
#include "types/except/except.hpp"
namespace srilakshmikanthanp::clipbirdesk::clipboard {
/**
* @brief Class to manage clipboard such get,
* set and notify the clipboard change
*/
class Clipboard : public QObject {
signals: // signals
/**
* @brief Signal to notify the clipboard change occurrence use
* the parameter or get method to get the clipboard data
* @param items clipboard data
*/
void OnClipboardChange(QVector<QPair<QString, QByteArray>>);
private: // members
// Use m_clipboard to only get, set and clear the clipboard
// for other operations use QApplication::clipboard()
KSystemClipboard *m_clipboard = KSystemClipboard::instance();
private: // just for Qt
/// @brief Qt meta object
Q_OBJECT
private: // disable copy and move
Q_DISABLE_COPY_MOVE(Clipboard)
private: // private slots
/// @brief Slot to notify the clipboard change
void onClipboardChangeImpl();
private: // mime types
const QString MIME_TYPE_TEXT = "text/plain";
const QString MIME_TYPE_PNG = "image/png";
const QString MIME_TYPE_HTML = "text/html";
private: // image type
const char* IMAGE_TYPE_PNG = "PNG";
public: // constructor
/**
* @brief Construct a new Clipboard object and manage
* the clipboard that is passed via the constructor
*
* @param clipboard Clipboard that is managed
* @param parent parent object
*/
explicit Clipboard(QObject* parent = nullptr);
/**
* @brief Get the clipboard data from the clipboard
*
* @return mime type and data
*/
QVector<QPair<QString, QByteArray>> get() const;
/**
* @brief Clear the clipboard content
*/
void clear();
/**
* @brief Set the clipboard data to the clipboard
*
* @param mime mime type of the data
* @param data data to be set
*/
void set(const QVector<QPair<QString, QByteArray>> data);
};
} // namespace srilakshmikanthanp::clipbirdesk::clipboard
What i am doing wrong, I am happy to provide any aditional info required, Thanks.