summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga.extern@allotropia.de>2025-01-07 13:43:36 +0100
committerBalazs Varga <balazs.varga.extern@allotropia.de>2025-01-10 13:04:22 +0100
commit6eb1a3c4b08f004c074dac41dee31bacb38216a5 (patch)
treed1efbce65bc4f5305ccd5bd98f91b81a5e97b2d0 /sfx2
parentc56556448a47a41b2a1dfbb070dadc051b34d351 (diff)
tdf#146947 - UI: Ability to show/reveal characters being typed into
password prompt to decrypt a document. Add toggle buttons for showing and hiding password characters in password textbox entries. Change-Id: Iba69d303431c2f9f2c987c67fcbd3f36b42dc057 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179889 Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de> Tested-by: Jenkins
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/inc/bitmaps.hlst3
-rw-r--r--sfx2/source/dialog/passwd.cxx85
-rw-r--r--sfx2/uiconfig/ui/password.ui295
3 files changed, 304 insertions, 79 deletions
diff --git a/sfx2/inc/bitmaps.hlst b/sfx2/inc/bitmaps.hlst
index 04169c38d2db..8d085bdb855b 100644
--- a/sfx2/inc/bitmaps.hlst
+++ b/sfx2/inc/bitmaps.hlst
@@ -97,4 +97,7 @@ inline constexpr OUString BMP_MENU_EXPORT = u"cmd/sc_exportto.png"_ustr;
inline constexpr OUString BMP_DONATE = u"res/donate.png"_ustr;
+inline constexpr OUString RID_SVXBMP_HIDEPASS = u"res/hidepass.png"_ustr;
+inline constexpr OUString RID_SVXBMP_SHOWPASS = u"res/showpass.png"_ustr;
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sfx2/source/dialog/passwd.cxx b/sfx2/source/dialog/passwd.cxx
index a98c8adbc39e..6222885f7bb5 100644
--- a/sfx2/source/dialog/passwd.cxx
+++ b/sfx2/source/dialog/passwd.cxx
@@ -25,6 +25,7 @@
#include <rtl/ustrbuf.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
+#include <bitmaps.hlst>
IMPL_LINK_NOARG(SfxPasswordDialog, EditModifyHdl, weld::Entry&, void)
{
@@ -144,6 +145,74 @@ IMPL_LINK_NOARG(SfxPasswordDialog, OKHdl, weld::Button&, void)
m_xDialog->response(RET_OK);
}
+IMPL_LINK(SfxPasswordDialog, ShowHdl, weld::Toggleable&, rToggleable, void)
+{
+ bool bChecked = rToggleable.get_active();
+ if (&rToggleable == m_xPass[0].get())
+ {
+ if (bChecked)
+ {
+ m_xPass[0]->set_from_icon_name(RID_SVXBMP_SHOWPASS);
+ m_xPassword1ED->set_visibility(true);
+ m_xPassword1ED->grab_focus();
+ }
+ else
+ {
+ m_xPass[0]->set_from_icon_name(RID_SVXBMP_HIDEPASS);
+ m_xPassword1ED->set_visibility(false);
+ m_xPassword1ED->grab_focus();
+ }
+ }
+ else if (&rToggleable == m_xPass[1].get())
+ {
+ if (bChecked)
+ {
+ m_xPass[1]->set_from_icon_name(RID_SVXBMP_SHOWPASS);
+ m_xConfirm1ED->set_visibility(true);
+ m_xConfirm1ED->grab_focus();
+ }
+ else
+ {
+ m_xPass[1]->set_from_icon_name(RID_SVXBMP_HIDEPASS);
+ m_xConfirm1ED->set_visibility(false);
+ m_xConfirm1ED->grab_focus();
+ }
+ }
+ else if (&rToggleable == m_xPass[2].get())
+ {
+ if (bChecked)
+ {
+ m_xPass[2]->set_from_icon_name(RID_SVXBMP_SHOWPASS);
+ m_xPassword2ED->set_visibility(true);
+ m_xPassword2ED->grab_focus();
+ }
+ else
+ {
+ m_xPass[2]->set_from_icon_name(RID_SVXBMP_HIDEPASS);
+ m_xPassword2ED->set_visibility(false);
+ m_xPassword2ED->grab_focus();
+ }
+ }
+ else if (&rToggleable == m_xPass[3].get())
+ {
+ if (bChecked)
+ {
+ m_xPass[3]->set_from_icon_name(RID_SVXBMP_SHOWPASS);
+ m_xConfirm2ED->set_visibility(true);
+ m_xConfirm2ED->grab_focus();
+ }
+ else
+ {
+ m_xPass[3]->set_from_icon_name(RID_SVXBMP_HIDEPASS);
+ m_xConfirm2ED->set_visibility(false);
+ m_xConfirm2ED->grab_focus();
+ }
+ }
+ else {
+ // should not reach it
+ }
+}
+
// CTOR / DTOR -----------------------------------------------------------
SfxPasswordDialog::SfxPasswordDialog(weld::Widget* pParent, const OUString* pGroupText)
@@ -185,6 +254,22 @@ SfxPasswordDialog::SfxPasswordDialog(weld::Widget* pParent, const OUString* pGro
m_xConfirm2ED->connect_insert_text(aLink2);
m_xOKBtn->connect_clicked(LINK(this, SfxPasswordDialog, OKHdl));
+ m_xPass[0] = m_xBuilder->weld_toggle_button(u"togglebt1"_ustr);
+ m_xPass[1] = m_xBuilder->weld_toggle_button(u"togglebt2"_ustr);
+ m_xPass[2] = m_xBuilder->weld_toggle_button(u"togglebt3"_ustr);
+ m_xPass[3] = m_xBuilder->weld_toggle_button(u"togglebt4"_ustr);
+
+ Link<weld::Toggleable&, void> aToggleLink = LINK(this, SfxPasswordDialog, 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);
+ }
+
if(moPasswordPolicy)
{
m_xPassword1PolicyLabel->set_label(
diff --git a/sfx2/uiconfig/ui/password.ui b/sfx2/uiconfig/ui/password.ui
index b2e9fbea716f..377d6f306e2e 100644
--- a/sfx2/uiconfig/ui/password.ui
+++ b/sfx2/uiconfig/ui/password.ui
@@ -2,6 +2,26 @@
<!-- Generated with glade 3.38.2 -->
<interface domain="sfx">
<requires lib="gtk+" version="3.20"/>
+ <object class="GtkImage" id="passimg1">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">res/hidepass.png</property>
+ </object>
+ <object class="GtkImage" id="passimg2">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">res/hidepass.png</property>
+ </object>
+ <object class="GtkImage" id="passimg3">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">res/hidepass.png</property>
+ </object>
+ <object class="GtkImage" id="passimg4">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">res/hidepass.png</property>
+ </object>
<object class="GtkDialog" id="PasswordDialog">
<property name="can-focus">False</property>
<property name="border-width">6</property>
@@ -115,7 +135,6 @@
<property name="can-focus">False</property>
<property name="label" translatable="yes" context="password|pass1ft">Password:</property>
<property name="use-underline">True</property>
- <property name="mnemonic-widget">pass1ed</property>
<property name="xalign">0</property>
</object>
<packing>
@@ -129,7 +148,6 @@
<property name="can-focus">False</property>
<property name="label" translatable="yes" context="password|confirm1ft">Confirm:</property>
<property name="use-underline">True</property>
- <property name="mnemonic-widget">confirm1ed</property>
<property name="xalign">0</property>
</object>
<packing>
@@ -151,67 +169,128 @@
</packing>
</child>
<child>
- <object class="GtkEntry" id="pass1ed">
+ <object class="GtkLevelBar" id="pass1bar">
<property name="visible">True</property>
- <property name="can-focus">True</property>
- <property name="hexpand">True</property>
- <property name="visibility">False</property>
- <property name="activates-default">True</property>
- <property name="truncate-multiline">True</property>
- <property name="input-purpose">password</property>
- <child internal-child="accessible">
- <object class="AtkObject" id="pass1ed-atkobject">
- <property name="AtkObject::accessible-name" translatable="yes" context="password|pass1ed-atkobject">Password</property>
- <property name="AtkObject::accessible-description" translatable="yes" context="password|extended_tip|pass1ed">Type a password. A password is case sensitive.</property>
- </object>
- </child>
+ <property name="can-focus">False</property>
</object>
<packing>
<property name="left-attach">1</property>
- <property name="top-attach">2</property>
+ <property name="top-attach">3</property>
</packing>
</child>
<child>
- <object class="GtkEntry" id="confirm1ed">
- <property name="visible">True</property>
- <property name="can-focus">True</property>
- <property name="hexpand">True</property>
- <property name="visibility">False</property>
- <property name="activates-default">True</property>
- <property name="truncate-multiline">True</property>
- <property name="input-purpose">password</property>
- <child internal-child="accessible">
- <object class="AtkObject" id="confirm1ed-atkobject">
- <property name="AtkObject::accessible-description" translatable="yes" context="password|extended_tip|confirm1ed">Re-enter the password.</property>
- </object>
- </child>
+ <object class="GtkLabel" id="pass1policylabel">
+ <property name="can-focus">False</property>
+ <property name="no-show-all">True</property>
+ <property name="halign">end</property>
+ <property name="hexpand">False</property>
+ <property name="wrap">True</property>
</object>
<packing>
<property name="left-attach">1</property>
- <property name="top-attach">4</property>
+ <property name="top-attach">1</property>
</packing>
</child>
<child>
- <object class="GtkLevelBar" id="pass1bar">
+ <object class="GtkBox" id="passwbox1">
<property name="visible">True</property>
<property name="can-focus">False</property>
+ <property name="hexpand">True</property>
+ <child>
+ <object class="GtkEntry" id="pass1ed">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="visibility">False</property>
+ <property name="activates-default">True</property>
+ <property name="truncate-multiline">True</property>
+ <property name="input-purpose">password</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="pass1ed-atkobject">
+ <property name="AtkObject::accessible-name" translatable="yes" context="password|pass1ed-atkobject">Password</property>
+ <property name="AtkObject::accessible-description" translatable="yes" context="password|extended_tip|pass1ed">Type a password. A password is case sensitive.</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="togglebt1">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="image">passimg1</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="togglebt1-atkobject">
+ <property name="AtkObject::accessible-name" translatable="yes" context="password|togglebt1-atkobject">Show characters</property>
+ <property name="AtkObject::accessible-description" translatable="yes" context="password|extended_tip|togglebt1">Show or hide password characters</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="left-attach">1</property>
- <property name="top-attach">3</property>
+ <property name="top-attach">2</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="pass1policylabel">
+ <object class="GtkBox" id="passwbox2">
+ <property name="visible">True</property>
<property name="can-focus">False</property>
- <property name="no-show-all">True</property>
- <property name="halign">end</property>
- <property name="hexpand">False</property>
- <property name="wrap">True</property>
+ <property name="hexpand">True</property>
+ <child>
+ <object class="GtkEntry" id="confirm1ed">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="visibility">False</property>
+ <property name="activates-default">True</property>
+ <property name="truncate-multiline">True</property>
+ <property name="input-purpose">password</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="confirm1ed-atkobject">
+ <property name="AtkObject::accessible-description" translatable="yes" context="password|extended_tip|confirm1ed">Re-enter the password.</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="togglebt2">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="image">passimg2</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="togglebt2-atkobject">
+ <property name="AtkObject::accessible-description" translatable="yes" context="password|extended_tip|togglebt2">Show or hide password characters</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="left-attach">1</property>
- <property name="top-attach">1</property>
+ <property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -260,7 +339,6 @@
<property name="can-focus">False</property>
<property name="label" translatable="yes" context="password|pass2ft">Password:</property>
<property name="use-underline">True</property>
- <property name="mnemonic-widget">pass2ed</property>
<property name="xalign">0</property>
</object>
<packing>
@@ -274,7 +352,6 @@
<property name="can-focus">False</property>
<property name="label" translatable="yes" context="password|confirm2ft">Confirm:</property>
<property name="use-underline">True</property>
- <property name="mnemonic-widget">confirm2ed</property>
<property name="xalign">0</property>
</object>
<packing>
@@ -283,66 +360,126 @@
</packing>
</child>
<child>
- <object class="GtkEntry" id="pass2ed">
+ <object class="GtkLevelBar" id="pass2bar">
<property name="visible">True</property>
- <property name="can-focus">True</property>
- <property name="hexpand">True</property>
- <property name="visibility">False</property>
- <property name="activates-default">True</property>
- <property name="truncate-multiline">True</property>
- <property name="input-purpose">password</property>
- <child internal-child="accessible">
- <object class="AtkObject" id="pass2ed-atkobject">
- <property name="AtkObject::accessible-description" translatable="yes" context="password|extended_tip|pass2ed">Type a password. A password is case sensitive.</property>
- </object>
- </child>
+ <property name="can-focus">False</property>
</object>
<packing>
<property name="left-attach">1</property>
- <property name="top-attach">1</property>
+ <property name="top-attach">2</property>
</packing>
</child>
<child>
- <object class="GtkEntry" id="confirm2ed">
- <property name="visible">True</property>
- <property name="can-focus">True</property>
- <property name="hexpand">True</property>
- <property name="visibility">False</property>
- <property name="activates-default">True</property>
- <property name="truncate-multiline">True</property>
- <property name="input-purpose">password</property>
- <child internal-child="accessible">
- <object class="AtkObject" id="confirm2ed-atkobject">
- <property name="AtkObject::accessible-description" translatable="yes" context="password|extended_tip|confirm2ed">Re-enter the password.</property>
- </object>
- </child>
+ <object class="GtkLabel" id="pass2policylabel">
+ <property name="can-focus">False</property>
+ <property name="no-show-all">True</property>
+ <property name="halign">end</property>
+ <property name="hexpand">False</property>
+ <property name="wrap">True</property>
</object>
<packing>
<property name="left-attach">1</property>
- <property name="top-attach">3</property>
+ <property name="top-attach">0</property>
</packing>
</child>
<child>
- <object class="GtkLevelBar" id="pass2bar">
+ <object class="GtkBox" id="passwbox3">
<property name="visible">True</property>
<property name="can-focus">False</property>
+ <property name="hexpand">True</property>
+ <child>
+ <object class="GtkEntry" id="pass2ed">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="visibility">False</property>
+ <property name="activates-default">True</property>
+ <property name="truncate-multiline">True</property>
+ <property name="input-purpose">password</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="pass2ed-atkobject">
+ <property name="AtkObject::accessible-description" translatable="yes" context="password|extended_tip|pass2ed">Type a password. A password is case sensitive.</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="togglebt3">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="image">passimg3</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="togglebt3-atkobject">
+ <property name="AtkObject::accessible-description" translatable="yes" context="password|extended_tip|togglebt3">Show or hide password characters</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="left-attach">1</property>
- <property name="top-attach">2</property>
+ <property name="top-attach">1</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="pass2policylabel">
+ <object class="GtkBox" id="passwbox4">
+ <property name="visible">True</property>
<property name="can-focus">False</property>
- <property name="no-show-all">True</property>
- <property name="halign">end</property>
- <property name="hexpand">False</property>
- <property name="wrap">True</property>
+ <property name="hexpand">True</property>
+ <child>
+ <object class="GtkEntry" id="confirm2ed">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="visibility">False</property>
+ <property name="activates-default">True</property>
+ <property name="truncate-multiline">True</property>
+ <property name="input-purpose">password</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="confirm2ed-atkobject">
+ <property name="AtkObject::accessible-description" translatable="yes" context="password|extended_tip|confirm2ed">Re-enter the password.</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="togglebt4">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="image">passimg4</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="togglebt4-atkobject">
+ <property name="AtkObject::accessible-description" translatable="yes" context="password|extended_tip|togglebt4">Show or hide password characters</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="left-attach">1</property>
- <property name="top-attach">0</property>
+ <property name="top-attach">3</property>
</packing>
</child>
<child>
@@ -377,11 +514,11 @@
<property name="margin-start">6</property>
<property name="xalign">0</property>
<attributes>
- <attribute name="scale" value="0.9"/>
+ <attribute name="scale" value="0.90000000000000002"/>
</attributes>
<child internal-child="accessible">
<object class="AtkObject" id="minlenft-atkobject">
- <property name="AtkObject::accessible-role" translatable="no">static</property>
+ <property name="AtkObject::accessible-role">static</property>
</object>
</child>
</object>
@@ -400,11 +537,11 @@
<property name="label" translatable="yes" context="password|onlyascii">Only Unicode 'Basic Latin' characters can be entered</property>
<property name="xalign">0</property>
<attributes>
- <attribute name="scale" value="0.9"/>
+ <attribute name="scale" value="0.90000000000000002"/>
</attributes>
<child internal-child="accessible">
<object class="AtkObject" id="onlyascii-atkobject">
- <property name="AtkObject::accessible-role" translatable="no">static</property>
+ <property name="AtkObject::accessible-role">static</property>
</object>
</child>
</object>