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

weld MasterPasswordCreateDialog and MasterPasswordDialog

Change-Id: I4c235546590046b06a1fea9b62d91cf2da664227
üst 98143564
...@@ -393,7 +393,7 @@ handleAuthenticationRequest_( ...@@ -393,7 +393,7 @@ handleAuthenticationRequest_(
void void
executeMasterPasswordDialog( executeMasterPasswordDialog(
vcl::Window * pParent, weld::Window* pParent,
LoginErrorInfo & rInfo, LoginErrorInfo & rInfo,
task::PasswordRequestMode nMode) task::PasswordRequestMode nMode)
{ {
...@@ -404,21 +404,19 @@ executeMasterPasswordDialog( ...@@ -404,21 +404,19 @@ executeMasterPasswordDialog(
std::locale aResLocale(Translate::Create("uui")); std::locale aResLocale(Translate::Create("uui"));
if( nMode == task::PasswordRequestMode_PASSWORD_CREATE ) if( nMode == task::PasswordRequestMode_PASSWORD_CREATE )
{ {
ScopedVclPtrInstance< MasterPasswordCreateDialog > xDialog( MasterPasswordCreateDialog aDialog(pParent, aResLocale);
pParent, aResLocale); rInfo.SetResult(aDialog.run()
rInfo.SetResult(xDialog->Execute()
== RET_OK ? DialogMask::ButtonsOk : DialogMask::ButtonsCancel); == RET_OK ? DialogMask::ButtonsOk : DialogMask::ButtonsCancel);
aMaster = OUStringToOString( aMaster = OUStringToOString(
xDialog->GetMasterPassword(), RTL_TEXTENCODING_UTF8); aDialog.GetMasterPassword(), RTL_TEXTENCODING_UTF8);
} }
else else
{ {
ScopedVclPtrInstance< MasterPasswordDialog > xDialog( MasterPasswordDialog aDialog(pParent, nMode, aResLocale);
pParent, nMode, aResLocale); rInfo.SetResult(aDialog.run()
rInfo.SetResult(xDialog->Execute()
== RET_OK ? DialogMask::ButtonsOk : DialogMask::ButtonsCancel); == RET_OK ? DialogMask::ButtonsOk : DialogMask::ButtonsCancel);
aMaster = OUStringToOString( aMaster = OUStringToOString(
xDialog->GetMasterPassword(), RTL_TEXTENCODING_UTF8); aDialog.GetMasterPassword(), RTL_TEXTENCODING_UTF8);
} }
} }
...@@ -446,7 +444,7 @@ executeMasterPasswordDialog( ...@@ -446,7 +444,7 @@ executeMasterPasswordDialog(
void void
handleMasterPasswordRequest_( handleMasterPasswordRequest_(
vcl::Window * pParent, weld::Window * pParent,
task::PasswordRequestMode nMode, task::PasswordRequestMode nMode,
uno::Sequence< uno::Reference< task::XInteractionContinuation > > const & uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
rContinuations) rContinuations)
...@@ -632,7 +630,9 @@ UUIInteractionHelper::handleMasterPasswordRequest( ...@@ -632,7 +630,9 @@ UUIInteractionHelper::handleMasterPasswordRequest(
task::MasterPasswordRequest aMasterPasswordRequest; task::MasterPasswordRequest aMasterPasswordRequest;
if (aAnyRequest >>= aMasterPasswordRequest) if (aAnyRequest >>= aMasterPasswordRequest)
{ {
handleMasterPasswordRequest_(getParentProperty(), uno::Reference<awt::XWindow> xParent = getParentXWindow();
handleMasterPasswordRequest_(Application::GetFrameWeld(xParent),
aMasterPasswordRequest.Mode, aMasterPasswordRequest.Mode,
rRequest->getContinuations()); rRequest->getContinuations());
return true; return true;
......
...@@ -27,52 +27,43 @@ ...@@ -27,52 +27,43 @@
// MasterPasswordCreateDialog--------------------------------------------------- // MasterPasswordCreateDialog---------------------------------------------------
IMPL_LINK_NOARG(MasterPasswordCreateDialog, EditHdl_Impl, Edit&, void) IMPL_LINK_NOARG(MasterPasswordCreateDialog, EditHdl_Impl, weld::Entry&, void)
{ {
m_pOKBtn->Enable( m_pEDMasterPasswordCrt->GetText().getLength() >= 1 ); m_xOKBtn->set_sensitive(m_xEDMasterPasswordCrt->get_text().getLength() >= 1);
} }
IMPL_LINK_NOARG(MasterPasswordCreateDialog, OKHdl_Impl, Button*, void) IMPL_LINK_NOARG(MasterPasswordCreateDialog, OKHdl_Impl, weld::Button&, void)
{ {
// compare both passwords and show message box if there are not equal!! // compare both passwords and show message box if there are not equal!!
if( m_pEDMasterPasswordCrt->GetText() == m_pEDMasterPasswordRepeat->GetText() ) if (m_xEDMasterPasswordCrt->get_text() == m_xEDMasterPasswordRepeat->get_text())
EndDialog( RET_OK ); m_xDialog->response(RET_OK);
else else
{ {
OUString aErrorMsg(Translate::get(STR_ERROR_PASSWORDS_NOT_IDENTICAL, rResLocale)); OUString aErrorMsg(Translate::get(STR_ERROR_PASSWORDS_NOT_IDENTICAL, rResLocale));
std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(), std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Warning, VclButtonsType::Ok, VclMessageType::Warning, VclButtonsType::Ok,
aErrorMsg)); aErrorMsg));
xErrorBox->run(); xErrorBox->run();
m_pEDMasterPasswordCrt->SetText( OUString() ); m_xEDMasterPasswordCrt->set_text( OUString() );
m_pEDMasterPasswordRepeat->SetText( OUString() ); m_xEDMasterPasswordRepeat->set_text( OUString() );
m_pEDMasterPasswordCrt->GrabFocus(); m_xEDMasterPasswordCrt->grab_focus();
} }
} }
MasterPasswordCreateDialog::MasterPasswordCreateDialog(vcl::Window* pParent, const std::locale& rLocale) MasterPasswordCreateDialog::MasterPasswordCreateDialog(weld::Window* pParent, const std::locale& rLocale)
: ModalDialog(pParent, "SetMasterPasswordDialog", "uui/ui/setmasterpassworddlg.ui") : GenericDialogController(pParent, "uui/ui/setmasterpassworddlg.ui", "SetMasterPasswordDialog")
, rResLocale(rLocale) , rResLocale(rLocale)
, m_xEDMasterPasswordCrt(m_xBuilder->weld_entry("password1"))
, m_xEDMasterPasswordRepeat(m_xBuilder->weld_entry("password2"))
, m_xOKBtn(m_xBuilder->weld_button("ok"))
{ {
get(m_pEDMasterPasswordCrt, "password1"); m_xOKBtn->set_sensitive(false);
get(m_pEDMasterPasswordRepeat, "password2"); m_xOKBtn->connect_clicked( LINK( this, MasterPasswordCreateDialog, OKHdl_Impl ) );
get(m_pOKBtn, "ok"); m_xEDMasterPasswordCrt->connect_changed( LINK( this, MasterPasswordCreateDialog, EditHdl_Impl ) );
m_pOKBtn->Enable( false );
m_pOKBtn->SetClickHdl( LINK( this, MasterPasswordCreateDialog, OKHdl_Impl ) );
m_pEDMasterPasswordCrt->SetModifyHdl( LINK( this, MasterPasswordCreateDialog, EditHdl_Impl ) );
} }
MasterPasswordCreateDialog::~MasterPasswordCreateDialog() MasterPasswordCreateDialog::~MasterPasswordCreateDialog()
{ {
disposeOnce();
}
void MasterPasswordCreateDialog::dispose()
{
m_pEDMasterPasswordCrt.clear();
m_pEDMasterPasswordRepeat.clear();
m_pOKBtn.clear();
ModalDialog::dispose();
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -21,33 +21,25 @@ ...@@ -21,33 +21,25 @@
#define INCLUDED_UUI_SOURCE_MASTERPASSCRTDLG_HXX #define INCLUDED_UUI_SOURCE_MASTERPASSCRTDLG_HXX
#include <com/sun/star/task/PasswordRequestMode.hpp> #include <com/sun/star/task/PasswordRequestMode.hpp>
#include <vcl/button.hxx> #include <vcl/weld.hxx>
#include <vcl/dialog.hxx>
#include <vcl/edit.hxx>
#include <vcl/group.hxx>
#include <vcl/fixed.hxx>
class MasterPasswordCreateDialog : public weld::GenericDialogController
class MasterPasswordCreateDialog : public ModalDialog
{ {
private: private:
VclPtr<Edit> m_pEDMasterPasswordCrt; const std::locale& rResLocale;
VclPtr<Edit> m_pEDMasterPasswordRepeat;
VclPtr<OKButton> m_pOKBtn;
std::unique_ptr<weld::Entry> m_xEDMasterPasswordCrt;
std::unique_ptr<weld::Entry> m_xEDMasterPasswordRepeat;
std::unique_ptr<weld::Button> m_xOKBtn;
DECL_LINK(OKHdl_Impl, Button*, void); DECL_LINK(OKHdl_Impl, weld::Button&, void);
DECL_LINK(EditHdl_Impl, Edit&, void); DECL_LINK(EditHdl_Impl, weld::Entry&, void);
public: public:
MasterPasswordCreateDialog(vcl::Window* pParent, const std::locale& rLocale); MasterPasswordCreateDialog(weld::Window* pParent, const std::locale& rLocale);
virtual ~MasterPasswordCreateDialog() override; virtual ~MasterPasswordCreateDialog() override;
virtual void dispose() override;
OUString GetMasterPassword() const { return m_pEDMasterPasswordCrt->GetText(); }
private: OUString GetMasterPassword() const { return m_xEDMasterPasswordCrt->get_text(); }
const std::locale& rResLocale;
}; };
#endif // INCLUDED_UUI_SOURCE_MASTERPASSCRTDLG_HXX #endif // INCLUDED_UUI_SOURCE_MASTERPASSCRTDLG_HXX
......
...@@ -25,45 +25,35 @@ ...@@ -25,45 +25,35 @@
// MasterPasswordDialog--------------------------------------------------- // MasterPasswordDialog---------------------------------------------------
IMPL_LINK_NOARG(MasterPasswordDialog, OKHdl_Impl, weld::Button&, void)
IMPL_LINK_NOARG(MasterPasswordDialog, OKHdl_Impl, Button*, void)
{ {
EndDialog( RET_OK ); m_xDialog->response(RET_OK);
} }
MasterPasswordDialog::MasterPasswordDialog MasterPasswordDialog::MasterPasswordDialog
( (
vcl::Window* pParent, weld::Window* pParent,
css::task::PasswordRequestMode nDialogMode, css::task::PasswordRequestMode nDialogMode,
const std::locale& rLocale const std::locale& rLocale
) )
: ModalDialog(pParent, "MasterPasswordDialog", "uui/ui/masterpassworddlg.ui") : GenericDialogController(pParent, "uui/ui/masterpassworddlg.ui", "MasterPasswordDialog")
, rResLocale(rLocale) , rResLocale(rLocale)
, m_xEDMasterPassword(m_xBuilder->weld_entry("password"))
, m_xOKBtn(m_xBuilder->weld_button("ok"))
{ {
get(m_pEDMasterPassword, "password");
get(m_pOKBtn, "ok");
if( nDialogMode == css::task::PasswordRequestMode_PASSWORD_REENTER ) if( nDialogMode == css::task::PasswordRequestMode_PASSWORD_REENTER )
{ {
OUString aErrorMsg(Translate::get(STR_ERROR_MASTERPASSWORD_WRONG, rResLocale)); OUString aErrorMsg(Translate::get(STR_ERROR_MASTERPASSWORD_WRONG, rResLocale));
std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(pParent ? pParent->GetFrameWeld() : nullptr, std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(pParent,
VclMessageType::Warning, VclButtonsType::Ok, aErrorMsg)); VclMessageType::Warning, VclButtonsType::Ok, aErrorMsg));
xErrorBox->run(); xErrorBox->run();
} }
m_pOKBtn->SetClickHdl( LINK( this, MasterPasswordDialog, OKHdl_Impl ) ); m_xOKBtn->connect_clicked( LINK( this, MasterPasswordDialog, OKHdl_Impl ) );
}; };
MasterPasswordDialog::~MasterPasswordDialog() MasterPasswordDialog::~MasterPasswordDialog()
{ {
disposeOnce();
}
void MasterPasswordDialog::dispose()
{
m_pEDMasterPassword.clear();
m_pOKBtn.clear();
ModalDialog::dispose();
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -21,28 +21,23 @@ ...@@ -21,28 +21,23 @@
#define INCLUDED_UUI_SOURCE_MASTERPASSWORDDLG_HXX #define INCLUDED_UUI_SOURCE_MASTERPASSWORDDLG_HXX
#include <com/sun/star/task/PasswordRequestMode.hpp> #include <com/sun/star/task/PasswordRequestMode.hpp>
#include <vcl/button.hxx> #include <vcl/weld.hxx>
#include <vcl/dialog.hxx>
#include <vcl/edit.hxx>
#include <vcl/group.hxx>
class MasterPasswordDialog : public weld::GenericDialogController
class MasterPasswordDialog : public ModalDialog
{ {
VclPtr<Edit> m_pEDMasterPassword; private:
VclPtr<OKButton> m_pOKBtn; const std::locale& rResLocale;
std::unique_ptr<weld::Entry> m_xEDMasterPassword;
std::unique_ptr<weld::Button> m_xOKBtn;
DECL_LINK(OKHdl_Impl, Button*, void); DECL_LINK(OKHdl_Impl, weld::Button&, void);
public: public:
MasterPasswordDialog(vcl::Window* pParent, css::task::PasswordRequestMode nDlgMode, const std::locale& rLocale); MasterPasswordDialog(weld::Window* pParent, css::task::PasswordRequestMode nDlgMode, const std::locale& rLocale);
virtual ~MasterPasswordDialog() override; virtual ~MasterPasswordDialog() override;
virtual void dispose() override;
OUString GetMasterPassword() const { return m_pEDMasterPassword->GetText(); } OUString GetMasterPassword() const { return m_xEDMasterPassword->get_text(); }
private:
const std::locale& rResLocale;
}; };
#endif // INCLUDED_UUI_SOURCE_MASTERPASSWORDDLG_HXX #endif // INCLUDED_UUI_SOURCE_MASTERPASSWORDDLG_HXX
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 --> <!-- Generated with glade 3.22.1 -->
<interface domain="uui"> <interface domain="uui">
<requires lib="gtk+" version="3.18"/> <requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="MasterPasswordDialog"> <object class="GtkDialog" id="MasterPasswordDialog">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="title" translatable="yes" context="masterpassworddlg|MasterPasswordDialog">Enter Master Password</property> <property name="title" translatable="yes" context="masterpassworddlg|MasterPasswordDialog">Enter Master 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> <property name="type_hint">dialog</property>
<child>
<placeholder/>
</child>
<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>
...@@ -81,11 +87,11 @@ ...@@ -81,11 +87,11 @@
<object class="GtkLabel" id="label1"> <object class="GtkLabel" id="label1">
<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">0</property>
<property name="yalign">0.54000002145767212</property>
<property name="label" translatable="yes" context="masterpassworddlg|label1">_Enter password:</property> <property name="label" translatable="yes" context="masterpassworddlg|label1">_Enter password:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">password</property> <property name="mnemonic_widget">password</property>
<property name="xalign">0</property>
<property name="yalign">0.54000002145767212</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -100,6 +106,7 @@ ...@@ -100,6 +106,7 @@
<property name="visibility">False</property> <property name="visibility">False</property>
<property name="activates_default">True</property> <property name="activates_default">True</property>
<property name="width_chars">35</property> <property name="width_chars">35</property>
<property name="input_purpose">password</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 --> <!-- Generated with glade 3.22.1 -->
<interface domain="uui"> <interface domain="uui">
<requires lib="gtk+" version="3.18"/> <requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="SetMasterPasswordDialog"> <object class="GtkDialog" id="SetMasterPasswordDialog">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="title" translatable="yes" context="setmasterpassworddlg|SetMasterPasswordDialog">Set Master Password</property> <property name="title" translatable="yes" context="setmasterpassworddlg|SetMasterPasswordDialog">Set Master 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> <property name="type_hint">dialog</property>
<child>
<placeholder/>
</child>
<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>
...@@ -80,10 +86,10 @@ ...@@ -80,10 +86,10 @@
<object class="GtkLabel" id="label1"> <object class="GtkLabel" id="label1">
<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">0</property>
<property name="label" translatable="yes" context="setmasterpassworddlg|label1">Passwords for web connections are protected by a master password. You will be asked to enter it once per session, if %PRODUCTNAME retrieves a password from the protected password list.</property> <property name="label" translatable="yes" context="setmasterpassworddlg|label1">Passwords for web connections are protected by a master password. You will be asked to enter it once per session, if %PRODUCTNAME retrieves a password from the protected password list.</property>
<property name="wrap">True</property> <property name="wrap">True</property>
<property name="max_width_chars">62</property> <property name="max_width_chars">62</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -96,10 +102,10 @@ ...@@ -96,10 +102,10 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="margin_top">6</property> <property name="margin_top">6</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="setmasterpassworddlg|label2">_Enter password:</property> <property name="label" translatable="yes" context="setmasterpassworddlg|label2">_Enter password:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">password1</property> <property name="mnemonic_widget">password1</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -112,6 +118,7 @@ ...@@ -112,6 +118,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">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>
...@@ -123,10 +130,10 @@ ...@@ -123,10 +130,10 @@
<object class="GtkLabel" id="label3"> <object class="GtkLabel" id="label3">
<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">0</property>
<property name="label" translatable="yes" context="setmasterpassworddlg|label3">_Reenter password:</property> <property name="label" translatable="yes" context="setmasterpassworddlg|label3">_Reenter password:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">password2</property> <property name="mnemonic_widget">password2</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -139,6 +146,8 @@ ...@@ -139,6 +146,8 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="visibility">False</property> <property name="visibility">False</property>
<property name="activates_default">True</property>
<property name="input_purpose">password</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -151,10 +160,10 @@ ...@@ -151,10 +160,10 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="margin_top">6</property> <property name="margin_top">6</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="setmasterpassworddlg|label4">Caution: If you forget the master password, you will be unable to access any of the information protected by it. Passwords are case sensitive.</property> <property name="label" translatable="yes" context="setmasterpassworddlg|label4">Caution: If you forget the master password, you will be unable to access any of the information protected by it. Passwords are case sensitive.</property>
<property name="wrap">True</property> <property name="wrap">True</property>
<property name="max_width_chars">62</property> <property name="max_width_chars">62</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
......
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