peerplays_migrated/programs/light_client/qml/main.qml

134 lines
3.3 KiB
QML
Raw Normal View History

2015-07-10 21:37:22 +00:00
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Dialogs 1.2
import QtQuick.Window 2.2
2015-07-10 21:37:22 +00:00
import Qt.labs.settings 1.0
2015-07-10 21:37:22 +00:00
import Graphene.Client 0.1
ApplicationWindow {
id: window
2015-07-10 21:37:22 +00:00
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Component.onCompleted: {
app.start("ws://localhost:8090", "user", "pass")
}
2015-07-10 21:37:22 +00:00
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-13 17:19:07 +00:00
GrapheneApplication {
id: app
2015-07-10 21:37:22 +00:00
}
Settings {
id: appSettings
category: "appSettings"
2015-07-10 21:37:22 +00:00
}
Connections {
target: app
onExceptionThrown: console.log("Exception from app: " + message)
}
2015-07-10 21:37:22 +00:00
Column {
anchors.centerIn: parent
Button {
text: "Transfer"
onClicked: formBox.showForm(Qt.createComponent("TransferForm.qml"), {},
function() {
console.log("Closed form")
})
}
TextField {
id: nameField
2015-07-14 13:46:38 +00:00
onAccepted: lookupNameButton.clicked()
focus: true
}
Button {
2015-07-14 13:46:38 +00:00
id: lookupNameButton
text: "Lookup Name"
onClicked: {
var acct = app.model.getAccount(nameField.text)
2015-07-13 21:24:25 +00:00
console.log(JSON.stringify(acct))
// @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" );
console.log(JSON.stringify(acct))
2015-07-13 21:24:25 +00:00
}
else
2015-07-13 21:24:25 +00:00
{
console.log("Waiting for result...")
acct.idChanged.connect(function(loadedAcct) {
2015-07-13 21:24:25 +00:00
console.log( "ID CHANGED" );
console.log(JSON.stringify(loadedAcct))
})
2015-07-13 21:24:25 +00:00
}
}
}
2015-07-14 13:46:38 +00:00
TextField {
id: idField
onAccepted: lookupIdButton.clicked()
focus: true
}
Button {
id: lookupIdButton
text: "Lookup ID"
onClicked: {
var acct = app.model.getAccount(parseInt(idField.text))
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("NAME ALREADY SET" );
console.log(JSON.stringify(acct))
}
else
{
console.log("Waiting for result...")
acct.nameChanged.connect(function(loadedAcct) {
console.log( "NAME CHANGED" );
console.log(JSON.stringify(acct))
})
}
}
}
2015-07-13 18:16:02 +00:00
}
FormBox {
id: formBox
anchors.fill: parent
z: 10
}
2015-07-10 21:37:22 +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
}
}