1// qclipboard.sip generated by MetaSIP
2//
3// This file is part of the QtGui Python extension module.
4//
5// Copyright (c) 2021 Riverbank Computing Limited <info@riverbankcomputing.com>
6//
7// This file is part of PyQt5.
8//
9// This file may be used under the terms of the GNU General Public License
10// version 3.0 as published by the Free Software Foundation and appearing in
11// the file LICENSE included in the packaging of this file.  Please review the
12// following information to ensure the GNU General Public License version 3.0
13// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
14//
15// If you do not wish to use this file under the terms of the GPL version 3.0
16// then you may purchase a commercial license.  For more information contact
17// info@riverbankcomputing.com.
18//
19// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21
22
23class QClipboard : QObject
24{
25%TypeHeaderCode
26#include <qclipboard.h>
27%End
28
29    explicit QClipboard(QObject *parent /TransferThis/);
30    virtual ~QClipboard();
31
32public:
33    enum Mode
34    {
35        Clipboard,
36        Selection,
37        FindBuffer,
38    };
39
40    void clear(QClipboard::Mode mode = QClipboard::Clipboard);
41    bool supportsFindBuffer() const;
42    bool supportsSelection() const;
43    bool ownsClipboard() const;
44    bool ownsFindBuffer() const;
45    bool ownsSelection() const;
46    QString text(QClipboard::Mode mode = QClipboard::Clipboard) const;
47    SIP_PYTUPLE text(const QString &subtype, QClipboard::Mode mode = QClipboard::Clipboard) const /TypeHint="Tuple[QString, QString]"/;
48%MethodCode
49        QString *text;
50        QString *subtype = new QString(*a0);
51
52        Py_BEGIN_ALLOW_THREADS
53        text = new QString(sipCpp->text(*subtype, a1));
54        Py_END_ALLOW_THREADS
55
56        PyObject *text_obj = sipConvertFromNewType(text, sipType_QString, NULL);
57        PyObject *subtype_obj = sipConvertFromNewType(subtype, sipType_QString, NULL);
58
59        if (text_obj && subtype_obj)
60            sipRes = PyTuple_Pack(2, text_obj, subtype_obj);
61
62        Py_XDECREF(text_obj);
63        Py_XDECREF(subtype_obj);
64%End
65
66    void setText(const QString &, QClipboard::Mode mode = QClipboard::Clipboard);
67    const QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard) const;
68    void setMimeData(QMimeData *data /GetWrapper/, QClipboard::Mode mode = QClipboard::Clipboard);
69%MethodCode
70        Py_BEGIN_ALLOW_THREADS
71        sipCpp->setMimeData(a0, a1);
72        Py_END_ALLOW_THREADS
73
74        // Transfer ownership to C++ and make sure the Python object stays alive by
75        // giving it a reference to itself.  The cycle will be broken by QMimeData's
76        // virtual dtor.  The reason we don't do the obvious and just use /Transfer/ is
77        // that the QClipboard Python object we would transfer ownership to is likely
78        // to be garbage collected immediately afterwards.
79        sipTransferTo(a0Wrapper, a0Wrapper);
80%End
81
82    QImage image(QClipboard::Mode mode = QClipboard::Clipboard) const;
83    QPixmap pixmap(QClipboard::Mode mode = QClipboard::Clipboard) const;
84    void setImage(const QImage &, QClipboard::Mode mode = QClipboard::Clipboard);
85    void setPixmap(const QPixmap &, QClipboard::Mode mode = QClipboard::Clipboard);
86
87signals:
88    void changed(QClipboard::Mode mode);
89    void dataChanged();
90    void findBufferChanged();
91    void selectionChanged();
92
93private:
94    QClipboard(const QClipboard &);
95};
96