mirror of https://github.com/ethereum/go-ethereum
parent
03b8c6841b
commit
0057bb4ef6
@ -0,0 +1,11 @@ |
||||
#pragma once |
||||
|
||||
#include "clipboard.hpp" |
||||
|
||||
typedef void Clipboard_; |
||||
|
||||
Clipboard_ *initClipboard() |
||||
{ |
||||
Clipboard *clipboard = new(Clipboard); |
||||
return static_cast<Clipboard_*>(clipboard); |
||||
} |
@ -0,0 +1,20 @@ |
||||
#include "clipboard.h" |
||||
|
||||
#include <QClipboard> |
||||
|
||||
Clipboard::Clipboard() |
||||
{ |
||||
connect(QApplication::clipboard(), &QClipboard::dataChanged, [this] { emit clipboardChanged();}); |
||||
} |
||||
|
||||
QString Clipboard::get() const |
||||
{ |
||||
QClipboard *clipboard = QApplication::clipboard(); |
||||
return clipboard->text(); |
||||
} |
||||
|
||||
void Clipboard::toClipboard(QString _text) |
||||
{ |
||||
QClipboard *clipboard = QApplicationion::clipboard(); |
||||
clipboard->setText(_text); |
||||
} |
@ -0,0 +1,15 @@ |
||||
package clipboard |
||||
|
||||
// #cgo CPPFLAGS: -I./
|
||||
// #cgo CXXFLAGS: -std=c++0x -pedantic-errors -Wall -fno-strict-aliasing
|
||||
// #cgo LDFLAGS: -lstdc++
|
||||
// #cgo pkg-config: Qt5Quick
|
||||
//
|
||||
// #include "capi.hpp"
|
||||
import "C" |
||||
|
||||
import "github.com/obscuren/qml" |
||||
|
||||
func SetQMLClipboard(context *qml.Context) { |
||||
context.SetVar("clipboard", (unsafe.Pointer)(C.initClipboard())) |
||||
} |
@ -0,0 +1,23 @@ |
||||
#pragma once |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
class Clipboard : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
Q_PROPERTY(QString get READ get WRITE toClipboard NOTIFY clipboardChanged) |
||||
public: |
||||
Clipboard(); |
||||
virtual ~Clipboard(){} |
||||
|
||||
Q_INVOKABLE void toClipboard(QString _text); |
||||
|
||||
signals: |
||||
void clipboardChanged(); |
||||
}; |
||||
|
||||
#ifdef __cplusplus |
||||
} // extern "C"
|
||||
#endif |
Loading…
Reference in new issue