2015-07-10 21:37:22 +00:00
|
|
|
import QtQuick 2.5
|
|
|
|
|
import QtQuick.Controls 1.4
|
|
|
|
|
import QtQuick.Dialogs 1.2
|
2015-07-13 21:22:06 +00:00
|
|
|
import QtQuick.Window 2.2
|
2015-07-10 21:37:22 +00:00
|
|
|
|
2015-07-10 22:54:54 +00:00
|
|
|
import Qt.labs.settings 1.0
|
|
|
|
|
|
2015-07-10 21:37:22 +00:00
|
|
|
import Graphene.Client 0.1
|
|
|
|
|
|
|
|
|
|
ApplicationWindow {
|
2015-07-10 22:54:54 +00:00
|
|
|
id: window
|
2015-07-10 21:37:22 +00:00
|
|
|
visible: true
|
|
|
|
|
width: 640
|
|
|
|
|
height: 480
|
|
|
|
|
title: qsTr("Hello World")
|
|
|
|
|
|
|
|
|
|
menuBar: MenuBar {
|
|
|
|
|
Menu {
|
|
|
|
|
title: qsTr("File")
|
|
|
|
|
MenuItem {
|
|
|
|
|
text: qsTr("&Open")
|
|
|
|
|
onTriggered: console.log("Open action triggered");
|
|
|
|
|
}
|
|
|
|
|
MenuItem {
|
|
|
|
|
text: qsTr("Exit")
|
|
|
|
|
onTriggered: Qt.quit();
|
2015-07-14 17:06:32 +00:00
|
|
|
shortcut: "Ctrl+Q"
|
2015-07-10 21:37:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-14 20:49:17 +00:00
|
|
|
statusBar: StatusBar {
|
|
|
|
|
Label {
|
|
|
|
|
anchors.right: parent.right
|
2015-07-29 19:50:12 +00:00
|
|
|
text: qsTr("Network: %1 Wallet: %2").arg(app.isConnected? qsTr("Connected") : qsTr("Disconnected"))
|
|
|
|
|
.arg(app.wallet.isLocked? qsTr("Locked") : qsTr("Unlocked"))
|
2015-07-14 20:49:17 +00:00
|
|
|
}
|
|
|
|
|
}
|
2015-07-10 21:37:22 +00:00
|
|
|
|
2015-07-13 17:19:07 +00:00
|
|
|
GrapheneApplication {
|
|
|
|
|
id: app
|
2015-07-29 19:50:12 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
|
var walletFile = appSettings.walletPath + "/wallet.json"
|
|
|
|
|
if (!wallet.open(walletFile)) {
|
|
|
|
|
// TODO: onboarding experience
|
|
|
|
|
wallet.create(walletFile, "default password", "default brain key")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-14 20:49:17 +00:00
|
|
|
Timer {
|
|
|
|
|
running: !app.isConnected
|
|
|
|
|
interval: 5000
|
|
|
|
|
repeat: true
|
|
|
|
|
onTriggered: app.start("ws://localhost:8090", "user", "pass")
|
|
|
|
|
triggeredOnStart: true
|
2015-07-10 21:37:22 +00:00
|
|
|
}
|
2015-07-10 22:54:54 +00:00
|
|
|
Settings {
|
|
|
|
|
id: appSettings
|
|
|
|
|
category: "appSettings"
|
2015-07-29 19:50:12 +00:00
|
|
|
|
|
|
|
|
property string walletPath: app.defaultDataPath()
|
2015-07-10 21:37:22 +00:00
|
|
|
}
|
2015-07-13 20:21:01 +00:00
|
|
|
Connections {
|
|
|
|
|
target: app
|
|
|
|
|
onExceptionThrown: console.log("Exception from app: " + message)
|
|
|
|
|
}
|
2015-07-10 21:37:22 +00:00
|
|
|
|
2015-07-13 20:21:01 +00:00
|
|
|
Column {
|
2015-07-10 22:54:54 +00:00
|
|
|
anchors.centerIn: parent
|
2015-07-14 20:49:17 +00:00
|
|
|
enabled: app.isConnected
|
|
|
|
|
|
2015-07-13 20:21:01 +00:00
|
|
|
Button {
|
|
|
|
|
text: "Transfer"
|
2015-07-24 19:55:58 +00:00
|
|
|
onClicked: {
|
|
|
|
|
var front = Qt.createComponent("TransferForm.qml")
|
|
|
|
|
// TODO: make back into a preview and confirm dialog
|
2015-07-27 20:01:16 +00:00
|
|
|
var back = Qt.createComponent("TransactionConfirmationForm.qml")
|
2015-07-24 19:55:58 +00:00
|
|
|
formBox.showForm(Qt.createComponent("FormFlipper.qml"), {frontComponent: front, backComponent: back},
|
2015-07-29 21:56:37 +00:00
|
|
|
function(arg) {
|
|
|
|
|
console.log("Closed form: " + JSON.stringify(arg))
|
2015-07-24 19:55:58 +00:00
|
|
|
})
|
|
|
|
|
}
|
2015-07-13 20:21:01 +00:00
|
|
|
}
|
|
|
|
|
TextField {
|
|
|
|
|
id: nameField
|
2015-07-14 13:46:38 +00:00
|
|
|
onAccepted: lookupNameButton.clicked()
|
2015-07-13 20:21:01 +00:00
|
|
|
focus: true
|
|
|
|
|
}
|
|
|
|
|
Button {
|
2015-07-14 13:46:38 +00:00
|
|
|
id: lookupNameButton
|
|
|
|
|
text: "Lookup Name"
|
2015-07-13 20:21:01 +00:00
|
|
|
onClicked: {
|
|
|
|
|
var acct = app.model.getAccount(nameField.text)
|
2015-07-13 21:24:25 +00:00
|
|
|
console.log(JSON.stringify(acct))
|
2015-07-13 20:21:01 +00:00
|
|
|
// @disable-check M126
|
|
|
|
|
if (acct == null)
|
|
|
|
|
console.log("Got back null account")
|
|
|
|
|
else if (acct.id >= 0)
|
2015-07-13 21:24:25 +00:00
|
|
|
{
|
|
|
|
|
console.log("ID ALREADY SET" );
|
2015-07-13 20:21:01 +00:00
|
|
|
console.log(JSON.stringify(acct))
|
2015-07-13 21:24:25 +00:00
|
|
|
}
|
2015-07-13 20:21:01 +00:00
|
|
|
else
|
2015-07-13 21:24:25 +00:00
|
|
|
{
|
2015-07-13 20:21:01 +00:00
|
|
|
console.log("Waiting for result...")
|
2015-07-14 21:30:15 +00:00
|
|
|
acct.idChanged.connect(function() {
|
2015-07-13 21:24:25 +00:00
|
|
|
console.log( "ID CHANGED" );
|
2015-07-14 21:30:15 +00:00
|
|
|
console.log(JSON.stringify(acct))
|
2015-07-13 20:21:01 +00:00
|
|
|
})
|
2015-07-13 21:24:25 +00:00
|
|
|
}
|
2015-07-13 20:21:01 +00:00
|
|
|
}
|
|
|
|
|
}
|
2015-07-13 21:22:06 +00:00
|
|
|
|
2015-07-14 13:46:38 +00:00
|
|
|
TextField {
|
2015-07-14 21:30:15 +00:00
|
|
|
id: accountIdField
|
|
|
|
|
onAccepted: lookupAccountIdButton.clicked()
|
2015-07-14 13:46:38 +00:00
|
|
|
focus: true
|
|
|
|
|
}
|
|
|
|
|
Button {
|
2015-07-14 21:30:15 +00:00
|
|
|
id: lookupAccountIdButton
|
|
|
|
|
text: "Lookup Account ID"
|
2015-07-14 13:46:38 +00:00
|
|
|
onClicked: {
|
2015-07-14 21:30:15 +00:00
|
|
|
var acct = app.model.getAccount(parseInt(accountIdField.text))
|
2015-07-14 13:46:38 +00:00
|
|
|
console.log(JSON.stringify(acct))
|
|
|
|
|
// @disable-check M126
|
|
|
|
|
if (acct == null)
|
|
|
|
|
console.log("Got back null account")
|
|
|
|
|
else if ( !(parseInt(acct.name) <= 0) )
|
|
|
|
|
console.log(JSON.stringify(acct))
|
2015-07-17 19:35:24 +00:00
|
|
|
else {
|
2015-07-14 13:46:38 +00:00
|
|
|
console.log("Waiting for result...")
|
2015-07-14 21:30:15 +00:00
|
|
|
acct.nameChanged.connect(function() {
|
|
|
|
|
console.log(JSON.stringify(acct))
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TextField {
|
|
|
|
|
id: assetIdField
|
|
|
|
|
onAccepted: lookupassetIdButton.clicked()
|
|
|
|
|
focus: true
|
|
|
|
|
}
|
|
|
|
|
Button {
|
|
|
|
|
id: lookupassetIdButton
|
|
|
|
|
text: "Lookup Asset ID"
|
|
|
|
|
onClicked: {
|
|
|
|
|
var acct = app.model.getAsset(parseInt(assetIdField.text))
|
|
|
|
|
console.log(JSON.stringify(acct))
|
|
|
|
|
// @disable-check M126
|
|
|
|
|
if (acct == null)
|
|
|
|
|
console.log("Got back null asset")
|
|
|
|
|
else if ( !(parseInt(acct.name) <= 0) )
|
|
|
|
|
{
|
|
|
|
|
console.log(JSON.stringify(acct))
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
console.log("Waiting for result...")
|
|
|
|
|
acct.nameChanged.connect(function() {
|
2015-07-14 13:46:38 +00:00
|
|
|
console.log(JSON.stringify(acct))
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-29 19:50:12 +00:00
|
|
|
TextField {
|
|
|
|
|
id: passwordField
|
|
|
|
|
echoMode: TextInput.Password
|
|
|
|
|
}
|
|
|
|
|
Button {
|
|
|
|
|
text: app.wallet.isLocked? "Unlock wallet" : "Lock wallet"
|
|
|
|
|
onClicked: {
|
|
|
|
|
if (app.wallet.isLocked)
|
|
|
|
|
app.wallet.unlock(passwordField.text)
|
|
|
|
|
else
|
|
|
|
|
app.wallet.lock()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
TextField {
|
|
|
|
|
id: keyField
|
|
|
|
|
placeholderText: "Private key"
|
|
|
|
|
}
|
|
|
|
|
TextField {
|
|
|
|
|
id: keyLabelField
|
|
|
|
|
placeholderText: "Key label"
|
|
|
|
|
}
|
|
|
|
|
Button {
|
|
|
|
|
text: "Import key"
|
|
|
|
|
enabled: !app.wallet.isLocked && keyField.text && keyLabelField.text
|
|
|
|
|
onClicked: app.wallet.importPrivateKey(keyField.text, keyLabelField.text)
|
|
|
|
|
}
|
2015-07-13 18:16:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FormBox {
|
|
|
|
|
id: formBox
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
z: 10
|
2015-07-10 22:54:54 +00:00
|
|
|
}
|
2015-07-10 21:37:22 +00:00
|
|
|
|
2015-07-10 22:54:54 +00:00
|
|
|
// This Settings is only for geometry -- it doesn't get an id. See appSettings for normal settings
|
|
|
|
|
Settings {
|
|
|
|
|
category: "windowGeometry"
|
|
|
|
|
property alias x: window.x
|
|
|
|
|
property alias y: window.y
|
|
|
|
|
property alias width: window.width
|
|
|
|
|
property alias height: window.height
|
2015-07-10 21:37:22 +00:00
|
|
|
}
|
|
|
|
|
}
|