Skip to content

Commit 67dc3be

Browse files
committed
Added a sample app ;-)
1 parent c35950d commit 67dc3be

File tree

3 files changed

+186
-0
lines changed

3 files changed

+186
-0
lines changed
82.1 KB
Loading
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
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+
8+
Rectangle {
9+
id: root
10+
property var title: "JeffCoin"
11+
property var iconSource: "./views/jeffcoin/jeff.png"
12+
property var menuItem
13+
property var filter
14+
property var address: "fc0a9436890478bb9b1c6ed7455c2535366f4a99"
15+
16+
function insertTx(message, blockNumber) {
17+
if(!message) return;
18+
19+
var from = message.from
20+
var to = message.input.substr(24, 40)
21+
var value = eth.fromNumber(message.input.substr(64, 64))
22+
23+
var me = eth.key().address;
24+
if((to == me|| from == me) && message.input.length == 128) {
25+
txModel.insert(0, {confirmations: blockNumber - message.number, from: from, to: to, value: value})
26+
}
27+
}
28+
29+
function setBalance() {
30+
var jeffCoinAmount = eth.fromNumber(eth.storageAt(address, eth.key().address)) + " JΞF"
31+
menuItem.secondaryTitle = jeffCoinAmount
32+
33+
balance.text = "<b>Balance</b>: " + jeffCoinAmount;
34+
}
35+
36+
function onReady() {
37+
setBalance()
38+
39+
filter = new ethx.watch({latest: -1, to: address})
40+
filter.changed(function(messages) {
41+
setBalance()
42+
43+
var blockNumber = eth.block(-1).number;
44+
for(var i = 0; i < messages.length; i++) {
45+
insertTx(messages.get(i), blockNumber);
46+
}
47+
});
48+
49+
var blockNumber = eth.block(-1).number;
50+
var messages = filter.messages()
51+
for(var i = messages.length-1; i >= 0; i--) {
52+
var message = messages.get(i)
53+
54+
insertTx(message, blockNumber)
55+
}
56+
57+
var chainChanged = ethx.watch("chain")
58+
chainChanged.changed(function() {
59+
for(var i = 0; i < txModel.count; i++) {
60+
var entry = txModel.get(i);
61+
entry.confirmations++;
62+
}
63+
});
64+
}
65+
66+
function onDestroy() {
67+
filter.uninstall()
68+
}
69+
70+
ColumnLayout {
71+
spacing: 10
72+
y: 40
73+
anchors.fill: parent
74+
75+
Text {
76+
id: balance
77+
text: "<b>Balance</b>: " + eth.fromNumber(eth.storageAt(address, eth.key().address)) + " JΞF"
78+
font.pixelSize: 24
79+
anchors {
80+
horizontalCenter: parent.horizontalCenter
81+
top: parent.top
82+
topMargin: 20
83+
}
84+
}
85+
86+
Rectangle {
87+
id: newTxPane
88+
color: "#ececec"
89+
border.color: "#cccccc"
90+
border.width: 1
91+
anchors {
92+
top: balance.bottom
93+
topMargin: 10
94+
left: parent.left
95+
leftMargin: 5
96+
right: parent.right
97+
rightMargin: 5
98+
}
99+
height: 100
100+
101+
RowLayout {
102+
id: amountFields
103+
spacing: 10
104+
anchors {
105+
top: parent.top
106+
topMargin: 20
107+
left: parent.left
108+
leftMargin: 20
109+
}
110+
111+
Text {
112+
text: "JΞF "
113+
}
114+
115+
// There's something off with the row layout where textfields won't listen to the width setting
116+
Rectangle {
117+
width: 50
118+
height: 20
119+
TextField {
120+
id: txValue
121+
width: parent.width
122+
placeholderText: "0.00"
123+
}
124+
}
125+
}
126+
127+
RowLayout {
128+
id: toFields
129+
spacing: 10
130+
anchors {
131+
top: amountFields.bottom
132+
topMargin: 5
133+
left: parent.left
134+
leftMargin: 20
135+
}
136+
137+
Text {
138+
text: "To"
139+
}
140+
141+
Rectangle {
142+
width: 200
143+
height: 20
144+
TextField {
145+
id: txTo
146+
width: parent.width
147+
placeholderText: "Address or name"
148+
}
149+
}
150+
151+
Button {
152+
text: "Send"
153+
onClicked: {
154+
eth.transact({from: eth.key().privateKey, to:address, gas: "9000", gasPrice: "100000000000", data: ["0x"+txTo.text, txValue.text]})
155+
}
156+
}
157+
}
158+
}
159+
160+
Rectangle {
161+
anchors {
162+
left: parent.left
163+
right: parent.right
164+
top: newTxPane.bottom
165+
topMargin: 10
166+
bottom: parent.bottom
167+
}
168+
TableView {
169+
id: txTableView
170+
anchors.fill : parent
171+
TableViewColumn{ role: "value" ; title: "Amount" ; width: 100 }
172+
TableViewColumn{ role: "from" ; title: "From" ; width: 280 }
173+
TableViewColumn{ role: "to" ; title: "To" ; width: 280 }
174+
TableViewColumn{ role: "confirmations" ; title: "Confirmations" ; width: 100 }
175+
176+
model: ListModel {
177+
id: txModel
178+
Component.onCompleted: {
179+
}
180+
}
181+
}
182+
}
183+
}
184+
}

mist/assets/qml/wallet.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ ApplicationWindow {
5555
addPlugin("./views/pending_tx.qml", {noAdd: true, close: false, section: "legacy"});
5656
addPlugin("./views/javascript.qml", {noAdd: true, close: false, section: "legacy"});
5757

58+
addPlugin("./views/jeffcoin/jeffcoin.qml", {noAdd: true, close: false, section: "apps"})
59+
5860
mainSplit.setView(wallet.view, wallet.menuItem);
5961

6062
// Call the ready handler

0 commit comments

Comments
 (0)