diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-04-02 14:12:53 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-04-02 17:04:20 +0200 |
commit | 7637054838aa71374dc02c32566dcd5d3ded2d0d (patch) | |
tree | 8f696dae590a768ad18c15714a6d41d6ebe27a6d /svx | |
parent | 52829d9a7a57fa98a0d8f109612352605c54cc47 (diff) |
weld SvxPasswordDialog
Change-Id: I2e51f1a0a96eb042a4460bb9591b63a169eb6de2
Reviewed-on: https://gerrit.libreoffice.org/52258
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/dialog/passwd.cxx | 99 | ||||
-rw-r--r-- | svx/uiconfig/ui/passwd.ui | 35 |
2 files changed, 64 insertions, 70 deletions
diff --git a/svx/source/dialog/passwd.cxx b/svx/source/dialog/passwd.cxx index 641624fd236e..45b6a1f284fb 100644 --- a/svx/source/dialog/passwd.cxx +++ b/svx/source/dialog/passwd.cxx @@ -24,93 +24,78 @@ #include <svx/dialmgr.hxx> #include <svx/strings.hrc> -IMPL_LINK_NOARG(SvxPasswordDialog, ButtonHdl, Button*, void) +IMPL_LINK_NOARG(SvxPasswordDialog, ButtonHdl, weld::Button&, void) { bool bOK = true; - if ( m_pNewPasswdED->GetText() != m_pRepeatPasswdED->GetText() ) + if (m_xNewPasswdED->get_text() != m_xRepeatPasswdED->get_text()) { - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, VclButtonsType::Ok, - aRepeatPasswdErrStr)); + m_aRepeatPasswdErrStr)); xBox->run(); - m_pNewPasswdED->SetText( "" ); - m_pRepeatPasswdED->SetText( "" ); - m_pNewPasswdED->GrabFocus(); + m_xNewPasswdED->set_text(""); + m_xRepeatPasswdED->set_text(""); + m_xNewPasswdED->grab_focus(); bOK = false; } - if ( bOK && aCheckPasswordHdl.IsSet() && !aCheckPasswordHdl.Call( this ) ) + if (bOK && m_aCheckPasswordHdl.IsSet() && !m_aCheckPasswordHdl.Call(this)) { - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, VclButtonsType::Ok, - aOldPasswdErrStr)); + m_aOldPasswdErrStr)); xBox->run(); - m_pOldPasswdED->SetText( "" ); - m_pOldPasswdED->GrabFocus(); + m_xOldPasswdED->set_text(""); + m_xOldPasswdED->grab_focus(); bOK = false; } - if ( bOK ) - EndDialog( RET_OK ); + if (bOK) + m_xDialog->response(RET_OK); } -IMPL_LINK_NOARG(SvxPasswordDialog, EditModifyHdl, Edit&, void) +IMPL_LINK_NOARG(SvxPasswordDialog, EditModifyHdl, weld::Entry&, void) { - if ( !bEmpty ) + if (!m_bEmpty) { - OUString aPasswd = comphelper::string::strip(m_pRepeatPasswdED->GetText(), ' '); - if ( aPasswd.isEmpty() && m_pOKBtn->IsEnabled() ) - m_pOKBtn->Disable(); - else if ( !aPasswd.isEmpty() && !m_pOKBtn->IsEnabled() ) - m_pOKBtn->Enable(); + OUString aPasswd = comphelper::string::strip(m_xRepeatPasswdED->get_text(), ' '); + if (aPasswd.isEmpty() && m_xOKBtn->get_sensitive()) + m_xOKBtn->set_sensitive(false); + else if (!aPasswd.isEmpty() && !m_xOKBtn->get_sensitive()) + m_xOKBtn->set_sensitive(true); } - else if ( !m_pOKBtn->IsEnabled() ) - m_pOKBtn->Enable(); + else if (!m_xOKBtn->get_sensitive()) + m_xOKBtn->set_sensitive(true); } - -SvxPasswordDialog::SvxPasswordDialog(vcl::Window* pParent, bool bAllowEmptyPasswords, bool bDisableOldPassword) - : SfxModalDialog(pParent, "PasswordDialog", "svx/ui/passwd.ui") - , aOldPasswdErrStr(SvxResId(RID_SVXSTR_ERR_OLD_PASSWD)) - , aRepeatPasswdErrStr(SvxResId(RID_SVXSTR_ERR_REPEAT_PASSWD )) - , bEmpty(bAllowEmptyPasswords) +SvxPasswordDialog::SvxPasswordDialog(weld::Window* pParent, bool bAllowEmptyPasswords, bool bDisableOldPassword) + : GenericDialogController(pParent, "svx/ui/passwd.ui", "PasswordDialog") + , m_aOldPasswdErrStr(SvxResId(RID_SVXSTR_ERR_OLD_PASSWD)) + , m_aRepeatPasswdErrStr(SvxResId(RID_SVXSTR_ERR_REPEAT_PASSWD )) + , m_bEmpty(bAllowEmptyPasswords) + , m_xOldFL(m_xBuilder->weld_label("oldpass")) + , m_xOldPasswdFT(m_xBuilder->weld_label("oldpassL")) + , m_xOldPasswdED(m_xBuilder->weld_entry("oldpassEntry")) + , m_xNewPasswdED(m_xBuilder->weld_entry("newpassEntry")) + , m_xRepeatPasswdED(m_xBuilder->weld_entry("confirmpassEntry")) + , m_xOKBtn(m_xBuilder->weld_button("ok")) { - get(m_pOldFL, "oldpass"); - get(m_pOldPasswdFT, "oldpassL"); - get(m_pOldPasswdED, "oldpassEntry"); - get(m_pNewPasswdED, "newpassEntry"); - get(m_pRepeatPasswdED, "confirmpassEntry"); - get(m_pOKBtn, "ok"); - - m_pOKBtn->SetClickHdl( LINK( this, SvxPasswordDialog, ButtonHdl ) ); - m_pRepeatPasswdED->SetModifyHdl( LINK( this, SvxPasswordDialog, EditModifyHdl ) ); - EditModifyHdl( *m_pRepeatPasswdED ); + m_xOKBtn->connect_clicked(LINK(this, SvxPasswordDialog, ButtonHdl)); + m_xRepeatPasswdED->connect_changed(LINK(this, SvxPasswordDialog, EditModifyHdl)); + EditModifyHdl(*m_xRepeatPasswdED); - if ( bDisableOldPassword ) + if (bDisableOldPassword) { - m_pOldFL->Disable(); - m_pOldPasswdFT->Disable(); - m_pOldPasswdED->Disable(); - m_pNewPasswdED->GrabFocus(); + m_xOldFL->set_sensitive(false); + m_xOldPasswdFT->set_sensitive(false); + m_xOldPasswdED->set_sensitive(false); + m_xNewPasswdED->grab_focus(); } } SvxPasswordDialog::~SvxPasswordDialog() { - disposeOnce(); -} - -void SvxPasswordDialog::dispose() -{ - m_pOldFL.clear(); - m_pOldPasswdFT.clear(); - m_pOldPasswdED.clear(); - m_pNewPasswdED.clear(); - m_pRepeatPasswdED.clear(); - m_pOKBtn.clear(); - SfxModalDialog::dispose(); } - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/uiconfig/ui/passwd.ui b/svx/uiconfig/ui/passwd.ui index ad45d317b0c5..b1367463462a 100644 --- a/svx/uiconfig/ui/passwd.ui +++ b/svx/uiconfig/ui/passwd.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.20.4 --> <interface domain="svx"> <requires lib="gtk+" version="3.18"/> <object class="GtkDialog" id="PasswordDialog"> @@ -7,23 +7,23 @@ <property name="border_width">6</property> <property name="title" translatable="yes" context="passwd|PasswordDialog">Change Password</property> <property name="modal">True</property> + <property name="default_width">0</property> + <property name="default_height">0</property> <property name="type_hint">dialog</property> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="can_focus">False</property> + <property name="orientation">vertical</property> <property name="spacing">12</property> <child internal-child="action_area"> <object class="GtkButtonBox" id="dialog-action_area1"> <property name="can_focus">False</property> - <property name="orientation">vertical</property> - <property name="layout_style">start</property> + <property name="layout_style">end</property> <child> - <object class="GtkButton" id="ok"> - <property name="label">gtk-ok</property> + <object class="GtkButton" id="cancel"> + <property name="label">gtk-cancel</property> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="has_default">True</property> <property name="receives_default">True</property> <property name="use_stock">True</property> </object> @@ -34,10 +34,12 @@ </packing> </child> <child> - <object class="GtkButton" id="cancel"> - <property name="label">gtk-cancel</property> + <object class="GtkButton" id="ok"> + <property name="label">gtk-ok</property> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="has_default">True</property> <property name="receives_default">True</property> <property name="use_stock">True</property> </object> @@ -59,6 +61,7 @@ <property name="expand">False</property> <property name="fill">True</property> <property name="position">2</property> + <property name="secondary">True</property> </packing> </child> </object> @@ -100,10 +103,10 @@ <object class="GtkLabel" id="oldpassL"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="passwd|oldpassL">_Password:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">oldpassEntry</property> + <property name="xalign">1</property> </object> <packing> <property name="expand">False</property> @@ -117,6 +120,7 @@ <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="visibility">False</property> + <property name="input_purpose">password</property> </object> <packing> <property name="expand">False</property> @@ -172,6 +176,7 @@ <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="visibility">False</property> + <property name="input_purpose">password</property> </object> <packing> <property name="left_attach">1</property> @@ -184,6 +189,7 @@ <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="visibility">False</property> + <property name="input_purpose">password</property> </object> <packing> <property name="left_attach">1</property> @@ -194,10 +200,10 @@ <object class="GtkLabel" id="label4"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="passwd|label4">Pa_ssword:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">newpassEntry</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -208,10 +214,10 @@ <object class="GtkLabel" id="label5"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="passwd|label5">Confi_rm:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">confirmpassEntry</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -249,10 +255,13 @@ </object> </child> <action-widgets> - <action-widget response="-5">ok</action-widget> <action-widget response="-6">cancel</action-widget> + <action-widget response="-5">ok</action-widget> <action-widget response="-11">help</action-widget> </action-widgets> + <child> + <placeholder/> + </child> </object> <object class="GtkSizeGroup" id="sizegroup1"> <widgets> |