Add C++ Clipboard class accessible from QML

This commit is contained in:
miruka
2019-10-25 08:36:24 -04:00
parent 7090ff601f
commit 30823a9bf5
4 changed files with 79 additions and 2 deletions

37
src/clipboard.h Normal file
View File

@@ -0,0 +1,37 @@
#ifndef CLIPBOARD_H
#define CLIPBOARD_H
#include <QGuiApplication>
#include <QObject>
class Clipboard : public QObject
{
Q_OBJECT
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(QString selection READ selection WRITE setSelection
NOTIFY selectionChanged)
Q_PROPERTY(bool supportsSelection READ supportsSelection CONSTANT)
public:
explicit Clipboard(QObject *parent = 0);
QString text() const;
void setText(const QString &text);
QString selection() const;
void setSelection(const QString &text);
bool supportsSelection() const;
signals:
void textChanged();
void selectionChanged();
private:
QClipboard *m_clipboard = QGuiApplication::clipboard();
};
#endif