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 * \class KSystemClipboard
19 * \inmodule KGuiAddons
20 * \brief Clipboard access for unfocussed windows.
21 *
22 * This class mimics QClipboard but unlike QClipboard it will continue
23 * to get updates even when our window does not have focus.
24 *
25 * This may require extra access permissions
26 *
27 * \since 5.89
28 */
29class KGUIADDONS_EXPORT KSystemClipboard : public QObject
30{
31 Q_OBJECT
32public:
33 /*!
34 * Returns a shared global SystemClipboard instance
35 */
36 static KSystemClipboard *instance();
37
38 /*!
39 * Sets the clipboard to the new contents
40 * The clipboard takes ownership of mime
41 */
42 virtual void setMimeData(QMimeData *mime, QClipboard::Mode mode) = 0;
43 /*!
44 * Clears the current clipboard
45 */
46 virtual void clear(QClipboard::Mode mode) = 0;
47 /*!
48 * Returns the current mime data received by the clipboard
49 */
50 virtual const QMimeData *mimeData(QClipboard::Mode mode) const = 0;
51 /*!
52 * Returns the text content of the Clipboard
53 *
54 * Similar to QClipboard::text(QClipboard::Mode mode)
55 */
56 QString text(QClipboard::Mode mode);
57Q_SIGNALS:
58 /*!
59 * Emitted when the clipboard changes similar to QClipboard::changed
60 */
61 void changed(QClipboard::Mode mode);
62
63protected:
64 KSystemClipboard(QObject *parent);
65};
66
67#endif
68

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