Browse Source

StateDialog.qml / TransactionDialog.qml redesign

TODO: refactor using Style.qml
cl-refactor
yann300 10 years ago
parent
commit
785cde6492
  1. 4
      mix/qml/NewProjectDialog.qml
  2. 2
      mix/qml/QHashTypeView.qml
  3. 2
      mix/qml/QIntTypeView.qml
  4. 2
      mix/qml/QStringTypeView.qml
  5. 65
      mix/qml/StateDialog.qml
  6. 1
      mix/qml/StateListModel.qml
  7. 164
      mix/qml/TransactionDialog.qml

4
mix/qml/NewProjectDialog.qml

@ -5,7 +5,7 @@ import QtQuick.Window 2.0
import QtQuick.Dialogs 1.1 import QtQuick.Dialogs 1.1
Window { Window {
id: newProjectWin
modality: Qt.WindowModal modality: Qt.WindowModal
width: 640 width: 640
@ -18,6 +18,8 @@ Window {
signal accepted signal accepted
function open() { function open() {
newProjectWin.setX((Screen.width - width) / 2);
newProjectWin.setY((Screen.height - height) / 2);
visible = true; visible = true;
titleField.focus = true; titleField.focus = true;
} }

2
mix/qml/QHashTypeView.qml

@ -12,6 +12,8 @@ Item
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
radius: 4
color: "#f7f7f7"
TextInput { TextInput {
id: textinput id: textinput
text: text text: text

2
mix/qml/QIntTypeView.qml

@ -12,6 +12,8 @@ Item
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
radius: 4
color: "#f7f7f7"
TextInput { TextInput {
id: textinput id: textinput
text: text text: text

2
mix/qml/QStringTypeView.qml

@ -12,6 +12,8 @@ Item
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
radius: 4
color: "#f7f7f7"
TextInput { TextInput {
id: textinput id: textinput
text: text text: text

65
mix/qml/StateDialog.qml

@ -12,9 +12,9 @@ Window {
id: modalStateDialog id: modalStateDialog
modality: Qt.WindowModal modality: Qt.WindowModal
width: 640 width: 450
height: 480 height: 480
title: qsTr("State Edition")
visible: false visible: false
color: StateDialogStyle.generic.backgroundColor color: StateDialogStyle.generic.backgroundColor
@ -36,10 +36,16 @@ Window {
transactionsModel.append(item.transactions[t]); transactionsModel.append(item.transactions[t]);
stateTransactions.push(item.transactions[t]); stateTransactions.push(item.transactions[t]);
} }
modalStateDialog.setX((Screen.width - width) / 2);
modalStateDialog.setY((Screen.height - height) / 2);
visible = true; visible = true;
isDefault = setDefault; isDefault = setDefault;
titleField.focus = true; titleField.focus = true;
defaultCheckBox.enabled = !isDefault; defaultCheckBox.enabled = !isDefault;
} }
function close() { function close() {
@ -110,15 +116,43 @@ Window {
ColumnLayout ColumnLayout
{ {
width: parent.width
anchors.top: dialogContent.bottom anchors.top: dialogContent.bottom
anchors.topMargin: 5 anchors.topMargin: 5
spacing: 5 spacing: 5
Label { RowLayout
text: qsTr("Transactions") {
font.family: regularFont.name Label {
color: "#808080" text: qsTr("Transactions")
font.family: regularFont.name
color: "#808080"
}
Button {
tooltip: qsTr("Create a new transaction")
onClicked: transactionsModel.addTransaction()
height: 5
width: 5
style: ButtonStyle
{
label: Text {
font.family: regularFont.name
text: qsTr("+")
font.pointSize: 15
color: "#808080"
height: 5
width: 5
}
background: Rectangle {
radius: 4
border.width: 1
color: "#f7f7f7"
height: 5
implicitHeight: 5
}
}
} }
}
ListView { ListView {
id: trList id: trList
@ -129,22 +163,6 @@ Window {
delegate: transactionRenderDelegate delegate: transactionRenderDelegate
visible: transactionsModel.count > 0 visible: transactionsModel.count > 0
} }
ToolButton {
onClicked: transactionsModel.addTransaction()
style: ButtonStyle
{
label: Text {
font.family: regularFont.name
text: qsTr("+")
font.pointSize: 20
color: "#808080"
}
background: Rectangle {
color: "transparent"
}
}
}
} }
RowLayout { RowLayout {
@ -260,5 +278,4 @@ Window {
} }
} }
} }
} }

1
mix/qml/StateListModel.qml

@ -2,6 +2,7 @@ import QtQuick 2.2
import QtQuick.Controls.Styles 1.1 import QtQuick.Controls.Styles 1.1
import QtQuick.Controls 1.1 import QtQuick.Controls 1.1
import QtQuick.Dialogs 1.1 import QtQuick.Dialogs 1.1
import QtQuick.Window 2.2
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import org.ethereum.qml.QEther 1.0 import org.ethereum.qml.QEther 1.0
import "js/QEtherHelper.js" as QEtherHelper import "js/QEtherHelper.js" as QEtherHelper

164
mix/qml/TransactionDialog.qml

@ -10,11 +10,11 @@ import "."
Window { Window {
id: modalTransactionDialog id: modalTransactionDialog
modality: Qt.WindowModal modality: Qt.WindowModal
width: 640 width: 450
height: 700 height: (paramsModel.count > 0 ? 550 : 300)
visible: false visible: false
color: StateDialogStyle.generic.backgroundColor color: StateDialogStyle.generic.backgroundColor
title: qsTr("Transaction Edition")
property int transactionIndex property int transactionIndex
property alias transactionParams: paramsModel; property alias transactionParams: paramsModel;
property alias gas: gasField.value; property alias gas: gasField.value;
@ -66,6 +66,9 @@ Window {
for (var p = 0; p < parameters.length; p++) for (var p = 0; p < parameters.length; p++)
loadParameter(parameters[p]); loadParameter(parameters[p]);
} }
modalTransactionDialog.setX((Screen.width - width) / 2);
modalTransactionDialog.setY((Screen.height - height) / 2);
visible = true; visible = true;
valueField.focus = true; valueField.focus = true;
} }
@ -108,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() function close()
{ {
visible = false; visible = false;
@ -163,13 +175,16 @@ Window {
id: regularFont id: regularFont
} }
ColumnLayout { Rectangle {
id: dialogContent anchors.fill: parent
width: parent.width
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
anchors.margins: 10 anchors.margins: 10
color: StateDialogStyle.generic.backgroundColor
ColumnLayout {
id: dialogContent
spacing: 30 spacing: 30
RowLayout RowLayout
{ {
@ -257,64 +272,74 @@ Window {
} }
} }
//ColumnLayout Label {
//{ text: qsTr("Parameters")
//Layout.fillHeight: true; Layout.preferredWidth: 75
//Layout.fillWidth: true; font.family: regularFont.name
//visible: paramsModel.count > 0 color: "#808080"
visible: paramsModel.count > 0
Label { }
text: qsTr("Parameters")
Layout.preferredWidth: 75
font.family: regularFont.name
color: "#808080"
visible: paramsModel.count > 0
}
ScrollView
{
Layout.fillWidth: true
visible: paramsModel.count > 0
ColumnLayout
{
id: paramRepeater
Layout.fillWidth: true
spacing: 10
Repeater Repeater
{ {
anchors.fill: parent
model: paramsModel model: paramsModel
visible: paramsModel.count > 0 visible: paramsModel.count > 0
Rectangle RowLayout
{ {
color: "transparent" id: row
Layout.fillWidth: true Layout.fillWidth: true
height: 150 height: 150
Label { Label {
id: typeLabel id: typeLabel
text: type text: type
font.family: regularFont.name
Layout.preferredWidth: 50
} }
Label { Label {
anchors.left: typeLabel.right
id: nameLabel id: nameLabel
text: name text: name
font.family: regularFont.name
Layout.preferredWidth: 50
} }
Label { Label {
anchors.left: nameLabel.right
id: equalLabel id: equalLabel
text: "=" text: "="
font.family: regularFont.name
Layout.preferredWidth: 15
} }
Loader Loader
{ {
anchors.left: equalLabel.right
id: typeLoader id: typeLoader
height: 50 Layout.preferredHeight: 50
width: 150 Layout.preferredWidth: 150
function getCurrent()
{
return modalTransactionDialog.param(name);
}
Connections { Connections {
target: typeLoader.item target: typeLoader.item
onTextChanged: { onTextChanged: {
console.log("text changed 0 " + value); typeLoader.getCurrent().value = typeLoader.item.text;
value = typeLoader.item.text;
console.log("text changed 1 " + value);
} }
} }
sourceComponent: sourceComponent:
{ {
console.log(type);
if (type.indexOf("int") !== -1) if (type.indexOf("int") !== -1)
return intViewComp; return intViewComp;
else if (type.indexOf("bool") !== -1) else if (type.indexOf("bool") !== -1)
@ -335,7 +360,7 @@ Window {
height: 50 height: 50
width: 150 width: 150
id: intView id: intView
text: value text: typeLoader.getCurrent().value
} }
} }
@ -350,10 +375,8 @@ Window {
defaultValue: "1" defaultValue: "1"
Component.onCompleted: Component.onCompleted:
{ {
/*loaderEditor.updateValue(styleData.row, styleData.role, var current = typeLoader.getCurrent().value;
(paramsModel.get(styleData.row).value === "" ? defaultValue : (current === "" ? text = defaultValue : text = current);
paramsModel.get(styleData.row).value));
text = (paramsModel.get(styleData.row).value === "" ? defaultValue : paramsModel.get(styleData.row).value);*/
} }
} }
} }
@ -366,7 +389,10 @@ Window {
height: 50 height: 50
width: 150 width: 150
id: stringView id: stringView
text: value text:
{
return typeLoader.getCurrent().value
}
} }
} }
@ -378,61 +404,34 @@ Window {
height: 50 height: 50
width: 150 width: 150
id: hashView id: hashView
text: value text: typeLoader.getCurrent().value
} }
} }
} }
} }
} }
//} }
/*TableView {
model: paramsModel
Layout.fillWidth: true
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 RowLayout
{ {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.right: parent.right; anchors.right: parent.right;
Button { Button {
text: qsTr("OK"); text: qsTr("OK");
onClicked: { onClicked: {
close(); close();
accepted(); accepted();
}
}
Button {
text: qsTr("Cancel");
onClicked: close();
} }
} }
Button {
text: qsTr("Cancel");
onClicked: close();
}
}
}
ListModel { ListModel {
id: paramsModel id: paramsModel
} }
@ -466,7 +465,6 @@ Window {
sourceComponent: sourceComponent:
{ {
console.log("role " + styleData.role);
if (styleData.role === "value") if (styleData.role === "value")
{ {
if (paramsModel.get(styleData.row) === undefined) if (paramsModel.get(styleData.row) === undefined)

Loading…
Cancel
Save