aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-03-03 07:54:41 +0800
committerobscuren <geffobscura@gmail.com>2014-03-03 07:54:41 +0800
commit3d2c3b0107d438dd081c57ef74036f4c5a03855f (patch)
treebdb4070b3a46caf5b3ce5facd8a3dfe3a4e43230
parenta482b0cc1b7ddbeae00988c7dd10391df01b0009 (diff)
downloaddexon-3d2c3b0107d438dd081c57ef74036f4c5a03855f.tar.gz
dexon-3d2c3b0107d438dd081c57ef74036f4c5a03855f.tar.zst
dexon-3d2c3b0107d438dd081c57ef74036f4c5a03855f.zip
Using asset path helper (includes a debug path atm)
-rw-r--r--ui/gui.go9
-rw-r--r--ui/ui_lib.go27
-rw-r--r--wallet.qml198
3 files changed, 147 insertions, 87 deletions
diff --git a/ui/gui.go b/ui/gui.go
index 389fe4f68..196d2cd76 100644
--- a/ui/gui.go
+++ b/ui/gui.go
@@ -9,8 +9,6 @@ import (
"github.com/ethereum/eth-go/ethdb"
"github.com/ethereum/eth-go/ethutil"
"github.com/niemeyer/qml"
- "bitbucket.org/kardianos/osext"
- "path/filepath"
"math/big"
"strings"
)
@@ -87,15 +85,12 @@ func (ui *Gui) Start() {
// Create a new QML engine
ui.engine = qml.NewEngine()
- // Get Binary Directory
- exedir , _ := osext.ExecutableFolder()
-
// Load the main QML interface
- component, err := ui.engine.LoadFile(filepath.Join(exedir, "wallet.qml"))
+ component, err := ui.engine.LoadFile(AssetPath("wallet.qml"))
if err != nil {
panic(err)
}
- ui.engine.LoadFile(filepath.Join(exedir, "transactions.qml"))
+ ui.engine.LoadFile(AssetPath("transactions.qml"))
ui.win = component.CreateWindow(nil)
diff --git a/ui/ui_lib.go b/ui/ui_lib.go
index c956fd032..2a1abee23 100644
--- a/ui/ui_lib.go
+++ b/ui/ui_lib.go
@@ -1,9 +1,13 @@
package ethui
import (
+ "bitbucket.org/kardianos/osext"
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go/ethutil"
"github.com/niemeyer/qml"
+ "path"
+ "path/filepath"
+ "runtime"
)
// UI Library that has some basic functionality exposed
@@ -38,3 +42,26 @@ func (ui *UiLib) Connect(button qml.Object) {
func (ui *UiLib) ConnectToPeer(addr string) {
ui.eth.ConnectToPeer(addr)
}
+
+func (ui *UiLib) AssetPath(p string) string {
+ return AssetPath(p)
+}
+
+func AssetPath(p string) string {
+ var base string
+ switch runtime.GOOS {
+ case "darwin":
+ // Get Binary Directory
+ exedir, _ := osext.ExecutableFolder()
+ base = filepath.Join(exedir, "../Resources")
+ base = "/Users/jeffrey/go/src/github.com/ethereum/go-ethereum"
+ case "linux":
+ base = "/usr/share/ethereal"
+ case "window":
+ fallthrough
+ default:
+ base = "."
+ }
+
+ return path.Join(base, p)
+}
diff --git a/wallet.qml b/wallet.qml
index e86551ad6..39bc21f39 100644
--- a/wallet.qml
+++ b/wallet.qml
@@ -115,116 +115,141 @@ ApplicationWindow {
}
}
}
-
- }
-
- property var txModel: ListModel {
- id: txModel
}
Rectangle {
- id: historyView
- property var title: "Transactions"
+ id: mainView
+ color: "#00000000"
anchors.right: parent.right
anchors.left: menu.right
anchors.bottom: parent.bottom
anchors.top: parent.top
- TableView {
- id: txTableView
- anchors.fill: parent
- TableViewColumn{ role: "value" ; title: "Value" ; width: 100 }
- TableViewColumn{ role: "address" ; title: "Address" ; width: 430 }
- model: txModel
+ property var txModel: ListModel {
+ id: txModel
}
- }
- Rectangle {
- id: newTxView
- property var title: "New transaction"
- visible: false
- anchors.right: parent.right
- anchors.left: menu.right
- anchors.bottom: parent.bottom
- anchors.top: parent.top
- color: "#00000000"
+ Rectangle {
+ id: historyView
+ anchors.fill: parent
- ColumnLayout {
- width: 400
- anchors.left: parent.left
- anchors.top: parent.top
- anchors.leftMargin: 5
- anchors.topMargin: 5
- TextField {
- id: txAmount
- width: 200
- placeholderText: "Amount"
- }
+ property var title: "Transactions"
+ TableView {
+ id: txTableView
+ anchors.fill: parent
+ TableViewColumn{ role: "value" ; title: "Value" ; width: 100 }
+ TableViewColumn{ role: "address" ; title: "Address" ; width: 430 }
- TextField {
- id: txReceiver
- placeholderText: "Receiver Address (or empty for contract)"
- Layout.fillWidth: true
+ model: txModel
}
+ }
- Label {
- text: "Transaction data"
- }
- TextArea {
- id: codeView
+ Rectangle {
+ id: newTxView
+ property var title: "New transaction"
+ visible: false
+ anchors.fill: parent
+ color: "#00000000"
+
+ ColumnLayout {
+ width: 400
+ anchors.left: parent.left
+ anchors.top: parent.top
+ anchors.leftMargin: 5
anchors.topMargin: 5
- Layout.fillWidth: true
- width: parent.width /2
- }
+ TextField {
+ id: txAmount
+ width: 200
+ placeholderText: "Amount"
+ }
+
+ TextField {
+ id: txReceiver
+ placeholderText: "Receiver Address (or empty for contract)"
+ Layout.fillWidth: true
+ }
- Button {
- text: "Send"
- onClicked: {
- console.log(eth.createTx(txReceiver.text, txAmount.text, codeView.text))
+ Label {
+ text: "Transaction data"
+ }
+ TextArea {
+ id: codeView
+ anchors.topMargin: 5
+ Layout.fillWidth: true
+ width: parent.width /2
+ }
+
+ Button {
+ text: "Send"
+ onClicked: {
+ console.log(eth.createTx(txReceiver.text, txAmount.text, codeView.text))
+ }
}
}
}
- }
- Rectangle {
- id: networkView
- property var title: "Network"
- visible: false
- anchors.right: parent.right
- anchors.bottom: parent.bottom
- anchors.top: parent.top
+ Rectangle {
+ id: networkView
+ property var title: "Network"
+ visible: false
+ anchors.fill: parent
+
+ TableView {
+ id: blockTable
+ width: parent.width
+ anchors.top: parent.top
+ anchors.bottom: logView.top
+ TableViewColumn{ role: "number" ; title: "#" ; width: 100 }
+ TableViewColumn{ role: "hash" ; title: "Hash" ; width: 560 }
+
+ model: blockModel
+
+ /*
+ onDoubleClicked: {
+ popup.visible = true
+ popup.block = eth.getBlock(blockModel.get(row).hash)
+ popup.hashLabel.text = popup.block.hash
+ }
+ */
+ }
- TableView {
- id: blockTable
- width: parent.width
- anchors.top: parent.top
- anchors.bottom: logView.top
- TableViewColumn{ role: "number" ; title: "#" ; width: 100 }
- TableViewColumn{ role: "hash" ; title: "Hash" ; width: 560 }
+ property var logModel: ListModel {
+ id: logModel
+ }
- model: blockModel
+ TableView {
+ id: logView
+ width: parent.width
+ height: 150
+ anchors.bottom: parent.bottom
+ TableViewColumn{ role: "description" ; title: "log" }
- onDoubleClicked: {
- popup.visible = true
- popup.block = eth.getBlock(blockModel.get(row).hash)
- popup.hashLabel.text = popup.block.hash
+ model: logModel
}
}
- property var logModel: ListModel {
- id: logModel
+ /*
+ signal addPlugin(string name)
+ Component {
+ id: pluginWindow
+ Rectangle {
+ anchors.fill: parent
+ Label {
+ id: pluginTitle
+ anchors.centerIn: parent
+ text: "Hello world"
+ }
+ Component.onCompleted: setView(this)
+ }
}
- TableView {
- id: logView
- width: parent.width
- height: 150
- anchors.bottom: parent.bottom
- TableViewColumn{ role: "description" ; title: "log" }
-
- model: logModel
+ onAddPlugin: {
+ var pluginWin = pluginWindow.createObject(mainView)
+ console.log(pluginWin)
+ pluginWin.pluginTitle.text = "Test"
}
+ */
}
}
@@ -249,6 +274,7 @@ ApplicationWindow {
}
text: "Connect"
}
+
Button {
id: importAppButton
anchors.left: connectButton.right
@@ -304,6 +330,10 @@ ApplicationWindow {
anchors.left: parent.left
anchors.leftMargin: 10
placeholderText: "address:port"
+ onAccepted: {
+ ui.connectToPeer(addrField.text)
+ addPeerWin.visible = false
+ }
}
Button {
anchors.left: addrField.right
@@ -315,6 +345,9 @@ ApplicationWindow {
addPeerWin.visible = false
}
}
+ Component.onCompleted: {
+ addrField.focus = true
+ }
}
Window {
@@ -346,6 +379,11 @@ ApplicationWindow {
}
+ function loadPlugin(name) {
+ console.log("Loading plugin" + name)
+ mainView.addPlugin(name)
+ }
+
function setWalletValue(value) {
walletValueLabel.text = value
}