github.com/jonasnick/go-ethereum@v0.7.12-0.20150216215225-22176f05d387/cmd/mist/assets/qml/views/miner.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 id: root 11 property var title: "Miner" 12 property var iconSource: "../miner.png" 13 property var menuItem 14 15 color: "#00000000" 16 17 Label { 18 visible: false 19 id: lastBlockLabel 20 objectName: "lastBlockLabel" 21 text: "---" 22 onTextChanged: { 23 //menuItem.secondaryTitle = text 24 } 25 } 26 27 Label { 28 objectName: "miningLabel" 29 visible: false 30 font.pixelSize: 10 31 anchors.right: lastBlockLabel.left 32 anchors.rightMargin: 5 33 onTextChanged: { 34 menuItem.secondaryTitle = text 35 } 36 } 37 38 ColumnLayout { 39 spacing: 10 40 anchors.fill: parent 41 42 Rectangle { 43 id: mainPane 44 color: "#00000000" 45 anchors { 46 top: parent.top 47 bottom: localTxPane.top 48 left: parent.left 49 right: parent.right 50 } 51 52 Rectangle { 53 id: menu 54 height: 25 55 anchors { 56 left: parent.left 57 } 58 59 RowLayout { 60 id: tools 61 anchors { 62 left: parent.left 63 right: parent.right 64 } 65 66 Button { 67 text: "Start" 68 onClicked: { 69 eth.setGasPrice(minGasPrice.text || "10000000000000"); 70 eth.setExtra(blockExtra.text) 71 if (eth.toggleMining()) { 72 this.text = "Stop"; 73 } else { 74 this.text = "Start"; 75 } 76 } 77 } 78 79 Rectangle { 80 id: minGasPriceRect 81 anchors.top: parent.top 82 anchors.topMargin: 2 83 width: 200 84 TextField { 85 id: minGasPrice 86 placeholderText: "Min Gas: 10000000000000" 87 width: 200 88 validator: RegExpValidator { regExp: /\d*/ } 89 } 90 } 91 92 Rectangle { 93 width: 300 94 anchors { 95 left: minGasPriceRect.right 96 leftMargin: 5 97 top: parent.top 98 topMargin: 2 99 } 100 101 TextField { 102 id: blockExtra 103 placeholderText: "Extra" 104 width: parent.width 105 maximumLength: 1024 106 } 107 } 108 } 109 } 110 111 Column { 112 anchors { 113 left: parent.left 114 right: parent.right 115 top: menu.bottom 116 topMargin: 5 117 } 118 119 Text { 120 text: "<b>Merged mining options</b>" 121 } 122 123 TableView { 124 id: mergedMiningTable 125 height: 300 126 anchors { 127 left: parent.left 128 right: parent.right 129 } 130 Component { 131 id: checkBoxDelegate 132 133 Item { 134 id: test 135 CheckBox { 136 anchors.fill: parent 137 checked: styleData.value 138 139 onClicked: { 140 var model = mergedMiningModel.get(styleData.row) 141 142 if (this.checked) { 143 model.id = txModel.createLocalTx(model.address, "0", "5000", "0", "") 144 } else { 145 txModel.removeWithId(model.id); 146 model.id = 0; 147 } 148 } 149 } 150 } 151 } 152 TableViewColumn{ role: "checked" ; title: "" ; width: 40 ; delegate: checkBoxDelegate } 153 TableViewColumn{ role: "name" ; title: "Name" ; width: 480 } 154 model: ListModel { 155 objectName: "mergedMiningModel" 156 id: mergedMiningModel 157 function addMergedMiningOption(model) { 158 this.append(model); 159 } 160 } 161 Component.onCompleted: { 162 /* 163 // XXX Temp. replace with above eventually 164 var tmpItems = ["JEVCoin", "Some coin", "Other coin", "Etc coin"]; 165 var address = "e6716f9544a56c530d868e4bfbacb172315bdead"; 166 for (var i = 0; i < tmpItems.length; i++) { 167 mergedMiningModel.append({checked: false, name: tmpItems[i], address: address, id: 0, itemId: i}); 168 } 169 */ 170 } 171 } 172 } 173 } 174 175 Rectangle { 176 id: localTxPane 177 color: "#ececec" 178 border.color: "#cccccc" 179 border.width: 1 180 anchors { 181 left: parent.left 182 right: parent.right 183 bottom: parent.bottom 184 } 185 height: 300 186 187 ColumnLayout { 188 spacing: 10 189 anchors.fill: parent 190 RowLayout { 191 id: newLocalTx 192 anchors { 193 left: parent.left 194 leftMargin: 5 195 top: parent.top 196 topMargin: 5 197 bottomMargin: 5 198 } 199 200 Text { 201 text: "Local tx" 202 } 203 204 Rectangle { 205 width: 250 206 color: "#00000000" 207 anchors.top: parent.top 208 anchors.topMargin: 2 209 210 TextField { 211 id: to 212 placeholderText: "To" 213 width: 250 214 validator: RegExpValidator { regExp: /[abcdefABCDEF1234567890]*/ } 215 } 216 } 217 TextField { 218 property var defaultGas: "5000" 219 id: gas 220 placeholderText: "Gas" 221 text: defaultGas 222 validator: RegExpValidator { regExp: /\d*/ } 223 } 224 TextField { 225 id: gasPrice 226 placeholderText: "Price" 227 validator: RegExpValidator { regExp: /\d*/ } 228 } 229 TextField { 230 id: value 231 placeholderText: "Amount" 232 text: "0" 233 validator: RegExpValidator { regExp: /\d*/ } 234 } 235 TextField { 236 id: data 237 placeholderText: "Data" 238 validator: RegExpValidator { regExp: /[abcdefABCDEF1234567890]*/ } 239 } 240 Button { 241 text: "Create" 242 onClicked: { 243 if (to.text.length == 40 && gasPrice.text.length != 0 && value.text.length != 0 && gas.text.length != 0) { 244 txModel.createLocalTx(to.text, gasPrice.text, gas.text, value.text, data.text); 245 246 to.text = ""; gasPrice.text = ""; 247 gas.text = gas.defaultGas; 248 value.text = "0" 249 } 250 } 251 } 252 } 253 254 TableView { 255 id: txTableView 256 anchors { 257 top: newLocalTx.bottom 258 topMargin: 5 259 left: parent.left 260 right: parent.right 261 bottom: parent.bottom 262 } 263 TableViewColumn{ role: "to" ; title: "To" ; width: 480 } 264 TableViewColumn{ role: "gas" ; title: "Gas" ; width: 100 } 265 TableViewColumn{ role: "gasPrice" ; title: "Gas Price" ; width: 100 } 266 TableViewColumn{ role: "value" ; title: "Amount" ; width: 100 } 267 TableViewColumn{ role: "data" ; title: "Data" ; width: 100 } 268 269 model: ListModel { 270 id: txModel 271 Component.onCompleted: { 272 } 273 function removeWithId(id) { 274 for (var i = 0; i < this.count; i++) { 275 if (txModel.get(i).id == id) { 276 this.remove(i); 277 eth.removeLocalTransaction(id) 278 break; 279 } 280 } 281 } 282 283 function createLocalTx(to, gasPrice, gas, value, data) { 284 var id = eth.addLocalTransaction(to, data, gas, gasPrice, value) 285 txModel.insert(0, {to: to, gas: gas, gasPrice: gasPrice, value: value, data: data, id: id}); 286 287 return id 288 } 289 } 290 } 291 } 292 } 293 } 294 }