File indexing completed on 2023-12-03 07:42:27

0001 /*
0002     SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KSYSTEMCLIPBOARD_H
0008 #define KSYSTEMCLIPBOARD_H
0009 
0010 #include <kguiaddons_export.h>
0011 
0012 #include <QClipboard>
0013 #include <QObject>
0014 
0015 class QMimeData;
0016 
0017 /**
0018  * This class mimics QClipboard but unlike QClipboard it will continue
0019  * to get updates even when our window does not have focus.
0020  *
0021  * This may require extra access permissions
0022  *
0023  * @since 5.89
0024  */
0025 class KGUIADDONS_EXPORT KSystemClipboard : public QObject
0026 {
0027     Q_OBJECT
0028 public:
0029     /**
0030      * Returns a shared global SystemClipboard instance
0031      */
0032     static KSystemClipboard *instance();
0033 
0034     /**
0035      * Sets the clipboard to the new contents
0036      * The clipboard takes ownership of mime
0037      */
0038     virtual void setMimeData(QMimeData *mime, QClipboard::Mode mode) = 0;
0039     /**
0040      * Clears the current clipboard
0041      */
0042     virtual void clear(QClipboard::Mode mode) = 0;
0043     /**
0044      * Returns the current mime data received by the clipboard
0045      */
0046     virtual const QMimeData *mimeData(QClipboard::Mode mode) const = 0;
0047     /**
0048      * Returns the text content of the Clipboard
0049      *
0050      * Similar to QClipboard::text(QClipboard::Mode mode)
0051      */
0052     QString text(QClipboard::Mode mode);
0053 Q_SIGNALS:
0054     /**
0055      * Emitted when the clipboard changes similar to QClipboard::changed
0056      */
0057     void changed(QClipboard::Mode mode);
0058 
0059 protected:
0060     KSystemClipboard(QObject *parent);
0061 };
0062 
0063 #endif