aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal/assets/qml/first_run.qml
blob: 0bd3b4ce10fa3f1e2d94f5720c65760917017794 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import QtQuick 2.0
import Ethereum 1.0

// Which ones do we actually need?
import QtQuick.Controls 1.0;
import QtQuick.Layouts 1.0;
import QtQuick.Dialogs 1.0;
import QtQuick.Window 2.1;
import QtQuick.Controls.Styles 1.1
import QtQuick.Dialogs 1.1

ApplicationWindow {
  id: wizardRoot
  width: 500
  height: 400
  title: "Ethereal first run setup"

  Column {
    spacing: 5
    anchors.leftMargin: 10
    anchors.left: parent.left

    Text {
      visible: true
      text: "<h2>Ethereal setup</h2>"
    }

    Column {
      id: restoreColumn
      spacing: 5
      Text {
        visible: true
        font.pointSize: 14
        text: "Restore your Ethereum account"
        id: restoreLabel
      }

      TextField {
        id: txPrivKey
        width: 480
        placeholderText: "Private key or mnemonic words"
        focus: true
        onTextChanged: {
          if(this.text.length == 64){
            detailLabel.text = "Private (hex) key detected."
            actionButton.enabled = true
          }
          else if(this.text.split(" ").length == 24){
            detailLabel.text = "Mnemonic key detected."
            actionButton.enabled = true
          }else{
            detailLabel.text = ""
            actionButton.enabled = false
          }
        }
      }
      Row {
        spacing: 10
        Button {
          id: actionButton
          text: "Restore"
          enabled: false
          onClicked: {
           var success = eth.importAndSetPrivKey(txPrivKey.text)
           if(success){
             importedDetails.visible = true
             restoreColumn.visible = false
             newKey.visible = false
             wizardRoot.height = 120
           }
          }
        }
        Text {
          id: detailLabel
          font.pointSize: 12
          anchors.topMargin: 10
        }
      }
    }
    Column {
      id: importedDetails
      visible: false
      Text {
        text: "<b>Your account has been imported. Please close the application and restart it again to let the changes take effect.</b>"
        wrapMode: Text.WordWrap
        width: 460
      }
    }
    Column {
      spacing: 5
      id: newDetailsColumn
      visible: false
      Text {
        font.pointSize: 14
        text: "Your account details"
      }
      Label {
        text: "Address"
      }
      TextField {
        id: addressInput
        readOnly:true
        width: 480
      }
      Label {
        text: "Private key"
      }
      TextField {
        id: privkeyInput
        readOnly:true
        width: 480
      }
      Label {
        text: "Mnemonic words"
      }
      TextField {
        id: mnemonicInput
        readOnly:true
        width: 480
      }
      Label {
        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>"
        wrapMode: Text.WordWrap
        width: 480
      }
      Label {
        text: "Please restart the application once you have completed the steps above."
        wrapMode: Text.WordWrap
        width: 480
      }
    }

  }
  Button {
    anchors.right: parent.right
    anchors.bottom: parent.bottom
    anchors.rightMargin: 10
    anchors.bottomMargin: 10
    id: newKey
    text: "I don't have an account yet"
    onClicked: {
      var res = eth.createAndSetPrivKey()
      mnemonicInput.text = res[0]
      addressInput.text = res[1]
      privkeyInput.text = res[2]

      // Hide restore
      restoreColumn.visible = false

      // Show new details
      newDetailsColumn.visible = true
      newKey.visible = false
    }
  }
}