Commit 8481a910 authored by Albert Vaca Cintora's avatar Albert Vaca Cintora

Migrated clipboard plugin to new format

parent 049c7087
......@@ -4,4 +4,4 @@ install(FILES kdeconnect_plugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR})
add_subdirectory(ping)
add_subdirectory(pausemusic)
add_subdirectory(mpriscontrol)
add_subdirectory(clipboard)
find_package(KDE4 REQUIRED)
include (KDE4Defaults)
include_directories(${KDE4_INCLUDES})
set(kdeconnect_clipboard_SRCS
clipboardplugin.cpp
../kdeconnectplugin.cpp
../pluginloader.cpp
../../networkpackage.cpp
../../device.cpp
)
kde4_add_plugin(kdeconnect_clipboard ${kdeconnect_clipboard_SRCS})
target_link_libraries(kdeconnect_clipboard
${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
${QT_QTNETWORK_LIBRARY}
qjson
)
install(TARGETS kdeconnect_clipboard DESTINATION ${PLUGIN_INSTALL_DIR} )
install(FILES kdeconnect_clipboard.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
......@@ -18,20 +18,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "clipboardpackageinterface.h"
#include "clipboardplugin.h"
#include <QClipboard>
#include <KDebug>
#include <QApplication>
ClipboardPackageInterface::ClipboardPackageInterface()
K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< ClipboardPlugin >(); )
K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_clipboard", "kdeconnect_clipboard") )
ClipboardPlugin::ClipboardPlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
{
clipboard = QApplication::clipboard();
ignore_next_clipboard_change = false;
connect(clipboard,SIGNAL(changed(QClipboard::Mode)),this,SLOT(clipboardChanged(QClipboard::Mode)));
}
void ClipboardPackageInterface::clipboardChanged(QClipboard::Mode mode)
void ClipboardPlugin::clipboardChanged(QClipboard::Mode mode)
{
if (mode != QClipboard::QClipboard::Clipboard) return;
......@@ -42,12 +46,12 @@ void ClipboardPackageInterface::clipboardChanged(QClipboard::Mode mode)
//qDebug() << "ClipboardChanged";
NetworkPackage np(PACKAGE_TYPE_CLIPBOARD);
np.set("content",clipboard->text());
emit sendPackage(np);
device()->sendPackage(np);
}
bool ClipboardPackageInterface::receivePackage(const Device& device, const NetworkPackage& np)
bool ClipboardPlugin::receivePackage(const NetworkPackage& np)
{
Q_UNUSED(device);
qDebug() << "AAAAAAAAAAAAAAAAAA";
if (np.type() == PACKAGE_TYPE_CLIPBOARD) {
ignore_next_clipboard_change = true;
clipboard->setText(np.get<QString>("content"));
......
......@@ -18,27 +18,26 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CLIPBOARDPACKAGEINTERFACE_H
#define CLIPBOARDPACKAGEINTERFACE_H
#ifndef CLIPBOARDPLUGIN_H
#define CLIPBOARDPLUGIN_H
#include <QObject>
#include <QClipboard>
#include "networkpackage.h"
#include "device.h"
#include "packageinterface.h"
#include "../kdeconnectplugin.h"
#include "../../networkpackage.h"
#include "../../device.h"
class ClipboardPackageInterface
: public PackageInterface
class ClipboardPlugin
: public KdeConnectPlugin
{
Q_OBJECT
public:
ClipboardPackageInterface();
virtual ~ClipboardPackageInterface() { }
explicit ClipboardPlugin(QObject *parent, const QVariantList &args);
public Q_SLOTS:
virtual bool receivePackage(const Device& device, const NetworkPackage& np);
virtual bool receivePackage(const NetworkPackage& np);
private Q_SLOTS:
void clipboardChanged(QClipboard::Mode mode);
......
[Desktop Entry]
Encoding=UTF-8
Type=Service
ServiceTypes=KdeConnect/Plugin
X-KDE-Library=kdeconnect_clipboard
X-KDE-PluginInfo-Author=Albert Vaca
X-KDE-PluginInfo-Email=albertvaka@gmail.com
X-KDE-PluginInfo-Name=kdeconnect_clipboard
X-KDE-PluginInfo-Version=0.1
X-KDE-PluginInfo-Website=http://albertvaka.wordpress.com
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
Icon=edit-paste
Name=Clipboard
Comment=Share the clipboard between devices
......@@ -18,8 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MPRISCONTROLPACKAGEINTERFACE_H
#define MPRISCONTROLPACKAGEINTERFACE_H
#ifndef MPRISCONTROLPLUGIN_H
#define MPRISCONTROLPLUGIN_H
#include <QSet>
#include <QString>
......@@ -45,10 +45,11 @@ private Q_SLOTS:
void propertiesChanged(const QString& interface, const QVariantMap& properties);
private:
QHash<QString, QString> playerList;
void addPlayer(const QString& ifaceName);
void removePlayer(const QString& ifaceName);
void sendPlayerList();
QHash<QString, QString> playerList;
int prevVolume;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment