Kaydet (Commit) 76370548 authored tarafından Caolán McNamara's avatar Caolán McNamara

weld SvxPasswordDialog

Change-Id: I2e51f1a0a96eb042a4460bb9591b63a169eb6de2
Reviewed-on: https://gerrit.libreoffice.org/52258Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 52829d9a
...@@ -668,10 +668,10 @@ IMPL_LINK( LibPage, ButtonHdl, Button *, pButton, void ) ...@@ -668,10 +668,10 @@ IMPL_LINK( LibPage, ButtonHdl, Button *, pButton, void )
bool const bProtected = xPasswd->isLibraryPasswordProtected( aLibName ); bool const bProtected = xPasswd->isLibraryPasswordProtected( aLibName );
// change password dialog // change password dialog
VclPtrInstance< SvxPasswordDialog > pDlg( this, true, !bProtected ); SvxPasswordDialog aDlg(GetFrameWeld(), true, !bProtected);
pDlg->SetCheckPasswordHdl( LINK( this, LibPage, CheckPasswordHdl ) ); aDlg.SetCheckPasswordHdl(LINK(this, LibPage, CheckPasswordHdl));
if ( pDlg->Execute() == RET_OK ) if (aDlg.run() == RET_OK)
{ {
bool const bNewProtected = xPasswd->isLibraryPasswordProtected( aLibName ); bool const bNewProtected = xPasswd->isLibraryPasswordProtected( aLibName );
......
...@@ -19,49 +19,39 @@ ...@@ -19,49 +19,39 @@
#ifndef INCLUDED_SVX_PASSWD_HXX #ifndef INCLUDED_SVX_PASSWD_HXX
#define INCLUDED_SVX_PASSWD_HXX #define INCLUDED_SVX_PASSWD_HXX
#include <sfx2/basedlgs.hxx> #include <vcl/weld.hxx>
#include <vcl/fixed.hxx>
#include <vcl/edit.hxx>
#include <vcl/button.hxx>
#include <svx/svxdllapi.h> #include <svx/svxdllapi.h>
// class SvxPasswordDialog ----------------------------------------------- // class SvxPasswordDialog -----------------------------------------------
class SVX_DLLPUBLIC SvxPasswordDialog : public SfxModalDialog class SVX_DLLPUBLIC SvxPasswordDialog : public weld::GenericDialogController
{ {
private: private:
VclPtr<FixedText> m_pOldFL; OUString m_aOldPasswdErrStr;
VclPtr<FixedText> m_pOldPasswdFT; OUString m_aRepeatPasswdErrStr;
VclPtr<Edit> m_pOldPasswdED; Link<SvxPasswordDialog*,bool> m_aCheckPasswordHdl;
VclPtr<Edit> m_pNewPasswdED; bool m_bEmpty;
VclPtr<Edit> m_pRepeatPasswdED;
VclPtr<OKButton> m_pOKBtn;
OUString aOldPasswdErrStr; std::unique_ptr<weld::Label> m_xOldFL;
OUString aRepeatPasswdErrStr; 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; DECL_LINK(ButtonHdl, weld::Button&, void);
DECL_LINK(EditModifyHdl, weld::Entry&, void);
bool bEmpty;
DECL_LINK(ButtonHdl, Button*, void);
DECL_LINK(EditModifyHdl, Edit&, void);
public: public:
SvxPasswordDialog( vcl::Window* pParent, bool bAllowEmptyPasswords, bool bDisableOldPassword ); SvxPasswordDialog(weld::Window* pParent, bool bAllowEmptyPasswords, bool bDisableOldPassword);
virtual ~SvxPasswordDialog() override; virtual ~SvxPasswordDialog() override;
virtual void dispose() override;
OUString GetOldPassword() const { return m_pOldPasswdED->GetText(); } OUString GetOldPassword() const { return m_xOldPasswdED->get_text(); }
OUString GetNewPassword() const { return m_pNewPasswdED->GetText(); } 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 #endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -24,93 +24,78 @@ ...@@ -24,93 +24,78 @@
#include <svx/dialmgr.hxx> #include <svx/dialmgr.hxx>
#include <svx/strings.hrc> #include <svx/strings.hrc>
IMPL_LINK_NOARG(SvxPasswordDialog, ButtonHdl, Button*, void) IMPL_LINK_NOARG(SvxPasswordDialog, ButtonHdl, weld::Button&, void)
{ {
bool bOK = true; 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, VclMessageType::Warning, VclButtonsType::Ok,
aRepeatPasswdErrStr)); m_aRepeatPasswdErrStr));
xBox->run(); xBox->run();
m_pNewPasswdED->SetText( "" ); m_xNewPasswdED->set_text("");
m_pRepeatPasswdED->SetText( "" ); m_xRepeatPasswdED->set_text("");
m_pNewPasswdED->GrabFocus(); m_xNewPasswdED->grab_focus();
bOK = false; 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, VclMessageType::Warning, VclButtonsType::Ok,
aOldPasswdErrStr)); m_aOldPasswdErrStr));
xBox->run(); xBox->run();
m_pOldPasswdED->SetText( "" ); m_xOldPasswdED->set_text("");
m_pOldPasswdED->GrabFocus(); m_xOldPasswdED->grab_focus();
bOK = false; bOK = false;
} }
if ( bOK ) if (bOK)
EndDialog( RET_OK ); 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(), ' '); OUString aPasswd = comphelper::string::strip(m_xRepeatPasswdED->get_text(), ' ');
if ( aPasswd.isEmpty() && m_pOKBtn->IsEnabled() ) if (aPasswd.isEmpty() && m_xOKBtn->get_sensitive())
m_pOKBtn->Disable(); m_xOKBtn->set_sensitive(false);
else if ( !aPasswd.isEmpty() && !m_pOKBtn->IsEnabled() ) else if (!aPasswd.isEmpty() && !m_xOKBtn->get_sensitive())
m_pOKBtn->Enable(); m_xOKBtn->set_sensitive(true);
} }
else if ( !m_pOKBtn->IsEnabled() ) else if (!m_xOKBtn->get_sensitive())
m_pOKBtn->Enable(); m_xOKBtn->set_sensitive(true);
} }
SvxPasswordDialog::SvxPasswordDialog(weld::Window* pParent, bool bAllowEmptyPasswords, bool bDisableOldPassword)
SvxPasswordDialog::SvxPasswordDialog(vcl::Window* pParent, bool bAllowEmptyPasswords, bool bDisableOldPassword) : GenericDialogController(pParent, "svx/ui/passwd.ui", "PasswordDialog")
: SfxModalDialog(pParent, "PasswordDialog", "svx/ui/passwd.ui") , m_aOldPasswdErrStr(SvxResId(RID_SVXSTR_ERR_OLD_PASSWD))
, aOldPasswdErrStr(SvxResId(RID_SVXSTR_ERR_OLD_PASSWD)) , m_aRepeatPasswdErrStr(SvxResId(RID_SVXSTR_ERR_REPEAT_PASSWD ))
, aRepeatPasswdErrStr(SvxResId(RID_SVXSTR_ERR_REPEAT_PASSWD )) , m_bEmpty(bAllowEmptyPasswords)
, 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"); m_xOKBtn->connect_clicked(LINK(this, SvxPasswordDialog, ButtonHdl));
get(m_pOldPasswdFT, "oldpassL"); m_xRepeatPasswdED->connect_changed(LINK(this, SvxPasswordDialog, EditModifyHdl));
get(m_pOldPasswdED, "oldpassEntry"); EditModifyHdl(*m_xRepeatPasswdED);
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 );
if ( bDisableOldPassword ) if (bDisableOldPassword)
{ {
m_pOldFL->Disable(); m_xOldFL->set_sensitive(false);
m_pOldPasswdFT->Disable(); m_xOldPasswdFT->set_sensitive(false);
m_pOldPasswdED->Disable(); m_xOldPasswdED->set_sensitive(false);
m_pNewPasswdED->GrabFocus(); m_xNewPasswdED->grab_focus();
} }
} }
SvxPasswordDialog::~SvxPasswordDialog() 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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 --> <!-- Generated with glade 3.20.4 -->
<interface domain="svx"> <interface domain="svx">
<requires lib="gtk+" version="3.18"/> <requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="PasswordDialog"> <object class="GtkDialog" id="PasswordDialog">
...@@ -7,23 +7,23 @@ ...@@ -7,23 +7,23 @@
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="title" translatable="yes" context="passwd|PasswordDialog">Change Password</property> <property name="title" translatable="yes" context="passwd|PasswordDialog">Change Password</property>
<property name="modal">True</property> <property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property> <property name="type_hint">dialog</property>
<child internal-child="vbox"> <child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1"> <object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property> <property name="spacing">12</property>
<child internal-child="action_area"> <child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1"> <object class="GtkButtonBox" id="dialog-action_area1">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="orientation">vertical</property> <property name="layout_style">end</property>
<property name="layout_style">start</property>
<child> <child>
<object class="GtkButton" id="ok"> <object class="GtkButton" id="cancel">
<property name="label">gtk-ok</property> <property name="label">gtk-cancel</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">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="receives_default">True</property>
<property name="use_stock">True</property> <property name="use_stock">True</property>
</object> </object>
...@@ -34,10 +34,12 @@ ...@@ -34,10 +34,12 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="cancel"> <object class="GtkButton" id="ok">
<property name="label">gtk-cancel</property> <property name="label">gtk-ok</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">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="receives_default">True</property>
<property name="use_stock">True</property> <property name="use_stock">True</property>
</object> </object>
...@@ -59,6 +61,7 @@ ...@@ -59,6 +61,7 @@
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">2</property>
<property name="secondary">True</property>
</packing> </packing>
</child> </child>
</object> </object>
...@@ -100,10 +103,10 @@ ...@@ -100,10 +103,10 @@
<object class="GtkLabel" id="oldpassL"> <object class="GtkLabel" id="oldpassL">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes" context="passwd|oldpassL">_Password:</property> <property name="label" translatable="yes" context="passwd|oldpassL">_Password:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">oldpassEntry</property> <property name="mnemonic_widget">oldpassEntry</property>
<property name="xalign">1</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -117,6 +120,7 @@ ...@@ -117,6 +120,7 @@
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="visibility">False</property> <property name="visibility">False</property>
<property name="input_purpose">password</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -172,6 +176,7 @@ ...@@ -172,6 +176,7 @@
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="visibility">False</property> <property name="visibility">False</property>
<property name="input_purpose">password</property>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
...@@ -184,6 +189,7 @@ ...@@ -184,6 +189,7 @@
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="visibility">False</property> <property name="visibility">False</property>
<property name="input_purpose">password</property>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
...@@ -194,10 +200,10 @@ ...@@ -194,10 +200,10 @@
<object class="GtkLabel" id="label4"> <object class="GtkLabel" id="label4">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</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="label" translatable="yes" context="passwd|label4">Pa_ssword:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">newpassEntry</property> <property name="mnemonic_widget">newpassEntry</property>
<property name="xalign">1</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
...@@ -208,10 +214,10 @@ ...@@ -208,10 +214,10 @@
<object class="GtkLabel" id="label5"> <object class="GtkLabel" id="label5">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</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="label" translatable="yes" context="passwd|label5">Confi_rm:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">confirmpassEntry</property> <property name="mnemonic_widget">confirmpassEntry</property>
<property name="xalign">1</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
...@@ -249,10 +255,13 @@ ...@@ -249,10 +255,13 @@
</object> </object>
</child> </child>
<action-widgets> <action-widgets>
<action-widget response="-5">ok</action-widget>
<action-widget response="-6">cancel</action-widget> <action-widget response="-6">cancel</action-widget>
<action-widget response="-5">ok</action-widget>
<action-widget response="-11">help</action-widget> <action-widget response="-11">help</action-widget>
</action-widgets> </action-widgets>
<child>
<placeholder/>
</child>
</object> </object>
<object class="GtkSizeGroup" id="sizegroup1"> <object class="GtkSizeGroup" id="sizegroup1">
<widgets> <widgets>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment