diff --git a/mix/qml/Application.qml b/mix/qml/Application.qml index b7a065cdf..3cbe847c7 100644 --- a/mix/qml/Application.qml +++ b/mix/qml/Application.qml @@ -178,7 +178,7 @@ ApplicationWindow { id: editStatesAction text: qsTr("Edit States") shortcut: "Ctrl+Alt+E" - onTriggered: stateList.show(); + onTriggered: stateList.open(); } Connections { diff --git a/mix/qml/DeploymentDialog.qml b/mix/qml/DeploymentDialog.qml index e8af2f664..2e7e1601b 100644 --- a/mix/qml/DeploymentDialog.qml +++ b/mix/qml/DeploymentDialog.qml @@ -2,7 +2,7 @@ import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Layouts 1.1 import QtQuick.Window 2.0 -import QtQuick.Dialogs 1.1 +import QtQuick.Dialogs 1.2 import QtQuick.Controls.Styles 1.3 import org.ethereum.qml.QEther 1.0 import "js/TransactionHelper.js" as TransactionHelper @@ -11,16 +11,11 @@ import "js/QEtherHelper.js" as QEtherHelper import "." -Window { - +Dialog { id: modalDeploymentDialog modality: Qt.ApplicationModal width: 735 - height: 320 - maximumWidth: width - minimumWidth: width - maximumHeight: height - minimumHeight: height + height: 400 visible: false property alias applicationUrlEth: applicationUrlEth.text property alias applicationUrlHttp: applicationUrlHttp.text @@ -32,8 +27,6 @@ Window { property string currentAccount property alias gasToUse: gasToUseInput.text - color: appStyle.generic.layout.backgroundColor - function close() { visible = false; @@ -41,10 +34,7 @@ Window { function open() { - modalDeploymentDialog.setX((Screen.width - width) / 2); - modalDeploymentDialog.setY((Screen.height - height) / 2); visible = true; - var requests = [{ //accounts jsonrpc: "2.0", @@ -160,136 +150,140 @@ Window { id: lightFont } - Column - { - spacing: 5 + contentItem: Rectangle { + color: appStyle.generic.layout.backgroundColor anchors.fill: parent - anchors.margins: 10 - ColumnLayout + Column { - id: containerDeploy - Layout.fillWidth: true - Layout.preferredHeight: 500 - RowLayout + spacing: 5 + anchors.fill: parent + anchors.margins: 10 + ColumnLayout { - Rectangle + id: containerDeploy + Layout.fillWidth: true + Layout.preferredHeight: 500 + RowLayout { - Layout.preferredWidth: 357 - DefaultLabel + Rectangle { - text: qsTr("Deployment") - font.family: lightFont.name - font.underline: true - anchors.centerIn: parent + Layout.preferredWidth: 357 + DefaultLabel + { + text: qsTr("Deployment") + font.family: lightFont.name + font.underline: true + anchors.centerIn: parent + } } - } - Button - { - action: displayHelpAction - 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: displayHelpAction + iconSource: "qrc:/qml/img/help.png" } - } - Button - { - action: openFolderAction - iconSource: "qrc:/qml/img/openedfolder.png" - } - - Action { - id: openFolderAction - enabled: deploymentDialog.packageBase64 !== "" - tooltip: qsTr("Open Package Folder") - onTriggered: { - fileIo.openFileBrowser(projectModel.deploymentDir); + Action { + id: displayHelpAction + tooltip: qsTr("Help") + onTriggered: { + Qt.openUrlExternally("https://github.com/ethereum/wiki/wiki/Mix:-The-DApp-IDE#deployment-to-network") + } } - } - Button - { - action: b64Action - iconSource: "qrc:/qml/img/b64.png" - } + Button + { + action: openFolderAction + iconSource: "qrc:/qml/img/openedfolder.png" + } - Action { - id: b64Action - enabled: deploymentDialog.packageBase64 !== "" - tooltip: qsTr("Copy Base64 conversion to ClipBoard") - onTriggered: { - clipboard.text = deploymentDialog.packageBase64; + Action { + id: openFolderAction + enabled: deploymentDialog.packageBase64 !== "" + tooltip: qsTr("Open Package Folder") + onTriggered: { + fileIo.openFileBrowser(projectModel.deploymentDir); + } } - } - Button - { - action: exitAction - iconSource: "qrc:/qml/img/exit.png" - } + Button + { + action: b64Action + iconSource: "qrc:/qml/img/b64.png" + } - Action { - id: exitAction - tooltip: qsTr("Exit") - onTriggered: { - close() + Action { + id: b64Action + enabled: deploymentDialog.packageBase64 !== "" + tooltip: qsTr("Copy Base64 conversion to ClipBoard") + onTriggered: { + clipboard.text = deploymentDialog.packageBase64; + } } - } - } - GridLayout - { - columns: 2 - width: parent.width + Button + { + action: exitAction + iconSource: "qrc:/qml/img/exit.png" + } - DefaultLabel - { - text: qsTr("Root Registrar address:") + Action { + id: exitAction + tooltip: qsTr("Exit") + onTriggered: { + close() + } + } } - DefaultTextField + GridLayout { - Layout.preferredWidth: 350 - id: registrarAddr - } + columns: 2 + width: parent.width - DefaultLabel - { - text: qsTr("Account used to deploy:") - } + DefaultLabel + { + text: qsTr("Root Registrar address:") + } - 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 - } + DefaultTextField + { + Layout.preferredWidth: 350 + id: registrarAddr } DefaultLabel { - anchors.verticalCenter: parent.verticalCenter - anchors.left: comboAccounts.right - anchors.leftMargin: 20 - id: balance; + text: qsTr("Account used to deploy:") + } + + 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 - Rectangle - { - Layout.preferredWidth: 357 - color: "transparent" - } + width: parent.width + height: 1 + color: "#5891d3" + } - Button + ColumnLayout + { + id: containerRegister + Layout.fillWidth: true + Layout.preferredHeight: 500 + RowLayout { - id: deployButton - action: runAction - iconSource: "qrc:/qml/img/run.png" - } - - 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)) + Layout.preferredHeight: 25 + Rectangle + { + Layout.preferredWidth: 356 + DefaultLabel { - if (contractRedeploy.checked) - deployWarningDialog.open(); - else - ProjectModelCode.startDeployProject(false); + text: qsTr("Registration") + font.family: lightFont.name + font.underline: true + anchors.centerIn: parent } } } - CheckBox + GridLayout { - anchors.left: deployButton.right - id: contractRedeploy - 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" - } + columns: 2 + Layout.fillWidth: true - ColumnLayout - { - id: containerRegister - Layout.fillWidth: true - Layout.preferredHeight: 500 - RowLayout - { - Layout.preferredHeight: 25 - Rectangle - { - Layout.preferredWidth: 356 DefaultLabel { - text: qsTr("Registration") - font.family: lightFont.name - font.underline: true - anchors.centerIn: parent + Layout.preferredWidth: 355 + text: qsTr("Local package URL") } - } - } - GridLayout - { - columns: 2 - Layout.fillWidth: true - - DefaultLabel - { - Layout.preferredWidth: 355 - text: qsTr("Local package URL") - } + DefaultTextField + { + Layout.preferredWidth: 350 + id: localPackageUrl + readOnly: true + enabled: rowRegister.isOkToRegister() + } - DefaultTextField - { - Layout.preferredWidth: 350 - id: localPackageUrl - readOnly: true - enabled: rowRegister.isOkToRegister() - } + DefaultLabel + { + Layout.preferredWidth: 355 + text: qsTr("URL Hint contract address:") + } - DefaultLabel - { - Layout.preferredWidth: 355 - text: qsTr("URL Hint contract address:") - } + DefaultTextField + { + Layout.preferredWidth: 350 + id: urlHintAddr + enabled: rowRegister.isOkToRegister() + } - DefaultTextField - { - Layout.preferredWidth: 350 - id: urlHintAddr - enabled: rowRegister.isOkToRegister() - } + DefaultLabel + { + Layout.preferredWidth: 355 + text: qsTr("Web Application Resources URL: ") + } - DefaultLabel - { - Layout.preferredWidth: 355 - text: qsTr("Web Application Resources URL: ") + DefaultTextField + { + Layout.preferredWidth: 350 + id: applicationUrlHttp + enabled: rowRegister.isOkToRegister() + } } - DefaultTextField + RowLayout { - Layout.preferredWidth: 350 - id: applicationUrlHttp - enabled: rowRegister.isOkToRegister() - } - } - - RowLayout - { - id: rowRegister - Layout.fillWidth: true + id: rowRegister + Layout.fillWidth: true - Rectangle - { - Layout.preferredWidth: 357 - color: "transparent" - } + Rectangle + { + Layout.preferredWidth: 357 + color: "transparent" + } - function isOkToRegister() - { - return Object.keys(projectModel.deploymentAddresses).length > 0 && deploymentDialog.packageHash !== ""; - } + function isOkToRegister() + { + return Object.keys(projectModel.deploymentAddresses).length > 0 && deploymentDialog.packageHash !== ""; + } - Button { - action: registerAction - iconSource: "qrc:/qml/img/note.png" - } + Button { + action: registerAction + iconSource: "qrc:/qml/img/note.png" + } - Action { - id: registerAction - enabled: rowRegister.isOkToRegister() - tooltip: qsTr("Register hosted Web Application.") - onTriggered: { - if (applicationUrlHttp.text === "" || deploymentDialog.packageHash === "") - { - 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.open(); - return; + Action { + id: registerAction + enabled: rowRegister.isOkToRegister() + tooltip: qsTr("Register hosted Web Application.") + onTriggered: { + if (applicationUrlHttp.text === "" || deploymentDialog.packageHash === "") + { + 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.open(); + 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(); } } } diff --git a/mix/qml/NewProjectDialog.qml b/mix/qml/NewProjectDialog.qml index 3ea2a5a4b..3c3c4e649 100644 --- a/mix/qml/NewProjectDialog.qml +++ b/mix/qml/NewProjectDialog.qml @@ -1,10 +1,11 @@ import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Layouts 1.1 +import QtQuick.Dialogs 1.2 import QtQuick.Window 2.0 import QtQuick.Dialogs 1.1 -Window { +Dialog { id: newProjectWin modality: Qt.ApplicationModal @@ -33,62 +34,65 @@ Window { close(); accepted(); } - - GridLayout { - id: dialogContent - columns: 2 + contentItem: Rectangle { anchors.fill: parent - anchors.margins: 10 - rowSpacing: 10 - columnSpacing: 10 + GridLayout + { + id: dialogContent + columns: 2 + anchors.fill: parent + anchors.margins: 10 + rowSpacing: 10 + columnSpacing: 10 - Label { - text: qsTr("Title") - } - TextField { - id: titleField - focus: true - Layout.fillWidth: true - Keys.onReturnPressed: { - if (okButton.enabled) - acceptAndClose(); + Label { + text: qsTr("Title") } - } - - Label { - text: qsTr("Path") - } - RowLayout { TextField { - id: pathField + id: titleField + focus: true Layout.fillWidth: true Keys.onReturnPressed: { if (okButton.enabled) acceptAndClose(); } } - Button { - text: qsTr("Browse") - onClicked: createProjectFileDialog.open() + + Label { + text: qsTr("Path") + } + RowLayout { + TextField { + id: pathField + Layout.fillWidth: true + Keys.onReturnPressed: { + if (okButton.enabled) + acceptAndClose(); + } + } + Button { + text: qsTr("Browse") + onClicked: createProjectFileDialog.open() + } } - } - RowLayout - { - anchors.bottom: parent.bottom - anchors.right: parent.right; + RowLayout + { + anchors.bottom: parent.bottom + anchors.right: parent.right; - Button { - id: okButton; - enabled: titleField.text != "" && pathField.text != "" - text: qsTr("OK"); - onClicked: { - acceptAndClose(); + Button { + id: okButton; + enabled: titleField.text != "" && pathField.text != "" + text: qsTr("OK"); + onClicked: { + acceptAndClose(); + } + } + Button { + text: qsTr("Cancel"); + onClicked: close(); } - } - Button { - text: qsTr("Cancel"); - onClicked: close(); } } } @@ -102,8 +106,8 @@ Window { var u = createProjectFileDialog.fileUrl.toString(); if (u.indexOf("file://") == 0) u = u.substring(7, u.length) - if (Qt.platform.os == "windows" && u.indexOf("/") == 0) - u = u.substring(1, u.length); + if (Qt.platform.os == "windows" && u.indexOf("/") == 0) + u = u.substring(1, u.length); pathField.text = u; } } diff --git a/mix/qml/StateDialog.qml b/mix/qml/StateDialog.qml index 9dc1549c9..0af27f055 100644 --- a/mix/qml/StateDialog.qml +++ b/mix/qml/StateDialog.qml @@ -1,6 +1,6 @@ import QtQuick 2.2 import QtQuick.Controls 1.1 -import QtQuick.Dialogs 1.1 +import QtQuick.Dialogs 1.2 import QtQuick.Layouts 1.1 import QtQuick.Window 2.0 import QtQuick.Controls.Styles 1.3 @@ -9,7 +9,7 @@ import "js/QEtherHelper.js" as QEtherHelper import "js/TransactionHelper.js" as TransactionHelper import "." -Window { +Dialog { id: modalStateDialog modality: Qt.ApplicationModal @@ -17,7 +17,6 @@ Window { height: 480 title: qsTr("Edit State") visible: false - color: stateDialogStyle.generic.backgroundColor property alias stateTitle: titleField.text property alias isDefault: defaultCheckBox.checked @@ -28,6 +27,10 @@ Window { property var stateAccounts: [] signal accepted + StateDialogStyle { + id: stateDialogStyle + } + function open(index, item, setDefault) { stateIndex = index; stateTitle = item.title; @@ -48,9 +51,6 @@ Window { stateAccounts.push(item.accounts[k]); } - modalStateDialog.setX((Screen.width - width) / 2); - modalStateDialog.setY((Screen.height - height) / 2); - visible = true; isDefault = setDefault; titleField.focus = true; @@ -77,338 +77,334 @@ Window { item.accounts = stateAccounts; return item; } - - StateDialogStyle { - id: stateDialogStyle - } - - ColumnLayout { - anchors.fill: parent - anchors.margins: 10 + contentItem: Rectangle { + color: stateDialogStyle.generic.backgroundColor ColumnLayout { - id: dialogContent - anchors.top: parent.top - - RowLayout - { - Layout.fillWidth: true - DefaultLabel { - Layout.preferredWidth: 75 - text: qsTr("Title") - } - DefaultTextField - { - id: titleField - Layout.fillWidth: true - } - } - - CommonSeparator - { - Layout.fillWidth: true - } - - RowLayout - { - Layout.fillWidth: true - - Rectangle - { - Layout.preferredWidth: 75 - DefaultLabel { - id: accountsLabel - Layout.preferredWidth: 75 - text: qsTr("Accounts") + anchors.fill: parent + ColumnLayout { + anchors.fill: parent + anchors.margins: 10 + ColumnLayout { + id: dialogContent + anchors.top: parent.top + RowLayout + { + Layout.fillWidth: true + DefaultLabel { + Layout.preferredWidth: 75 + text: qsTr("Title") + } + DefaultTextField + { + id: titleField + Layout.fillWidth: true + } } - Button + CommonSeparator { - anchors.top: accountsLabel.bottom - anchors.topMargin: 10 - iconSource: "qrc:/qml/img/plus.png" - action: newAccountAction + Layout.fillWidth: true } - Action { - id: newAccountAction - tooltip: qsTr("Add new Account") - onTriggered: - { - var account = stateListModel.newAccount("1000000", QEther.Ether); - stateAccounts.push(account); - accountsModel.append(account); - } - } - } + RowLayout + { + Layout.fillWidth: true - MessageDialog - { - id: alertAlreadyUsed - 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 - } + Rectangle + { + Layout.preferredWidth: 75 + DefaultLabel { + id: accountsLabel + Layout.preferredWidth: 75 + text: qsTr("Accounts") + } - TableView - { - id: accountsView - Layout.fillWidth: true - model: accountsModel - headerVisible: false - TableViewColumn { - role: "name" - title: qsTr("Name") - width: 150 - delegate: Item { - RowLayout + Button { - height: 25 - width: parent.width - Button + anchors.top: accountsLabel.bottom + anchors.topMargin: 10 + iconSource: "qrc:/qml/img/plus.png" + action: newAccountAction + } + + Action { + id: newAccountAction + tooltip: qsTr("Add new Account") + onTriggered: { - iconSource: "qrc:/qml/img/delete_sign.png" - action: deleteAccountAction + var account = stateListModel.newAccount("1000000", QEther.Ether); + stateAccounts.push(account); + accountsModel.append(account); } + } + } - Action { - id: deleteAccountAction - tooltip: qsTr("Delete Account") - onTriggered: + MessageDialog + { + id: alertAlreadyUsed + 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)) - alertAlreadyUsed.open(); - else + height: 25 + width: parent.width + Button { - stateAccounts.splice(styleData.row, 1); - accountsModel.remove(styleData.row); + iconSource: "qrc:/qml/img/delete_sign.png" + 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 { - anchors.verticalCenter: parent.verticalCenter - onTextChanged: { - if (styleData.row > -1) - stateAccounts[styleData.row].name = text; - } - text: { - return styleData.value + TableViewColumn { + role: "balance" + title: qsTr("Balance") + width: 200 + delegate: Item { + Ether { + id: balanceField + edit: true + displayFormattedValue: false + value: styleData.value } } } + rowDelegate: + Rectangle { + color: styleData.alternate ? "transparent" : "#f0f0f0" + height: 30; + } } } - TableViewColumn { - role: "balance" - title: qsTr("Balance") - width: 200 - delegate: Item { - Ether { - id: balanceField - edit: true - displayFormattedValue: false - value: styleData.value - } + CommonSeparator + { + Layout.fillWidth: true + } + + RowLayout + { + Layout.fillWidth: true + DefaultLabel { + Layout.preferredWidth: 75 + text: qsTr("Default") + } + CheckBox { + id: defaultCheckBox + Layout.fillWidth: true } } - rowDelegate: - Rectangle { - color: styleData.alternate ? "transparent" : "#f0f0f0" - height: 30; + + CommonSeparator + { + Layout.fillWidth: true } } - } - CommonSeparator - { - Layout.fillWidth: true - } + ColumnLayout { + anchors.top: dialogContent.bottom + anchors.topMargin: 5 + spacing: 0 + RowLayout + { + Layout.preferredWidth: 150 + DefaultLabel { + text: qsTr("Transactions: ") + } - RowLayout - { - Layout.fillWidth: true - DefaultLabel { - Layout.preferredWidth: 75 - text: qsTr("Default") - } - CheckBox { - id: defaultCheckBox - Layout.fillWidth: true - } - } + Button + { + iconSource: "qrc:/qml/img/plus.png" + action: newTrAction + width: 10 + height: 10 + anchors.right: parent.right + } - CommonSeparator - { - Layout.fillWidth: true - } - } + Action { + id: newTrAction + tooltip: qsTr("Create a new transaction") + onTriggered: transactionsModel.addTransaction() + } + } - ColumnLayout { - anchors.top: dialogContent.bottom - anchors.topMargin: 5 - spacing: 0 - RowLayout - { - Layout.preferredWidth: 150 - DefaultLabel { - text: qsTr("Transactions: ") + ScrollView + { + Layout.fillHeight: true + Layout.preferredWidth: 300 + Column + { + Layout.fillHeight: true + Repeater + { + id: trRepeater + model: transactionsModel + delegate: transactionRenderDelegate + visible: transactionsModel.count > 0 + height: 20 * transactionsModel.count + } + } + } } - Button + RowLayout { - iconSource: "qrc:/qml/img/plus.png" - action: newTrAction - width: 10 - height: 10 - anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.right: parent.right; + + Button { + text: qsTr("OK"); + onClicked: { + close(); + accepted(); + } + } + Button { + text: qsTr("Cancel"); + onClicked: close(); + } } - Action { - id: newTrAction - tooltip: qsTr("Create a new transaction") - onTriggered: transactionsModel.addTransaction() - } - } + ListModel { + id: accountsModel - ScrollView - { - Layout.fillHeight: true - Layout.preferredWidth: 300 - Column - { - Layout.fillHeight: true - Repeater + function removeAccount(_i) { - id: trRepeater - model: transactionsModel - delegate: transactionRenderDelegate - visible: transactionsModel.count > 0 - height: 20 * transactionsModel.count + accountsModel.remove(_i); + stateAccounts.splice(_i, 1); } } - } - CommonSeparator - { - 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 { + id: transactionsModel - ListModel { - id: transactionsModel + function editTransaction(index) { + transactionDialog.stateAccounts = stateAccounts; + transactionDialog.open(index, transactionsModel.get(index)); + } - function editTransaction(index) { - transactionDialog.stateAccounts = stateAccounts; - transactionDialog.open(index, transactionsModel.get(index)); - } + function addTransaction() { - 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 - // 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); - } + function deleteTransaction(index) { + stateTransactions.splice(index, 1); + transactionsModel.remove(index); + } - function deleteTransaction(index) { - stateTransactions.splice(index, 1); - transactionsModel.remove(index); - } + function isUsed(secret) + { + for (var i in stateTransactions) + { + if (stateTransactions[i].sender === secret) + return true; + } + return false; + } + } - function isUsed(secret) - { - for (var i in stateTransactions) - { - if (stateTransactions[i].sender === secret) - return true; - } - return false; - } - } + Component { + id: transactionRenderDelegate + RowLayout { + DefaultLabel { + Layout.preferredWidth: 150 + text: functionId + } - Component { - id: transactionRenderDelegate - RowLayout { - DefaultLabel { - Layout.preferredWidth: 150 - text: functionId - } + Button + { + id: deleteBtn + iconSource: "qrc:/qml/img/delete_sign.png" + action: deleteAction + width: 10 + height: 10 + Action { + id: deleteAction + tooltip: qsTr("Delete") + onTriggered: transactionsModel.deleteTransaction(index) + } + } - Button - { - id: deleteBtn - iconSource: "qrc:/qml/img/delete_sign.png" - action: deleteAction - width: 10 - height: 10 - Action { - id: deleteAction - tooltip: qsTr("Delete") - onTriggered: transactionsModel.deleteTransaction(index) + Button + { + iconSource: "qrc:/qml/img/edit.png" + action: editAction + visible: stdContract === false + width: 10 + height: 10 + Action { + id: editAction + tooltip: qsTr("Edit") + onTriggered: transactionsModel.editTransaction(index) + } + } + } } - } - Button - { - iconSource: "qrc:/qml/img/edit.png" - action: editAction - visible: stdContract === false - width: 10 - height: 10 - Action { - id: editAction - tooltip: qsTr("Edit") - onTriggered: transactionsModel.editTransaction(index) + 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); + } + } } } } } - - 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); - } - } - } } diff --git a/mix/qml/StateList.qml b/mix/qml/StateList.qml index 2e1bb4a06..39567feac 100644 --- a/mix/qml/StateList.qml +++ b/mix/qml/StateList.qml @@ -1,39 +1,50 @@ import QtQuick 2.2 import QtQuick.Controls 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.Window 2.0 import "." -Window { +Dialog { id: stateListContainer modality: Qt.WindowModal - width: 640 height: 480 - visible: false - ColumnLayout - { + contentItem: Rectangle { anchors.fill: parent - TableView { - id: list - Layout.fillHeight: true - Layout.fillWidth: true - model: projectModel.stateListModel - itemDelegate: renderDelegate - headerDelegate: null - TableViewColumn { - role: "title" - title: qsTr("State") - width: list.width + ColumnLayout + { + anchors.fill: parent + TableView { + id: list + Layout.fillHeight: true + Layout.fillWidth: true + model: projectModel.stateListModel + itemDelegate: renderDelegate + headerDelegate: null + frameVisible: false + TableViewColumn { + role: "title" + title: qsTr("State") + width: list.width + } } - } - Button { - anchors.bottom: parent.bottom - action: addStateAction + Row{ + spacing: 5 + anchors.bottom: parent.bottom + anchors.right: parent.right + anchors.rightMargin: 10 + Button { + action: addStateAction + } + + Button { + action: closeAction + } + } } } @@ -69,12 +80,21 @@ Window { } } - Action { - id: addStateAction - text: "&Add State" - shortcut: "Ctrl+T" - enabled: codeModel.hasContract && !clientModel.running; - onTriggered: list.model.addState(); + Row + { + Action { + id: addStateAction + text: qsTr("Add State") + shortcut: "Ctrl+T" + enabled: codeModel.hasContract && !clientModel.running; + onTriggered: list.model.addState(); + } + + Action { + id: closeAction + text: qsTr("Close") + onTriggered: stateListContainer.close(); + } } } diff --git a/mix/qml/TransactionDialog.qml b/mix/qml/TransactionDialog.qml index 62a799b26..f53e16a06 100644 --- a/mix/qml/TransactionDialog.qml +++ b/mix/qml/TransactionDialog.qml @@ -1,19 +1,19 @@ import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Layouts 1.1 +import QtQuick.Dialogs 1.2 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 { +Dialog { id: modalTransactionDialog modality: Qt.ApplicationModal width: 520 - height: 500; + height: 500 visible: false - color: transactionDialogStyle.generic.backgroundColor title: qsTr("Edit Transaction") property int transactionIndex property alias gas: gasValueEdit.gasValue; @@ -27,6 +27,10 @@ Window { property alias stateAccounts: senderComboBox.model signal accepted; + StateDialogStyle { + id: transactionDialogStyle + } + function open(index, item) { rowFunction.visible = !useTransactionDefaultValue; rowValue.visible = !useTransactionDefaultValue; @@ -73,8 +77,6 @@ Window { } } initTypeLoader(); - modalTransactionDialog.setX((Screen.width - width) / 2); - modalTransactionDialog.setY((Screen.height - height) / 2); visible = true; valueField.focus = true; @@ -178,214 +180,219 @@ Window { item.parameters = paramValues; return item; } - - StateDialogStyle { - id: transactionDialogStyle - } - - ColumnLayout { - anchors.fill: parent - anchors.margins: 10 - + contentItem: Rectangle { + color: transactionDialogStyle.generic.backgroundColor ColumnLayout { - id: dialogContent - anchors.top: parent.top - spacing: 10 - RowLayout - { - id: rowSender - Layout.fillWidth: true - height: 150 - DefaultLabel { - Layout.preferredWidth: 75 - text: qsTr("Sender") - } - ComboBox { - - function select(secret) + anchors.fill: parent + ColumnLayout { + anchors.fill: parent + anchors.margins: 10 + + ColumnLayout { + id: dialogContent + anchors.top: parent.top + spacing: 10 + RowLayout { - for (var i in model) - if (model[i].secret === secret) + id: rowSender + Layout.fillWidth: true + height: 150 + DefaultLabel { + Layout.preferredWidth: 75 + text: qsTr("Sender") + } + ComboBox { + + function select(secret) { - currentIndex = i; - break; + for (var i in model) + if (model[i].secret === secret) + { + currentIndex = i; + break; + } } - } - id: senderComboBox - Layout.preferredWidth: 350 - currentIndex: 0 - textRole: "name" - editable: false - } - } + id: senderComboBox + Layout.preferredWidth: 350 + currentIndex: 0 + textRole: "name" + editable: false + } + } - RowLayout - { - id: rowContract - Layout.fillWidth: true - height: 150 - DefaultLabel { - Layout.preferredWidth: 75 - text: qsTr("Contract") - } - ComboBox { - id: contractComboBox - function currentValue() { - return (currentIndex >=0 && currentIndex < contractsModel.count) ? contractsModel.get(currentIndex).cid : ""; + RowLayout + { + id: rowContract + Layout.fillWidth: true + height: 150 + DefaultLabel { + Layout.preferredWidth: 75 + text: qsTr("Contract") + } + ComboBox { + id: contractComboBox + function currentValue() { + 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 - textRole: "text" - editable: false - model: ListModel { - id: contractsModel + + RowLayout + { + id: rowFunction + Layout.fillWidth: true + 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 - { - id: rowFunction - Layout.fillWidth: true - 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 + RowLayout + { + id: rowValue + Layout.fillWidth: true + height: 150 + DefaultLabel { + Layout.preferredWidth: 75 + text: qsTr("Value") + } + Ether { + id: valueField + edit: true + displayFormattedValue: true + } } - onCurrentIndexChanged: { - loadParameters(); + + CommonSeparator + { + Layout.fillWidth: true } - } - } - CommonSeparator - { - Layout.fillWidth: true - } + RowLayout + { + 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 - { - id: rowValue - Layout.fillWidth: true - height: 150 - DefaultLabel { - Layout.preferredWidth: 75 - text: qsTr("Value") - } - Ether { - id: valueField - edit: true - displayFormattedValue: true - } - } + CommonSeparator + { + Layout.fillWidth: true + } - CommonSeparator - { - Layout.fillWidth: true - } + RowLayout + { + id: rowGasPrice + Layout.fillWidth: true + height: 150 + DefaultLabel { + Layout.preferredWidth: 75 + text: qsTr("Gas Price") + } + Ether { + id: gasPriceField + edit: true + displayFormattedValue: true + } + } - RowLayout - { - id: rowGas - Layout.fillWidth: true - height: 150 - DefaultLabel { - Layout.preferredWidth: 75 - text: qsTr("Gas") - } + CommonSeparator + { + Layout.fillWidth: true + } - DefaultTextField - { - property variant gasValue - onGasValueChanged: text = gasValue.value(); - onTextChanged: gasValue.setValue(text); - implicitWidth: 200 - id: gasValueEdit; - } - } + DefaultLabel { + id: paramLabel + text: qsTr("Parameters:") + Layout.preferredWidth: 75 + } - CommonSeparator - { - Layout.fillWidth: true - } + ScrollView + { + id: paramScroll + anchors.top: paramLabel.bottom + anchors.topMargin: 10 + Layout.fillWidth: true + Layout.fillHeight: true + StructView + { + id: typeLoader + Layout.preferredWidth: 150 + members: paramsModel; + } + } - RowLayout - { - id: rowGasPrice - Layout.fillWidth: true - height: 150 - DefaultLabel { - Layout.preferredWidth: 75 - text: qsTr("Gas Price") - } - Ether { - id: gasPriceField - edit: true - displayFormattedValue: true + CommonSeparator + { + Layout.fillWidth: true + visible: paramsModel.length > 0 + } } } - CommonSeparator - { - Layout.fillWidth: true - } - - DefaultLabel { - id: paramLabel - text: qsTr("Parameters:") - Layout.preferredWidth: 75 - } - - ScrollView + RowLayout { - id: paramScroll - anchors.top: paramLabel.bottom - anchors.topMargin: 10 - Layout.fillWidth: true - Layout.fillHeight: true - StructView - { - id: typeLoader - Layout.preferredWidth: 150 - members: paramsModel; + anchors.bottom: parent.bottom + anchors.right: parent.right; + + Button { + text: qsTr("OK"); + onClicked: { + close(); + accepted(); + } } - } - CommonSeparator - { - Layout.fillWidth: true - visible: paramsModel.length > 0 - } - } - - RowLayout - { - anchors.bottom: parent.bottom - anchors.right: parent.right; - - Button { - text: qsTr("OK"); - onClicked: { - acceptAndClose(); + Button { + text: qsTr("Cancel"); + onClicked: close(); + Layout.fillWidth: true } } - Button { - text: qsTr("Cancel"); - onClicked: close(); - } } } } +