diff options
author | Sarper Akdemir <sarper.akdemir.extern@allotropia.de> | 2023-11-08 08:43:41 +0300 |
---|---|---|
committer | Sarper Akdemir <sarper.akdemir.extern@allotropia.de> | 2023-11-15 19:48:44 +0100 |
commit | e8fc5d7fcab6b283ec0655b1d7cab5bf28fde240 (patch) | |
tree | 402db53e4ca0d9d4eab4392ae4d475f0ddb5321c | |
parent | cdcff8c34144e883eca9dc6e1a85968ed34909c2 (diff) |
tdf#157518: add password strength bar to sfx2/ui/password.ui
Change-Id: I181b71c6072a61651b33835f76e8deebb5f8d58a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159371
Tested-by: Jenkins
Reviewed-by: Sarper Akdemir <sarper.akdemir.extern@allotropia.de>
-rw-r--r-- | include/sfx2/passwd.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/dialog/passwd.cxx | 21 | ||||
-rw-r--r-- | sfx2/uiconfig/ui/password.ui | 34 |
3 files changed, 52 insertions, 5 deletions
diff --git a/include/sfx2/passwd.hxx b/include/sfx2/passwd.hxx index 98c70787ca0e..bc5e478bbf03 100644 --- a/include/sfx2/passwd.hxx +++ b/include/sfx2/passwd.hxx @@ -50,12 +50,14 @@ private: std::unique_ptr<weld::Entry> m_xUserED; std::unique_ptr<weld::Label> m_xPassword1FT; std::unique_ptr<weld::Entry> m_xPassword1ED; + std::unique_ptr<weld::LevelBar> m_xPassword1StrengthBar; std::unique_ptr<weld::Label> m_xConfirm1FT; std::unique_ptr<weld::Entry> m_xConfirm1ED; std::unique_ptr<weld::Frame> m_xPassword2Box; std::unique_ptr<weld::Label> m_xPassword2FT; std::unique_ptr<weld::Entry> m_xPassword2ED; + std::unique_ptr<weld::LevelBar> m_xPassword2StrengthBar; std::unique_ptr<weld::Label> m_xConfirm2FT; std::unique_ptr<weld::Entry> m_xConfirm2ED; diff --git a/sfx2/source/dialog/passwd.cxx b/sfx2/source/dialog/passwd.cxx index 51f3abd84c0c..a69d0aef352a 100644 --- a/sfx2/source/dialog/passwd.cxx +++ b/sfx2/source/dialog/passwd.cxx @@ -20,6 +20,7 @@ #include <sfx2/passwd.hxx> #include <sfx2/sfxresid.hxx> #include <sfx2/strings.hrc> +#include <svl/PasswordHelper.hxx> #include <rtl/ustrbuf.hxx> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> @@ -31,10 +32,22 @@ IMPL_LINK_NOARG(SfxPasswordDialog, EditModifyHdl, weld::Entry&, void) void SfxPasswordDialog::ModifyHdl() { - bool bEnable = m_xPassword1ED->get_text().getLength() >= mnMinLen; + OUString aPassword1Text = m_xPassword1ED->get_text(); + bool bEnable = aPassword1Text.getLength() >= mnMinLen; if (m_xPassword2ED->get_visible()) bEnable = (bEnable && (m_xPassword2ED->get_text().getLength() >= mnMinLen)); m_xOKBtn->set_sensitive(bEnable); + + if (m_xConfirm1ED->get_visible()) + { + m_xPassword1StrengthBar->set_percentage( + SvPasswordHelper::GetPasswordStrengthPercentage(aPassword1Text)); + } + if (m_xConfirm2ED->get_visible()) + { + m_xPassword2StrengthBar->set_percentage( + SvPasswordHelper::GetPasswordStrengthPercentage(m_xPassword2ED->get_text())); + } } IMPL_LINK(SfxPasswordDialog, InsertTextHdl, OUString&, rTest, bool) @@ -100,11 +113,13 @@ SfxPasswordDialog::SfxPasswordDialog(weld::Widget* pParent, const OUString* pGro , m_xUserED(m_xBuilder->weld_entry("usered")) , m_xPassword1FT(m_xBuilder->weld_label("pass1ft")) , m_xPassword1ED(m_xBuilder->weld_entry("pass1ed")) + , m_xPassword1StrengthBar(m_xBuilder->weld_level_bar("pass1bar")) , m_xConfirm1FT(m_xBuilder->weld_label("confirm1ft")) , m_xConfirm1ED(m_xBuilder->weld_entry("confirm1ed")) , m_xPassword2Box(m_xBuilder->weld_frame("password2frame")) , m_xPassword2FT(m_xBuilder->weld_label("pass2ft")) , m_xPassword2ED(m_xBuilder->weld_entry("pass2ed")) + , m_xPassword2StrengthBar(m_xBuilder->weld_level_bar("pass2bar")) , m_xConfirm2FT(m_xBuilder->weld_label("confirm2ft")) , m_xConfirm2ED(m_xBuilder->weld_entry("confirm2ed")) , m_xMinLengthFT(m_xBuilder->weld_label("minlenft")) @@ -177,6 +192,7 @@ void SfxPasswordDialog::PreRun() m_xUserED->hide(); m_xConfirm1FT->hide(); m_xConfirm1ED->hide(); + m_xPassword1StrengthBar->hide(); m_xPassword1FT->hide(); m_xPassword2Box->hide(); m_xPassword2FT->hide(); @@ -184,6 +200,7 @@ void SfxPasswordDialog::PreRun() m_xPassword2FT->hide(); m_xConfirm2FT->hide(); m_xConfirm2ED->hide(); + m_xPassword2StrengthBar->hide(); if (mnExtras != SfxShowExtras::NONE) m_xPassword1FT->show(); @@ -196,6 +213,7 @@ void SfxPasswordDialog::PreRun() { m_xConfirm1FT->show(); m_xConfirm1ED->show(); + m_xPassword1StrengthBar->show(); } if (mnExtras & SfxShowExtras::PASSWORD2) { @@ -207,6 +225,7 @@ void SfxPasswordDialog::PreRun() { m_xConfirm2FT->show(); m_xConfirm2ED->show(); + m_xPassword2StrengthBar->show(); } } diff --git a/sfx2/uiconfig/ui/password.ui b/sfx2/uiconfig/ui/password.ui index d17b8d9077e3..0eabdd68682b 100644 --- a/sfx2/uiconfig/ui/password.ui +++ b/sfx2/uiconfig/ui/password.ui @@ -87,7 +87,7 @@ <property name="label-xalign">0</property> <property name="shadow-type">none</property> <child> - <!-- n-columns=2 n-rows=3 --> + <!-- n-columns=2 n-rows=4 --> <object class="GtkGrid" id="grid1"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -134,7 +134,7 @@ </object> <packing> <property name="left-attach">0</property> - <property name="top-attach">2</property> + <property name="top-attach">3</property> </packing> </child> <child> @@ -188,9 +188,22 @@ </object> <packing> <property name="left-attach">1</property> + <property name="top-attach">3</property> + </packing> + </child> + <child> + <object class="GtkLevelBar" id="pass1bar"> + <property name="visible">True</property> + <property name="can-focus">False</property> + </object> + <packing> + <property name="left-attach">1</property> <property name="top-attach">2</property> </packing> </child> + <child> + <placeholder/> + </child> </object> </child> <child type="label"> @@ -217,7 +230,7 @@ <property name="label-xalign">0</property> <property name="shadow-type">none</property> <child> - <!-- n-columns=2 n-rows=2 --> + <!-- n-columns=2 n-rows=3 --> <object class="GtkGrid" id="grid2"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -250,7 +263,7 @@ </object> <packing> <property name="left-attach">0</property> - <property name="top-attach">1</property> + <property name="top-attach">2</property> </packing> </child> <child> @@ -290,9 +303,22 @@ </object> <packing> <property name="left-attach">1</property> + <property name="top-attach">2</property> + </packing> + </child> + <child> + <object class="GtkLevelBar" id="pass2bar"> + <property name="visible">True</property> + <property name="can-focus">False</property> + </object> + <packing> + <property name="left-attach">1</property> <property name="top-attach">1</property> </packing> </child> + <child> + <placeholder/> + </child> </object> </child> <child type="label"> |