Browse Source

Merge pull request #1500 from yann300/ui_macos

Fix #629
cl-refactor
Arkadiy Paronyan 10 years ago
parent
commit
9cf995a71a
  1. 2
      mix/qml/Application.qml
  2. 448
      mix/qml/DeploymentDialog.qml
  3. 94
      mix/qml/NewProjectDialog.qml
  4. 564
      mix/qml/StateDialog.qml
  5. 74
      mix/qml/StateList.qml
  6. 379
      mix/qml/TransactionDialog.qml

2
mix/qml/Application.qml

@ -178,7 +178,7 @@ ApplicationWindow {
id: editStatesAction id: editStatesAction
text: qsTr("Edit States") text: qsTr("Edit States")
shortcut: "Ctrl+Alt+E" shortcut: "Ctrl+Alt+E"
onTriggered: stateList.show(); onTriggered: stateList.open();
} }
Connections { Connections {

448
mix/qml/DeploymentDialog.qml

@ -2,7 +2,7 @@ import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Window 2.0 import QtQuick.Window 2.0
import QtQuick.Dialogs 1.1 import QtQuick.Dialogs 1.2
import QtQuick.Controls.Styles 1.3 import QtQuick.Controls.Styles 1.3
import org.ethereum.qml.QEther 1.0 import org.ethereum.qml.QEther 1.0
import "js/TransactionHelper.js" as TransactionHelper import "js/TransactionHelper.js" as TransactionHelper
@ -11,16 +11,11 @@ import "js/QEtherHelper.js" as QEtherHelper
import "." import "."
Window { Dialog {
id: modalDeploymentDialog id: modalDeploymentDialog
modality: Qt.ApplicationModal modality: Qt.ApplicationModal
width: 735 width: 735
height: 320 height: 400
maximumWidth: width
minimumWidth: width
maximumHeight: height
minimumHeight: height
visible: false visible: false
property alias applicationUrlEth: applicationUrlEth.text property alias applicationUrlEth: applicationUrlEth.text
property alias applicationUrlHttp: applicationUrlHttp.text property alias applicationUrlHttp: applicationUrlHttp.text
@ -32,8 +27,6 @@ Window {
property string currentAccount property string currentAccount
property alias gasToUse: gasToUseInput.text property alias gasToUse: gasToUseInput.text
color: appStyle.generic.layout.backgroundColor
function close() function close()
{ {
visible = false; visible = false;
@ -41,10 +34,7 @@ Window {
function open() function open()
{ {
modalDeploymentDialog.setX((Screen.width - width) / 2);
modalDeploymentDialog.setY((Screen.height - height) / 2);
visible = true; visible = true;
var requests = [{ var requests = [{
//accounts //accounts
jsonrpc: "2.0", jsonrpc: "2.0",
@ -160,136 +150,140 @@ Window {
id: lightFont id: lightFont
} }
Column contentItem: Rectangle {
{ color: appStyle.generic.layout.backgroundColor
spacing: 5
anchors.fill: parent anchors.fill: parent
anchors.margins: 10 Column
ColumnLayout
{ {
id: containerDeploy spacing: 5
Layout.fillWidth: true anchors.fill: parent
Layout.preferredHeight: 500 anchors.margins: 10
RowLayout ColumnLayout
{ {
Rectangle id: containerDeploy
Layout.fillWidth: true
Layout.preferredHeight: 500
RowLayout
{ {
Layout.preferredWidth: 357 Rectangle
DefaultLabel
{ {
text: qsTr("Deployment") Layout.preferredWidth: 357
font.family: lightFont.name DefaultLabel
font.underline: true {
anchors.centerIn: parent text: qsTr("Deployment")
font.family: lightFont.name
font.underline: true
anchors.centerIn: parent
}
} }
}
Button Button
{ {
action: displayHelpAction action: displayHelpAction
iconSource: "qrc:/qml/img/help.png" iconSource: "qrc:/qml/img/help.png"
}
Action {
id: displayHelpAction
tooltip: qsTr("Help")
onTriggered: {
Qt.openUrlExternally("https://github.com/ethereum/wiki/wiki/Mix:-The-DApp-IDE#deployment-to-network")
} }
}
Button Action {
{ id: displayHelpAction
action: openFolderAction tooltip: qsTr("Help")
iconSource: "qrc:/qml/img/openedfolder.png" onTriggered: {
} Qt.openUrlExternally("https://github.com/ethereum/wiki/wiki/Mix:-The-DApp-IDE#deployment-to-network")
}
Action {
id: openFolderAction
enabled: deploymentDialog.packageBase64 !== ""
tooltip: qsTr("Open Package Folder")
onTriggered: {
fileIo.openFileBrowser(projectModel.deploymentDir);
} }
}
Button Button
{ {
action: b64Action action: openFolderAction
iconSource: "qrc:/qml/img/b64.png" iconSource: "qrc:/qml/img/openedfolder.png"
} }
Action { Action {
id: b64Action id: openFolderAction
enabled: deploymentDialog.packageBase64 !== "" enabled: deploymentDialog.packageBase64 !== ""
tooltip: qsTr("Copy Base64 conversion to ClipBoard") tooltip: qsTr("Open Package Folder")
onTriggered: { onTriggered: {
clipboard.text = deploymentDialog.packageBase64; fileIo.openFileBrowser(projectModel.deploymentDir);
}
} }
}
Button Button
{ {
action: exitAction action: b64Action
iconSource: "qrc:/qml/img/exit.png" iconSource: "qrc:/qml/img/b64.png"
} }
Action { Action {
id: exitAction id: b64Action
tooltip: qsTr("Exit") enabled: deploymentDialog.packageBase64 !== ""
onTriggered: { tooltip: qsTr("Copy Base64 conversion to ClipBoard")
close() onTriggered: {
clipboard.text = deploymentDialog.packageBase64;
}
} }
}
}
GridLayout Button
{ {
columns: 2 action: exitAction
width: parent.width iconSource: "qrc:/qml/img/exit.png"
}
DefaultLabel Action {
{ id: exitAction
text: qsTr("Root Registrar address:") tooltip: qsTr("Exit")
onTriggered: {
close()
}
}
} }
DefaultTextField GridLayout
{ {
Layout.preferredWidth: 350 columns: 2
id: registrarAddr width: parent.width
}
DefaultLabel DefaultLabel
{ {
text: qsTr("Account used to deploy:") text: qsTr("Root Registrar address:")
} }
Rectangle DefaultTextField
{ {
width: 300 Layout.preferredWidth: 350
height: 25 id: registrarAddr
color: "transparent"
ComboBox {
id: comboAccounts
property var balances: []
onCurrentIndexChanged : {
if (modelAccounts.count > 0)
{
currentAccount = modelAccounts.get(currentIndex).id;
balance.text = balances[currentIndex];
}
}
model: ListModel {
id: modelAccounts
}
} }
DefaultLabel DefaultLabel
{ {
anchors.verticalCenter: parent.verticalCenter text: qsTr("Account used to deploy:")
anchors.left: comboAccounts.right }
anchors.leftMargin: 20
id: balance; Rectangle
{
width: 300
height: 25
color: "transparent"
ComboBox {
id: comboAccounts
property var balances: []
onCurrentIndexChanged : {
if (modelAccounts.count > 0)
{
currentAccount = modelAccounts.get(currentIndex).id;
balance.text = balances[currentIndex];
}
}
model: ListModel {
id: modelAccounts
}
}
DefaultLabel
{
anchors.verticalCenter: parent.verticalCenter
anchors.left: comboAccounts.right
anchors.leftMargin: 20
id: balance;
}
} }
} }
@ -335,167 +329,119 @@ Window {
} }
} }
RowLayout Rectangle
{ {
Layout.fillWidth: true width: parent.width
Rectangle height: 1
{ color: "#5891d3"
Layout.preferredWidth: 357 }
color: "transparent"
}
Button ColumnLayout
{
id: containerRegister
Layout.fillWidth: true
Layout.preferredHeight: 500
RowLayout
{ {
id: deployButton Layout.preferredHeight: 25
action: runAction Rectangle
iconSource: "qrc:/qml/img/run.png" {
} Layout.preferredWidth: 356
DefaultLabel
Action {
id: runAction
tooltip: qsTr("Deploy contract(s) and Package resources files.")
onTriggered: {
var inError = [];
var ethUrl = ProjectModelCode.formatAppUrl(applicationUrlEth.text);
for (var k in ethUrl)
{
if (ethUrl[k].length > 32)
inError.push(qsTr("Member too long: " + ethUrl[k]) + "\n");
}
if (!stopForInputError(inError))
{ {
if (contractRedeploy.checked) text: qsTr("Registration")
deployWarningDialog.open(); font.family: lightFont.name
else font.underline: true
ProjectModelCode.startDeployProject(false); anchors.centerIn: parent
} }
} }
} }
CheckBox GridLayout
{ {
anchors.left: deployButton.right columns: 2
id: contractRedeploy Layout.fillWidth: true
enabled: Object.keys(projectModel.deploymentAddresses).length > 0
checked: Object.keys(projectModel.deploymentAddresses).length == 0
text: qsTr("Deploy Contract(s)")
anchors.verticalCenter: parent.verticalCenter
}
}
}
Rectangle
{
width: parent.width
height: 1
color: "#5891d3"
}
ColumnLayout
{
id: containerRegister
Layout.fillWidth: true
Layout.preferredHeight: 500
RowLayout
{
Layout.preferredHeight: 25
Rectangle
{
Layout.preferredWidth: 356
DefaultLabel DefaultLabel
{ {
text: qsTr("Registration") Layout.preferredWidth: 355
font.family: lightFont.name text: qsTr("Local package URL")
font.underline: true
anchors.centerIn: parent
} }
}
}
GridLayout DefaultTextField
{ {
columns: 2 Layout.preferredWidth: 350
Layout.fillWidth: true id: localPackageUrl
readOnly: true
DefaultLabel enabled: rowRegister.isOkToRegister()
{ }
Layout.preferredWidth: 355
text: qsTr("Local package URL")
}
DefaultTextField DefaultLabel
{ {
Layout.preferredWidth: 350 Layout.preferredWidth: 355
id: localPackageUrl text: qsTr("URL Hint contract address:")
readOnly: true }
enabled: rowRegister.isOkToRegister()
}
DefaultLabel DefaultTextField
{ {
Layout.preferredWidth: 355 Layout.preferredWidth: 350
text: qsTr("URL Hint contract address:") id: urlHintAddr
} enabled: rowRegister.isOkToRegister()
}
DefaultTextField DefaultLabel
{ {
Layout.preferredWidth: 350 Layout.preferredWidth: 355
id: urlHintAddr text: qsTr("Web Application Resources URL: ")
enabled: rowRegister.isOkToRegister() }
}
DefaultLabel DefaultTextField
{ {
Layout.preferredWidth: 355 Layout.preferredWidth: 350
text: qsTr("Web Application Resources URL: ") id: applicationUrlHttp
enabled: rowRegister.isOkToRegister()
}
} }
DefaultTextField RowLayout
{ {
Layout.preferredWidth: 350 id: rowRegister
id: applicationUrlHttp Layout.fillWidth: true
enabled: rowRegister.isOkToRegister()
}
}
RowLayout
{
id: rowRegister
Layout.fillWidth: true
Rectangle Rectangle
{ {
Layout.preferredWidth: 357 Layout.preferredWidth: 357
color: "transparent" color: "transparent"
} }
function isOkToRegister() function isOkToRegister()
{ {
return Object.keys(projectModel.deploymentAddresses).length > 0 && deploymentDialog.packageHash !== ""; return Object.keys(projectModel.deploymentAddresses).length > 0 && deploymentDialog.packageHash !== "";
} }
Button { Button {
action: registerAction action: registerAction
iconSource: "qrc:/qml/img/note.png" iconSource: "qrc:/qml/img/note.png"
} }
Action { Action {
id: registerAction id: registerAction
enabled: rowRegister.isOkToRegister() enabled: rowRegister.isOkToRegister()
tooltip: qsTr("Register hosted Web Application.") tooltip: qsTr("Register hosted Web Application.")
onTriggered: { onTriggered: {
if (applicationUrlHttp.text === "" || deploymentDialog.packageHash === "") if (applicationUrlHttp.text === "" || deploymentDialog.packageHash === "")
{ {
deployDialog.title = text; deployDialog.title = text;
deployDialog.text = qsTr("Please provide the link where the resources are stored and ensure the package is aleary built using the deployment step.") deployDialog.text = qsTr("Please provide the link where the resources are stored and ensure the package is aleary built using the deployment step.")
deployDialog.open(); deployDialog.open();
return; return;
}
var inError = [];
if (applicationUrlHttp.text.length > 32)
inError.push(qsTr(applicationUrlHttp.text));
if (!stopForInputError(inError))
ProjectModelCode.registerToUrlHint();
} }
var inError = [];
if (applicationUrlHttp.text.length > 32)
inError.push(qsTr(applicationUrlHttp.text));
if (!stopForInputError(inError))
ProjectModelCode.registerToUrlHint();
} }
} }
} }

94
mix/qml/NewProjectDialog.qml

@ -1,10 +1,11 @@
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.2
import QtQuick.Window 2.0 import QtQuick.Window 2.0
import QtQuick.Dialogs 1.1 import QtQuick.Dialogs 1.1
Window { Dialog {
id: newProjectWin id: newProjectWin
modality: Qt.ApplicationModal modality: Qt.ApplicationModal
@ -33,62 +34,65 @@ Window {
close(); close();
accepted(); accepted();
} }
contentItem: Rectangle {
GridLayout {
id: dialogContent
columns: 2
anchors.fill: parent anchors.fill: parent
anchors.margins: 10 GridLayout
rowSpacing: 10 {
columnSpacing: 10 id: dialogContent
columns: 2
anchors.fill: parent
anchors.margins: 10
rowSpacing: 10
columnSpacing: 10
Label { Label {
text: qsTr("Title") text: qsTr("Title")
}
TextField {
id: titleField
focus: true
Layout.fillWidth: true
Keys.onReturnPressed: {
if (okButton.enabled)
acceptAndClose();
} }
}
Label {
text: qsTr("Path")
}
RowLayout {
TextField { TextField {
id: pathField id: titleField
focus: true
Layout.fillWidth: true Layout.fillWidth: true
Keys.onReturnPressed: { Keys.onReturnPressed: {
if (okButton.enabled) if (okButton.enabled)
acceptAndClose(); acceptAndClose();
} }
} }
Button {
text: qsTr("Browse") Label {
onClicked: createProjectFileDialog.open() text: qsTr("Path")
}
RowLayout {
TextField {
id: pathField
Layout.fillWidth: true
Keys.onReturnPressed: {
if (okButton.enabled)
acceptAndClose();
}
}
Button {
text: qsTr("Browse")
onClicked: createProjectFileDialog.open()
}
} }
}
RowLayout RowLayout
{ {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.right: parent.right; anchors.right: parent.right;
Button { Button {
id: okButton; id: okButton;
enabled: titleField.text != "" && pathField.text != "" enabled: titleField.text != "" && pathField.text != ""
text: qsTr("OK"); text: qsTr("OK");
onClicked: { onClicked: {
acceptAndClose(); acceptAndClose();
}
}
Button {
text: qsTr("Cancel");
onClicked: close();
} }
}
Button {
text: qsTr("Cancel");
onClicked: close();
} }
} }
} }
@ -102,8 +106,8 @@ Window {
var u = createProjectFileDialog.fileUrl.toString(); var u = createProjectFileDialog.fileUrl.toString();
if (u.indexOf("file://") == 0) if (u.indexOf("file://") == 0)
u = u.substring(7, u.length) u = u.substring(7, u.length)
if (Qt.platform.os == "windows" && u.indexOf("/") == 0) if (Qt.platform.os == "windows" && u.indexOf("/") == 0)
u = u.substring(1, u.length); u = u.substring(1, u.length);
pathField.text = u; pathField.text = u;
} }
} }

564
mix/qml/StateDialog.qml

@ -1,6 +1,6 @@
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Controls 1.1
import QtQuick.Dialogs 1.1 import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Window 2.0 import QtQuick.Window 2.0
import QtQuick.Controls.Styles 1.3 import QtQuick.Controls.Styles 1.3
@ -9,7 +9,7 @@ import "js/QEtherHelper.js" as QEtherHelper
import "js/TransactionHelper.js" as TransactionHelper import "js/TransactionHelper.js" as TransactionHelper
import "." import "."
Window { Dialog {
id: modalStateDialog id: modalStateDialog
modality: Qt.ApplicationModal modality: Qt.ApplicationModal
@ -17,7 +17,6 @@ Window {
height: 480 height: 480
title: qsTr("Edit State") title: qsTr("Edit State")
visible: false visible: false
color: stateDialogStyle.generic.backgroundColor
property alias stateTitle: titleField.text property alias stateTitle: titleField.text
property alias isDefault: defaultCheckBox.checked property alias isDefault: defaultCheckBox.checked
@ -28,6 +27,10 @@ Window {
property var stateAccounts: [] property var stateAccounts: []
signal accepted signal accepted
StateDialogStyle {
id: stateDialogStyle
}
function open(index, item, setDefault) { function open(index, item, setDefault) {
stateIndex = index; stateIndex = index;
stateTitle = item.title; stateTitle = item.title;
@ -48,9 +51,6 @@ Window {
stateAccounts.push(item.accounts[k]); stateAccounts.push(item.accounts[k]);
} }
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;
@ -77,338 +77,334 @@ Window {
item.accounts = stateAccounts; item.accounts = stateAccounts;
return item; return item;
} }
contentItem: Rectangle {
StateDialogStyle { color: stateDialogStyle.generic.backgroundColor
id: stateDialogStyle
}
ColumnLayout {
anchors.fill: parent
anchors.margins: 10
ColumnLayout { ColumnLayout {
id: dialogContent anchors.fill: parent
anchors.top: parent.top ColumnLayout {
anchors.fill: parent
RowLayout anchors.margins: 10
{ ColumnLayout {
Layout.fillWidth: true id: dialogContent
DefaultLabel { anchors.top: parent.top
Layout.preferredWidth: 75 RowLayout
text: qsTr("Title") {
} Layout.fillWidth: true
DefaultTextField DefaultLabel {
{ Layout.preferredWidth: 75
id: titleField text: qsTr("Title")
Layout.fillWidth: true }
} DefaultTextField
} {
id: titleField
CommonSeparator Layout.fillWidth: true
{ }
Layout.fillWidth: true
}
RowLayout
{
Layout.fillWidth: true
Rectangle
{
Layout.preferredWidth: 75
DefaultLabel {
id: accountsLabel
Layout.preferredWidth: 75
text: qsTr("Accounts")
} }
Button CommonSeparator
{ {
anchors.top: accountsLabel.bottom Layout.fillWidth: true
anchors.topMargin: 10
iconSource: "qrc:/qml/img/plus.png"
action: newAccountAction
} }
Action { RowLayout
id: newAccountAction {
tooltip: qsTr("Add new Account") Layout.fillWidth: true
onTriggered:
{
var account = stateListModel.newAccount("1000000", QEther.Ether);
stateAccounts.push(account);
accountsModel.append(account);
}
}
}
MessageDialog Rectangle
{ {
id: alertAlreadyUsed Layout.preferredWidth: 75
text: qsTr("This account is in use. You cannot remove it. The first account is used to deploy config contract and cannot be removed.") DefaultLabel {
icon: StandardIcon.Warning id: accountsLabel
standardButtons: StandardButton.Ok Layout.preferredWidth: 75
} text: qsTr("Accounts")
}
TableView Button
{
id: accountsView
Layout.fillWidth: true
model: accountsModel
headerVisible: false
TableViewColumn {
role: "name"
title: qsTr("Name")
width: 150
delegate: Item {
RowLayout
{ {
height: 25 anchors.top: accountsLabel.bottom
width: parent.width anchors.topMargin: 10
Button iconSource: "qrc:/qml/img/plus.png"
action: newAccountAction
}
Action {
id: newAccountAction
tooltip: qsTr("Add new Account")
onTriggered:
{ {
iconSource: "qrc:/qml/img/delete_sign.png" var account = stateListModel.newAccount("1000000", QEther.Ether);
action: deleteAccountAction stateAccounts.push(account);
accountsModel.append(account);
} }
}
}
Action { MessageDialog
id: deleteAccountAction {
tooltip: qsTr("Delete Account") id: alertAlreadyUsed
onTriggered: text: qsTr("This account is in use. You cannot remove it. The first account is used to deploy config contract and cannot be removed.")
icon: StandardIcon.Warning
standardButtons: StandardButton.Ok
}
TableView
{
id: accountsView
Layout.fillWidth: true
model: accountsModel
headerVisible: false
TableViewColumn {
role: "name"
title: qsTr("Name")
width: 150
delegate: Item {
RowLayout
{ {
if (transactionsModel.isUsed(stateAccounts[styleData.row].secret)) height: 25
alertAlreadyUsed.open(); width: parent.width
else Button
{ {
stateAccounts.splice(styleData.row, 1); iconSource: "qrc:/qml/img/delete_sign.png"
accountsModel.remove(styleData.row); action: deleteAccountAction
}
Action {
id: deleteAccountAction
tooltip: qsTr("Delete Account")
onTriggered:
{
if (transactionsModel.isUsed(stateAccounts[styleData.row].secret))
alertAlreadyUsed.open();
else
{
stateAccounts.splice(styleData.row, 1);
accountsModel.remove(styleData.row);
}
}
}
DefaultTextField {
anchors.verticalCenter: parent.verticalCenter
onTextChanged: {
if (styleData.row > -1)
stateAccounts[styleData.row].name = text;
}
text: {
return styleData.value
}
} }
} }
} }
}
DefaultTextField { TableViewColumn {
anchors.verticalCenter: parent.verticalCenter role: "balance"
onTextChanged: { title: qsTr("Balance")
if (styleData.row > -1) width: 200
stateAccounts[styleData.row].name = text; delegate: Item {
} Ether {
text: { id: balanceField
return styleData.value edit: true
displayFormattedValue: false
value: styleData.value
} }
} }
} }
rowDelegate:
Rectangle {
color: styleData.alternate ? "transparent" : "#f0f0f0"
height: 30;
}
} }
} }
TableViewColumn { CommonSeparator
role: "balance" {
title: qsTr("Balance") Layout.fillWidth: true
width: 200 }
delegate: Item {
Ether { RowLayout
id: balanceField {
edit: true Layout.fillWidth: true
displayFormattedValue: false DefaultLabel {
value: styleData.value Layout.preferredWidth: 75
} text: qsTr("Default")
}
CheckBox {
id: defaultCheckBox
Layout.fillWidth: true
} }
} }
rowDelegate:
Rectangle { CommonSeparator
color: styleData.alternate ? "transparent" : "#f0f0f0" {
height: 30; Layout.fillWidth: true
} }
} }
}
CommonSeparator ColumnLayout {
{ anchors.top: dialogContent.bottom
Layout.fillWidth: true anchors.topMargin: 5
} spacing: 0
RowLayout
{
Layout.preferredWidth: 150
DefaultLabel {
text: qsTr("Transactions: ")
}
RowLayout Button
{ {
Layout.fillWidth: true iconSource: "qrc:/qml/img/plus.png"
DefaultLabel { action: newTrAction
Layout.preferredWidth: 75 width: 10
text: qsTr("Default") height: 10
} anchors.right: parent.right
CheckBox { }
id: defaultCheckBox
Layout.fillWidth: true
}
}
CommonSeparator Action {
{ id: newTrAction
Layout.fillWidth: true tooltip: qsTr("Create a new transaction")
} onTriggered: transactionsModel.addTransaction()
} }
}
ColumnLayout { ScrollView
anchors.top: dialogContent.bottom {
anchors.topMargin: 5 Layout.fillHeight: true
spacing: 0 Layout.preferredWidth: 300
RowLayout Column
{ {
Layout.preferredWidth: 150 Layout.fillHeight: true
DefaultLabel { Repeater
text: qsTr("Transactions: ") {
id: trRepeater
model: transactionsModel
delegate: transactionRenderDelegate
visible: transactionsModel.count > 0
height: 20 * transactionsModel.count
}
}
}
} }
Button RowLayout
{ {
iconSource: "qrc:/qml/img/plus.png" anchors.bottom: parent.bottom
action: newTrAction anchors.right: parent.right;
width: 10
height: 10 Button {
anchors.right: parent.right text: qsTr("OK");
onClicked: {
close();
accepted();
}
}
Button {
text: qsTr("Cancel");
onClicked: close();
}
} }
Action { ListModel {
id: newTrAction id: accountsModel
tooltip: qsTr("Create a new transaction")
onTriggered: transactionsModel.addTransaction()
}
}
ScrollView function removeAccount(_i)
{
Layout.fillHeight: true
Layout.preferredWidth: 300
Column
{
Layout.fillHeight: true
Repeater
{ {
id: trRepeater accountsModel.remove(_i);
model: transactionsModel stateAccounts.splice(_i, 1);
delegate: transactionRenderDelegate
visible: transactionsModel.count > 0
height: 20 * transactionsModel.count
} }
} }
}
CommonSeparator ListModel {
{ id: transactionsModel
Layout.fillWidth: true
}
}
RowLayout
{
anchors.bottom: parent.bottom
anchors.right: parent.right;
Button {
text: qsTr("OK");
onClicked: {
acceptAndClose();
}
}
Button {
text: qsTr("Cancel");
onClicked: close();
}
}
}
ListModel {
id: accountsModel
function removeAccount(_i)
{
accountsModel.remove(_i);
stateAccounts.splice(_i, 1);
}
}
ListModel { function editTransaction(index) {
id: transactionsModel transactionDialog.stateAccounts = stateAccounts;
transactionDialog.open(index, transactionsModel.get(index));
}
function editTransaction(index) { function addTransaction() {
transactionDialog.stateAccounts = stateAccounts;
transactionDialog.open(index, transactionsModel.get(index));
}
function addTransaction() { // Set next id here to work around Qt bug
// https://bugreports.qt-project.org/browse/QTBUG-41327
// Second call to signal handler would just edit the item that was just created, no harm done
var item = TransactionHelper.defaultTransaction();
transactionDialog.stateAccounts = stateAccounts;
transactionDialog.open(transactionsModel.count, item);
}
// Set next id here to work around Qt bug function deleteTransaction(index) {
// https://bugreports.qt-project.org/browse/QTBUG-41327 stateTransactions.splice(index, 1);
// Second call to signal handler would just edit the item that was just created, no harm done transactionsModel.remove(index);
var item = TransactionHelper.defaultTransaction(); }
transactionDialog.stateAccounts = stateAccounts;
transactionDialog.open(transactionsModel.count, item);
}
function deleteTransaction(index) { function isUsed(secret)
stateTransactions.splice(index, 1); {
transactionsModel.remove(index); for (var i in stateTransactions)
} {
if (stateTransactions[i].sender === secret)
return true;
}
return false;
}
}
function isUsed(secret) Component {
{ id: transactionRenderDelegate
for (var i in stateTransactions) RowLayout {
{ DefaultLabel {
if (stateTransactions[i].sender === secret) Layout.preferredWidth: 150
return true; text: functionId
} }
return false;
}
}
Component { Button
id: transactionRenderDelegate {
RowLayout { id: deleteBtn
DefaultLabel { iconSource: "qrc:/qml/img/delete_sign.png"
Layout.preferredWidth: 150 action: deleteAction
text: functionId width: 10
} height: 10
Action {
id: deleteAction
tooltip: qsTr("Delete")
onTriggered: transactionsModel.deleteTransaction(index)
}
}
Button Button
{ {
id: deleteBtn iconSource: "qrc:/qml/img/edit.png"
iconSource: "qrc:/qml/img/delete_sign.png" action: editAction
action: deleteAction visible: stdContract === false
width: 10 width: 10
height: 10 height: 10
Action { Action {
id: deleteAction id: editAction
tooltip: qsTr("Delete") tooltip: qsTr("Edit")
onTriggered: transactionsModel.deleteTransaction(index) onTriggered: transactionsModel.editTransaction(index)
}
}
}
} }
}
Button TransactionDialog
{ {
iconSource: "qrc:/qml/img/edit.png" id: transactionDialog
action: editAction onAccepted:
visible: stdContract === false {
width: 10 var item = transactionDialog.getItem();
height: 10
Action { if (transactionDialog.transactionIndex < transactionsModel.count) {
id: editAction transactionsModel.set(transactionDialog.transactionIndex, item);
tooltip: qsTr("Edit") stateTransactions[transactionDialog.transactionIndex] = item;
onTriggered: transactionsModel.editTransaction(index) } else {
transactionsModel.append(item);
stateTransactions.push(item);
}
}
} }
} }
} }
} }
TransactionDialog
{
id: transactionDialog
onAccepted:
{
var item = transactionDialog.getItem();
if (transactionDialog.transactionIndex < transactionsModel.count) {
transactionsModel.set(transactionDialog.transactionIndex, item);
stateTransactions[transactionDialog.transactionIndex] = item;
} else {
transactionsModel.append(item);
stateTransactions.push(item);
}
}
}
} }

74
mix/qml/StateList.qml

@ -1,39 +1,50 @@
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1 import QtQuick.Controls.Styles 1.1
import QtQuick.Dialogs 1.1 import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Window 2.0 import QtQuick.Window 2.0
import "." import "."
Window { Dialog {
id: stateListContainer id: stateListContainer
modality: Qt.WindowModal modality: Qt.WindowModal
width: 640 width: 640
height: 480 height: 480
visible: false visible: false
ColumnLayout contentItem: Rectangle {
{
anchors.fill: parent anchors.fill: parent
TableView { ColumnLayout
id: list {
Layout.fillHeight: true anchors.fill: parent
Layout.fillWidth: true TableView {
model: projectModel.stateListModel id: list
itemDelegate: renderDelegate Layout.fillHeight: true
headerDelegate: null Layout.fillWidth: true
TableViewColumn { model: projectModel.stateListModel
role: "title" itemDelegate: renderDelegate
title: qsTr("State") headerDelegate: null
width: list.width frameVisible: false
TableViewColumn {
role: "title"
title: qsTr("State")
width: list.width
}
} }
}
Button { Row{
anchors.bottom: parent.bottom spacing: 5
action: addStateAction anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.rightMargin: 10
Button {
action: addStateAction
}
Button {
action: closeAction
}
}
} }
} }
@ -69,12 +80,21 @@ Window {
} }
} }
Action { Row
id: addStateAction {
text: "&Add State" Action {
shortcut: "Ctrl+T" id: addStateAction
enabled: codeModel.hasContract && !clientModel.running; text: qsTr("Add State")
onTriggered: list.model.addState(); shortcut: "Ctrl+T"
enabled: codeModel.hasContract && !clientModel.running;
onTriggered: list.model.addState();
}
Action {
id: closeAction
text: qsTr("Close")
onTriggered: stateListContainer.close();
}
} }
} }

379
mix/qml/TransactionDialog.qml

@ -1,19 +1,19 @@
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.2
import QtQuick.Window 2.0 import QtQuick.Window 2.0
import QtQuick.Controls.Styles 1.3 import QtQuick.Controls.Styles 1.3
import org.ethereum.qml.QEther 1.0 import org.ethereum.qml.QEther 1.0
import "js/TransactionHelper.js" as TransactionHelper import "js/TransactionHelper.js" as TransactionHelper
import "." import "."
Window { Dialog {
id: modalTransactionDialog id: modalTransactionDialog
modality: Qt.ApplicationModal modality: Qt.ApplicationModal
width: 520 width: 520
height: 500; height: 500
visible: false visible: false
color: transactionDialogStyle.generic.backgroundColor
title: qsTr("Edit Transaction") title: qsTr("Edit Transaction")
property int transactionIndex property int transactionIndex
property alias gas: gasValueEdit.gasValue; property alias gas: gasValueEdit.gasValue;
@ -27,6 +27,10 @@ Window {
property alias stateAccounts: senderComboBox.model property alias stateAccounts: senderComboBox.model
signal accepted; signal accepted;
StateDialogStyle {
id: transactionDialogStyle
}
function open(index, item) { function open(index, item) {
rowFunction.visible = !useTransactionDefaultValue; rowFunction.visible = !useTransactionDefaultValue;
rowValue.visible = !useTransactionDefaultValue; rowValue.visible = !useTransactionDefaultValue;
@ -73,8 +77,6 @@ Window {
} }
} }
initTypeLoader(); initTypeLoader();
modalTransactionDialog.setX((Screen.width - width) / 2);
modalTransactionDialog.setY((Screen.height - height) / 2);
visible = true; visible = true;
valueField.focus = true; valueField.focus = true;
@ -178,214 +180,219 @@ Window {
item.parameters = paramValues; item.parameters = paramValues;
return item; return item;
} }
contentItem: Rectangle {
StateDialogStyle { color: transactionDialogStyle.generic.backgroundColor
id: transactionDialogStyle
}
ColumnLayout {
anchors.fill: parent
anchors.margins: 10
ColumnLayout { ColumnLayout {
id: dialogContent anchors.fill: parent
anchors.top: parent.top ColumnLayout {
spacing: 10 anchors.fill: parent
RowLayout anchors.margins: 10
{
id: rowSender ColumnLayout {
Layout.fillWidth: true id: dialogContent
height: 150 anchors.top: parent.top
DefaultLabel { spacing: 10
Layout.preferredWidth: 75 RowLayout
text: qsTr("Sender")
}
ComboBox {
function select(secret)
{ {
for (var i in model) id: rowSender
if (model[i].secret === secret) Layout.fillWidth: true
height: 150
DefaultLabel {
Layout.preferredWidth: 75
text: qsTr("Sender")
}
ComboBox {
function select(secret)
{ {
currentIndex = i; for (var i in model)
break; if (model[i].secret === secret)
{
currentIndex = i;
break;
}
} }
}
id: senderComboBox id: senderComboBox
Layout.preferredWidth: 350 Layout.preferredWidth: 350
currentIndex: 0 currentIndex: 0
textRole: "name" textRole: "name"
editable: false editable: false
} }
} }
RowLayout RowLayout
{ {
id: rowContract id: rowContract
Layout.fillWidth: true Layout.fillWidth: true
height: 150 height: 150
DefaultLabel { DefaultLabel {
Layout.preferredWidth: 75 Layout.preferredWidth: 75
text: qsTr("Contract") text: qsTr("Contract")
} }
ComboBox { ComboBox {
id: contractComboBox id: contractComboBox
function currentValue() { function currentValue() {
return (currentIndex >=0 && currentIndex < contractsModel.count) ? contractsModel.get(currentIndex).cid : ""; return (currentIndex >=0 && currentIndex < contractsModel.count) ? contractsModel.get(currentIndex).cid : "";
}
Layout.preferredWidth: 350
currentIndex: -1
textRole: "text"
editable: false
model: ListModel {
id: contractsModel
}
onCurrentIndexChanged: {
loadFunctions(currentValue());
}
}
} }
Layout.preferredWidth: 350
currentIndex: -1 RowLayout
textRole: "text" {
editable: false id: rowFunction
model: ListModel { Layout.fillWidth: true
id: contractsModel height: 150
DefaultLabel {
Layout.preferredWidth: 75
text: qsTr("Function")
}
ComboBox {
id: functionComboBox
Layout.preferredWidth: 350
currentIndex: -1
textRole: "text"
editable: false
model: ListModel {
id: functionsModel
}
onCurrentIndexChanged: {
loadParameters();
}
}
} }
onCurrentIndexChanged: {
loadFunctions(currentValue()); CommonSeparator
{
Layout.fillWidth: true
} }
}
}
RowLayout RowLayout
{ {
id: rowFunction id: rowValue
Layout.fillWidth: true Layout.fillWidth: true
height: 150 height: 150
DefaultLabel { DefaultLabel {
Layout.preferredWidth: 75 Layout.preferredWidth: 75
text: qsTr("Function") text: qsTr("Value")
} }
ComboBox { Ether {
id: functionComboBox id: valueField
Layout.preferredWidth: 350 edit: true
currentIndex: -1 displayFormattedValue: true
textRole: "text" }
editable: false
model: ListModel {
id: functionsModel
} }
onCurrentIndexChanged: {
loadParameters(); CommonSeparator
{
Layout.fillWidth: true
} }
}
}
CommonSeparator RowLayout
{ {
Layout.fillWidth: true id: rowGas
} Layout.fillWidth: true
height: 150
DefaultLabel {
Layout.preferredWidth: 75
text: qsTr("Gas")
}
DefaultTextField
{
property variant gasValue
onGasValueChanged: text = gasValue.value();
onTextChanged: gasValue.setValue(text);
implicitWidth: 200
id: gasValueEdit;
}
}
RowLayout CommonSeparator
{ {
id: rowValue Layout.fillWidth: true
Layout.fillWidth: true }
height: 150
DefaultLabel {
Layout.preferredWidth: 75
text: qsTr("Value")
}
Ether {
id: valueField
edit: true
displayFormattedValue: true
}
}
CommonSeparator RowLayout
{ {
Layout.fillWidth: true id: rowGasPrice
} Layout.fillWidth: true
height: 150
DefaultLabel {
Layout.preferredWidth: 75
text: qsTr("Gas Price")
}
Ether {
id: gasPriceField
edit: true
displayFormattedValue: true
}
}
RowLayout CommonSeparator
{ {
id: rowGas Layout.fillWidth: true
Layout.fillWidth: true }
height: 150
DefaultLabel {
Layout.preferredWidth: 75
text: qsTr("Gas")
}
DefaultTextField DefaultLabel {
{ id: paramLabel
property variant gasValue text: qsTr("Parameters:")
onGasValueChanged: text = gasValue.value(); Layout.preferredWidth: 75
onTextChanged: gasValue.setValue(text); }
implicitWidth: 200
id: gasValueEdit;
}
}
CommonSeparator ScrollView
{ {
Layout.fillWidth: true id: paramScroll
} anchors.top: paramLabel.bottom
anchors.topMargin: 10
Layout.fillWidth: true
Layout.fillHeight: true
StructView
{
id: typeLoader
Layout.preferredWidth: 150
members: paramsModel;
}
}
RowLayout CommonSeparator
{ {
id: rowGasPrice Layout.fillWidth: true
Layout.fillWidth: true visible: paramsModel.length > 0
height: 150 }
DefaultLabel {
Layout.preferredWidth: 75
text: qsTr("Gas Price")
}
Ether {
id: gasPriceField
edit: true
displayFormattedValue: true
} }
} }
CommonSeparator RowLayout
{
Layout.fillWidth: true
}
DefaultLabel {
id: paramLabel
text: qsTr("Parameters:")
Layout.preferredWidth: 75
}
ScrollView
{ {
id: paramScroll anchors.bottom: parent.bottom
anchors.top: paramLabel.bottom anchors.right: parent.right;
anchors.topMargin: 10
Layout.fillWidth: true Button {
Layout.fillHeight: true text: qsTr("OK");
StructView onClicked: {
{ close();
id: typeLoader accepted();
Layout.preferredWidth: 150 }
members: paramsModel;
} }
}
CommonSeparator Button {
{ text: qsTr("Cancel");
Layout.fillWidth: true onClicked: close();
visible: paramsModel.length > 0 Layout.fillWidth: true
}
}
RowLayout
{
anchors.bottom: parent.bottom
anchors.right: parent.right;
Button {
text: qsTr("OK");
onClicked: {
acceptAndClose();
} }
} }
Button {
text: qsTr("Cancel");
onClicked: close();
}
} }
} }
} }

Loading…
Cancel
Save