Browse Source

- Add Reusable common controls (Text, Label, ...).

- Add Generic Style.qml.
 - TransactionDialog/StateDialog ui improvement.
 - Other Small changes.
cl-refactor
yann300 10 years ago
committed by yann300
parent
commit
07ced4cab3
  1. 3
      mix/ClientModel.cpp
  2. 9
      mix/qml/CommonSeparator.qml
  3. 16
      mix/qml/DefaultLabel.qml
  4. 13
      mix/qml/DefaultTextField.qml
  5. 11
      mix/qml/Ether.qml
  6. 2
      mix/qml/MainContent.qml
  7. 2
      mix/qml/NewProjectDialog.qml
  8. 1
      mix/qml/QHashTypeView.qml
  9. 1
      mix/qml/QIntTypeView.qml
  10. 1
      mix/qml/QStringTypeView.qml
  11. 192
      mix/qml/StateDialog.qml
  12. 9
      mix/qml/StateListModel.qml
  13. 16
      mix/qml/Style.qml
  14. 124
      mix/qml/TransactionDialog.qml
  15. 10
      mix/qml/TransactionLog.qml
  16. 4
      mix/qml/WebPreview.qml
  17. BIN
      mix/qml/img/delete_sign.png
  18. BIN
      mix/qml/img/edit.png
  19. BIN
      mix/qml/img/plus.png
  20. 9
      mix/qml/js/QEtherHelper.js
  21. 2
      mix/qml/js/TransactionHelper.js
  22. 1
      mix/qml/qmldir
  23. 7
      mix/res.qrc

3
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<QEther*>(transaction.value("gas")))->toU256Wei();
u256 gas = boost::get<u256>(qvariant_cast<QBigInt*>(transaction.value("gas"))->internalValue());
u256 value = (qvariant_cast<QEther*>(transaction.value("value")))->toU256Wei();
u256 gasPrice = (qvariant_cast<QEther*>(transaction.value("gasPrice")))->toU256Wei();

9
mix/qml/CommonSeparator.qml

@ -0,0 +1,9 @@
import QtQuick 2.0
import "."
Rectangle
{
height: 3
color: Style.generic.layout.separatorColor
}

16
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
}
}

13
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;
}
}

11
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

2
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

2
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

1
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

1
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

1
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

192
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,38 +61,38 @@ 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 {
RowLayout
{
Layout.fillWidth: true
DefaultLabel {
Layout.preferredWidth: 75
text: qsTr("Title")
font.family: regularFont.name
color: "#808080"
}
TextField {
DefaultTextField
{
id: titleField
focus: true
Layout.fillWidth: true
font.family: regularFont.name
}
}
CommonSeparator
{
Layout.fillWidth: true
}
Label {
RowLayout
{
Layout.fillWidth: true
DefaultLabel {
Layout.preferredWidth: 75
text: qsTr("Balance")
font.family: regularFont.name
color: "#808080"
}
Ether {
id: balanceField
@ -99,11 +100,19 @@ Window {
displayFormattedValue: true
Layout.fillWidth: true
}
}
CommonSeparator
{
Layout.fillWidth: true
}
Label {
RowLayout
{
Layout.fillWidth: true
DefaultLabel {
Layout.preferredWidth: 75
text: qsTr("Default")
font.family: regularFont.name
color: "#808080"
}
CheckBox {
id: defaultCheckBox
@ -111,55 +120,60 @@ Window {
}
}
CommonSeparator
{
Layout.fillWidth: true
}
}
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.preferredWidth: 300
Column
{
Layout.fillHeight: true
Layout.minimumHeight: 20 * transactionsModel.count
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
DefaultLabel {
Layout.preferredWidth: 150
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"
}
}
}
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
{
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
width: 10
height: 10
Action {
id: editAction
tooltip: qsTr("Edit")
onTriggered: transactionsModel.editTransaction(index)
}
}
}

9
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,

16
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"
}
}
}

124
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,23 +231,34 @@ 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
@ -258,11 +266,9 @@ Window {
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

10
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

4
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)

BIN
mix/qml/img/delete_sign.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

BIN
mix/qml/img/edit.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 B

BIN
mix/qml/img/plus.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

9
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;
}

2
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: {}

1
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

7
mix/res.qrc

@ -90,5 +90,12 @@
<file>qml/CodeEditorStyle.qml</file>
<file>qml/StatusPaneStyle.qml</file>
<file>qml/StateStyle.qml</file>
<file>qml/img/plus.png</file>
<file>qml/img/delete_sign.png</file>
<file>qml/img/edit.png</file>
<file>qml/DefaultLabel.qml</file>
<file>qml/DefaultTextField.qml</file>
<file>qml/CommonSeparator.qml</file>
<file>qml/Style.qml</file>
</qresource>
</RCC>

Loading…
Cancel
Save