Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add password strength indicator to password entry fields #7885

Merged
merged 1 commit into from
May 31, 2022

Conversation

jmdana
Copy link
Contributor

@jmdana jmdana commented Apr 13, 2022

Fixes #7437 (partially, entry edit view only)
Fixes #5220

This change adds a password strength indicator to PasswordEditWidget (I have followed the way it is done in PasswordGeneratorWidget).

I want to contribute some code to the project and thought that this could be a good "first issue". Please be gentle ;)

Screenshots

Screenshot_20220413_120737

Screenshot_20220413_120832

Testing strategy

Testing was quite straightforward. As far as I know, the screenshots above are the only two places where PasswordEditWidget is used. I went to the windows shown above and tried different combinations of passwords to see how the indicator behaves, trying to replicate exactly what is done in PasswordGeneratorWidget.

Both development and testing were made on Linux only.

Type of change

  • ✅ New feature (change that adds functionality)

Comments

I'm basically doing the same as in PasswordGeneratorWidget so, would it be worth refactoring and making a derived class of QProgressBar? I would say it is but it is up to you, just let me know.

Thanks for the software ;)

@droidmonkey
Copy link
Member

Great! Can you align the quality text to be under the text edit (shift it right)?

@codecov-commenter
Copy link

codecov-commenter commented Apr 13, 2022

Codecov Report

Merging #7885 (5e30494) into develop (692c95b) will increase coverage by 0.07%.
The diff coverage is 91.04%.

@@             Coverage Diff             @@
##           develop    #7885      +/-   ##
===========================================
+ Coverage    64.31%   64.38%   +0.07%     
===========================================
  Files          339      339              
  Lines        43430    43529      +99     
===========================================
+ Hits         27932    28025      +93     
- Misses       15498    15504       +6     
Impacted Files Coverage Δ
src/autotype/PickcharsDialog.cpp 0.00% <0.00%> (ø)
src/gui/OpVaultOpenWidget.cpp 10.00% <0.00%> (ø)
src/keeshare/group/EditGroupWidgetKeeShare.cpp 34.47% <0.00%> (ø)
src/gui/PasswordGeneratorWidget.cpp 68.85% <33.33%> (ø)
src/gui/DatabaseOpenWidget.cpp 56.27% <75.00%> (ø)
src/gui/entry/EditEntryWidget.cpp 72.28% <75.00%> (+0.05%) ⬆️
src/gui/PasswordWidget.cpp 89.43% <97.25%> (ø)
src/gui/KeePass1OpenWidget.cpp 82.14% <100.00%> (ø)
src/gui/databasekey/PasswordEditWidget.cpp 82.14% <100.00%> (+1.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 692c95b...5e30494. Read the comment docs.

@jmdana
Copy link
Contributor Author

jmdana commented Apr 13, 2022

Great! Can you align the quality text to be under the text edit (shift it right)?

Like this?

Screenshot_20220413_130823

That's exactly how it appears in the password generation window.

I could also change the layout from "Form" to "Grid" and have the label and the bar next to each other

@michaelk83
Copy link

Fixes #7437

@jmdana This PR doesn't address #7437 (yet?). That issue talks about the entry edit widget and preview panel.

@jmdana
Copy link
Contributor Author

jmdana commented Apr 13, 2022

Fixes #7437

@jmdana This PR doesn't address #7437 (yet?). That issue talks about the entry edit widget and preview panel.

True! I don't know what I was thinking.

If I amend the commit and push force, will I mess the pull request?

@droidmonkey
Copy link
Member

droidmonkey commented Apr 13, 2022

Nope that is the preferred way to update the PR.

For the quality label I was thinking inline with the quality bar, not below it. You can wrap the two elements in a horizontal layout to make it "one" for the form layout.

Really this should be built into the PasswordWidget not the databasekey/PasswordEditWidget. That way you can show the quality no matter where the PasswordWidget is used. Make it an option because you obviously don't need that when unlocking your database.

@jmdana
Copy link
Contributor Author

jmdana commented Apr 13, 2022

I agree, that would be the best.

Now, from what I see, PasswordEdit extends QLineEdit. I see that you add the icons in there but, as far as I understand, in order to implement the progress bar as in the screenshots, PasswordEdit would have to extend a Layout instead (so we can include both widgets in the object).

Is that what you mean? Am I missing something?

@droidmonkey
Copy link
Member

Yes that's exactly what I mean.

@jmdana
Copy link
Contributor Author

jmdana commented Apr 13, 2022

Yes that's exactly what I mean.

Ok, I'll give it a try.

@jmdana jmdana force-pushed the feature/passwd_strength branch from 23dabb7 to 402d273 Compare April 13, 2022 20:52
@jmdana
Copy link
Contributor Author

jmdana commented Apr 13, 2022

keepass3
keepass2
keepass1

The change involves many files so here is a small summary:

  • PasswordEdit is now PasswordWidget, which encapsulates both the previous text entry and the quality bar. Adding new stuff should be very easy now.

  • In order to keep other objects working I have created methods which work as an interface between the new widget and the text entry inside. If, in the future, new objects are added to the widget, changes will be transparent to others. It also allows for some customization within the widget.

  • The textChanged signal, which was used by a few other widgets, is now propagated. Other objects keep using the same definition of the signal (which means they are listening to the widget now, instead of the text entry) and it is the widget who decides how to implement it. Currently, the widget propagates the signal every time it is captured coming from the text entry.

  • By default, the quality bar is hidden. setQualityVisible(bool b) does the trick.

  • Currently, the quality bar can be seen in the entry menu, database creation and database password change. The password generator is still using the previous implementation, maybe should be part of another commit?

  • About the quality label, well, here is what I think:

    • When side by side with the quality bar, because the length of the string is variable, sometimes the gap between the label and the bar is too large. If we make the gap variable then the bar starts moving around. Personally, I don't really like how it looks.
    • If we move the label to the right we solve the previous problem but I don't like it either. It seems too far away from where the user should be looking at.
    • Under the bar takes a lof ot space...

    So my solution was to add it as a tooltip. How many people don't understand what a colored-moving bar under a password field means? I think it is quite obvious but maybe I'm wrong. As it is right now, any change should be very easy to do.

What a simple "first issue" :)

@jmdana
Copy link
Contributor Author

jmdana commented Apr 13, 2022

It looks like a test is having a bad time compiling (I didn't even look at them to be honest) and there was some issue with the formatting (I probably didn't reformat all the files after the class refactor).

I'll have a look at some point during the next few days.

@@ -77,7 +77,9 @@ PickcharsDialog::PickcharsDialog(const QString& string, QWidget* parent)
// Remove last selected character
auto shortcut = new QShortcut(Qt::Key_Backspace, this);
connect(shortcut, &QShortcut::activated, this, [this] {
auto text = m_ui->selectedChars->text();
// auto text = m_ui->selectedChars->text();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be removed

auto text = m_ui->selectedChars->text();
// auto text = m_ui->selectedChars->text();
auto text = m_ui->selectedChars->getText();
// m_ui->selectedChars->setText(text.left(text.size() - 1));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be removed

@droidmonkey
Copy link
Member

droidmonkey commented Apr 13, 2022

Looking nice! Love the compact design

@jmdana jmdana force-pushed the feature/passwd_strength branch 2 times, most recently from 7baf8fa to 5e30494 Compare April 14, 2022 20:16
@jmdana jmdana changed the title Add password strength indicator to PasswordEditWidget Add password strength indicator to password entry fields Apr 15, 2022
@droidmonkey droidmonkey self-requested a review May 1, 2022 14:15
@droidmonkey droidmonkey added user interface new feature pr: backport pending Pull request yet to be backported to a previous release labels May 1, 2022
@droidmonkey droidmonkey added this to the v2.7.2 milestone May 1, 2022
@droidmonkey droidmonkey force-pushed the feature/passwd_strength branch 2 times, most recently from 4ad252d to 0b93393 Compare May 28, 2022 21:17
@droidmonkey
Copy link
Member

Cleaned up the code and improved the visual look of the quality bar. Great job on this one!

@droidmonkey droidmonkey force-pushed the feature/passwd_strength branch 2 times, most recently from 26b6822 to a6d3a0a Compare May 30, 2022 15:14
@droidmonkey droidmonkey force-pushed the feature/passwd_strength branch from a6d3a0a to 829095e Compare May 31, 2022 03:32
@droidmonkey droidmonkey merged commit a740fe1 into keepassxreboot:develop May 31, 2022
@jmdana
Copy link
Contributor Author

jmdana commented Jun 2, 2022

Cleaned up the code and improved the visual look of the quality bar. Great job on this one!

Thanks!

@droidmonkey droidmonkey added pr: backported Pull request backported to previous release and removed pr: backport pending Pull request yet to be backported to a previous release labels Jun 27, 2022
@phoerious phoerious added pr: new feature Pull request that adds a new feature and removed new feature labels Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: backported Pull request backported to previous release pr: new feature Pull request that adds a new feature user interface
Projects
None yet
5 participants