1/*
2 SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KSYSTEMCLIPBOARD_H
8#define KSYSTEMCLIPBOARD_H
9
10#include <kguiaddons_export.h>
11
12#include <QClipboard>
13#include <QObject>
14
15class QMimeData;
16
17/**
18 * This class mimics QClipboard but unlike QClipboard it will continue
19 * to get updates even when our window does not have focus.
20 *
21 * This may require extra access permissions
22 *
23 * @since 5.89
24 */
25class KGUIADDONS_EXPORT KSystemClipboard : public QObject
26{
27 Q_OBJECT
28public:
29 /**
30 * Returns a shared global SystemClipboard instance
31 */
32 static KSystemClipboard *instance();
33
34 /**
35 * Sets the clipboard to the new contents
36 * The clipboard takes ownership of mime
37 */
38 virtual void setMimeData(QMimeData *mime, QClipboard::Mode mode) = 0;
39 /**
40 * Clears the current clipboard
41 */
42 virtual void clear(QClipboard::Mode mode) = 0;
43 /**
44 * Returns the current mime data received by the clipboard
45 */
46 virtual const QMimeData *mimeData(QClipboard::Mode mode) const = 0;
47 /**
48 * Returns the text content of the Clipboard
49 *
50 * Similar to QClipboard::text(QClipboard::Mode mode)
51 */
52 QString text(QClipboard::Mode mode);
53Q_SIGNALS:
54 /**
55 * Emitted when the clipboard changes similar to QClipboard::changed
56 */
57 void changed(QClipboard::Mode mode);
58
59protected:
60 KSystemClipboard(QObject *parent);
61};
62
63#endif
64

source code of kguiaddons/src/systemclipboard/ksystemclipboard.h