[GUI] More work on transfer form
This commit is contained in:
parent
f57205a2e6
commit
5f5f376ed3
8 changed files with 150 additions and 43 deletions
|
|
@ -19,6 +19,7 @@ using boost::multi_index_container;
|
||||||
using namespace boost::multi_index;
|
using namespace boost::multi_index;
|
||||||
|
|
||||||
using ObjectId = qint64;
|
using ObjectId = qint64;
|
||||||
|
Q_DECLARE_METATYPE(ObjectId)
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(std::function<void()>)
|
Q_DECLARE_METATYPE(std::function<void()>)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ int main(int argc, char *argv[])
|
||||||
app.setOrganizationName("Cryptonomex, Inc.");
|
app.setOrganizationName("Cryptonomex, Inc.");
|
||||||
|
|
||||||
qRegisterMetaType<std::function<void()>>();
|
qRegisterMetaType<std::function<void()>>();
|
||||||
|
qRegisterMetaType<ObjectId>();
|
||||||
|
|
||||||
qmlRegisterType<Asset>("Graphene.Client", 0, 1, "Asset");
|
qmlRegisterType<Asset>("Graphene.Client", 0, 1, "Asset");
|
||||||
qmlRegisterType<Balance>("Graphene.Client", 0, 1, "Balance");
|
qmlRegisterType<Balance>("Graphene.Client", 0, 1, "Balance");
|
||||||
|
|
|
||||||
54
programs/light_client/qml/AccountPicker.qml
Normal file
54
programs/light_client/qml/AccountPicker.qml
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
import QtQuick 2.5
|
||||||
|
import QtQuick.Controls 1.4
|
||||||
|
import QtQuick.Dialogs 1.2
|
||||||
|
import QtQuick.Layouts 1.2
|
||||||
|
|
||||||
|
import Graphene.Client 0.1
|
||||||
|
|
||||||
|
import "."
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
property Account account
|
||||||
|
|
||||||
|
property alias placeholderText: accountNameField.placeholderText
|
||||||
|
|
||||||
|
function setFocus() {
|
||||||
|
accountNameField.forceActiveFocus()
|
||||||
|
}
|
||||||
|
|
||||||
|
Identicon {
|
||||||
|
name: accountNameField.text
|
||||||
|
width: Scaling.cm(2)
|
||||||
|
height: Scaling.cm(2)
|
||||||
|
}
|
||||||
|
Column {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
TextField {
|
||||||
|
id: accountNameField
|
||||||
|
|
||||||
|
width: parent.width
|
||||||
|
onEditingFinished: accountDetails.update(text)
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
id: accountDetails
|
||||||
|
function update(name) {
|
||||||
|
if (!name)
|
||||||
|
{
|
||||||
|
text = ""
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
account = app.model.getAccount(name)
|
||||||
|
if (account == null)
|
||||||
|
text = qsTr("Error fetching account.")
|
||||||
|
else
|
||||||
|
text = Qt.binding(function() {
|
||||||
|
if (account == null)
|
||||||
|
return qsTr("Account does not exist.")
|
||||||
|
return qsTr("Account ID: %1").arg(account.id < 0? qsTr("Loading...")
|
||||||
|
: account.id)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -22,8 +22,14 @@ Rectangle {
|
||||||
function showForm(formType, params, closedCallback) {
|
function showForm(formType, params, closedCallback) {
|
||||||
if (formType.status === Component.Error)
|
if (formType.status === Component.Error)
|
||||||
console.log(formType.errorString())
|
console.log(formType.errorString())
|
||||||
|
if (!params instanceof Object)
|
||||||
|
params = {app: app}
|
||||||
|
else
|
||||||
|
params.app = app
|
||||||
|
|
||||||
formContainer.data = [formType.createObject(formContainer, params)]
|
var form = formType.createObject(formContainer, params)
|
||||||
|
formContainer.data = [form]
|
||||||
|
form.finished.connect(function(){state = "HIDDEN"})
|
||||||
if (closedCallback instanceof Function)
|
if (closedCallback instanceof Function)
|
||||||
internal.callback = closedCallback
|
internal.callback = closedCallback
|
||||||
state = "SHOWN"
|
state = "SHOWN"
|
||||||
|
|
|
||||||
39
programs/light_client/qml/Identicon.qml
Normal file
39
programs/light_client/qml/Identicon.qml
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
import QtQuick 2.5
|
||||||
|
|
||||||
|
import "jdenticon/jdenticon-1.0.1.min.js" as Jdenticon
|
||||||
|
|
||||||
|
Canvas {
|
||||||
|
id: identicon
|
||||||
|
contextType: "2d"
|
||||||
|
|
||||||
|
property var name
|
||||||
|
onNameChanged: requestPaint()
|
||||||
|
|
||||||
|
onPaint: {
|
||||||
|
if (name)
|
||||||
|
Jdenticon.draw(identicon, name)
|
||||||
|
else {
|
||||||
|
var context = identicon.context
|
||||||
|
context.reset()
|
||||||
|
var draw_circle = function(context, x, y, radius) {
|
||||||
|
context.beginPath()
|
||||||
|
context.arc(x, y, radius, 0, 2 * Math.PI, false)
|
||||||
|
context.fillStyle = "rgba(0, 0, 0, 0.1)"
|
||||||
|
context.fill()
|
||||||
|
}
|
||||||
|
var size = Math.min(identicon.height, identicon.width)
|
||||||
|
var centerX = size / 2
|
||||||
|
var centerY = size / 2
|
||||||
|
var radius = size/15
|
||||||
|
draw_circle(context, centerX, centerY, radius)
|
||||||
|
draw_circle(context, 2*radius, 2*radius, radius)
|
||||||
|
draw_circle(context, centerX, 2*radius, radius)
|
||||||
|
draw_circle(context, size - 2*radius, 2*radius, radius)
|
||||||
|
draw_circle(context, size - 2*radius, centerY, radius)
|
||||||
|
draw_circle(context, size - 2*radius, size - 2*radius, radius)
|
||||||
|
draw_circle(context, centerX, size - 2*radius, radius)
|
||||||
|
draw_circle(context, 2*radius, size - 2*radius, radius)
|
||||||
|
draw_circle(context, 2*radius, centerY, radius)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,57 +3,61 @@ import QtQuick.Controls 1.4
|
||||||
import QtQuick.Dialogs 1.2
|
import QtQuick.Dialogs 1.2
|
||||||
import QtQuick.Layouts 1.2
|
import QtQuick.Layouts 1.2
|
||||||
|
|
||||||
|
import Graphene.Client 0.1
|
||||||
|
|
||||||
import "."
|
import "."
|
||||||
import "jdenticon/jdenticon-1.0.1.min.js" as Jdenticon
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
|
property alias senderAccount: senderPicker.account
|
||||||
|
property alias receiverAccount: recipientPicker.account
|
||||||
|
|
||||||
|
property GrapheneApplication app
|
||||||
|
signal finished
|
||||||
|
|
||||||
Component.onCompleted: console.log("Made a transfer form")
|
Component.onCompleted: console.log("Made a transfer form")
|
||||||
Component.onDestruction: console.log("Destroyed a transfer form")
|
Component.onDestruction: console.log("Destroyed a transfer form")
|
||||||
|
|
||||||
Column {
|
ColumnLayout {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
width: parent.width - Scaling.cm(2)
|
||||||
|
spacing: Scaling.cm(1)
|
||||||
|
|
||||||
|
AccountPicker {
|
||||||
|
id: senderPicker
|
||||||
|
width: parent.width
|
||||||
|
Component.onCompleted: setFocus()
|
||||||
|
placeholderText: qsTr("Sender")
|
||||||
|
}
|
||||||
|
AccountPicker {
|
||||||
|
id: recipientPicker
|
||||||
|
width: parent.width
|
||||||
|
placeholderText: qsTr("Recipient")
|
||||||
|
layoutDirection: Qt.RightToLeft
|
||||||
|
}
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Canvas {
|
width: parent.width
|
||||||
id: identicon
|
SpinBox {
|
||||||
width: Scaling.cm(2)
|
Layout.preferredWidth: Scaling.cm(4)
|
||||||
height: Scaling.cm(2)
|
Layout.minimumWidth: Scaling.cm(1.5)
|
||||||
contextType: "2d"
|
enabled: senderPicker.account
|
||||||
|
minimumValue: 0
|
||||||
onPaint: {
|
maximumValue: Number.POSITIVE_INFINITY
|
||||||
if (nameField.text)
|
|
||||||
Jdenticon.draw(identicon, nameField.text)
|
|
||||||
else {
|
|
||||||
var context = identicon.context
|
|
||||||
context.reset()
|
|
||||||
var draw_circle = function(context, x, y, radius) {
|
|
||||||
context.beginPath()
|
|
||||||
context.arc(x, y, radius, 0, 2 * Math.PI, false)
|
|
||||||
context.fillStyle = "rgba(0, 0, 0, 0.1)"
|
|
||||||
context.fill()
|
|
||||||
}
|
|
||||||
var size = Math.min(identicon.height, identicon.width)
|
|
||||||
var centerX = size / 2
|
|
||||||
var centerY = size / 2
|
|
||||||
var radius = size/15
|
|
||||||
draw_circle(context, centerX, centerY, radius)
|
|
||||||
draw_circle(context, 2*radius, 2*radius, radius)
|
|
||||||
draw_circle(context, centerX, 2*radius, radius)
|
|
||||||
draw_circle(context, size - 2*radius, 2*radius, radius)
|
|
||||||
draw_circle(context, size - 2*radius, centerY, radius)
|
|
||||||
draw_circle(context, size - 2*radius, size - 2*radius, radius)
|
|
||||||
draw_circle(context, centerX, size - 2*radius, radius)
|
|
||||||
draw_circle(context, 2*radius, size - 2*radius, radius)
|
|
||||||
draw_circle(context, 2*radius, centerY, radius)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
TextField {
|
ComboBox {
|
||||||
id: nameField
|
Layout.minimumWidth: Scaling.cm(3)
|
||||||
Layout.fillWidth: true
|
enabled: senderPicker.account
|
||||||
onTextChanged: identicon.requestPaint()
|
model: ["CORE", "USD", "GOLD"]
|
||||||
|
}
|
||||||
|
Item { Layout.fillWidth: true }
|
||||||
|
Button {
|
||||||
|
text: qsTr("Cancel")
|
||||||
|
onClicked: finished()
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
text: qsTr("Transfer")
|
||||||
|
enabled: senderPicker.account
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,9 +76,9 @@ ApplicationWindow {
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
console.log("Waiting for result...")
|
console.log("Waiting for result...")
|
||||||
acct.idChanged.connect(function(loadedAcct) {
|
acct.idChanged.connect(function() {
|
||||||
console.log( "ID CHANGED" );
|
console.log( "ID CHANGED" );
|
||||||
console.log(JSON.stringify(loadedAcct))
|
console.log(JSON.stringify(acct))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,10 @@
|
||||||
<file>main.qml</file>
|
<file>main.qml</file>
|
||||||
<file>TransferForm.qml</file>
|
<file>TransferForm.qml</file>
|
||||||
<file>FormBox.qml</file>
|
<file>FormBox.qml</file>
|
||||||
<file>jdenticon/jdenticon-1.0.1.min.js</file>
|
|
||||||
<file>Scaling.qml</file>
|
<file>Scaling.qml</file>
|
||||||
|
<file>Identicon.qml</file>
|
||||||
|
<file>AccountPicker.qml</file>
|
||||||
|
<file>jdenticon/jdenticon-1.0.1.min.js</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue