|
|
@ -2,16 +2,19 @@ import QtQuick 2.2 |
|
|
|
import QtQuick.Controls 1.1 |
|
|
|
import QtQuick.Layouts 1.1 |
|
|
|
import QtQuick.Window 2.0 |
|
|
|
import QtQuick.Controls.Styles 1.3 |
|
|
|
import org.ethereum.qml.QEther 1.0 |
|
|
|
import "js/TransactionHelper.js" as TransactionHelper |
|
|
|
import "." |
|
|
|
|
|
|
|
Window { |
|
|
|
id: modalTransactionDialog |
|
|
|
modality: Qt.WindowModal |
|
|
|
width:640 |
|
|
|
height:640 |
|
|
|
width: 450 |
|
|
|
height: (paramsModel.count > 0 ? 550 : 300) |
|
|
|
visible: false |
|
|
|
|
|
|
|
color: StateDialogStyle.generic.backgroundColor |
|
|
|
title: qsTr("Transaction Edition") |
|
|
|
property int transactionIndex |
|
|
|
property alias transactionParams: paramsModel; |
|
|
|
property alias gas: gasField.value; |
|
|
@ -63,6 +66,9 @@ Window { |
|
|
|
for (var p = 0; p < parameters.length; p++) |
|
|
|
loadParameter(parameters[p]); |
|
|
|
} |
|
|
|
modalTransactionDialog.setX((Screen.width - width) / 2); |
|
|
|
modalTransactionDialog.setY((Screen.height - height) / 2); |
|
|
|
|
|
|
|
visible = true; |
|
|
|
valueField.focus = true; |
|
|
|
} |
|
|
@ -105,6 +111,15 @@ Window { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function param(name) |
|
|
|
{ |
|
|
|
for (var k = 0; k < paramsModel.count; k++) |
|
|
|
{ |
|
|
|
if (paramsModel.get(k).name === name) |
|
|
|
return paramsModel.get(k); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function close() |
|
|
|
{ |
|
|
|
visible = false; |
|
|
@ -155,264 +170,269 @@ Window { |
|
|
|
return item; |
|
|
|
} |
|
|
|
|
|
|
|
ColumnLayout { |
|
|
|
id: dialogContent |
|
|
|
width: parent.width |
|
|
|
SourceSansProRegular |
|
|
|
{ |
|
|
|
id: regularFont |
|
|
|
} |
|
|
|
|
|
|
|
Rectangle { |
|
|
|
anchors.fill: parent |
|
|
|
anchors.left: parent.left |
|
|
|
anchors.right: parent.right |
|
|
|
anchors.top: parent.top |
|
|
|
anchors.margins: 10 |
|
|
|
spacing: 30 |
|
|
|
RowLayout |
|
|
|
{ |
|
|
|
id: rowFunction |
|
|
|
Layout.fillWidth: true |
|
|
|
height: 150 |
|
|
|
Label { |
|
|
|
Layout.preferredWidth: 75 |
|
|
|
text: qsTr("Function") |
|
|
|
} |
|
|
|
ComboBox { |
|
|
|
id: functionComboBox |
|
|
|
color: StateDialogStyle.generic.backgroundColor |
|
|
|
|
|
|
|
ColumnLayout { |
|
|
|
id: dialogContent |
|
|
|
spacing: 30 |
|
|
|
RowLayout |
|
|
|
{ |
|
|
|
id: rowFunction |
|
|
|
Layout.fillWidth: true |
|
|
|
currentIndex: -1 |
|
|
|
textRole: "text" |
|
|
|
editable: false |
|
|
|
model: ListModel { |
|
|
|
id: functionsModel |
|
|
|
height: 150 |
|
|
|
Label { |
|
|
|
Layout.preferredWidth: 75 |
|
|
|
text: qsTr("Function") |
|
|
|
font.family: regularFont.name |
|
|
|
color: "#808080" |
|
|
|
} |
|
|
|
onCurrentIndexChanged: { |
|
|
|
loadParameters(); |
|
|
|
ComboBox { |
|
|
|
id: functionComboBox |
|
|
|
Layout.preferredWidth: 350 |
|
|
|
currentIndex: -1 |
|
|
|
textRole: "text" |
|
|
|
editable: false |
|
|
|
model: ListModel { |
|
|
|
id: functionsModel |
|
|
|
} |
|
|
|
onCurrentIndexChanged: { |
|
|
|
loadParameters(); |
|
|
|
} |
|
|
|
style: ComboBoxStyle { |
|
|
|
font: regularFont.name |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RowLayout |
|
|
|
{ |
|
|
|
id: rowValue |
|
|
|
Layout.fillWidth: true |
|
|
|
Label { |
|
|
|
Layout.preferredWidth: 75 |
|
|
|
text: qsTr("Value") |
|
|
|
} |
|
|
|
Rectangle |
|
|
|
RowLayout |
|
|
|
{ |
|
|
|
id: rowValue |
|
|
|
Layout.fillWidth: true |
|
|
|
height: 150 |
|
|
|
Label { |
|
|
|
Layout.preferredWidth: 75 |
|
|
|
text: qsTr("Value") |
|
|
|
font.family: regularFont.name |
|
|
|
color: "#808080" |
|
|
|
} |
|
|
|
Ether { |
|
|
|
id: valueField |
|
|
|
edit: true |
|
|
|
displayFormattedValue: true |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RowLayout |
|
|
|
{ |
|
|
|
id: rowGas |
|
|
|
Layout.fillWidth: true |
|
|
|
Label { |
|
|
|
Layout.preferredWidth: 75 |
|
|
|
text: qsTr("Gas") |
|
|
|
} |
|
|
|
Rectangle |
|
|
|
RowLayout |
|
|
|
{ |
|
|
|
id: rowGas |
|
|
|
Layout.fillWidth: true |
|
|
|
height: 150 |
|
|
|
Label { |
|
|
|
Layout.preferredWidth: 75 |
|
|
|
text: qsTr("Gas") |
|
|
|
font.family: regularFont.name |
|
|
|
color: "#808080" |
|
|
|
} |
|
|
|
Ether { |
|
|
|
id: gasField |
|
|
|
edit: true |
|
|
|
displayFormattedValue: true |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
RowLayout |
|
|
|
{ |
|
|
|
id: rowGasPrice |
|
|
|
Layout.fillWidth: true |
|
|
|
Label { |
|
|
|
Layout.preferredWidth: 75 |
|
|
|
text: qsTr("Gas Price") |
|
|
|
} |
|
|
|
Rectangle |
|
|
|
RowLayout |
|
|
|
{ |
|
|
|
id: rowGasPrice |
|
|
|
Layout.fillWidth: true |
|
|
|
height: 150 |
|
|
|
Label { |
|
|
|
Layout.preferredWidth: 75 |
|
|
|
text: qsTr("Gas Price") |
|
|
|
font.family: regularFont.name |
|
|
|
color: "#808080" |
|
|
|
} |
|
|
|
Ether { |
|
|
|
id: gasPriceField |
|
|
|
edit: true |
|
|
|
displayFormattedValue: true |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
RowLayout |
|
|
|
{ |
|
|
|
Layout.fillWidth: true |
|
|
|
Label { |
|
|
|
text: qsTr("Parameters") |
|
|
|
Layout.preferredWidth: 75 |
|
|
|
font.family: regularFont.name |
|
|
|
color: "#808080" |
|
|
|
visible: paramsModel.count > 0 |
|
|
|
} |
|
|
|
TableView { |
|
|
|
model: paramsModel |
|
|
|
Layout.preferredWidth: 120 * 2 + 240 |
|
|
|
Layout.minimumHeight: 150 |
|
|
|
Layout.preferredHeight: 400 |
|
|
|
Layout.maximumHeight: 600 |
|
|
|
TableViewColumn { |
|
|
|
role: "name" |
|
|
|
title: qsTr("Name") |
|
|
|
width: 120 |
|
|
|
} |
|
|
|
TableViewColumn { |
|
|
|
role: "type" |
|
|
|
title: qsTr("Type") |
|
|
|
width: 120 |
|
|
|
} |
|
|
|
TableViewColumn { |
|
|
|
role: "value" |
|
|
|
title: qsTr("Value") |
|
|
|
width: 240 |
|
|
|
} |
|
|
|
|
|
|
|
rowDelegate: rowDelegate |
|
|
|
itemDelegate: editableDelegate |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
RowLayout |
|
|
|
{ |
|
|
|
anchors.bottom: parent.bottom |
|
|
|
anchors.right: parent.right; |
|
|
|
|
|
|
|
Button { |
|
|
|
text: qsTr("OK"); |
|
|
|
onClicked: { |
|
|
|
close(); |
|
|
|
accepted(); |
|
|
|
} |
|
|
|
} |
|
|
|
Button { |
|
|
|
text: qsTr("Cancel"); |
|
|
|
onClicked: close(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ListModel { |
|
|
|
id: paramsModel |
|
|
|
} |
|
|
|
|
|
|
|
Component { |
|
|
|
id: rowDelegate |
|
|
|
Item { |
|
|
|
height: 100 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Component { |
|
|
|
id: editableDelegate |
|
|
|
Item { |
|
|
|
Loader { |
|
|
|
id: loaderEditor |
|
|
|
anchors.fill: parent |
|
|
|
anchors.margins: 4 |
|
|
|
Connections { |
|
|
|
target: loaderEditor.item |
|
|
|
onTextChanged: { |
|
|
|
if (styleData.role === "value" && styleData.row < paramsModel.count) |
|
|
|
loaderEditor.updateValue(styleData.row, styleData.role, loaderEditor.item.text); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function updateValue(row, role, value) |
|
|
|
{ |
|
|
|
paramsModel.setProperty(styleData.row, styleData.role, value); |
|
|
|
} |
|
|
|
|
|
|
|
sourceComponent: |
|
|
|
{ |
|
|
|
if (styleData.role === "value") |
|
|
|
{ |
|
|
|
if (paramsModel.get(styleData.row) === undefined) |
|
|
|
return null; |
|
|
|
if (paramsModel.get(styleData.row).type.indexOf("int") !== -1) |
|
|
|
return intViewComp; |
|
|
|
else if (paramsModel.get(styleData.row).type.indexOf("bool") !== -1) |
|
|
|
return boolViewComp; |
|
|
|
else if (paramsModel.get(styleData.row).type.indexOf("string") !== -1) |
|
|
|
return stringViewComp; |
|
|
|
else if (paramsModel.get(styleData.row).type.indexOf("hash") !== -1) |
|
|
|
return hashViewComp; |
|
|
|
} |
|
|
|
else |
|
|
|
return editor; |
|
|
|
} |
|
|
|
|
|
|
|
Component |
|
|
|
{ |
|
|
|
id: intViewComp |
|
|
|
QIntTypeView |
|
|
|
{ |
|
|
|
id: intView |
|
|
|
text: styleData.value |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Component |
|
|
|
ScrollView |
|
|
|
{ |
|
|
|
Layout.fillWidth: true |
|
|
|
visible: paramsModel.count > 0 |
|
|
|
ColumnLayout |
|
|
|
{ |
|
|
|
id: boolViewComp |
|
|
|
QBoolTypeView |
|
|
|
id: paramRepeater |
|
|
|
Layout.fillWidth: true |
|
|
|
spacing: 10 |
|
|
|
Repeater |
|
|
|
{ |
|
|
|
id: boolView |
|
|
|
defaultValue: "1" |
|
|
|
Component.onCompleted: |
|
|
|
anchors.fill: parent |
|
|
|
model: paramsModel |
|
|
|
visible: paramsModel.count > 0 |
|
|
|
RowLayout |
|
|
|
{ |
|
|
|
loaderEditor.updateValue(styleData.row, styleData.role, |
|
|
|
(paramsModel.get(styleData.row).value === "" ? defaultValue : |
|
|
|
paramsModel.get(styleData.row).value)); |
|
|
|
text = (paramsModel.get(styleData.row).value === "" ? defaultValue : paramsModel.get(styleData.row).value); |
|
|
|
id: row |
|
|
|
Layout.fillWidth: true |
|
|
|
height: 150 |
|
|
|
|
|
|
|
Label { |
|
|
|
id: typeLabel |
|
|
|
text: type |
|
|
|
font.family: regularFont.name |
|
|
|
Layout.preferredWidth: 50 |
|
|
|
} |
|
|
|
|
|
|
|
Label { |
|
|
|
id: nameLabel |
|
|
|
text: name |
|
|
|
font.family: regularFont.name |
|
|
|
Layout.preferredWidth: 50 |
|
|
|
} |
|
|
|
|
|
|
|
Label { |
|
|
|
id: equalLabel |
|
|
|
text: "=" |
|
|
|
font.family: regularFont.name |
|
|
|
Layout.preferredWidth: 15 |
|
|
|
} |
|
|
|
|
|
|
|
Loader |
|
|
|
{ |
|
|
|
id: typeLoader |
|
|
|
Layout.preferredHeight: 50 |
|
|
|
Layout.preferredWidth: 150 |
|
|
|
function getCurrent() |
|
|
|
{ |
|
|
|
return modalTransactionDialog.param(name); |
|
|
|
} |
|
|
|
|
|
|
|
Connections { |
|
|
|
target: typeLoader.item |
|
|
|
onTextChanged: { |
|
|
|
typeLoader.getCurrent().value = typeLoader.item.text; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
sourceComponent: |
|
|
|
{ |
|
|
|
if (type.indexOf("int") !== -1) |
|
|
|
return intViewComp; |
|
|
|
else if (type.indexOf("bool") !== -1) |
|
|
|
return boolViewComp; |
|
|
|
else if (type.indexOf("string") !== -1) |
|
|
|
return stringViewComp; |
|
|
|
else if (type.indexOf("hash") !== -1) |
|
|
|
return hashViewComp; |
|
|
|
else |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
Component |
|
|
|
{ |
|
|
|
id: intViewComp |
|
|
|
QIntTypeView |
|
|
|
{ |
|
|
|
height: 50 |
|
|
|
width: 150 |
|
|
|
id: intView |
|
|
|
text: typeLoader.getCurrent().value |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Component |
|
|
|
{ |
|
|
|
id: boolViewComp |
|
|
|
QBoolTypeView |
|
|
|
{ |
|
|
|
height: 50 |
|
|
|
width: 150 |
|
|
|
id: boolView |
|
|
|
defaultValue: "1" |
|
|
|
Component.onCompleted: |
|
|
|
{ |
|
|
|
var current = typeLoader.getCurrent().value; |
|
|
|
(current === "" ? text = defaultValue : text = current); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Component |
|
|
|
{ |
|
|
|
id: stringViewComp |
|
|
|
QStringTypeView |
|
|
|
{ |
|
|
|
height: 50 |
|
|
|
width: 150 |
|
|
|
id: stringView |
|
|
|
text: |
|
|
|
{ |
|
|
|
return typeLoader.getCurrent().value |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Component |
|
|
|
{ |
|
|
|
id: hashViewComp |
|
|
|
QHashTypeView |
|
|
|
{ |
|
|
|
height: 50 |
|
|
|
width: 150 |
|
|
|
id: hashView |
|
|
|
text: typeLoader.getCurrent().value |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Component |
|
|
|
{ |
|
|
|
id: stringViewComp |
|
|
|
QStringTypeView |
|
|
|
{ |
|
|
|
id: stringView |
|
|
|
text: styleData.value |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Component |
|
|
|
{ |
|
|
|
id: hashViewComp |
|
|
|
QHashTypeView |
|
|
|
{ |
|
|
|
id: hashView |
|
|
|
text: styleData.value |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Component { |
|
|
|
id: editor |
|
|
|
TextInput { |
|
|
|
id: textinput |
|
|
|
readOnly: true |
|
|
|
color: styleData.textColor |
|
|
|
text: styleData.value |
|
|
|
MouseArea { |
|
|
|
id: mouseArea |
|
|
|
anchors.fill: parent |
|
|
|
hoverEnabled: true |
|
|
|
onClicked: textinput.forceActiveFocus() |
|
|
|
} |
|
|
|
} |
|
|
|
RowLayout |
|
|
|
{ |
|
|
|
anchors.bottom: parent.bottom |
|
|
|
anchors.right: parent.right; |
|
|
|
|
|
|
|
Button { |
|
|
|
text: qsTr("OK"); |
|
|
|
onClicked: { |
|
|
|
close(); |
|
|
|
accepted(); |
|
|
|
} |
|
|
|
} |
|
|
|
Button { |
|
|
|
text: qsTr("Cancel"); |
|
|
|
onClicked: close(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
ListModel { |
|
|
|
id: paramsModel |
|
|
|
} |
|
|
|
} |
|
|
|