Skip to content

Commit c43ea30

Browse files
committed
Refactored some code and fixed #37
1 parent 5d15563 commit c43ea30

File tree

2 files changed

+214
-155
lines changed

2 files changed

+214
-155
lines changed

ethereal/assets/qml/first_run.qml

Lines changed: 131 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -10,146 +10,146 @@ import QtQuick.Controls.Styles 1.1
1010
import QtQuick.Dialogs 1.1
1111

1212
ApplicationWindow {
13-
id: wizardRoot
14-
width: 500
15-
height: 400
16-
title: "Ethereal first run setup"
13+
id: wizardRoot
14+
width: 500
15+
height: 400
16+
title: "Ethereal first run setup"
1717

18-
Column {
19-
spacing: 5
20-
anchors.leftMargin: 10
21-
anchors.left: parent.left
18+
Column {
19+
spacing: 5
20+
anchors.leftMargin: 10
21+
anchors.left: parent.left
2222

23-
Text {
24-
visible: true
25-
text: "<h2>Ethereal setup</h2>"
26-
}
23+
Text {
24+
visible: true
25+
text: "<h2>Ethereal setup</h2>"
26+
}
2727

28-
Column {
29-
id: restoreColumn
30-
spacing: 5
31-
Text {
32-
visible: true
33-
font.pointSize: 14
34-
text: "Restore your Ethereum account"
35-
id: restoreLabel
36-
}
28+
Column {
29+
id: restoreColumn
30+
spacing: 5
31+
Text {
32+
visible: true
33+
font.pointSize: 14
34+
text: "Restore your Ethereum account"
35+
id: restoreLabel
36+
}
3737

38-
TextField {
39-
id: txPrivKey
40-
width: 480
41-
placeholderText: "Private key or mnemonic words"
42-
focus: true
43-
onTextChanged: {
44-
if(this.text.length == 64){
45-
detailLabel.text = "Private (hex) key detected."
46-
actionButton.enabled = true
47-
}
48-
else if(this.text.split(" ").length == 24){
49-
detailLabel.text = "Mnemonic key detected."
50-
actionButton.enabled = true
51-
}else{
52-
detailLabel.text = ""
53-
actionButton.enabled = false
54-
}
38+
TextField {
39+
id: txPrivKey
40+
width: 480
41+
placeholderText: "Private key or mnemonic words"
42+
focus: true
43+
onTextChanged: {
44+
if(this.text.length == 64){
45+
detailLabel.text = "Private (hex) key detected."
46+
actionButton.enabled = true
47+
}
48+
else if(this.text.split(" ").length == 24){
49+
detailLabel.text = "Mnemonic key detected."
50+
actionButton.enabled = true
51+
}else{
52+
detailLabel.text = ""
53+
actionButton.enabled = false
54+
}
55+
}
56+
}
57+
Row {
58+
spacing: 10
59+
Button {
60+
id: actionButton
61+
text: "Restore"
62+
enabled: false
63+
onClicked: {
64+
var success = lib.importAndSetPrivKey(txPrivKey.text)
65+
if(success){
66+
importedDetails.visible = true
67+
restoreColumn.visible = false
68+
newKey.visible = false
69+
wizardRoot.height = 120
70+
}
71+
}
72+
}
73+
Text {
74+
id: detailLabel
75+
font.pointSize: 12
76+
anchors.topMargin: 10
77+
}
78+
}
5579
}
56-
}
57-
Row {
58-
spacing: 10
59-
Button {
60-
id: actionButton
61-
text: "Restore"
62-
enabled: false
63-
onClicked: {
64-
var success = eth.importAndSetPrivKey(txPrivKey.text)
65-
if(success){
66-
importedDetails.visible = true
67-
restoreColumn.visible = false
68-
newKey.visible = false
69-
wizardRoot.height = 120
70-
}
71-
}
80+
Column {
81+
id: importedDetails
82+
visible: false
83+
Text {
84+
text: "<b>Your account has been imported. Please close the application and restart it again to let the changes take effect.</b>"
85+
wrapMode: Text.WordWrap
86+
width: 460
87+
}
7288
}
73-
Text {
74-
id: detailLabel
75-
font.pointSize: 12
76-
anchors.topMargin: 10
89+
Column {
90+
spacing: 5
91+
id: newDetailsColumn
92+
visible: false
93+
Text {
94+
font.pointSize: 14
95+
text: "Your account details"
96+
}
97+
Label {
98+
text: "Address"
99+
}
100+
TextField {
101+
id: addressInput
102+
readOnly:true
103+
width: 480
104+
}
105+
Label {
106+
text: "Private key"
107+
}
108+
TextField {
109+
id: privkeyInput
110+
readOnly:true
111+
width: 480
112+
}
113+
Label {
114+
text: "Mnemonic words"
115+
}
116+
TextField {
117+
id: mnemonicInput
118+
readOnly:true
119+
width: 480
120+
}
121+
Label {
122+
text: "<b>A new account has been created. Please take the time to write down the <i>24 words</i>. You can use those to restore your account at a later date.</b>"
123+
wrapMode: Text.WordWrap
124+
width: 480
125+
}
126+
Label {
127+
text: "Please restart the application once you have completed the steps above."
128+
wrapMode: Text.WordWrap
129+
width: 480
130+
}
77131
}
78-
}
79-
}
80-
Column {
81-
id: importedDetails
82-
visible: false
83-
Text {
84-
text: "<b>Your account has been imported. Please close the application and restart it again to let the changes take effect.</b>"
85-
wrapMode: Text.WordWrap
86-
width: 460
87-
}
88-
}
89-
Column {
90-
spacing: 5
91-
id: newDetailsColumn
92-
visible: false
93-
Text {
94-
font.pointSize: 14
95-
text: "Your account details"
96-
}
97-
Label {
98-
text: "Address"
99-
}
100-
TextField {
101-
id: addressInput
102-
readOnly:true
103-
width: 480
104-
}
105-
Label {
106-
text: "Private key"
107-
}
108-
TextField {
109-
id: privkeyInput
110-
readOnly:true
111-
width: 480
112-
}
113-
Label {
114-
text: "Mnemonic words"
115-
}
116-
TextField {
117-
id: mnemonicInput
118-
readOnly:true
119-
width: 480
120-
}
121-
Label {
122-
text: "<b>A new account has been created. Please take the time to write down the <i>24 words</i>. You can use those to restore your account at a later date.</b>"
123-
wrapMode: Text.WordWrap
124-
width: 480
125-
}
126-
Label {
127-
text: "Please restart the application once you have completed the steps above."
128-
wrapMode: Text.WordWrap
129-
width: 480
130-
}
131-
}
132132

133-
}
134-
Button {
135-
anchors.right: parent.right
136-
anchors.bottom: parent.bottom
137-
anchors.rightMargin: 10
138-
anchors.bottomMargin: 10
139-
id: newKey
140-
text: "I don't have an account yet"
141-
onClicked: {
142-
var res = eth.createAndSetPrivKey()
143-
mnemonicInput.text = res[0]
144-
addressInput.text = res[1]
145-
privkeyInput.text = res[2]
133+
}
134+
Button {
135+
anchors.right: parent.right
136+
anchors.bottom: parent.bottom
137+
anchors.rightMargin: 10
138+
anchors.bottomMargin: 10
139+
id: newKey
140+
text: "I don't have an account yet"
141+
onClicked: {
142+
var res = lib.createAndSetPrivKey()
143+
mnemonicInput.text = res[0]
144+
addressInput.text = res[1]
145+
privkeyInput.text = res[2]
146146

147-
// Hide restore
148-
restoreColumn.visible = false
147+
// Hide restore
148+
restoreColumn.visible = false
149149

150-
// Show new details
151-
newDetailsColumn.visible = true
152-
newKey.visible = false
150+
// Show new details
151+
newDetailsColumn.visible = true
152+
newKey.visible = false
153+
}
153154
}
154-
}
155155
}

0 commit comments

Comments
 (0)