uui/source/passworddlg.cxx | 34 +++++++++++++--------------------- uui/source/passworddlg.hxx | 3 ++- 2 files changed, 15 insertions(+), 22 deletions(-)
New commits: commit 84a59903e28145fb7f7e3f6fd87843042662581a Author: Xisco Fauli <[email protected]> AuthorDate: Fri Jan 23 15:46:07 2026 +0100 Commit: Xisco Fauli <[email protected]> CommitDate: Fri Jan 23 18:57:19 2026 +0100 uui: simplify code a bit * No need to use an array * No need to call set_from_icon_name in the constructor. Both toggles are not active at that point and the .ui file already uses <property name="icon-name">res/hidepass.png</property> for both of them Change-Id: I3e956c0d0101e8a8d1de6bccb7ec0e397f0aa712 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198007 Reviewed-by: Xisco Fauli <[email protected]> Tested-by: Jenkins diff --git a/uui/source/passworddlg.cxx b/uui/source/passworddlg.cxx index 4698b427f808..7471271b6ef3 100644 --- a/uui/source/passworddlg.cxx +++ b/uui/source/passworddlg.cxx @@ -40,6 +40,8 @@ PasswordDialog::PasswordDialog(weld::Window* pParent, , m_xFTConfirmPassword(m_xBuilder->weld_label(u"confirmpassFT"_ustr)) , m_xEDConfirmPassword(m_xBuilder->weld_entry(u"confirmpassEntry"_ustr)) , m_xOKBtn(m_xBuilder->weld_button(u"ok"_ustr)) + , m_xBtn1(m_xBuilder->weld_toggle_button(u"togglebt1"_ustr)) + , m_xBtn2(m_xBuilder->weld_toggle_button(u"togglebt2"_ustr)) , nMinLen(1) , aPasswdMismatch(Translate::get(STR_PASSWORD_MISMATCH, rResLocale)) { @@ -48,27 +50,17 @@ PasswordDialog::PasswordDialog(weld::Window* pParent, // tdf#115964 we can be launched before the parent has resized to its final size m_xDialog->set_centered_on_parent(true); - m_xPass[0] = m_xBuilder->weld_toggle_button(u"togglebt1"_ustr); - m_xPass[1] = m_xBuilder->weld_toggle_button(u"togglebt2"_ustr); - Link<weld::Toggleable&, void> aToggleLink = LINK(this, PasswordDialog, ShowHdl); - - for (auto& aPass : m_xPass) - { - if (aPass->get_active()) - aPass->set_from_icon_name(RID_SVXBMP_SHOWPASS); - else - aPass->set_from_icon_name(RID_SVXBMP_HIDEPASS); - aPass->connect_toggled(aToggleLink); - } + m_xBtn1->connect_toggled(aToggleLink); + m_xBtn2->connect_toggled(aToggleLink); // default settings for enter password or reenter passwd... m_xFTConfirmPassword->hide(); m_xEDConfirmPassword->hide(); - m_xPass[1]->hide(); + m_xBtn2->hide(); m_xFTConfirmPassword->set_sensitive(false); m_xEDConfirmPassword->set_sensitive(false); - m_xPass[1]->set_sensitive(false); + m_xBtn2->set_sensitive(false); // settings for create password if (nDialogMode == task::PasswordRequestMode_PASSWORD_CREATE) @@ -80,7 +72,7 @@ PasswordDialog::PasswordDialog(weld::Window* pParent, m_xEDConfirmPassword->show(); m_xFTConfirmPassword->set_sensitive(true); m_xEDConfirmPassword->set_sensitive(true); - m_xPass[1]->show(); + m_xBtn2->show(); } auto xOpenLabel = m_xBuilder->weld_label(u"openPasswordLabel"_ustr); @@ -170,32 +162,32 @@ IMPL_LINK_NOARG(PasswordDialog, OKHdl_Impl, weld::Button&, void) IMPL_LINK(PasswordDialog, ShowHdl, weld::Toggleable& ,rToggleable, void) { bool bChecked = rToggleable.get_active(); - if (&rToggleable == m_xPass[0].get()) + if (&rToggleable == m_xBtn1.get()) { if (bChecked) { - m_xPass[0]->set_from_icon_name(RID_SVXBMP_SHOWPASS); + m_xBtn1->set_from_icon_name(RID_SVXBMP_SHOWPASS); m_xEDPassword->set_visibility(true); m_xEDPassword->grab_focus(); } else { - m_xPass[0]->set_from_icon_name(RID_SVXBMP_HIDEPASS); + m_xBtn1->set_from_icon_name(RID_SVXBMP_HIDEPASS); m_xEDPassword->set_visibility(false); m_xEDPassword->grab_focus(); } } - else if (&rToggleable == m_xPass[1].get()) + else if (&rToggleable == m_xBtn2.get()) { if (bChecked) { - m_xPass[1]->set_from_icon_name(RID_SVXBMP_SHOWPASS); + m_xBtn2->set_from_icon_name(RID_SVXBMP_SHOWPASS); m_xEDConfirmPassword->set_visibility(true); m_xEDConfirmPassword->grab_focus(); } else { - m_xPass[1]->set_from_icon_name(RID_SVXBMP_HIDEPASS); + m_xBtn2->set_from_icon_name(RID_SVXBMP_HIDEPASS); m_xEDConfirmPassword->set_visibility(false); m_xEDConfirmPassword->grab_focus(); } diff --git a/uui/source/passworddlg.hxx b/uui/source/passworddlg.hxx index dcd0f0f5b3b1..357176cf8e9e 100644 --- a/uui/source/passworddlg.hxx +++ b/uui/source/passworddlg.hxx @@ -31,7 +31,8 @@ class PasswordDialog : public weld::GenericDialogController std::unique_ptr<weld::Label> m_xFTConfirmPassword; std::unique_ptr<weld::Entry> m_xEDConfirmPassword; std::unique_ptr<weld::Button> m_xOKBtn; - std::array<std::unique_ptr<weld::ToggleButton>, 2> m_xPass; + std::unique_ptr<weld::ToggleButton> m_xBtn1; + std::unique_ptr<weld::ToggleButton> m_xBtn2; sal_uInt16 nMinLen; OUString aPasswdMismatch;
