Merge clipboard.h and clipboard.cpp
This commit is contained in:
parent
715a6ca530
commit
bbdc16c5c9
|
@ -12,10 +12,8 @@ RCC_DIR = $$BUILD_DIR/rcc
|
||||||
QRC_FILE = $$BUILD_DIR/resources.qrc
|
QRC_FILE = $$BUILD_DIR/resources.qrc
|
||||||
|
|
||||||
RESOURCES += $$QRC_FILE
|
RESOURCES += $$QRC_FILE
|
||||||
HEADERS += src/utils.h src/clipboard.h \
|
HEADERS += src/utils.h src/clipboard.h submodules/hsluv-c/src/hsluv.h
|
||||||
submodules/hsluv-c/src/hsluv.h
|
SOURCES += src/main.cpp submodules/hsluv-c/src/hsluv.c
|
||||||
SOURCES += src/main.cpp src/clipboard.cpp \
|
|
||||||
submodules/hsluv-c/src/hsluv.c
|
|
||||||
TARGET = mirage
|
TARGET = mirage
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Clipboard::setText(const QString &text) {
|
|
||||||
m_clipboard->setText(text, QClipboard::Clipboard);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString Clipboard::selection() const {
|
|
||||||
return m_clipboard->text(QClipboard::Selection);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Clipboard::setSelection(const QString &text) {
|
|
||||||
if (m_clipboard->supportsSelection()) {
|
|
||||||
m_clipboard->setText(text, QClipboard::Selection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Clipboard::supportsSelection() const {
|
|
||||||
return m_clipboard->supportsSelection();
|
|
||||||
}
|
|
|
@ -7,6 +7,7 @@
|
||||||
#define CLIPBOARD_H
|
#define CLIPBOARD_H
|
||||||
|
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
|
#include <QClipboard>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,25 +21,48 @@ class Clipboard : public QObject
|
||||||
Q_PROPERTY(bool supportsSelection READ supportsSelection CONSTANT)
|
Q_PROPERTY(bool supportsSelection READ supportsSelection CONSTANT)
|
||||||
|
|
||||||
public:
|
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
|
// 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
|
// 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:
|
signals:
|
||||||
void textChanged();
|
void textChanged();
|
||||||
void selectionChanged();
|
void selectionChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QClipboard *m_clipboard = QGuiApplication::clipboard();
|
QClipboard *clipboard = QGuiApplication::clipboard();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user