github.com/jonasnick/go-ethereum@v0.7.12-0.20150216215225-22176f05d387/cmd/mist/assets/qml/views/transaction.qml (about) 1 import QtQuick 2.0 2 import QtQuick.Controls 1.0; 3 import QtQuick.Layouts 1.0; 4 import QtQuick.Dialogs 1.0; 5 import QtQuick.Window 2.1; 6 import QtQuick.Controls.Styles 1.1 7 import Ethereum 1.0 8 9 Rectangle { 10 property var title: "New Transaction" 11 property var menuItem 12 13 objectName: "newTxView" 14 visible: false 15 anchors.fill: parent 16 color: "#00000000" 17 18 Column { 19 id: mainContractColumn 20 anchors.fill: parent 21 22 23 states: [ 24 State{ 25 name: "ERROR" 26 27 PropertyChanges { target: txResult; visible:true} 28 PropertyChanges { target: codeView; visible:true} 29 }, 30 State { 31 name: "DONE" 32 33 PropertyChanges { target: txValue; visible:false} 34 PropertyChanges { target: txGas; visible:false} 35 PropertyChanges { target: txGasPrice; visible:false} 36 PropertyChanges { target: codeView; visible:false} 37 PropertyChanges { target: txButton; visible:false} 38 PropertyChanges { target: txDataLabel; visible:false} 39 PropertyChanges { target: atLabel; visible:false} 40 PropertyChanges { target: txFuelRecipient; visible:false} 41 PropertyChanges { target: valueDenom; visible:false} 42 PropertyChanges { target: gasDenom; visible:false} 43 44 PropertyChanges { target: txResult; visible:true} 45 PropertyChanges { target: txOutput; visible:true} 46 PropertyChanges { target: newTxButton; visible:true} 47 }, 48 State { 49 name: "SETUP" 50 51 PropertyChanges { target: txValue; visible:true; text: ""} 52 PropertyChanges { target: txGas; visible:true;} 53 PropertyChanges { target: txGasPrice; visible:true;} 54 PropertyChanges { target: codeView; visible:true; text: ""} 55 PropertyChanges { target: txButton; visible:true} 56 PropertyChanges { target: txDataLabel; visible:true} 57 PropertyChanges { target: valueDenom; visible:true} 58 PropertyChanges { target: gasDenom; visible:true} 59 60 PropertyChanges { target: txResult; visible:false} 61 PropertyChanges { target: txOutput; visible:false} 62 PropertyChanges { target: newTxButton; visible:false} 63 } 64 ] 65 width: 400 66 spacing: 5 67 anchors.left: parent.left 68 anchors.top: parent.top 69 anchors.leftMargin: 5 70 anchors.topMargin: 5 71 72 ListModel { 73 id: denomModel 74 ListElement { text: "Wei" ; zeros: "" } 75 ListElement { text: "Ada" ; zeros: "000" } 76 ListElement { text: "Babbage" ; zeros: "000000" } 77 ListElement { text: "Shannon" ; zeros: "000000000" } 78 ListElement { text: "Szabo" ; zeros: "000000000000" } 79 ListElement { text: "Finney" ; zeros: "000000000000000" } 80 ListElement { text: "Ether" ; zeros: "000000000000000000" } 81 ListElement { text: "Einstein" ;zeros: "000000000000000000000" } 82 ListElement { text: "Douglas" ; zeros: "000000000000000000000000000000000000000000" } 83 } 84 85 86 TextField { 87 id: txFuelRecipient 88 placeholderText: "Address / Name or empty for contract" 89 //validator: RegExpValidator { regExp: /[a-f0-9]{40}/ } 90 width: 400 91 } 92 93 RowLayout { 94 TextField { 95 id: txValue 96 width: 222 97 placeholderText: "Amount" 98 validator: RegExpValidator { regExp: /\d*/ } 99 onTextChanged: { 100 contractFormReady() 101 } 102 } 103 104 ComboBox { 105 id: valueDenom 106 currentIndex: 5 107 model: denomModel 108 } 109 } 110 111 RowLayout { 112 TextField { 113 id: txGas 114 width: 50 115 validator: RegExpValidator { regExp: /\d*/ } 116 placeholderText: "Gas" 117 text: "5000" 118 } 119 Label { 120 id: atLabel 121 text: "@" 122 } 123 124 TextField { 125 id: txGasPrice 126 width: 200 127 placeholderText: "Gas price" 128 text: "10" 129 validator: RegExpValidator { regExp: /\d*/ } 130 } 131 132 ComboBox { 133 id: gasDenom 134 currentIndex: 4 135 model: denomModel 136 } 137 } 138 139 Label { 140 id: txDataLabel 141 text: "Data" 142 } 143 144 TextArea { 145 id: codeView 146 height: 300 147 anchors.topMargin: 5 148 width: 400 149 onTextChanged: { 150 contractFormReady() 151 } 152 } 153 154 155 Button { 156 id: txButton 157 /* enabled: false */ 158 states: [ 159 State { 160 name: "READY" 161 PropertyChanges { target: txButton; /*enabled: true*/} 162 }, 163 State { 164 name: "NOTREADY" 165 PropertyChanges { target: txButton; /*enabled:false*/} 166 } 167 ] 168 text: "Send" 169 onClicked: { 170 var value = txValue.text + denomModel.get(valueDenom.currentIndex).zeros; 171 var gasPrice = txGasPrice.text + denomModel.get(gasDenom.currentIndex).zeros; 172 var res = gui.transact(txFuelRecipient.text, value, txGas.text, gasPrice, codeView.text) 173 if(res[1]) { 174 txResult.text = "Your contract <b>could not</b> be sent over the network:\n<b>" 175 txResult.text += res[1].error() 176 txResult.text += "</b>" 177 mainContractColumn.state = "ERROR" 178 } else { 179 txResult.text = "Your transaction has been submitted:\n" 180 txOutput.text = res.toString() 181 mainContractColumn.state = "DONE" 182 183 console.log(res) 184 } 185 } 186 } 187 Text { 188 id: txResult 189 visible: false 190 } 191 TextField { 192 id: txOutput 193 visible: false 194 width: 530 195 } 196 Button { 197 id: newTxButton 198 visible: false 199 text: "Create a new transaction" 200 onClicked: { 201 this.visible = false 202 txResult.text = "" 203 txOutput.text = "" 204 mainContractColumn.state = "SETUP" 205 } 206 } 207 } 208 209 function contractFormReady(){ 210 if(codeView.text.length > 0 && txValue.text.length > 0 && txGas.text.length > 0 && txGasPrice.length > 0) { 211 txButton.state = "READY" 212 }else{ 213 txButton.state = "NOTREADY" 214 } 215 } 216 }