forked from cerc-io/plugeth
WIP QT Clipboard
This commit is contained in:
parent
03b8c6841b
commit
0057bb4ef6
@ -246,6 +246,7 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
property var blockModel: ListModel {
|
property var blockModel: ListModel {
|
||||||
|
@ -131,6 +131,7 @@ func (gui *Gui) Start(assetPath string) {
|
|||||||
context.SetVar("gui", gui)
|
context.SetVar("gui", gui)
|
||||||
context.SetVar("eth", gui.uiLib)
|
context.SetVar("eth", gui.uiLib)
|
||||||
context.SetVar("shh", gui.whisper)
|
context.SetVar("shh", gui.whisper)
|
||||||
|
//clipboard.SetQMLClipboard(context)
|
||||||
|
|
||||||
win, err := gui.showWallet(context)
|
win, err := gui.showWallet(context)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -80,7 +80,7 @@ type RpcServer interface {
|
|||||||
|
|
||||||
type Log struct {
|
type Log struct {
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
Topics []string `json:"topics"`
|
Topic []string `json:"topics"`
|
||||||
Data string `json:"data"`
|
Data string `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,11 +89,11 @@ func toLogs(logs state.Logs) (ls []Log) {
|
|||||||
|
|
||||||
for i, log := range logs {
|
for i, log := range logs {
|
||||||
var l Log
|
var l Log
|
||||||
l.Topics = make([]string, len(log.Topics()))
|
l.Topic = make([]string, len(log.Topics()))
|
||||||
l.Address = toHex(log.Address())
|
l.Address = toHex(log.Address())
|
||||||
l.Data = toHex(log.Data())
|
l.Data = toHex(log.Data())
|
||||||
for j, topic := range log.Topics() {
|
for j, topic := range log.Topics() {
|
||||||
l.Topics[j] = toHex(topic)
|
l.Topic[j] = toHex(topic)
|
||||||
}
|
}
|
||||||
ls[i] = l
|
ls[i] = l
|
||||||
}
|
}
|
||||||
|
11
ui/qt/clipboard/capi.hpp
Normal file
11
ui/qt/clipboard/capi.hpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "clipboard.hpp"
|
||||||
|
|
||||||
|
typedef void Clipboard_;
|
||||||
|
|
||||||
|
Clipboard_ *initClipboard()
|
||||||
|
{
|
||||||
|
Clipboard *clipboard = new(Clipboard);
|
||||||
|
return static_cast<Clipboard_*>(clipboard);
|
||||||
|
}
|
20
ui/qt/clipboard/clipboard.cpp
Normal file
20
ui/qt/clipboard/clipboard.cpp
Normal file
@ -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);
|
||||||
|
}
|
15
ui/qt/clipboard/clipboard.go
Normal file
15
ui/qt/clipboard/clipboard.go
Normal file
@ -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()))
|
||||||
|
}
|
23
ui/qt/clipboard/clipboard.hpp
Normal file
23
ui/qt/clipboard/clipboard.hpp
Normal file
@ -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
|
@ -150,7 +150,7 @@ type Transaction struct {
|
|||||||
func NewTx(tx *types.Transaction) *Transaction {
|
func NewTx(tx *types.Transaction) *Transaction {
|
||||||
hash := toHex(tx.Hash())
|
hash := toHex(tx.Hash())
|
||||||
receiver := toHex(tx.To())
|
receiver := toHex(tx.To())
|
||||||
if receiver == "0000000000000000000000000000000000000000" {
|
if len(receiver) == 0 {
|
||||||
receiver = toHex(core.AddressFromMessage(tx))
|
receiver = toHex(core.AddressFromMessage(tx))
|
||||||
}
|
}
|
||||||
sender := toHex(tx.From())
|
sender := toHex(tx.From())
|
||||||
|
Loading…
Reference in New Issue
Block a user