From 6e5b352dc007e31bb59f555531580994f7c2bf56 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 11 Feb 2015 10:42:10 +0100 Subject: [PATCH] - Add SourceSansPro*.qml - Ui changes on state/transaction dialog --- mix/QEther.cpp | 4 +- mix/qml/Ether.qml | 11 ++ mix/qml/FilesSection.qml | 6 +- mix/qml/ProjectList.qml | 4 +- mix/qml/QHashTypeView.qml | 7 + mix/qml/QIntTypeView.qml | 7 + mix/qml/QStringTypeView.qml | 7 + mix/qml/SourceSansProBold.qml | 6 + mix/qml/SourceSansProLight.qml | 7 + mix/qml/SourceSansProRegular.qml | 8 + mix/qml/StateDialog.qml | 155 +++++++++++----- mix/qml/StateDialogStyle.qml | 17 ++ mix/qml/TransactionDialog.qml | 294 ++++++++++++++++++++----------- mix/qml/qmldir | 1 + mix/res.qrc | 4 + 15 files changed, 382 insertions(+), 156 deletions(-) create mode 100644 mix/qml/SourceSansProBold.qml create mode 100644 mix/qml/SourceSansProLight.qml create mode 100644 mix/qml/SourceSansProRegular.qml create mode 100644 mix/qml/StateDialogStyle.qml diff --git a/mix/QEther.cpp b/mix/QEther.cpp index 46562d440..4eef1fbdb 100644 --- a/mix/QEther.cpp +++ b/mix/QEther.cpp @@ -35,7 +35,7 @@ QBigInt* QEther::toWei() const const char* key = units.valueToKey(m_currentUnit); for (std::pair rawUnit: dev::eth::units()) { - if (rawUnit.second == QString(key).toLower().toStdString()) + if (QString::fromStdString(rawUnit.second).toLower() == QString(key).toLower()) return multiply(new QBigInt(rawUnit.first)); } return new QBigInt(dev::u256(0)); @@ -46,7 +46,7 @@ void QEther::setUnit(QString const& _unit) QMetaEnum units = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("EtherUnit")); for (int k = 0; k < units.keyCount(); k++) { - if (QString(units.key(k)).toLower() == _unit) + if (QString(units.key(k)).toLower() == _unit.toLower()) { m_currentUnit = static_cast(units.keysToValue(units.key(k))); return; diff --git a/mix/qml/Ether.qml b/mix/qml/Ether.qml index a5fd5dba2..61727b848 100644 --- a/mix/qml/Ether.qml +++ b/mix/qml/Ether.qml @@ -32,6 +32,11 @@ RowLayout { units.currentIndex = unit; } + SourceSansProRegular + { + id: regularFont + } + TextField { implicitWidth: 200 @@ -46,6 +51,7 @@ RowLayout { readOnly: !edit visible: edit id: etherValueEdit; + font.family: regularFont.name } ComboBox @@ -81,10 +87,15 @@ RowLayout { ListElement { text: "Kwei"; } ListElement { text: "wei"; } } + style: ComboBoxStyle + { + font: regularFont.name + } } Text { visible: displayFormattedValue id: formattedValue + font.family: regularFont.name } } diff --git a/mix/qml/FilesSection.qml b/mix/qml/FilesSection.qml index 32202f839..e002d6394 100644 --- a/mix/qml/FilesSection.qml +++ b/mix/qml/FilesSection.qml @@ -48,16 +48,14 @@ ColumnLayout { model.remove(i); } - FontLoader + SourceSansProRegular { id: fileNameFont - source: "qrc:/qml/fonts/SourceSansPro-Regular.ttf" } - FontLoader + SourceSansProBold { id: boldFont - source: "qrc:/qml/fonts/SourceSansPro-Bold.ttf" } RowLayout diff --git a/mix/qml/ProjectList.qml b/mix/qml/ProjectList.qml index 138e86fe9..66dc7de2a 100644 --- a/mix/qml/ProjectList.qml +++ b/mix/qml/ProjectList.qml @@ -12,10 +12,10 @@ Item { anchors.fill: parent id: filesCol spacing: 0 - FontLoader + + SourceSansProLight { id: srcSansProLight - source: "qrc:/qml/fonts/SourceSansPro-Light.ttf" } Rectangle diff --git a/mix/qml/QHashTypeView.qml b/mix/qml/QHashTypeView.qml index e36514fab..b97284a34 100644 --- a/mix/qml/QHashTypeView.qml +++ b/mix/qml/QHashTypeView.qml @@ -4,6 +4,12 @@ Item { property alias text: textinput.text id: editRoot + + SourceSansProBold + { + id: boldFont + } + Rectangle { anchors.fill: parent TextInput { @@ -11,6 +17,7 @@ Item text: text anchors.fill: parent wrapMode: Text.WrapAnywhere + font.family: boldFont.name MouseArea { id: mouseArea anchors.fill: parent diff --git a/mix/qml/QIntTypeView.qml b/mix/qml/QIntTypeView.qml index f794a3b2d..6bf7f1aa7 100644 --- a/mix/qml/QIntTypeView.qml +++ b/mix/qml/QIntTypeView.qml @@ -4,12 +4,19 @@ Item { property alias text: textinput.text id: editRoot + + SourceSansProBold + { + id: boldFont + } + Rectangle { anchors.fill: parent TextInput { id: textinput text: text anchors.fill: parent + font.family: boldFont.name MouseArea { id: mouseArea anchors.fill: parent diff --git a/mix/qml/QStringTypeView.qml b/mix/qml/QStringTypeView.qml index a78fc1d26..7f0059cc9 100644 --- a/mix/qml/QStringTypeView.qml +++ b/mix/qml/QStringTypeView.qml @@ -4,6 +4,12 @@ Item { property alias text: textinput.text id: editRoot + + SourceSansProBold + { + id: boldFont + } + Rectangle { anchors.fill: parent TextInput { @@ -11,6 +17,7 @@ Item text: text anchors.fill: parent wrapMode: Text.WrapAnywhere + font.family: boldFont.name MouseArea { id: mouseArea anchors.fill: parent diff --git a/mix/qml/SourceSansProBold.qml b/mix/qml/SourceSansProBold.qml new file mode 100644 index 000000000..39c99cc8d --- /dev/null +++ b/mix/qml/SourceSansProBold.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +FontLoader +{ + source: "qrc:/qml/fonts/SourceSansPro-Bold.ttf" +} diff --git a/mix/qml/SourceSansProLight.qml b/mix/qml/SourceSansProLight.qml new file mode 100644 index 000000000..f46abedd5 --- /dev/null +++ b/mix/qml/SourceSansProLight.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +FontLoader +{ + source: "qrc:/qml/fonts/SourceSansPro-Light.ttf" +} + diff --git a/mix/qml/SourceSansProRegular.qml b/mix/qml/SourceSansProRegular.qml new file mode 100644 index 000000000..d9ce908e0 --- /dev/null +++ b/mix/qml/SourceSansProRegular.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +FontLoader +{ + source: "qrc:/qml/fonts/SourceSansPro-Regular.ttf" +} + + diff --git a/mix/qml/StateDialog.qml b/mix/qml/StateDialog.qml index fa48c640e..7f659e7f4 100644 --- a/mix/qml/StateDialog.qml +++ b/mix/qml/StateDialog.qml @@ -2,9 +2,11 @@ import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Layouts 1.1 import QtQuick.Window 2.0 +import QtQuick.Controls.Styles 1.3 import org.ethereum.qml.QEther 1.0 import "js/QEtherHelper.js" as QEtherHelper import "js/TransactionHelper.js" as TransactionHelper +import "." Window { id: modalStateDialog @@ -14,6 +16,7 @@ Window { height: 480 visible: false + color: StateDialogStyle.generic.backgroundColor property alias stateTitle: titleField.text property alias stateBalance: balanceField.value @@ -53,59 +56,96 @@ Window { return item; } - GridLayout { - id: dialogContent - columns: 2 + SourceSansProRegular + { + id: regularFont + } + + Rectangle + { anchors.fill: parent anchors.margins: 10 - rowSpacing: 10 - columnSpacing: 10 + color: StateDialogStyle.generic.backgroundColor + GridLayout { + id: dialogContent + columns: 2 + anchors.top: parent.top + rowSpacing: 10 + columnSpacing: 10 - Label { - text: qsTr("Title") - } - TextField { - id: titleField - focus: true - Layout.fillWidth: true - } + Label { + text: qsTr("Title") + font.family: regularFont.name + color: "#808080" + } + TextField { + id: titleField + focus: true + Layout.fillWidth: true + font.family: regularFont.name + } - Label { - text: qsTr("Balance") - } - Ether { - id: balanceField - edit: true - displayFormattedValue: true - Layout.fillWidth: true - } + Label { + text: qsTr("Balance") + font.family: regularFont.name + color: "#808080" + } + Ether { + id: balanceField + edit: true + displayFormattedValue: true + Layout.fillWidth: true + } - Label { - text: qsTr("Default") - } - CheckBox { - id: defaultCheckBox - Layout.fillWidth: true + Label { + text: qsTr("Default") + font.family: regularFont.name + color: "#808080" + } + CheckBox { + id: defaultCheckBox + Layout.fillWidth: true + } } - Label { - text: qsTr("Transactions") - } - ListView { - Layout.fillWidth: true - Layout.fillHeight: true - model: transactionsModel - delegate: transactionRenderDelegate - } + ColumnLayout + { + width: parent.width + anchors.top: dialogContent.bottom + anchors.topMargin: 5 + spacing: 5 + Label { + text: qsTr("Transactions") + font.family: regularFont.name + color: "#808080" + } - Label { + ListView { + id: trList + Layout.preferredWidth: 200 + Layout.fillHeight: true + Layout.minimumHeight: 20 * transactionsModel.count + model: transactionsModel + delegate: transactionRenderDelegate + 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" + } + } + } } - Button { - text: qsTr("Add") - onClicked: transactionsModel.addTransaction() - } - } RowLayout { anchors.bottom: parent.bottom @@ -123,6 +163,10 @@ Window { onClicked: close(); } } +} + + + ListModel { id: transactionsModel @@ -160,18 +204,43 @@ Window { text: functionId font.pointSize: 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" + } + } } 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" + } + } } } } diff --git a/mix/qml/StateDialogStyle.qml b/mix/qml/StateDialogStyle.qml new file mode 100644 index 000000000..39214312a --- /dev/null +++ b/mix/qml/StateDialogStyle.qml @@ -0,0 +1,17 @@ +pragma Singleton +import QtQuick 2.0 + +QtObject { + property QtObject generic: QtObject + { + property string backgroundColor: "#ededed" + } + + property QtObject stateDialog: QtObject + { + } + + property QtObject transactionDialog: QtObject + { + } +} diff --git a/mix/qml/TransactionDialog.qml b/mix/qml/TransactionDialog.qml index 3e6cf0236..90e7e03ba 100644 --- a/mix/qml/TransactionDialog.qml +++ b/mix/qml/TransactionDialog.qml @@ -2,15 +2,18 @@ import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Layouts 1.1 import QtQuick.Window 2.0 +import QtQuick.Controls.Styles 1.3 import org.ethereum.qml.QEther 1.0 import "js/TransactionHelper.js" as TransactionHelper +import "." Window { id: modalTransactionDialog modality: Qt.WindowModal - width:640 - height:640 + width: 640 + height: 700 visible: false + color: StateDialogStyle.generic.backgroundColor property int transactionIndex property alias transactionParams: paramsModel; @@ -155,11 +158,17 @@ Window { return item; } + SourceSansProRegular + { + id: regularFont + } + ColumnLayout { id: dialogContent width: parent.width anchors.left: parent.left anchors.right: parent.right + anchors.top: parent.top anchors.margins: 10 spacing: 30 RowLayout @@ -170,10 +179,12 @@ Window { Label { Layout.preferredWidth: 75 text: qsTr("Function") + font.family: regularFont.name + color: "#808080" } ComboBox { id: functionComboBox - Layout.fillWidth: true + Layout.preferredWidth: 350 currentIndex: -1 textRole: "text" editable: false @@ -183,6 +194,10 @@ Window { onCurrentIndexChanged: { loadParameters(); } + style: ComboBoxStyle + { + font: regularFont.name + } } } @@ -191,18 +206,17 @@ Window { { id: rowValue Layout.fillWidth: true + height: 150 Label { Layout.preferredWidth: 75 text: qsTr("Value") + font.family: regularFont.name + color: "#808080" } - Rectangle - { - Layout.fillWidth: true - Ether { - id: valueField - edit: true - displayFormattedValue: true - } + Ether { + id: valueField + edit: true + displayFormattedValue: true } } @@ -211,18 +225,17 @@ Window { { id: rowGas Layout.fillWidth: true + height: 150 Label { Layout.preferredWidth: 75 text: qsTr("Gas") + font.family: regularFont.name + color: "#808080" } - Rectangle - { - Layout.fillWidth: true - Ether { - id: gasField - edit: true - displayFormattedValue: true - } + Ether { + id: gasField + edit: true + displayFormattedValue: true } } @@ -230,31 +243,153 @@ Window { { id: rowGasPrice Layout.fillWidth: true + height: 150 Label { Layout.preferredWidth: 75 text: qsTr("Gas Price") + font.family: regularFont.name + color: "#808080" } - Rectangle - { - Layout.fillWidth: true - Ether { - id: gasPriceField - edit: true - displayFormattedValue: true - } + Ether { + id: gasPriceField + edit: true + displayFormattedValue: true } } - RowLayout - { - Layout.fillWidth: true - Label { - text: qsTr("Parameters") - Layout.preferredWidth: 75 - } - TableView { + //ColumnLayout + //{ + //Layout.fillHeight: true; + //Layout.fillWidth: true; + //visible: paramsModel.count > 0 + + Label { + text: qsTr("Parameters") + Layout.preferredWidth: 75 + font.family: regularFont.name + color: "#808080" + visible: paramsModel.count > 0 + } + + Repeater + { + model: paramsModel + visible: paramsModel.count > 0 + Rectangle + { + color: "transparent" + Layout.fillWidth: true + height: 150 + Label { + id: typeLabel + text: type + } + + Label { + anchors.left: typeLabel.right + id: nameLabel + text: name + } + + Label { + anchors.left: nameLabel.right + id: equalLabel + text: "=" + } + + Loader + { + anchors.left: equalLabel.right + id: typeLoader + height: 50 + width: 150 + Connections { + target: typeLoader.item + onTextChanged: { + console.log("text changed 0 " + value); + value = typeLoader.item.text; + console.log("text changed 1 " + value); + } + } + + sourceComponent: + { + console.log(type); + if (type.indexOf("int") !== -1) + return intViewComp; + else if (type.indexOf("bool") !== -1) + return boolViewComp; + else if (type.indexOf("string") !== -1) + return stringViewComp; + else if (type.indexOf("hash") !== -1) + return hashViewComp; + else + return null; + } + + Component + { + id: intViewComp + QIntTypeView + { + height: 50 + width: 150 + id: intView + text: value + } + } + + Component + { + id: boolViewComp + QBoolTypeView + { + height: 50 + width: 150 + id: boolView + defaultValue: "1" + Component.onCompleted: + { + /*loaderEditor.updateValue(styleData.row, styleData.role, + (paramsModel.get(styleData.row).value === "" ? defaultValue : + paramsModel.get(styleData.row).value)); + text = (paramsModel.get(styleData.row).value === "" ? defaultValue : paramsModel.get(styleData.row).value);*/ + } + } + } + + Component + { + id: stringViewComp + QStringTypeView + { + height: 50 + width: 150 + id: stringView + text: value + } + } + + Component + { + id: hashViewComp + QHashTypeView + { + height: 50 + width: 150 + id: hashView + text: value + } + } + } + + } + } + //} + + /*TableView { model: paramsModel - Layout.preferredWidth: 120 * 2 + 240 + Layout.fillWidth: true Layout.minimumHeight: 150 Layout.preferredHeight: 400 Layout.maximumHeight: 600 @@ -276,27 +411,26 @@ Window { rowDelegate: rowDelegate itemDelegate: editableDelegate - } + }*/ } - } - RowLayout - { - anchors.bottom: parent.bottom - anchors.right: parent.right; - - Button { - text: qsTr("OK"); - onClicked: { - close(); - accepted(); + RowLayout + { + anchors.bottom: parent.bottom + anchors.right: parent.right; + + Button { + text: qsTr("OK"); + onClicked: { + close(); + accepted(); + } + } + Button { + text: qsTr("Cancel"); + onClicked: close(); } } - Button { - text: qsTr("Cancel"); - onClicked: close(); - } - } ListModel { @@ -332,6 +466,7 @@ Window { sourceComponent: { + console.log("role " + styleData.role); if (styleData.role === "value") { if (paramsModel.get(styleData.row) === undefined) @@ -349,53 +484,7 @@ Window { return editor; } - Component - { - id: intViewComp - QIntTypeView - { - id: intView - text: styleData.value - } - } - - Component - { - id: boolViewComp - QBoolTypeView - { - id: boolView - defaultValue: "1" - Component.onCompleted: - { - loaderEditor.updateValue(styleData.row, styleData.role, - (paramsModel.get(styleData.row).value === "" ? defaultValue : - paramsModel.get(styleData.row).value)); - text = (paramsModel.get(styleData.row).value === "" ? defaultValue : paramsModel.get(styleData.row).value); - } - } - } - - Component - { - id: stringViewComp - QStringTypeView - { - id: stringView - text: styleData.value - } - } - - Component - { - id: hashViewComp - QHashTypeView - { - id: hashView - text: styleData.value - } - } Component { id: editor @@ -404,12 +493,7 @@ Window { readOnly: true color: styleData.textColor text: styleData.value - MouseArea { - id: mouseArea - anchors.fill: parent - hoverEnabled: true - onClicked: textinput.forceActiveFocus() - } + font.family: regularFont.name } } } diff --git a/mix/qml/qmldir b/mix/qml/qmldir index 819842274..0fefc3b29 100644 --- a/mix/qml/qmldir +++ b/mix/qml/qmldir @@ -1 +1,2 @@ singleton Style 1.0 Style.qml +singleton StateDialogStyle 1.0 StateDialogStyle.qml diff --git a/mix/res.qrc b/mix/res.qrc index a33323870..d05c3f5b1 100644 --- a/mix/res.qrc +++ b/mix/res.qrc @@ -83,5 +83,9 @@ qml/img/closedtriangleindicator_filesproject.png qml/img/opentriangleindicator_filesproject.png qml/img/projecticon.png + qml/SourceSansProRegular.qml + qml/SourceSansProBold.qml + qml/SourceSansProLight.qml + qml/StateDialogStyle.qml