File indexing completed on 2024-09-01 03:32:52
0001 // SPDX-FileCopyrightText: 2014 by Aleix Pol <aleixpol@kde.org> 0002 // SPDX-License-Identifier: GPL-2.0-or-later 0003 0004 #ifndef CLIPBOARD_H 0005 #define CLIPBOARD_H 0006 0007 #include <QClipboard> 0008 #include <QVariant> 0009 0010 class ClipboardPrivate; 0011 0012 class Clipboard : public QObject 0013 { 0014 Q_OBJECT 0015 /** 0016 * Controls the state this object will be monitoring and extracting its contents from. 0017 */ 0018 Q_PROPERTY(QClipboard::Mode mode READ mode WRITE setMode NOTIFY modeChanged) 0019 0020 /** 0021 * Provides the contents currently in the clipboard and lets modify them. 0022 */ 0023 Q_PROPERTY(QVariant content READ content WRITE setContent NOTIFY contentChanged) 0024 0025 /** 0026 * Figure out the nature of the contents in the clipboard. 0027 */ 0028 Q_PROPERTY(QStringList formats READ formats NOTIFY contentChanged) 0029 0030 public: 0031 explicit Clipboard(QObject *parent = nullptr); 0032 0033 QClipboard::Mode mode() const; 0034 void setMode(QClipboard::Mode mode); 0035 0036 Q_SCRIPTABLE QVariant contentFormat(const QString &format) const; 0037 QVariant content() const; 0038 void setContent(const QVariant &content); 0039 0040 QStringList formats() const; 0041 0042 Q_SCRIPTABLE void clear(); 0043 0044 Q_SIGNALS: 0045 void modeChanged(QClipboard::Mode mode); 0046 void contentChanged(); 0047 0048 private Q_SLOTS: 0049 void clipboardChanged(QClipboard::Mode m); 0050 0051 private: 0052 QClipboard *m_clipboard; 0053 QClipboard::Mode m_mode; 0054 }; 0055 0056 #endif