diff --git a/mix/ClientModel.cpp b/mix/ClientModel.cpp index b7be8988a..57caf573c 100644 --- a/mix/ClientModel.cpp +++ b/mix/ClientModel.cpp @@ -156,7 +156,8 @@ void ClientModel::setupState(QVariantMap _state) { QVariantMap transaction = t.toMap(); QString functionId = transaction.value("functionId").toString(); - u256 gas = (qvariant_cast(transaction.value("gas")))->toU256Wei(); + + u256 gas = boost::get(qvariant_cast(transaction.value("gas"))->internalValue()); u256 value = (qvariant_cast(transaction.value("value")))->toU256Wei(); u256 gasPrice = (qvariant_cast(transaction.value("gasPrice")))->toU256Wei(); diff --git a/mix/qml/CommonSeparator.qml b/mix/qml/CommonSeparator.qml new file mode 100644 index 000000000..4d081e05f --- /dev/null +++ b/mix/qml/CommonSeparator.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 +import "." + +Rectangle +{ + height: 3 + color: Style.generic.layout.separatorColor +} + diff --git a/mix/qml/DefaultLabel.qml b/mix/qml/DefaultLabel.qml new file mode 100644 index 000000000..da5495863 --- /dev/null +++ b/mix/qml/DefaultLabel.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 +import QtQuick.Controls 1.1 + +Label { + text: text + font.family: regularFont.name + + SourceSansProRegular + { + id: regularFont + } +} + + + + diff --git a/mix/qml/DefaultTextField.qml b/mix/qml/DefaultTextField.qml new file mode 100644 index 000000000..6705273db --- /dev/null +++ b/mix/qml/DefaultTextField.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 +import QtQuick.Controls 1.1 + +TextField { + id: titleField + focus: true + font.family: regularFont.name + + SourceSansProRegular + { + id: regularFont; + } +} diff --git a/mix/qml/Ether.qml b/mix/qml/Ether.qml index f737b12b6..be41fced9 100644 --- a/mix/qml/Ether.qml +++ b/mix/qml/Ether.qml @@ -32,12 +32,8 @@ RowLayout { units.currentIndex = unit; } - SourceSansProRegular - { - id: regularFont - } - TextField + DefaultTextField { implicitWidth: 200 onTextChanged: @@ -51,7 +47,10 @@ RowLayout { readOnly: !edit visible: edit id: etherValueEdit; - font.family: regularFont.name + } + + SourceSansProBold { + id: regularFont; } ComboBox diff --git a/mix/qml/MainContent.qml b/mix/qml/MainContent.qml index d984e2753..6c6781878 100644 --- a/mix/qml/MainContent.qml +++ b/mix/qml/MainContent.qml @@ -85,7 +85,7 @@ Rectangle { property alias webWidth: webPreview.width property alias webHeight: webPreview.height property alias showProjectView: projectList.visible - property bool runOnProjectLoad: false + property bool runOnProjectLoad: true } ColumnLayout diff --git a/mix/qml/NewProjectDialog.qml b/mix/qml/NewProjectDialog.qml index 770775df2..4fcb524b2 100644 --- a/mix/qml/NewProjectDialog.qml +++ b/mix/qml/NewProjectDialog.qml @@ -6,7 +6,7 @@ import QtQuick.Dialogs 1.1 Window { id: newProjectWin - modality: Qt.WindowModal + modality: Qt.ApplicationModal width: 640 height: 120 diff --git a/mix/qml/QHashTypeView.qml b/mix/qml/QHashTypeView.qml index 6f3c1910e..73678f953 100644 --- a/mix/qml/QHashTypeView.qml +++ b/mix/qml/QHashTypeView.qml @@ -19,6 +19,7 @@ Item text: text anchors.fill: parent wrapMode: Text.WrapAnywhere + clip: true font.family: boldFont.name MouseArea { id: mouseArea diff --git a/mix/qml/QIntTypeView.qml b/mix/qml/QIntTypeView.qml index 00a08d819..98344dd8b 100644 --- a/mix/qml/QIntTypeView.qml +++ b/mix/qml/QIntTypeView.qml @@ -19,6 +19,7 @@ Item text: text anchors.fill: parent font.family: boldFont.name + clip: true MouseArea { id: mouseArea anchors.fill: parent diff --git a/mix/qml/QStringTypeView.qml b/mix/qml/QStringTypeView.qml index 7e7d2ec76..016206e6d 100644 --- a/mix/qml/QStringTypeView.qml +++ b/mix/qml/QStringTypeView.qml @@ -17,6 +17,7 @@ Item TextInput { id: textinput text: text + clip: true anchors.fill: parent wrapMode: Text.WrapAnywhere font.family: boldFont.name diff --git a/mix/qml/StateDialog.qml b/mix/qml/StateDialog.qml index a8ac27ecf..ebcf5fd1d 100644 --- a/mix/qml/StateDialog.qml +++ b/mix/qml/StateDialog.qml @@ -10,11 +10,11 @@ import "." Window { id: modalStateDialog - modality: Qt.WindowModal + modality: Qt.ApplicationModal width: 450 height: 480 - title: qsTr("State Edition") + title: qsTr("Edit State") visible: false color: StateDialogStyle.generic.backgroundColor @@ -44,6 +44,7 @@ Window { isDefault = setDefault; titleField.focus = true; defaultCheckBox.enabled = !isDefault; + forceActiveFocus(); } function close() { @@ -60,53 +61,67 @@ Window { return item; } - SourceSansProRegular - { - id: regularFont - } - - Rectangle { + ColumnLayout { anchors.fill: parent anchors.margins: 10 - color: StateDialogStyle.generic.backgroundColor - GridLayout { + ColumnLayout { id: dialogContent - columns: 2 anchors.top: parent.top - rowSpacing: 10 - columnSpacing: 10 - Label { - text: qsTr("Title") - font.family: regularFont.name - color: "#808080" + RowLayout + { + Layout.fillWidth: true + DefaultLabel { + Layout.preferredWidth: 75 + text: qsTr("Title") + } + DefaultTextField + { + id: titleField + Layout.fillWidth: true + } } - TextField { - id: titleField - focus: true + + CommonSeparator + { Layout.fillWidth: true - font.family: regularFont.name } - Label { - text: qsTr("Balance") - font.family: regularFont.name - color: "#808080" + RowLayout + { + Layout.fillWidth: true + DefaultLabel { + Layout.preferredWidth: 75 + text: qsTr("Balance") + } + Ether { + id: balanceField + edit: true + displayFormattedValue: true + Layout.fillWidth: true + } } - Ether { - id: balanceField - edit: true - displayFormattedValue: true + + CommonSeparator + { Layout.fillWidth: true } - Label { - text: qsTr("Default") - font.family: regularFont.name - color: "#808080" + RowLayout + { + Layout.fillWidth: true + DefaultLabel { + Layout.preferredWidth: 75 + text: qsTr("Default") + } + CheckBox { + id: defaultCheckBox + Layout.fillWidth: true + } } - CheckBox { - id: defaultCheckBox + + CommonSeparator + { Layout.fillWidth: true } } @@ -114,52 +129,51 @@ Window { ColumnLayout { anchors.top: dialogContent.bottom anchors.topMargin: 5 - spacing: 5 + spacing: 0 RowLayout { - Label { - text: qsTr("Transactions") - font.family: regularFont.name - color: "#808080" + DefaultLabel { + text: qsTr("Transactions: ") } - 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 - } - } + Button + { + iconSource: "qrc:/qml/img/plus.png" + action: newTrAction + width: 10 + height: 10 + } + Action { + id: newTrAction + tooltip: qsTr("Create a new transaction") + onTriggered: transactionsModel.addTransaction() } } - ListView { - id: trList - Layout.preferredWidth: 200 + ScrollView + { Layout.fillHeight: true - Layout.minimumHeight: 20 * transactionsModel.count - model: transactionsModel - delegate: transactionRenderDelegate - visible: transactionsModel.count > 0 + Layout.preferredWidth: 300 + Column + { + Layout.fillHeight: true + Repeater + { + id: trRepeater + model: transactionsModel + delegate: transactionRenderDelegate + visible: transactionsModel.count > 0 + height: 20 * transactionsModel.count + } + } } - } + CommonSeparator + { + Layout.fillWidth: true + } + } RowLayout { @@ -204,53 +218,37 @@ Window { Component { id: transactionRenderDelegate - Item { - id: wrapperItem - height: 20 - width: parent.width - RowLayout { - anchors.fill: parent - Text { - Layout.fillWidth: true - Layout.fillHeight: true - text: functionId - font.pointSize: StateStyle.general.basicFontSize //12 - verticalAlignment: Text.AlignBottom - font.family: regularFont.name - } - ToolButton { - text: qsTr("Edit"); - visible: !stdContract - Layout.fillHeight: true - onClicked: transactionsModel.editTransaction(index) - style: ButtonStyle { - label: Text { - font.family: regularFont.name - text: qsTr("Edit") - font.italic: true - font.pointSize: 9 - } - background: Rectangle { - color: "transparent" - } - } + 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) } - ToolButton { - visible: index >= 0 ? !transactionsModel.get(index).executeConstructor : false - text: qsTr("Delete"); - Layout.fillHeight: true - onClicked: transactionsModel.deleteTransaction(index) - style: ButtonStyle { - label: Text { - font.family: regularFont.name - text: qsTr("Delete") - font.italic: true - font.pointSize: 9 - } - background: Rectangle { - color: "transparent" - } - } + } + + Button + { + iconSource: "qrc:/qml/img/edit.png" + action: editAction + visible: !stdContract + width: 10 + height: 10 + Action { + id: editAction + tooltip: qsTr("Edit") + onTriggered: transactionsModel.editTransaction(index) } } } diff --git a/mix/qml/StateListModel.qml b/mix/qml/StateListModel.qml index fd7959477..67372421c 100644 --- a/mix/qml/StateListModel.qml +++ b/mix/qml/StateListModel.qml @@ -25,7 +25,7 @@ Item { functionId: t.functionId, url: t.url, value: QEtherHelper.createEther(t.value.value, t.value.unit), - gas: QEtherHelper.createEther(t.gas.value, t.gas.unit), + gas: QEtherHelper.createBigInt(t.gas.value), //t.gas,//QEtherHelper.createEther(t.gas.value, t.gas.unit), gasPrice: QEtherHelper.createEther(t.gasPrice.value, t.gasPrice.unit), executeConstructor: t.executeConstructor, stdContract: t.stdContract, @@ -81,7 +81,7 @@ Item { functionId: t.functionId, url: t.url, value: { value: t.value.value, unit: t.value.unit }, - gas: { value: t.gas.value, unit: t.gas.unit }, + gas: { value: t.gas.value() }, gasPrice: { value: t.gasPrice.value, unit: t.gasPrice.unit }, executeConstructor: t.executeConstructor, stdContract: t.stdContract, @@ -157,7 +157,7 @@ Item { function defaultTransactionItem() { return { value: QEtherHelper.createEther("100", QEther.Wei), - gas: QEtherHelper.createEther("125000", QEther.Wei), + gas: QEtherHelper.createBigInt("125000"), gasPrice: QEtherHelper.createEther("10000000000000", QEther.Wei), executeConstructor: false, stdContract: false @@ -165,7 +165,8 @@ Item { } function createDefaultState() { - var ether = QEtherHelper.createEther("100000000000000000000000000", QEther.Wei); + //var ether = QEtherHelper.createEther("100000000000000000000000000", QEther.Wei); + var ether = QEtherHelper.createEther("1000000", QEther.Ether); var item = { title: "", balance: ether, diff --git a/mix/qml/Style.qml b/mix/qml/Style.qml new file mode 100644 index 000000000..4dd5d978c --- /dev/null +++ b/mix/qml/Style.qml @@ -0,0 +1,16 @@ +pragma Singleton +import QtQuick 2.0 + +QtObject { + + function absoluteSize(rel) + { + return systemPointSize + rel; + } + + property QtObject generic: QtObject { + property QtObject layout : QtObject { + property string separatorColor: "#f7f7f7" + } + } +} diff --git a/mix/qml/TransactionDialog.qml b/mix/qml/TransactionDialog.qml index 4b2b46cd2..cef82ecc9 100644 --- a/mix/qml/TransactionDialog.qml +++ b/mix/qml/TransactionDialog.qml @@ -9,15 +9,15 @@ import "." Window { id: modalTransactionDialog - modality: Qt.WindowModal + modality: Qt.ApplicationModal width: 450 - height: (paramsModel.count > 0 ? 550 : 300) + height: (paramsModel.count > 0 ? 500 : 300) visible: false color: StateDialogStyle.generic.backgroundColor - title: qsTr("Transaction Edition") + title: qsTr("Edit Transaction") property int transactionIndex property alias transactionParams: paramsModel; - property alias gas: gasField.value; + property alias gas: gasValueEdit.gasValue; property alias gasPrice: gasPriceField.value; property alias transactionValue: valueField.value; property alias functionId: functionComboBox.currentText; @@ -36,7 +36,7 @@ Window { rowGasPrice.visible = !useTransactionDefaultValue; transactionIndex = index; - gasField.value = item.gas; + gasValueEdit.gasValue = item.gas; gasPriceField.value = item.gasPrice; valueField.value = item.value; var functionId = item.functionId; @@ -170,32 +170,27 @@ Window { return item; } - SourceSansProRegular - { - id: regularFont - } - - Rectangle { + ColumnLayout { anchors.fill: parent - anchors.left: parent.left - anchors.right: parent.right - anchors.top: parent.top anchors.margins: 10 - color: StateDialogStyle.generic.backgroundColor + + SourceSansProLight + { + id: lightFont + } ColumnLayout { id: dialogContent - spacing: 30 + anchors.top: parent.top + spacing: 10 RowLayout { id: rowFunction Layout.fillWidth: true height: 150 - Label { + DefaultLabel { Layout.preferredWidth: 75 text: qsTr("Function") - font.family: regularFont.name - color: "#808080" } ComboBox { id: functionComboBox @@ -210,22 +205,24 @@ Window { loadParameters(); } style: ComboBoxStyle { - font: regularFont.name + font: lightFont.name } } } + CommonSeparator + { + Layout.fillWidth: true + } RowLayout { id: rowValue Layout.fillWidth: true height: 150 - Label { + DefaultLabel { Layout.preferredWidth: 75 text: qsTr("Value") - font.family: regularFont.name - color: "#808080" } Ether { id: valueField @@ -234,35 +231,44 @@ Window { } } + CommonSeparator + { + Layout.fillWidth: true + } RowLayout { id: rowGas Layout.fillWidth: true height: 150 - Label { + DefaultLabel { Layout.preferredWidth: 75 text: qsTr("Gas") - font.family: regularFont.name - color: "#808080" } - Ether { - id: gasField - edit: true - displayFormattedValue: true + + DefaultTextField + { + property variant gasValue + onGasValueChanged: text = gasValue.value(); + onTextChanged: gasValue.setValue(text); + implicitWidth: 200 + id: gasValueEdit; } } + CommonSeparator + { + Layout.fillWidth: true + } + RowLayout { id: rowGasPrice Layout.fillWidth: true height: 150 - Label { + DefaultLabel { Layout.preferredWidth: 75 text: qsTr("Gas Price") - font.family: regularFont.name - color: "#808080" } Ether { id: gasPriceField @@ -271,59 +277,62 @@ Window { } } - Label { - text: qsTr("Parameters") + CommonSeparator + { + Layout.fillWidth: true + } + + DefaultLabel { + id: paramLabel + text: qsTr("Parameters:") Layout.preferredWidth: 75 - font.family: regularFont.name - color: "#808080" visible: paramsModel.count > 0 } ScrollView { - Layout.fillWidth: true + anchors.top: paramLabel.bottom + anchors.topMargin: 10 + Layout.preferredWidth: 350 + Layout.fillHeight: true visible: paramsModel.count > 0 - ColumnLayout + Column { id: paramRepeater Layout.fillWidth: true - spacing: 10 + Layout.fillHeight: true + spacing: 3 Repeater { - anchors.fill: parent + height: 20 * paramsModel.count model: paramsModel visible: paramsModel.count > 0 RowLayout { id: row Layout.fillWidth: true - height: 150 - - Label { + height: 20 + DefaultLabel { id: typeLabel text: type - font.family: regularFont.name Layout.preferredWidth: 50 } - Label { + DefaultLabel { id: nameLabel text: name - font.family: regularFont.name - Layout.preferredWidth: 50 + Layout.preferredWidth: 80 } - Label { + DefaultLabel { id: equalLabel text: "=" - font.family: regularFont.name Layout.preferredWidth: 15 } Loader { id: typeLoader - Layout.preferredHeight: 50 Layout.preferredWidth: 150 function getCurrent() { @@ -356,7 +365,7 @@ Window { id: intViewComp QIntTypeView { - height: 50 + height: 20 width: 150 id: intView text: typeLoader.getCurrent().value @@ -368,7 +377,7 @@ Window { id: boolViewComp QBoolTypeView { - height: 50 + height: 20 width: 150 id: boolView defaultValue: "1" @@ -385,7 +394,7 @@ Window { id: stringViewComp QStringTypeView { - height: 50 + height: 20 width: 150 id: stringView text: @@ -400,7 +409,7 @@ Window { id: hashViewComp QHashTypeView { - height: 50 + height: 20 width: 150 id: hashView text: typeLoader.getCurrent().value @@ -411,6 +420,11 @@ Window { } } } + + CommonSeparator + { + Layout.fillWidth: true + } } RowLayout diff --git a/mix/qml/TransactionLog.qml b/mix/qml/TransactionLog.qml index b31956898..61d2e0920 100644 --- a/mix/qml/TransactionLog.qml +++ b/mix/qml/TransactionLog.qml @@ -32,6 +32,16 @@ Item { anchors.fill: parent RowLayout { + Connections + { + target: projectModel + onProjectSaved: + { + if (codeModel.hasContract && !clientModel.running) + projectModel.stateListModel.debugDefaultState(); + } + } + ComboBox { id: statesCombo model: projectModel.stateListModel diff --git a/mix/qml/WebPreview.qml b/mix/qml/WebPreview.qml index f4ddca84e..f258c2e21 100644 --- a/mix/qml/WebPreview.qml +++ b/mix/qml/WebPreview.qml @@ -72,8 +72,8 @@ Item { Connections { target: projectModel - onProjectSaved : reloadOnSave(); - onDocumentSaved: reloadOnSave(); + //onProjectSaved : reloadOnSave(); + //onDocumentSaved: reloadOnSave(); onDocumentAdded: { var document = projectModel.getDocument(documentId) if (document.isHtml) diff --git a/mix/qml/img/delete_sign.png b/mix/qml/img/delete_sign.png new file mode 100644 index 000000000..5c00a20ba Binary files /dev/null and b/mix/qml/img/delete_sign.png differ diff --git a/mix/qml/img/edit.png b/mix/qml/img/edit.png new file mode 100644 index 000000000..0530fd192 Binary files /dev/null and b/mix/qml/img/edit.png differ diff --git a/mix/qml/img/plus.png b/mix/qml/img/plus.png new file mode 100644 index 000000000..fa8f5b9df Binary files /dev/null and b/mix/qml/img/plus.png differ diff --git a/mix/qml/js/QEtherHelper.js b/mix/qml/js/QEtherHelper.js index 9761b2f45..7563941d2 100644 --- a/mix/qml/js/QEtherHelper.js +++ b/mix/qml/js/QEtherHelper.js @@ -6,3 +6,12 @@ function createEther(_value, _unit, _parent) ether.setUnit(_unit); return ether; } + +function createBigInt(_value) +{ + var bigintComponent = Qt.createComponent("qrc:/qml/BigIntValue.qml"); + var bigint = bigintComponent.createObject(); + bigint.setValue(_value); + return bigint; +} + diff --git a/mix/qml/js/TransactionHelper.js b/mix/qml/js/TransactionHelper.js index f404685cf..87dd74beb 100644 --- a/mix/qml/js/TransactionHelper.js +++ b/mix/qml/js/TransactionHelper.js @@ -5,7 +5,7 @@ function defaultTransaction() return { value: createEther("0", QEther.Wei), functionId: "", - gas: createEther("125000", QEther.Wei), + gas: createBigInt("125000"), gasPrice: createEther("100000", QEther.Wei), executeConstructor: false, parameters: {} diff --git a/mix/qml/qmldir b/mix/qml/qmldir index a90fd7135..ca8e494fe 100644 --- a/mix/qml/qmldir +++ b/mix/qml/qmldir @@ -1,3 +1,4 @@ +singleton Style 1.0 Style.qml singleton StateDialogStyle 1.0 StateDialogStyle.qml singleton ProjectFilesStyle 1.0 ProjectFilesStyle.qml singleton DebuggerPaneStyle 1.0 DebuggerPaneStyle.qml diff --git a/mix/res.qrc b/mix/res.qrc index 5d44e1299..6d9ce3d79 100644 --- a/mix/res.qrc +++ b/mix/res.qrc @@ -90,5 +90,12 @@ qml/CodeEditorStyle.qml qml/StatusPaneStyle.qml qml/StateStyle.qml + qml/img/plus.png + qml/img/delete_sign.png + qml/img/edit.png + qml/DefaultLabel.qml + qml/DefaultTextField.qml + qml/CommonSeparator.qml + qml/Style.qml