moment/src/clipboard.cpp

43 lines
943 B
C++
Raw Normal View History

2019-12-18 09:50:21 +11:00
// Function implementations of the Clipboard class, see the clipboard.h file.
#include <QClipboard>
#include "clipboard.h"
Clipboard::Clipboard(QObject *parent)
: QObject(parent) {
connect(m_clipboard, &QClipboard::dataChanged,
this, &Clipboard::textChanged);
connect(m_clipboard, &QClipboard::selectionChanged,
this, &Clipboard::selectionChanged);
}
QString Clipboard::text() const {
return m_clipboard->text(QClipboard::Clipboard);
}
2019-12-18 09:50:21 +11:00
void Clipboard::setText(const QString &text) {
m_clipboard->setText(text, QClipboard::Clipboard);
}
QString Clipboard::selection() const {
return m_clipboard->text(QClipboard::Selection);
}
2019-12-18 09:50:21 +11:00
void Clipboard::setSelection(const QString &text) {
if (m_clipboard->supportsSelection()) {
m_clipboard->setText(text, QClipboard::Selection);
}
}
bool Clipboard::supportsSelection() const {
return m_clipboard->supportsSelection();
}