The ClipboardEngine provides a service which in turn starts a ClipboardJob. The following operations are globally supported: * configureKlipper * clearHistory And the following operations are supported on uuid (base64): * select * remove * edit * barcode * action barcode is only supported if klipper gets compiled with prison support, this is announced as data element "supportsBarcodes" in the "clipboard" source of the DataEngine.wilder-5.14
parent
4555ed3ffb
commit
1b7c7dd2fe
8 changed files with 231 additions and 3 deletions
@ -0,0 +1,72 @@ |
|||||||
|
/********************************************************************
|
||||||
|
This file is part of the KDE project. |
||||||
|
|
||||||
|
Copyright (C) 2014 Martin Gräßlin <mgraesslin@kde.org> |
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify |
||||||
|
it under the terms of the GNU General Public License as published by |
||||||
|
the Free Software Foundation; either version 2 of the License, or |
||||||
|
(at your option) any later version. |
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, |
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
GNU General Public License for more details. |
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License |
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*********************************************************************/ |
||||||
|
#include "clipboardjob.h" |
||||||
|
#include "klipper.h" |
||||||
|
#include "history.h" |
||||||
|
#include "historyitem.h" |
||||||
|
|
||||||
|
ClipboardJob::ClipboardJob(Klipper *klipper, const QString &destination, const QString &operation, const QVariantMap ¶meters, QObject *parent) |
||||||
|
: Plasma::ServiceJob(destination, operation, parameters, parent) |
||||||
|
, m_klipper(klipper) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
void ClipboardJob::start() |
||||||
|
{ |
||||||
|
const QString operation = operationName(); |
||||||
|
// first check for operations not needing an item
|
||||||
|
if (operation == QLatin1String("clearHistory")) { |
||||||
|
m_klipper->slotAskClearHistory(); |
||||||
|
setResult(true); |
||||||
|
return; |
||||||
|
} else if (operation == QLatin1String("configureKlipper")) { |
||||||
|
m_klipper->slotConfigure(); |
||||||
|
setResult(true); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
// other operations need the item
|
||||||
|
HistoryItemConstPtr item = m_klipper->history()->find(QByteArray::fromBase64(destination().toUtf8())); |
||||||
|
if (item.isNull()) { |
||||||
|
setResult(false); |
||||||
|
return; |
||||||
|
} |
||||||
|
if (operation == QLatin1String("select")) { |
||||||
|
m_klipper->history()->slotMoveToTop(item->uuid()); |
||||||
|
setResult(true); |
||||||
|
} else if (operation == QLatin1String("remove")) { |
||||||
|
m_klipper->history()->remove(item); |
||||||
|
setResult(true); |
||||||
|
} else if (operation == QLatin1String("edit")) { |
||||||
|
m_klipper->editData(item); |
||||||
|
setResult(true); |
||||||
|
} else if (operation == QLatin1String("barcode")) { |
||||||
|
#ifdef HAVE_PRISON |
||||||
|
m_klipper->showBarcode(item); |
||||||
|
setResult(true); |
||||||
|
#else |
||||||
|
setResult(false); |
||||||
|
#endif |
||||||
|
} else if (operation == QLatin1String("action")) { |
||||||
|
m_klipper->urlGrabber()->invokeAction(item); |
||||||
|
setResult(true); |
||||||
|
} else { |
||||||
|
setResult(false); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,39 @@ |
|||||||
|
/********************************************************************
|
||||||
|
This file is part of the KDE project. |
||||||
|
|
||||||
|
Copyright (C) 2014 Martin Gräßlin <mgraesslin@kde.org> |
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify |
||||||
|
it under the terms of the GNU General Public License as published by |
||||||
|
the Free Software Foundation; either version 2 of the License, or |
||||||
|
(at your option) any later version. |
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, |
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
GNU General Public License for more details. |
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License |
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*********************************************************************/ |
||||||
|
#ifndef KLIPPER_CLIPBOARDJOB_H |
||||||
|
#define KLIPPER_CLIPBOARDJOB_H |
||||||
|
|
||||||
|
#include <Plasma/ServiceJob> |
||||||
|
|
||||||
|
class Klipper; |
||||||
|
|
||||||
|
class ClipboardJob : public Plasma::ServiceJob |
||||||
|
{ |
||||||
|
Q_OBJECT |
||||||
|
public: |
||||||
|
ClipboardJob(Klipper *klipper, const QString &destination, const QString &operation, const QVariantMap ¶meters, QObject *parent=0); |
||||||
|
~ClipboardJob() = default; |
||||||
|
|
||||||
|
void start() override; |
||||||
|
|
||||||
|
private: |
||||||
|
Klipper *m_klipper; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif |
||||||
@ -0,0 +1,33 @@ |
|||||||
|
/********************************************************************
|
||||||
|
This file is part of the KDE project. |
||||||
|
|
||||||
|
Copyright (C) 2014 Martin Gräßlin <mgraesslin@kde.org> |
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify |
||||||
|
it under the terms of the GNU General Public License as published by |
||||||
|
the Free Software Foundation; either version 2 of the License, or |
||||||
|
(at your option) any later version. |
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, |
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
GNU General Public License for more details. |
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License |
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*********************************************************************/ |
||||||
|
#include "clipboardservice.h" |
||||||
|
#include "clipboardjob.h" |
||||||
|
|
||||||
|
ClipboardService::ClipboardService(Klipper *klipper, const QString &uuid) |
||||||
|
: Plasma::Service() |
||||||
|
, m_klipper(klipper) |
||||||
|
, m_uuid(uuid) |
||||||
|
{ |
||||||
|
setName(QStringLiteral("org.kde.plasma.clipboard")); |
||||||
|
} |
||||||
|
|
||||||
|
Plasma::ServiceJob *ClipboardService::createJob(const QString &operation, QVariantMap ¶meters) |
||||||
|
{ |
||||||
|
return new ClipboardJob(m_klipper, m_uuid, operation, parameters, this); |
||||||
|
} |
||||||
@ -0,0 +1,41 @@ |
|||||||
|
/********************************************************************
|
||||||
|
This file is part of the KDE project. |
||||||
|
|
||||||
|
Copyright (C) 2014 Martin Gräßlin <mgraesslin@kde.org> |
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify |
||||||
|
it under the terms of the GNU General Public License as published by |
||||||
|
the Free Software Foundation; either version 2 of the License, or |
||||||
|
(at your option) any later version. |
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, |
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
GNU General Public License for more details. |
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License |
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*********************************************************************/ |
||||||
|
#ifndef KLIPPER_CLIPBOARDSERVICE_H |
||||||
|
#define KLIPPER_CLIPBOARDSERVICE_H |
||||||
|
|
||||||
|
#include <Plasma/Service> |
||||||
|
|
||||||
|
class Klipper; |
||||||
|
|
||||||
|
class ClipboardService : public Plasma::Service |
||||||
|
{ |
||||||
|
Q_OBJECT |
||||||
|
public: |
||||||
|
ClipboardService(Klipper *klipper, const QString &uuid); |
||||||
|
~ClipboardService() = default; |
||||||
|
|
||||||
|
protected: |
||||||
|
Plasma::ServiceJob *createJob(const QString &operation, QVariantMap ¶meters) override; |
||||||
|
|
||||||
|
private: |
||||||
|
Klipper *m_klipper; |
||||||
|
QString m_uuid; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!DOCTYPE kcfg SYSTEM |
||||||
|
"http://www.kde.org/standards/kcfg/1.0/kcfg.xsd"> |
||||||
|
<kcfg> |
||||||
|
<group name="select"> |
||||||
|
</group> |
||||||
|
<group name="remove"> |
||||||
|
</group> |
||||||
|
<group name="edit"> |
||||||
|
</group> |
||||||
|
<group name="barcode"> |
||||||
|
</group> |
||||||
|
<group name="action"> |
||||||
|
</group> |
||||||
|
<group name="configureKlipper"> |
||||||
|
</group> |
||||||
|
<group name="clearHistory"> |
||||||
|
</group> |
||||||
|
</kcfg> |
||||||
Loading…
Reference in new issue