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_(
void
executeMasterPasswordDialog(
vcl::Window * pParent,
weld::Window* pParent,
LoginErrorInfo & rInfo,
task::PasswordRequestMode nMode)
{
......@@ -404,21 +404,19 @@ executeMasterPasswordDialog(
std::locale aResLocale(Translate::Create("uui"));
if( nMode == task::PasswordRequestMode_PASSWORD_CREATE )
{
ScopedVclPtrInstance< MasterPasswordCreateDialog > xDialog(
pParent, aResLocale);
rInfo.SetResult(xDialog->Execute()
MasterPasswordCreateDialog aDialog(pParent, aResLocale);
rInfo.SetResult(aDialog.run()
== RET_OK ? DialogMask::ButtonsOk : DialogMask::ButtonsCancel);
aMaster = OUStringToOString(
xDialog->GetMasterPassword(), RTL_TEXTENCODING_UTF8);
aDialog.GetMasterPassword(), RTL_TEXTENCODING_UTF8);
}
else
{
ScopedVclPtrInstance< MasterPasswordDialog > xDialog(
pParent, nMode, aResLocale);
rInfo.SetResult(xDialog->Execute()
MasterPasswordDialog aDialog(pParent, nMode, aResLocale);
rInfo.SetResult(aDialog.run()
== RET_OK ? DialogMask::ButtonsOk : DialogMask::ButtonsCancel);
aMaster = OUStringToOString(
xDialog->GetMasterPassword(), RTL_TEXTENCODING_UTF8);
aDialog.GetMasterPassword(), RTL_TEXTENCODING_UTF8);
}
}
......@@ -446,7 +444,7 @@ executeMasterPasswordDialog(
void
handleMasterPasswordRequest_(
vcl::Window * pParent,
weld::Window * pParent,
task::PasswordRequestMode nMode,
uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
rContinuations)
......@@ -632,7 +630,9 @@ UUIInteractionHelper::handleMasterPasswordRequest(
task::MasterPasswordRequest aMasterPasswordRequest;
if (aAnyRequest >>= aMasterPasswordRequest)
{
handleMasterPasswordRequest_(getParentProperty(),
uno::Reference<awt::XWindow> xParent = getParentXWindow();
handleMasterPasswordRequest_(Application::GetFrameWeld(xParent),
aMasterPasswordRequest.Mode,
rRequest->getContinuations());
return true;
......
......@@ -27,52 +27,43 @@
// 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!!
if( m_pEDMasterPasswordCrt->GetText() == m_pEDMasterPasswordRepeat->GetText() )
EndDialog( RET_OK );
if (m_xEDMasterPasswordCrt->get_text() == m_xEDMasterPasswordRepeat->get_text())
m_xDialog->response(RET_OK);
else
{
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,
aErrorMsg));
xErrorBox->run();
m_pEDMasterPasswordCrt->SetText( OUString() );
m_pEDMasterPasswordRepeat->SetText( OUString() );
m_pEDMasterPasswordCrt->GrabFocus();
m_xEDMasterPasswordCrt->set_text( OUString() );
m_xEDMasterPasswordRepeat->set_text( OUString() );
m_xEDMasterPasswordCrt->grab_focus();
}
}
MasterPasswordCreateDialog::MasterPasswordCreateDialog(vcl::Window* pParent, const std::locale& rLocale)
: ModalDialog(pParent, "SetMasterPasswordDialog", "uui/ui/setmasterpassworddlg.ui")
MasterPasswordCreateDialog::MasterPasswordCreateDialog(weld::Window* pParent, const std::locale& rLocale)
: GenericDialogController(pParent, "uui/ui/setmasterpassworddlg.ui", "SetMasterPasswordDialog")
, 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");
get(m_pEDMasterPasswordRepeat, "password2");
get(m_pOKBtn, "ok");
m_pOKBtn->Enable( false );
m_pOKBtn->SetClickHdl( LINK( this, MasterPasswordCreateDialog, OKHdl_Impl ) );
m_pEDMasterPasswordCrt->SetModifyHdl( LINK( this, MasterPasswordCreateDialog, EditHdl_Impl ) );
m_xOKBtn->set_sensitive(false);
m_xOKBtn->connect_clicked( LINK( this, MasterPasswordCreateDialog, OKHdl_Impl ) );
m_xEDMasterPasswordCrt->connect_changed( LINK( this, MasterPasswordCreateDialog, EditHdl_Impl ) );
}
MasterPasswordCreateDialog::~MasterPasswordCreateDialog()
{
disposeOnce();
}
void MasterPasswordCreateDialog::dispose()
{
m_pEDMasterPasswordCrt.clear();
m_pEDMasterPasswordRepeat.clear();
m_pOKBtn.clear();
ModalDialog::dispose();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -21,33 +21,25 @@
#define INCLUDED_UUI_SOURCE_MASTERPASSCRTDLG_HXX
#include <com/sun/star/task/PasswordRequestMode.hpp>
#include <vcl/button.hxx>
#include <vcl/dialog.hxx>
#include <vcl/edit.hxx>
#include <vcl/group.hxx>
#include <vcl/fixed.hxx>
#include <vcl/weld.hxx>
class MasterPasswordCreateDialog : public ModalDialog
class MasterPasswordCreateDialog : public weld::GenericDialogController
{
private:
VclPtr<Edit> m_pEDMasterPasswordCrt;
VclPtr<Edit> m_pEDMasterPasswordRepeat;
VclPtr<OKButton> m_pOKBtn;
const std::locale& rResLocale;
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(EditHdl_Impl, Edit&, void);
DECL_LINK(OKHdl_Impl, weld::Button&, void);
DECL_LINK(EditHdl_Impl, weld::Entry&, void);
public:
MasterPasswordCreateDialog(vcl::Window* pParent, const std::locale& rLocale);
MasterPasswordCreateDialog(weld::Window* pParent, const std::locale& rLocale);
virtual ~MasterPasswordCreateDialog() override;
virtual void dispose() override;
OUString GetMasterPassword() const { return m_pEDMasterPasswordCrt->GetText(); }
private:
const std::locale& rResLocale;
OUString GetMasterPassword() const { return m_xEDMasterPasswordCrt->get_text(); }
};
#endif // INCLUDED_UUI_SOURCE_MASTERPASSCRTDLG_HXX
......
......@@ -25,45 +25,35 @@
// MasterPasswordDialog---------------------------------------------------
IMPL_LINK_NOARG(MasterPasswordDialog, OKHdl_Impl, Button*, void)
IMPL_LINK_NOARG(MasterPasswordDialog, OKHdl_Impl, weld::Button&, void)
{
EndDialog( RET_OK );
m_xDialog->response(RET_OK);
}
MasterPasswordDialog::MasterPasswordDialog
(
vcl::Window* pParent,
weld::Window* pParent,
css::task::PasswordRequestMode nDialogMode,
const std::locale& rLocale
)
: ModalDialog(pParent, "MasterPasswordDialog", "uui/ui/masterpassworddlg.ui")
: GenericDialogController(pParent, "uui/ui/masterpassworddlg.ui", "MasterPasswordDialog")
, 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 )
{
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));
xErrorBox->run();
}
m_pOKBtn->SetClickHdl( LINK( this, MasterPasswordDialog, OKHdl_Impl ) );
m_xOKBtn->connect_clicked( LINK( this, MasterPasswordDialog, OKHdl_Impl ) );
};
MasterPasswordDialog::~MasterPasswordDialog()
{
disposeOnce();
}
void MasterPasswordDialog::dispose()
{
m_pEDMasterPassword.clear();
m_pOKBtn.clear();
ModalDialog::dispose();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -21,28 +21,23 @@
#define INCLUDED_UUI_SOURCE_MASTERPASSWORDDLG_HXX
#include <com/sun/star/task/PasswordRequestMode.hpp>
#include <vcl/button.hxx>
#include <vcl/dialog.hxx>
#include <vcl/edit.hxx>
#include <vcl/group.hxx>
#include <vcl/weld.hxx>
class MasterPasswordDialog : public ModalDialog
class MasterPasswordDialog : public weld::GenericDialogController
{
VclPtr<Edit> m_pEDMasterPassword;
VclPtr<OKButton> m_pOKBtn;
private:
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:
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 void dispose() override;
OUString GetMasterPassword() const { return m_pEDMasterPassword->GetText(); }
private:
const std::locale& rResLocale;
OUString GetMasterPassword() const { return m_xEDMasterPassword->get_text(); }
};
#endif // INCLUDED_UUI_SOURCE_MASTERPASSWORDDLG_HXX
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="uui">
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="MasterPasswordDialog">
<property name="can_focus">False</property>
<property name="border_width">6</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>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
......@@ -81,11 +87,11 @@
<object class="GtkLabel" id="label1">
<property name="visible">True</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="use_underline">True</property>
<property name="mnemonic_widget">password</property>
<property name="xalign">0</property>
<property name="yalign">0.54000002145767212</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -100,6 +106,7 @@
<property name="visibility">False</property>
<property name="activates_default">True</property>
<property name="width_chars">35</property>
<property name="input_purpose">password</property>
</object>
<packing>
<property name="expand">False</property>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="uui">
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="SetMasterPasswordDialog">
<property name="can_focus">False</property>
<property name="border_width">6</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>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
......@@ -80,10 +86,10 @@
<object class="GtkLabel" id="label1">
<property name="visible">True</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="wrap">True</property>
<property name="max_width_chars">62</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -96,10 +102,10 @@
<property name="visible">True</property>
<property name="can_focus">False</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="use_underline">True</property>
<property name="mnemonic_widget">password1</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -112,6 +118,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="visibility">False</property>
<property name="input_purpose">password</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -123,10 +130,10 @@
<object class="GtkLabel" id="label3">
<property name="visible">True</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="use_underline">True</property>
<property name="mnemonic_widget">password2</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -139,6 +146,8 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="visibility">False</property>
<property name="activates_default">True</property>
<property name="input_purpose">password</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -151,10 +160,10 @@
<property name="visible">True</property>
<property name="can_focus">False</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="wrap">True</property>
<property name="max_width_chars">62</property>
<property name="xalign">0</property>
</object>
<packing>
<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