From cdcff8c34144e883eca9dc6e1a85968ed34909c2 Mon Sep 17 00:00:00 2001 From: Sarper Akdemir Date: Wed, 8 Nov 2023 07:36:52 +0300 Subject: tdf#157518: add password strength meter to setmasterpassworddlg Moves PasswordStrength bits that provide utility functions from cui to svl, merging them with PasswordHelper there. Adds password strength bar for the set master password dialog. (accessible via Tools -> Options -> LibreOffice -> Security -> Passwords for Web Connections) Change-Id: I8dc1090a041f8388c2e139beb1d0d9a0beb8acb0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159370 Tested-by: Jenkins Reviewed-by: Sarper Akdemir --- uui/source/masterpasscrtdlg.cxx | 7 ++++++- uui/source/masterpasscrtdlg.hxx | 1 + uui/uiconfig/ui/setmasterpassworddlg.ui | 23 +++++++++++++++++------ 3 files changed, 24 insertions(+), 7 deletions(-) (limited to 'uui') diff --git a/uui/source/masterpasscrtdlg.cxx b/uui/source/masterpasscrtdlg.cxx index 4801bec28f85..2216ea5a1d48 100644 --- a/uui/source/masterpasscrtdlg.cxx +++ b/uui/source/masterpasscrtdlg.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include "masterpasscrtdlg.hxx" // MasterPasswordCreateDialog--------------------------------------------------- @@ -28,7 +29,10 @@ IMPL_LINK_NOARG(MasterPasswordCreateDialog, EditHdl_Impl, weld::Entry&, void) { - m_xOKBtn->set_sensitive(m_xEDMasterPasswordCrt->get_text().getLength() >= 1); + OUString aPasswordText = m_xEDMasterPasswordCrt->get_text(); + m_xOKBtn->set_sensitive(aPasswordText.getLength() >= 1); + m_xPasswdStrengthBar->set_percentage( + SvPasswordHelper::GetPasswordStrengthPercentage(aPasswordText)); } IMPL_LINK_NOARG(MasterPasswordCreateDialog, OKHdl_Impl, weld::Button&, void) @@ -55,6 +59,7 @@ MasterPasswordCreateDialog::MasterPasswordCreateDialog(weld::Window* pParent, co , m_xEDMasterPasswordCrt(m_xBuilder->weld_entry("password1")) , m_xEDMasterPasswordRepeat(m_xBuilder->weld_entry("password2")) , m_xOKBtn(m_xBuilder->weld_button("ok")) + , m_xPasswdStrengthBar(m_xBuilder->weld_level_bar("password1levelbar")) { m_xOKBtn->set_sensitive(false); m_xOKBtn->connect_clicked( LINK( this, MasterPasswordCreateDialog, OKHdl_Impl ) ); diff --git a/uui/source/masterpasscrtdlg.hxx b/uui/source/masterpasscrtdlg.hxx index a8695fc1ed27..f7f01cda79cc 100644 --- a/uui/source/masterpasscrtdlg.hxx +++ b/uui/source/masterpasscrtdlg.hxx @@ -29,6 +29,7 @@ private: std::unique_ptr m_xEDMasterPasswordCrt; std::unique_ptr m_xEDMasterPasswordRepeat; std::unique_ptr m_xOKBtn; + std::unique_ptr m_xPasswdStrengthBar; DECL_LINK(OKHdl_Impl, weld::Button&, void); DECL_LINK(EditHdl_Impl, weld::Entry&, void); diff --git a/uui/uiconfig/ui/setmasterpassworddlg.ui b/uui/uiconfig/ui/setmasterpassworddlg.ui index 0402b4de7b35..52cec48eb30a 100644 --- a/uui/uiconfig/ui/setmasterpassworddlg.ui +++ b/uui/uiconfig/ui/setmasterpassworddlg.ui @@ -129,19 +129,30 @@ 2 + + + True + False + + + False + True + 3 + + True - False + False _Reenter password: - True - password2 + True + password2 0 False True - 3 + 4 @@ -161,7 +172,7 @@ False True - 4 + 5 @@ -180,7 +191,7 @@ False True - 5 + 6 -- cgit