summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-06-17 14:09:29 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-06-17 16:37:17 +0200
commita81d7c4e0379a021664f8f6c5e9032a47fcf61d6 (patch)
tree79f8560e76a2dbba57f3355663727290e5999cc5 /cui
parent9da14cf5461a1883718da9f92e03dd0dd6e28efd (diff)
tdf#43452 indicate when maximum password length has been reached
Change-Id: I58ba5887d41a80aa0ef2be547351f2faeccfa3cb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96533 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui')
-rw-r--r--cui/inc/strings.hrc1
-rw-r--r--cui/source/dialogs/passwdomdlg.cxx30
-rw-r--r--cui/source/inc/passwdomdlg.hxx7
-rw-r--r--cui/uiconfig/ui/password.ui222
4 files changed, 209 insertions, 51 deletions
diff --git a/cui/inc/strings.hrc b/cui/inc/strings.hrc
index 6312f38b6d53..dcfbcc0f4e9c 100644
--- a/cui/inc/strings.hrc
+++ b/cui/inc/strings.hrc
@@ -210,6 +210,7 @@
#define RID_SVXSTR_TWO_PASSWORDS_MISMATCH NC_("RID_SVXSTR_TWO_PASSWORDS_MISMATCH", "The confirmation passwords did not match the original passwords. Set the passwords again.")
#define RID_SVXSTR_INVALID_STATE_FOR_OK_BUTTON NC_("RID_SVXSTR_INVALID_STATE_FOR_OK_BUTTON", "Please enter a password to open or to modify, or check the open read-only option to continue.")
#define RID_SVXSTR_INVALID_STATE_FOR_OK_BUTTON_V2 NC_("RID_SVXSTR_INVALID_STATE_FOR_OK_BUTTON_V2", "Set the password by entering the same password in both boxes.")
+#define RID_SVXSTR_PASSWORD_LEN_INDICATOR NC_("RID_SVXSTR_PASSWORD_LEN_INDICATOR", "Password length limit of %1 reached")
#define STR_AUTOLINK NC_("STR_AUTOLINK", "Automatic")
#define STR_MANUALLINK NC_("STR_MANUALLINK", "Manual")
diff --git a/cui/source/dialogs/passwdomdlg.cxx b/cui/source/dialogs/passwdomdlg.cxx
index f7b359bac237..250f9e728253 100644
--- a/cui/source/dialogs/passwdomdlg.cxx
+++ b/cui/source/dialogs/passwdomdlg.cxx
@@ -69,21 +69,43 @@ IMPL_LINK_NOARG(PasswordToOpenModifyDialog, OkBtnClickHdl, weld::Button&, void)
}
}
+IMPL_LINK(PasswordToOpenModifyDialog, ChangeHdl, weld::Entry&, rEntry, void)
+{
+ weld::Label* pIndicator = nullptr;
+ int nLength = rEntry.get_text().getLength();
+ if (&rEntry == m_xPasswdToOpenED.get())
+ pIndicator = m_xPasswdToOpenInd.get();
+ else if (&rEntry == m_xReenterPasswdToOpenED.get())
+ pIndicator = m_xReenterPasswdToOpenInd.get();
+ else if (&rEntry == m_xPasswdToModifyED.get())
+ pIndicator = m_xPasswdToModifyInd.get();
+ else if (&rEntry == m_xReenterPasswdToModifyED.get())
+ pIndicator = m_xReenterPasswdToModifyInd.get();
+ assert(pIndicator);
+ pIndicator->set_visible(nLength >= m_nMaxPasswdLen);
+}
+
PasswordToOpenModifyDialog::PasswordToOpenModifyDialog(weld::Window * pParent, sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify)
: SfxDialogController(pParent, "cui/ui/password.ui", "PasswordDialog")
, m_xPasswdToOpenED(m_xBuilder->weld_entry("newpassEntry"))
+ , m_xPasswdToOpenInd(m_xBuilder->weld_label("newpassIndicator"))
, m_xReenterPasswdToOpenED(m_xBuilder->weld_entry("confirmpassEntry"))
+ , m_xReenterPasswdToOpenInd(m_xBuilder->weld_label("confirmpassIndicator"))
, m_xOptionsExpander(m_xBuilder->weld_expander("expander"))
, m_xOk(m_xBuilder->weld_button("ok"))
, m_xOpenReadonlyCB(m_xBuilder->weld_check_button("readonly"))
, m_xPasswdToModifyFT(m_xBuilder->weld_label("label7"))
, m_xPasswdToModifyED(m_xBuilder->weld_entry("newpassroEntry"))
+ , m_xPasswdToModifyInd(m_xBuilder->weld_label("newpassroIndicator"))
, m_xReenterPasswdToModifyFT(m_xBuilder->weld_label("label8"))
, m_xReenterPasswdToModifyED(m_xBuilder->weld_entry("confirmropassEntry"))
+ , m_xReenterPasswdToModifyInd(m_xBuilder->weld_label("confirmropassIndicator"))
, m_aOneMismatch( CuiResId( RID_SVXSTR_ONE_PASSWORD_MISMATCH ) )
, m_aTwoMismatch( CuiResId( RID_SVXSTR_TWO_PASSWORDS_MISMATCH ) )
, m_aInvalidStateForOkButton( CuiResId( RID_SVXSTR_INVALID_STATE_FOR_OK_BUTTON ) )
, m_aInvalidStateForOkButton_v2( CuiResId( RID_SVXSTR_INVALID_STATE_FOR_OK_BUTTON_V2 ) )
+ , m_aIndicatorTemplate(CuiResId(RID_SVXSTR_PASSWORD_LEN_INDICATOR).replaceFirst("%1", OUString::number(nMaxPasswdLen)))
+ , m_nMaxPasswdLen(nMaxPasswdLen)
, m_bIsPasswordToModify( bIsPasswordToModify )
{
m_xOk->connect_clicked(LINK(this, PasswordToOpenModifyDialog, OkBtnClickHdl));
@@ -91,9 +113,17 @@ PasswordToOpenModifyDialog::PasswordToOpenModifyDialog(weld::Window * pParent, s
if (nMaxPasswdLen)
{
m_xPasswdToOpenED->set_max_length( nMaxPasswdLen );
+ m_xPasswdToOpenED->connect_changed(LINK(this, PasswordToOpenModifyDialog, ChangeHdl));
+ m_xPasswdToOpenInd->set_label(m_aIndicatorTemplate);
m_xReenterPasswdToOpenED->set_max_length( nMaxPasswdLen );
+ m_xReenterPasswdToOpenED->connect_changed(LINK(this, PasswordToOpenModifyDialog, ChangeHdl));
+ m_xReenterPasswdToOpenInd->set_label(m_aIndicatorTemplate);
m_xPasswdToModifyED->set_max_length( nMaxPasswdLen );
+ m_xPasswdToModifyED->connect_changed(LINK(this, PasswordToOpenModifyDialog, ChangeHdl));
+ m_xPasswdToModifyInd->set_label(m_aIndicatorTemplate);
m_xReenterPasswdToModifyED->set_max_length( nMaxPasswdLen );
+ m_xReenterPasswdToModifyED->connect_changed(LINK(this, PasswordToOpenModifyDialog, ChangeHdl));
+ m_xReenterPasswdToModifyInd->set_label(m_aIndicatorTemplate);
}
m_xPasswdToOpenED->grab_focus();
diff --git a/cui/source/inc/passwdomdlg.hxx b/cui/source/inc/passwdomdlg.hxx
index e49634026e93..1f690ca391c7 100644
--- a/cui/source/inc/passwdomdlg.hxx
+++ b/cui/source/inc/passwdomdlg.hxx
@@ -25,25 +25,32 @@
class PasswordToOpenModifyDialog : public SfxDialogController
{
std::unique_ptr<weld::Entry> m_xPasswdToOpenED;
+ std::unique_ptr<weld::Label> m_xPasswdToOpenInd;
std::unique_ptr<weld::Entry> m_xReenterPasswdToOpenED;
+ std::unique_ptr<weld::Label> m_xReenterPasswdToOpenInd;
std::unique_ptr<weld::Expander> m_xOptionsExpander;
std::unique_ptr<weld::Button> m_xOk;
std::unique_ptr<weld::CheckButton> m_xOpenReadonlyCB;
std::unique_ptr<weld::Label> m_xPasswdToModifyFT;
std::unique_ptr<weld::Entry> m_xPasswdToModifyED;
+ std::unique_ptr<weld::Label> m_xPasswdToModifyInd;
std::unique_ptr<weld::Label> m_xReenterPasswdToModifyFT;
std::unique_ptr<weld::Entry> m_xReenterPasswdToModifyED;
+ std::unique_ptr<weld::Label> m_xReenterPasswdToModifyInd;
OUString m_aOneMismatch;
OUString m_aTwoMismatch;
OUString m_aInvalidStateForOkButton;
OUString m_aInvalidStateForOkButton_v2;
+ OUString m_aIndicatorTemplate;
+ int m_nMaxPasswdLen;
bool m_bIsPasswordToModify;
DECL_LINK(OkBtnClickHdl, weld::Button&, void);
DECL_LINK(ReadonlyOnOffHdl, weld::Button&, void);
+ DECL_LINK(ChangeHdl, weld::Entry&, void);
PasswordToOpenModifyDialog( const PasswordToOpenModifyDialog & ) = delete;
PasswordToOpenModifyDialog & operator = ( const PasswordToOpenModifyDialog & ) = delete;
diff --git a/cui/uiconfig/ui/password.ui b/cui/uiconfig/ui/password.ui
index 7023aca120b6..5720c2520004 100644
--- a/cui/uiconfig/ui/password.ui
+++ b/cui/uiconfig/ui/password.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.2 -->
+<!-- Generated with glade 3.22.2 -->
<interface domain="cui">
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="PasswordDialog">
@@ -86,34 +86,6 @@
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
- <object class="GtkLabel" id="label5">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes" context="password|label5">Confirm password</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">confirmpassEntry</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label4">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes" context="password|label4">_Enter password to open</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">newpassEntry</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
<object class="GtkEntry" id="newpassEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -194,21 +166,21 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label7">
+ <object class="GtkEntry" id="newpassroEntry">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes" context="password|label7">Enter password to allow editing</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">newpassroEntry</property>
- <property name="xalign">0</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="input_purpose">password</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">1</property>
+ <property name="top_attach">2</property>
</packing>
</child>
<child>
- <object class="GtkEntry" id="newpassroEntry">
+ <object class="GtkEntry" id="confirmropassEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
@@ -218,35 +190,95 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">4</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label8">
+ <object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes" context="password|label8">Confirm password</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">confirmropassEntry</property>
- <property name="xalign">0</property>
+ <child>
+ <object class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="password|label7">Enter password to allow editing</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">newpassroEntry</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="newpassroIndicator">
+ <property name="can_focus">False</property>
+ <property name="no_show_all">True</property>
+ <property name="halign">end</property>
+ <property name="hexpand">True</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">newpassEntry</property>
+ <property name="xalign">0</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="newpassroIndicator-atkobject">
+ <property name="AtkObject::accessible-role">static</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">1</property>
</packing>
</child>
<child>
- <object class="GtkEntry" id="confirmropassEntry">
+ <object class="GtkGrid">
<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="input_purpose">password</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="password|label8">Confirm password</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">confirmropassEntry</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="confirmropassIndicator">
+ <property name="can_focus">False</property>
+ <property name="no_show_all">True</property>
+ <property name="halign">end</property>
+ <property name="hexpand">True</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">newpassEntry</property>
+ <property name="xalign">0</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="confirmropassIndicator-atkobject">
+ <property name="AtkObject::accessible-role">static</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">3</property>
</packing>
</child>
</object>
@@ -279,6 +311,94 @@
<property name="top_attach">5</property>
</packing>
</child>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="password|label4">_Enter password to open</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">newpassEntry</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="newpassIndicator">
+ <property name="can_focus">False</property>
+ <property name="no_show_all">True</property>
+ <property name="halign">end</property>
+ <property name="hexpand">True</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">newpassEntry</property>
+ <property name="xalign">0</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="newpassIndicator-atkobject">
+ <property name="AtkObject::accessible-role">static</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="password|label5">Confirm password</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">confirmpassEntry</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="confirmpassIndicator">
+ <property name="can_focus">False</property>
+ <property name="no_show_all">True</property>
+ <property name="halign">end</property>
+ <property name="hexpand">True</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">newpassEntry</property>
+ <property name="xalign">0</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="confirmpassIndicator-atkobject">
+ <property name="AtkObject::accessible-role">static</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
</object>
</child>
</object>