[ui] Add toggle for unblinding password fields #11480

pull tjps wants to merge 1 commits into bitcoin:master from tjps:tjps_wallet_dialog changing 3 files +18 −0
  1. tjps commented at 5:01 AM on October 11, 2017: contributor

    Proposed change for adding the ability to toggle password visibility in the password dialog. This is similar to functionality in most password managers and is specifically added with the use case of password managers in mind - the password in that case is likely pasted twice into both the new password and confirm password fields.

    If this is a welcome change, I am open to suggestions on rearranging the layout.

  2. fanquake added the label GUI on Oct 11, 2017
  3. laanwj commented at 6:54 AM on October 11, 2017: member

    This is similar to functionality in most password managers and is specifically added with the use case of password managers in mind

    I don't entirely follow how this helps with password managers. As far as I know, you already paste into both the new password and confirm password fields?

  4. tjps commented at 7:22 AM on October 11, 2017: contributor

    The idea is that say you miss the actual password copy, or you copy the wrong entry, or you use the middle-click paste (Linux distros) instead of system clipboard paste, etc. - any disconnect between what you think you are putting in that field and what is actually put in that field.

    I realize this may be a rarer use case, but an option to unblind the password field is an increasingly common UI element and would certainly add to peace of mind for my own use case when setting a password generated by a password manager.

    As it is now, the flow to verify is to create a new wallet, generate a password, encrypt the wallet with it, then attempt to sign a message to verify that unlock works. This simplifies that process and potentially has other use cases as well, without reducing security.

  5. laanwj commented at 8:12 AM on October 11, 2017: member

    any disconnect between what you think you are putting in that field and what is actually put in that field.

    Yes, that seems like a valid argument to me, I just didn't follow before, concept ACK then.

  6. in src/qt/askpassphrasedialog.cpp:27 in e9c00fcced outdated
      22 | @@ -23,7 +23,8 @@ AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent) :
      23 |      ui(new Ui::AskPassphraseDialog),
      24 |      mode(_mode),
      25 |      model(0),
      26 | -    fCapsLock(false)
      27 | +    fCapsLock(false),
      28 | +    fShowPass(false)
    


    promag commented at 8:25 AM on October 11, 2017:

    Remove this variable. Use toggled(bool checked) signal (http://doc.qt.io/qt-5/qabstractbutton.html#toggled) which gives the state needed.


    tjps commented at 9:04 AM on October 11, 2017:

    I had initially tried that, but toggled(bool) was not firing. It turns out I was setting the 'checkable' property incorrectly. Fixed now.

  7. promag commented at 8:28 AM on October 11, 2017: member

    Concept ACK.

    In terms of UI QLineEdit could be extended to support this feature, but probably that's too much.

  8. promag commented at 8:31 AM on October 11, 2017: member

    BTW, IIRC in windows the password is only visible while the button is being pressed, it's like a sneak peek. Just saying that there are other alternatives of achieving this.

    I also wonder if this button is a candidate for a new icon?

  9. tjps commented at 9:07 AM on October 11, 2017: contributor

    Re: extending QLineEdit to support this, I had thought it would be neat to add a small "eye" icon (such as in KeyPassX) to right border of the control to support this, but didn't want to scope creep this PR.

    I also see that there are very few icon graphics in the repo and didn't want to start down the path of adding one just for this, but using an icon would remove the need for any translation work for this new element.

  10. in src/qt/askpassphrasedialog.cpp:238 in 458df5822e outdated
     234 | @@ -234,6 +235,15 @@ bool AskPassphraseDialog::event(QEvent *event)
     235 |      return QWidget::event(event);
     236 |  }
     237 |  
     238 | +void AskPassphraseDialog::setShowPass(bool showPass)
    


    promag commented at 9:13 AM on October 11, 2017:

    Nit, this is not a setter, just void showPassword(bool show).

    Edit: or void toggleShowPassword(bool show). The idea is that this slot is an action, not a property change.


    tjps commented at 6:01 PM on October 11, 2017:

    Changed. Thanks for the pointer, I'm new to Qt.

  11. in src/qt/forms/askpassphrasedialog.ui:70 in 458df5822e outdated
      70 | +          <enum>QLineEdit::Password</enum>
      71 | +         </property>
      72 | +        </widget>
      73 | +       </item>
      74 | +       <item>
      75 | +        <widget class="QToolButton" name="passShow">
    


    promag commented at 9:13 AM on October 11, 2017:

    Nit, name="toggleShowPasswordButton".

  12. in src/qt/askpassphrasedialog.cpp:240 in 458df5822e outdated
     234 | @@ -234,6 +235,15 @@ bool AskPassphraseDialog::event(QEvent *event)
     235 |      return QWidget::event(event);
     236 |  }
     237 |  
     238 | +void AskPassphraseDialog::setShowPass(bool showPass)
     239 | +{
     240 | +    ui->passShow->setDown(showPass);
    


    promag commented at 9:14 AM on October 11, 2017:

    Why?


    tjps commented at 6:00 PM on October 11, 2017:

    You mean why setDown()? That is to show that it is in the 'active' state when the passwords are visible. When you toggle back to masking the passwords, the button returns to the original up state.

  13. promag commented at 9:14 AM on October 11, 2017: member

    @tjps yes I think this is fine without icon for the moment.

  14. laanwj commented at 9:28 AM on October 11, 2017: member

    I also see that there are very few icon graphics in the repo and didn't want to start down the path of adding one just for this, but using an icon would remove the need for any translation work for this new element.

    Yes, agree, an eye icon would be nice. Edit: We have an eye icon in the repository, used in the transaction list: <img src="https://github.com/bitcoin/bitcoin/raw/master/src/qt/res/icons/eye.png"> Would it be heretical to suggest re-using that?

  15. promag commented at 9:48 AM on October 11, 2017: member

    Agree, use the existing eye icon.

  16. tjps commented at 1:04 AM on October 12, 2017: contributor

    Addressed comments, and switched to using the eye icon.

    The only remaining question in my mind is placement of the button on the form - currently it is right-aligned above the topmost text input, but it might possibly make sense to the right of the top-most text input.

  17. meshcollider commented at 10:50 AM on October 12, 2017: contributor

    Concept ACK. Could you post a screenshot?

  18. tjps commented at 6:48 PM on October 12, 2017: contributor

    Screenshot: screenshot at 2017-10-12 11 46 27

    I'd also consider putting it out to the right of the top-most text input, adding another narrow vertical column.

  19. achow101 commented at 7:01 PM on October 12, 2017: member

    screenshot-looks-good-and-utACK 26234dbb77ef7de1dbf65728081d3b2ba9e15b0d

  20. in src/qt/askpassphrasedialog.cpp:243 in 26234dbb77 outdated
     236 | @@ -234,6 +237,15 @@ bool AskPassphraseDialog::event(QEvent *event)
     237 |      return QWidget::event(event);
     238 |  }
     239 |  
     240 | +void AskPassphraseDialog::toggleShowPassword(bool show)
     241 | +{
     242 | +    ui->toggleShowPasswordButton->setDown(show);
     243 | +    auto mode = show ? QLineEdit::Normal : QLineEdit::Password;
    


    jonasschnelli commented at 7:29 PM on October 12, 2017:

    nit: does the auto here make sense? IMO this is a way of using auto that leads to confusion reading the code.


    tjps commented at 11:23 PM on October 12, 2017:

    auto is one of the rare items in C++11 I go back and forth on. My general heuristic is that if the thing declared as auto is used in at most the next five lines, and the type of the variable doesn't add anything meaningful to the understanding of the code, then auto is fine (and maybe slightly preferable).

    In this case, mode is used just in the following three lines as an argument to a descriptively named setter. I don't think explicitly declaring it as QSomeEnumType adds anything here.


    promag commented at 11:31 PM on October 12, 2017:

    IMO const auto echo_mode = ... and the RHS is descriptive enough.

  21. jonasschnelli commented at 7:29 PM on October 12, 2017: contributor

    Concept ACK. Test soon.

  22. sipa commented at 11:09 PM on October 12, 2017: member

    Concept-looks-nice ACK

  23. in src/qt/askpassphrasedialog.cpp:240 in 26234dbb77 outdated
     236 | @@ -234,6 +237,15 @@ bool AskPassphraseDialog::event(QEvent *event)
     237 |      return QWidget::event(event);
     238 |  }
     239 |  
     240 | +void AskPassphraseDialog::toggleShowPassword(bool show)
     241 | +{
     242 | +    ui->toggleShowPasswordButton->setDown(show);
    


    promag commented at 11:28 PM on October 12, 2017:

    I haven't tested, but since the button is checkable this shouldn't be necessary right?


    tjps commented at 1:06 AM on October 13, 2017:

    It did not visually switch to being 'down' when toggled until I added the setDown() call. It seems to require both the checkable = true and the call to setDown().

  24. in src/qt/askpassphrasedialog.cpp:43 in 26234dbb77 outdated
      39 | @@ -40,6 +40,8 @@ AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent) :
      40 |      ui->passEdit2->installEventFilter(this);
      41 |      ui->passEdit3->installEventFilter(this);
      42 |  
      43 | +    ui->toggleShowPasswordButton->setIcon(QIcon(":/icons/eye"));
    


    promag commented at 11:28 PM on October 12, 2017:

    This can be set in the .ui?


    tjps commented at 1:15 AM on October 13, 2017:

    It turns out it can. Wasn't immediately apparent from the docs, but then I discovered QtCreator which made it much simpler to play around with.

  25. jonasschnelli commented at 4:03 AM on October 15, 2017: contributor

    Tested a bit. Works as intended. UX wise it feels uncommon/unknown. Usually for a such show-passphrase features you have a checkbox "show password. The mysterious eye-icon may lead to confusion.

    I would recommend something like this (not 1:1 applicable): <img width="588" alt="bildschirmfoto 2017-10-14 um 21 01 59" src="https://user-images.githubusercontent.com/178464/31581524-03b2a0be-b123-11e7-92c1-1f1b80491763.png">

  26. tjps commented at 6:39 PM on October 18, 2017: contributor

    So what do people prefer, the all-seeing eye on the top-right (pictured above), or a normal checkbox underneath like this:

    screenshot at 2017-10-18 11 37 32

    I have a slight preference for the eye, but can go either way. What's the consensus?

  27. meshcollider commented at 7:30 PM on October 18, 2017: contributor

    Slight preference for the checkbox personally, it's clearer than the eye

  28. promag commented at 7:39 PM on October 18, 2017: member

    :+1: checkbox, the layout is also cleaner.

  29. [ui] Add toggle for unblinding password fields ff35de8f03
  30. tjps commented at 8:58 PM on October 18, 2017: contributor

    Checkbox seems to be the group consensus, and it also makes the tabstop ordering clearer.

  31. laanwj commented at 12:46 PM on October 19, 2017: member

    I'd also consider putting it out to the right of the top-most text input, adding another narrow vertical column.

    Yes, if you stick with the icon, definitely line it up to the right of the input field, currently the association is not clear.

    No strong opinion with regard to checkbox versus eye icon, though I slightly prefer the eye from a practical point of view because it doesn't add a translation message.

  32. promag commented at 10:55 PM on October 19, 2017: member

    Yes, if you stick with the icon, definitely line it up to the right of the input field, currently the association is not clear. @laanwj IMO the checkbox alternative is more clear regarding what it does, which is to show all passwords. Until you press the icon button you don't know if only the first password is shown or all.

    Edit: maybe the checkbox text should be "Show passwords" (plural).

  33. tjps commented at 1:03 AM on October 25, 2017: contributor

    @promag - what's the process for reaching consensus here? I'm eager to get this into mainline so it is included in the next release so I don't have to run a patched version locally.

    Should it be 'Show password' or 'Show passwords'? Should it change based on the number of edit fields visible on the form?

  34. tjps commented at 8:48 PM on November 6, 2017: contributor

    @promag @laanwj - 2 week check-in. I feel like consensus has been reached on what form the input should take, any chance to get this merged? Thanks.

  35. laanwj commented at 7:26 AM on November 7, 2017: member

    @tjps sorry, lost track of this a bit because of the focus on 0.15.1. Back on earth now.

    Tested ACK ff35de8

  36. laanwj merged this on Nov 7, 2017
  37. laanwj closed this on Nov 7, 2017

  38. laanwj referenced this in commit ffc0b11503 on Nov 7, 2017
  39. tjps commented at 7:37 AM on November 7, 2017: contributor

    @laanwj no worries, I appreciate that there is a lot more important things going on in the space recently. Thanks!

  40. tjps deleted the branch on Nov 17, 2017
  41. PastaPastaPasta referenced this in commit 644e2dab57 on Dec 22, 2019
  42. PastaPastaPasta referenced this in commit 579ff8f4ac on Jan 2, 2020
  43. PastaPastaPasta referenced this in commit 586c8b096b on Jan 4, 2020
  44. PastaPastaPasta referenced this in commit b4caab5f94 on Jan 12, 2020
  45. PastaPastaPasta referenced this in commit 6c586043f5 on Jan 12, 2020
  46. PastaPastaPasta referenced this in commit e2c4fcf57c on Jan 12, 2020
  47. PastaPastaPasta referenced this in commit a38252dd3b on Jan 12, 2020
  48. PastaPastaPasta referenced this in commit 1d0c88bd6e on Jan 12, 2020
  49. PastaPastaPasta referenced this in commit 46cc3eb8f1 on Jan 12, 2020
  50. PastaPastaPasta referenced this in commit c85b038beb on Jan 16, 2020
  51. ckti referenced this in commit 1b318b72ea on Mar 28, 2021
  52. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 21:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me