diff options
-rw-r--r-- | basctl/source/basicide/moduldl2.cxx | 6 | ||||
-rw-r--r-- | include/svx/passwd.hxx | 48 | ||||
-rw-r--r-- | svx/source/dialog/passwd.cxx | 99 | ||||
-rw-r--r-- | svx/uiconfig/ui/passwd.ui | 35 |
4 files changed, 86 insertions, 102 deletions
diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx index a1a11613ca19..2722a2dfd187 100644 --- a/basctl/source/basicide/moduldl2.cxx +++ b/basctl/source/basicide/moduldl2.cxx @@ -668,10 +668,10 @@ IMPL_LINK( LibPage, ButtonHdl, Button *, pButton, void ) bool const bProtected = xPasswd->isLibraryPasswordProtected( aLibName ); // change password dialog - VclPtrInstance< SvxPasswordDialog > pDlg( this, true, !bProtected ); - pDlg->SetCheckPasswordHdl( LINK( this, LibPage, CheckPasswordHdl ) ); + SvxPasswordDialog aDlg(GetFrameWeld(), true, !bProtected); + aDlg.SetCheckPasswordHdl(LINK(this, LibPage, CheckPasswordHdl)); - if ( pDlg->Execute() == RET_OK ) + if (aDlg.run() == RET_OK) { bool const bNewProtected = xPasswd->isLibraryPasswordProtected( aLibName ); diff --git a/include/svx/passwd.hxx b/include/svx/passwd.hxx index 2ddbb6373f56..227d1288f813 100644 --- a/include/svx/passwd.hxx +++ b/include/svx/passwd.hxx @@ -19,49 +19,39 @@ #ifndef INCLUDED_SVX_PASSWD_HXX #define INCLUDED_SVX_PASSWD_HXX -#include <sfx2/basedlgs.hxx> - -#include <vcl/fixed.hxx> - -#include <vcl/edit.hxx> - -#include <vcl/button.hxx> +#include <vcl/weld.hxx> #include <svx/svxdllapi.h> // class SvxPasswordDialog ----------------------------------------------- -class SVX_DLLPUBLIC SvxPasswordDialog : public SfxModalDialog +class SVX_DLLPUBLIC SvxPasswordDialog : public weld::GenericDialogController { private: - VclPtr<FixedText> m_pOldFL; - VclPtr<FixedText> m_pOldPasswdFT; - VclPtr<Edit> m_pOldPasswdED; - VclPtr<Edit> m_pNewPasswdED; - VclPtr<Edit> m_pRepeatPasswdED; - VclPtr<OKButton> m_pOKBtn; + OUString m_aOldPasswdErrStr; + OUString m_aRepeatPasswdErrStr; + Link<SvxPasswordDialog*,bool> m_aCheckPasswordHdl; + bool m_bEmpty; - OUString aOldPasswdErrStr; - OUString aRepeatPasswdErrStr; + std::unique_ptr<weld::Label> m_xOldFL; + std::unique_ptr<weld::Label> m_xOldPasswdFT; + std::unique_ptr<weld::Entry> m_xOldPasswdED; + std::unique_ptr<weld::Entry> m_xNewPasswdED; + std::unique_ptr<weld::Entry> m_xRepeatPasswdED; + std::unique_ptr<weld::Button> m_xOKBtn; - Link<SvxPasswordDialog*,bool> aCheckPasswordHdl; - - bool bEmpty; - - DECL_LINK(ButtonHdl, Button*, void); - DECL_LINK(EditModifyHdl, Edit&, void); + DECL_LINK(ButtonHdl, weld::Button&, void); + DECL_LINK(EditModifyHdl, weld::Entry&, void); public: - SvxPasswordDialog( vcl::Window* pParent, bool bAllowEmptyPasswords, bool bDisableOldPassword ); - virtual ~SvxPasswordDialog() override; - virtual void dispose() override; + SvxPasswordDialog(weld::Window* pParent, bool bAllowEmptyPasswords, bool bDisableOldPassword); + virtual ~SvxPasswordDialog() override; - OUString GetOldPassword() const { return m_pOldPasswdED->GetText(); } - OUString GetNewPassword() const { return m_pNewPasswdED->GetText(); } + OUString GetOldPassword() const { return m_xOldPasswdED->get_text(); } + OUString GetNewPassword() const { return m_xNewPasswdED->get_text(); } - void SetCheckPasswordHdl( const Link<SvxPasswordDialog*,bool>& rLink ) { aCheckPasswordHdl = rLink; } + void SetCheckPasswordHdl( const Link<SvxPasswordDialog*,bool>& rLink ) { m_aCheckPasswordHdl = rLink; } }; - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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> |