first_run.qml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. import QtQuick 2.0
  2. import Ethereum 1.0
  3. // Which ones do we actually need?
  4. import QtQuick.Controls 1.0;
  5. import QtQuick.Layouts 1.0;
  6. import QtQuick.Dialogs 1.0;
  7. import QtQuick.Window 2.1;
  8. import QtQuick.Controls.Styles 1.1
  9. import QtQuick.Dialogs 1.1
  10. ApplicationWindow {
  11. id: wizardRoot
  12. width: 500
  13. height: 400
  14. title: "Ethereal first run setup"
  15. Column {
  16. spacing: 5
  17. anchors.leftMargin: 10
  18. anchors.left: parent.left
  19. Text {
  20. visible: true
  21. text: "<h2>Ethereal setup</h2>"
  22. }
  23. Column {
  24. id: restoreColumn
  25. spacing: 5
  26. Text {
  27. visible: true
  28. font.pointSize: 14
  29. text: "Restore your Ethereum account"
  30. id: restoreLabel
  31. }
  32. TextField {
  33. id: txPrivKey
  34. width: 480
  35. placeholderText: "Private key or mnemonic words"
  36. focus: true
  37. onTextChanged: {
  38. if(this.text.length == 64){
  39. detailLabel.text = "Private (hex) key detected."
  40. actionButton.enabled = true
  41. }
  42. else if(this.text.split(" ").length == 24){
  43. detailLabel.text = "Mnemonic key detected."
  44. actionButton.enabled = true
  45. }else{
  46. detailLabel.text = ""
  47. actionButton.enabled = false
  48. }
  49. }
  50. }
  51. Row {
  52. spacing: 10
  53. Button {
  54. id: actionButton
  55. text: "Restore"
  56. enabled: false
  57. onClicked: {
  58. var success = lib.importAndSetPrivKey(txPrivKey.text)
  59. if(success){
  60. importedDetails.visible = true
  61. restoreColumn.visible = false
  62. newKey.visible = false
  63. wizardRoot.height = 120
  64. }
  65. }
  66. }
  67. Text {
  68. id: detailLabel
  69. font.pointSize: 12
  70. anchors.topMargin: 10
  71. }
  72. }
  73. }
  74. Column {
  75. id: importedDetails
  76. visible: false
  77. Text {
  78. text: "<b>Your account has been imported. Please close the application and restart it again to let the changes take effect.</b>"
  79. wrapMode: Text.WordWrap
  80. width: 460
  81. }
  82. }
  83. Column {
  84. spacing: 5
  85. id: newDetailsColumn
  86. visible: false
  87. Text {
  88. font.pointSize: 14
  89. text: "Your account details"
  90. }
  91. Label {
  92. text: "Address"
  93. }
  94. TextField {
  95. id: addressInput
  96. readOnly:true
  97. width: 480
  98. }
  99. Label {
  100. text: "Private key"
  101. }
  102. TextField {
  103. id: privkeyInput
  104. readOnly:true
  105. width: 480
  106. }
  107. Label {
  108. text: "Mnemonic words"
  109. }
  110. TextField {
  111. id: mnemonicInput
  112. readOnly:true
  113. width: 480
  114. }
  115. Label {
  116. 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>"
  117. wrapMode: Text.WordWrap
  118. width: 480
  119. }
  120. Label {
  121. text: "Please restart the application once you have completed the steps above."
  122. wrapMode: Text.WordWrap
  123. width: 480
  124. }
  125. }
  126. }
  127. Button {
  128. anchors.right: parent.right
  129. anchors.bottom: parent.bottom
  130. anchors.rightMargin: 10
  131. anchors.bottomMargin: 10
  132. id: newKey
  133. text: "I don't have an account yet"
  134. onClicked: {
  135. var res = lib.createAndSetPrivKey()
  136. mnemonicInput.text = res[0]
  137. addressInput.text = res[1]
  138. privkeyInput.text = res[2]
  139. // Hide restore
  140. restoreColumn.visible = false
  141. // Show new details
  142. newDetailsColumn.visible = true
  143. newKey.visible = false
  144. }
  145. }
  146. }