File indexing completed on 2023-09-24 03:51:58
0001 /* 0002 * Copyright 2014 Aleix Pol Gonzalez <aleixpol@blue-systems.com> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Library General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2 of the License, or (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 * Library General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Library General Public License 0015 * along with this library; see the file COPYING.LIB. If not, write to 0016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef CLIPBOARD_H 0021 #define CLIPBOARD_H 0022 0023 #include <QClipboard> 0024 #include <QVariant> 0025 0026 class ClipboardPrivate; 0027 0028 class Clipboard : public QObject 0029 { 0030 Q_OBJECT 0031 /** 0032 * Controls the state this object will be monitoring and extracting its contents from. 0033 */ 0034 Q_PROPERTY(QClipboard::Mode mode READ mode WRITE setMode NOTIFY modeChanged) 0035 0036 /** 0037 * Provides the contents currently in the clipboard and lets modify them. 0038 */ 0039 Q_PROPERTY(QVariant content READ content WRITE setContent NOTIFY contentChanged) 0040 0041 /** 0042 * Figure out the nature of the contents in the clipboard. 0043 */ 0044 Q_PROPERTY(QStringList formats READ formats NOTIFY contentChanged) 0045 0046 public: 0047 explicit Clipboard(QObject* parent = nullptr); 0048 0049 QClipboard::Mode mode() const; 0050 void setMode(QClipboard::Mode mode); 0051 0052 Q_SCRIPTABLE QVariant contentFormat(const QString &format) const; 0053 QVariant content() const; 0054 void setContent(const QVariant &content); 0055 0056 QStringList formats() const; 0057 0058 Q_SCRIPTABLE void clear(); 0059 0060 Q_SIGNALS: 0061 void modeChanged(QClipboard::Mode mode); 0062 void contentChanged(); 0063 0064 private Q_SLOTS: 0065 void clipboardChanged(QClipboard::Mode m); 0066 0067 private: 0068 QClipboard* m_clipboard; 0069 QClipboard::Mode m_mode; 0070 }; 0071 0072 #endif