Merge clipboard.h and clipboard.cpp
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#define CLIPBOARD_H
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QClipboard>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
@@ -20,25 +21,48 @@ class Clipboard : public QObject
|
||||
Q_PROPERTY(bool supportsSelection READ supportsSelection CONSTANT)
|
||||
|
||||
public:
|
||||
explicit Clipboard(QObject *parent = 0);
|
||||
explicit Clipboard(QObject *parent = nullptr) : QObject(parent) {
|
||||
connect(this->clipboard, &QClipboard::dataChanged,
|
||||
this, &Clipboard::textChanged);
|
||||
|
||||
connect(this->clipboard, &QClipboard::selectionChanged,
|
||||
this, &Clipboard::selectionChanged);
|
||||
}
|
||||
|
||||
// Normal primary clipboard
|
||||
QString text() const;
|
||||
void setText(const QString &text);
|
||||
|
||||
QString text() const {
|
||||
return this->clipboard->text(QClipboard::Clipboard);
|
||||
}
|
||||
|
||||
void setText(const QString &text) const {
|
||||
this->clipboard->setText(text, QClipboard::Clipboard);
|
||||
}
|
||||
|
||||
// X11 select-middle-click-paste clipboard
|
||||
QString selection() const;
|
||||
void setSelection(const QString &text);
|
||||
|
||||
bool supportsSelection() const;
|
||||
QString selection() const {
|
||||
return this->clipboard->text(QClipboard::Selection);
|
||||
}
|
||||
|
||||
void setSelection(const QString &text) const {
|
||||
if (this->clipboard->supportsSelection()) {
|
||||
this->clipboard->setText(text, QClipboard::Selection);
|
||||
}
|
||||
}
|
||||
|
||||
// Info
|
||||
|
||||
bool supportsSelection() const {
|
||||
return this->clipboard->supportsSelection();
|
||||
}
|
||||
|
||||
signals:
|
||||
void textChanged();
|
||||
void selectionChanged();
|
||||
|
||||
private:
|
||||
QClipboard *m_clipboard = QGuiApplication::clipboard();
|
||||
QClipboard *clipboard = QGuiApplication::clipboard();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user