Class: MastercoinWallet::FirstRunWindow
- Inherits:
-
Qt::Dialog
- Object
- Qt::Dialog
- MastercoinWallet::FirstRunWindow
- Defined in:
- lib/mastercoin-wallet/gui/first_run_window.rb
Instance Method Summary collapse
- #check_valid ⇒ Object
- #create_and_save_config ⇒ Object
-
#initialize(parent = nil) ⇒ FirstRunWindow
constructor
A new instance of FirstRunWindow.
- #invalid! ⇒ Object
- #on_password_input_textChanged(text) ⇒ Object
- #on_private_key_input_textChanged(text) ⇒ Object
- #on_repeat_password_input_textChanged(text) ⇒ Object
- #valid! ⇒ Object
Constructor Details
#initialize(parent = nil) ⇒ FirstRunWindow
Returns a new instance of FirstRunWindow.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mastercoin-wallet/gui/first_run_window.rb', line 8 def initialize(parent=nil) super(parent) setWindowTitle(tr("Mastercoin wallet - First run")) @ui = Ui_FirstRunWindow.new @ui.setupUi(self) @password_input = findChild(Qt::LineEdit, "password_input") @password_confirmation_input = findChild(Qt::LineEdit, "repeat_password_input") @private_key = findChild(Qt::LineEdit, "private_key_input") @submit = findChild(Qt::PushButton, "submit_button") @error_label = findChild(Qt::Label, "fault") @address_label = findChild(Qt::Label, "address") connect(@submit, SIGNAL('clicked()'), self, SLOT('create_and_save_config()')) end |
Instance Method Details
#check_valid ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/mastercoin-wallet/gui/first_run_window.rb', line 36 def check_valid valid = true unless @password_confirmation == @password @error_label.setText("Password does not match confirmation.") invalid! return else @error_label.setText("Password matches confirmation.") end if @password.length < 8 @error_label.setText("Please use at least 8 characters for your password.") invalid! return end unless @priv_key invalid! return end valid! end |
#create_and_save_config ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/mastercoin-wallet/gui/first_run_window.rb', line 26 def create_and_save_config MastercoinWallet.config.set_encrypted_key(:private_key, @priv_key, @password) MastercoinWallet.config.set_key(:address, @address) MastercoinWallet.config.save Qt::MessageBox.information(self, tr("First run complete"), tr("Congratulations you have now setup your wallet. The application will now shut down please reboot to make use of your Mastercoin wallet.")) $qApp.quit() end |
#invalid! ⇒ Object
61 62 63 |
# File 'lib/mastercoin-wallet/gui/first_run_window.rb', line 61 def invalid! @submit.enabled = false end |
#on_password_input_textChanged(text) ⇒ Object
69 70 71 72 |
# File 'lib/mastercoin-wallet/gui/first_run_window.rb', line 69 def on_password_input_textChanged(text) @password = text check_valid end |
#on_private_key_input_textChanged(text) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/mastercoin-wallet/gui/first_run_window.rb', line 79 def on_private_key_input_textChanged(text) @priv_key = text begin @address = Bitcoin::Key.from_base58(@priv_key).addr @address_label.setText("Address for private key: #{@address}") check_valid rescue ArgumentError, RuntimeError, OpenSSL::BNError begin @address = Bitcoin::Key.new(@priv_key).addr @address_label.setText("Address for private key: #{@address}") check_valid rescue RuntimeError, OpenSSL::BNError @address_label.setText("Cannot get Bitcoin address from private key.") invalid! end end end |
#on_repeat_password_input_textChanged(text) ⇒ Object
74 75 76 77 |
# File 'lib/mastercoin-wallet/gui/first_run_window.rb', line 74 def on_repeat_password_input_textChanged(text) @password_confirmation = text check_valid end |
#valid! ⇒ Object
65 66 67 |
# File 'lib/mastercoin-wallet/gui/first_run_window.rb', line 65 def valid! @submit.enabled = true end |