Working out UI
This commit is contained in:
parent
3e8b27c9dc
commit
2b967558ce
@ -21,7 +21,7 @@ func Init() {
|
|||||||
flag.BoolVar(&StartConsole, "c", false, "debug and testing console")
|
flag.BoolVar(&StartConsole, "c", false, "debug and testing console")
|
||||||
flag.BoolVar(&StartMining, "m", false, "start dagger mining")
|
flag.BoolVar(&StartMining, "m", false, "start dagger mining")
|
||||||
flag.BoolVar(&ShowGenesis, "g", false, "prints genesis header and exits")
|
flag.BoolVar(&ShowGenesis, "g", false, "prints genesis header and exits")
|
||||||
flag.BoolVar(&UseGui, "gui", false, "use the gui")
|
flag.BoolVar(&UseGui, "gui", true, "use the gui")
|
||||||
flag.BoolVar(&UseUPnP, "upnp", false, "enable UPnP support")
|
flag.BoolVar(&UseUPnP, "upnp", false, "enable UPnP support")
|
||||||
flag.BoolVar(&UseSeed, "seed", true, "seed peers")
|
flag.BoolVar(&UseSeed, "seed", true, "seed peers")
|
||||||
flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key")
|
flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key")
|
||||||
|
21
ui/gui.go
21
ui/gui.go
@ -56,10 +56,12 @@ func (ui *Gui) Start() {
|
|||||||
|
|
||||||
context := ui.engine.Context()
|
context := ui.engine.Context()
|
||||||
context.SetVar("eth", ui.lib)
|
context.SetVar("eth", ui.lib)
|
||||||
context.SetVar("ui", &UiLib{engine: ui.engine})
|
context.SetVar("ui", &UiLib{engine: ui.engine, eth: ui.eth})
|
||||||
|
|
||||||
ui.eth.BlockManager.SecondaryBlockProcessor = ui
|
ui.eth.BlockManager.SecondaryBlockProcessor = ui
|
||||||
|
|
||||||
|
ethutil.Config.Log.AddLogSystem(ui)
|
||||||
|
|
||||||
go ui.setInitialBlockChain()
|
go ui.setInitialBlockChain()
|
||||||
go ui.updatePeers()
|
go ui.updatePeers()
|
||||||
|
|
||||||
@ -73,13 +75,23 @@ func (ui *Gui) setInitialBlockChain() {
|
|||||||
ui.ProcessBlock(block)
|
ui.ProcessBlock(block)
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.eth.Start()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ui *Gui) ProcessBlock(block *ethchain.Block) {
|
func (ui *Gui) ProcessBlock(block *ethchain.Block) {
|
||||||
ui.win.Root().Call("addBlock", NewBlockFromBlock(block))
|
ui.win.Root().Call("addBlock", NewBlockFromBlock(block))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ui *Gui) Println(v ...interface{}) {
|
||||||
|
str := fmt.Sprintln(v...)
|
||||||
|
// remove last \n
|
||||||
|
ui.win.Root().Call("addLog", str[:len(str)-1])
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ui *Gui) Printf(format string, v ...interface{}) {
|
||||||
|
str := strings.TrimRight(fmt.Sprintf(format, v...), "\n")
|
||||||
|
ui.win.Root().Call("addLog", str)
|
||||||
|
}
|
||||||
|
|
||||||
func (ui *Gui) updatePeers() {
|
func (ui *Gui) updatePeers() {
|
||||||
for {
|
for {
|
||||||
ui.win.Root().Call("setPeers", fmt.Sprintf("%d / %d", ui.eth.Peers().Len(), ui.eth.MaxPeers))
|
ui.win.Root().Call("setPeers", fmt.Sprintf("%d / %d", ui.eth.Peers().Len(), ui.eth.MaxPeers))
|
||||||
@ -89,6 +101,7 @@ func (ui *Gui) updatePeers() {
|
|||||||
|
|
||||||
type UiLib struct {
|
type UiLib struct {
|
||||||
engine *qml.Engine
|
engine *qml.Engine
|
||||||
|
eth *eth.Ethereum
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ui *UiLib) Open(path string) {
|
func (ui *UiLib) Open(path string) {
|
||||||
@ -104,6 +117,10 @@ func (ui *UiLib) Open(path string) {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ui *UiLib) Connect() {
|
||||||
|
ui.eth.Start()
|
||||||
|
}
|
||||||
|
|
||||||
type Tester struct {
|
type Tester struct {
|
||||||
root qml.Object
|
root qml.Object
|
||||||
}
|
}
|
||||||
|
46
wallet.qml
46
wallet.qml
@ -2,6 +2,7 @@ import QtQuick 2.0
|
|||||||
import QtQuick.Controls 1.0;
|
import QtQuick.Controls 1.0;
|
||||||
import QtQuick.Layouts 1.0;
|
import QtQuick.Layouts 1.0;
|
||||||
import QtQuick.Dialogs 1.0;
|
import QtQuick.Dialogs 1.0;
|
||||||
|
import QtQuick.Window 2.1;
|
||||||
import GoExtensions 1.0
|
import GoExtensions 1.0
|
||||||
|
|
||||||
ApplicationWindow {
|
ApplicationWindow {
|
||||||
@ -60,20 +61,36 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TableView {
|
TableView {
|
||||||
|
id: blockTable
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: 100
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
anchors.top: splitView.bottom
|
anchors.top: splitView.bottom
|
||||||
|
anchors.bottom: logView.top
|
||||||
TableViewColumn{ role: "number" ; title: "#" ; width: 100 }
|
TableViewColumn{ role: "number" ; title: "#" ; width: 100 }
|
||||||
TableViewColumn{ role: "hash" ; title: "Hash" ; width: 560 }
|
TableViewColumn{ role: "hash" ; title: "Hash" ; width: 560 }
|
||||||
|
|
||||||
model: blockModel
|
model: blockModel
|
||||||
|
|
||||||
onDoubleClicked: {
|
onDoubleClicked: {
|
||||||
console.log(eth.getBlock(blockModel.get(row).hash))
|
popup.visible = true
|
||||||
|
popup.block = eth.getBlock(blockModel.get(row).hash)
|
||||||
|
popup.hashLabel.text = popup.block.hash
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
property var logModel: ListModel {
|
||||||
|
id: logModel
|
||||||
|
}
|
||||||
|
|
||||||
|
TableView {
|
||||||
|
id: logView
|
||||||
|
width: parent.width
|
||||||
|
height: 150
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
TableViewColumn{ role: "description" ; title: "log" }
|
||||||
|
|
||||||
|
model: logModel
|
||||||
|
}
|
||||||
|
|
||||||
FileDialog {
|
FileDialog {
|
||||||
id: openAppDialog
|
id: openAppDialog
|
||||||
title: "Open QML Application"
|
title: "Open QML Application"
|
||||||
@ -86,6 +103,13 @@ ApplicationWindow {
|
|||||||
RowLayout {
|
RowLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
Button {
|
Button {
|
||||||
|
id: connectButton
|
||||||
|
onClicked: ui.connect()
|
||||||
|
text: "Connect"
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
anchors.left: connectButton.right
|
||||||
|
anchors.leftMargin: 5
|
||||||
onClicked: openAppDialog.open()
|
onClicked: openAppDialog.open()
|
||||||
text: "Import App"
|
text: "Import App"
|
||||||
}
|
}
|
||||||
@ -107,10 +131,26 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Window {
|
||||||
|
id: popup
|
||||||
|
visible: false
|
||||||
|
property var block
|
||||||
|
Label {
|
||||||
|
id: hashLabel
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function addBlock(block) {
|
function addBlock(block) {
|
||||||
blockModel.insert(0, {number: block.number, hash: block.hash})
|
blockModel.insert(0, {number: block.number, hash: block.hash})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addLog(str) {
|
||||||
|
console.log(str)
|
||||||
|
logModel.insert(0, {description: str})
|
||||||
|
}
|
||||||
|
|
||||||
function setPeers(text) {
|
function setPeers(text) {
|
||||||
peerLabel.text = text
|
peerLabel.text = text
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user