diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-05-16 21:19:52 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-05-17 09:04:57 +0100 |
commit | 3c8b38521aa584704cfa153c51fb15ca601daf9f (patch) | |
tree | c9c042ff6d899bbfbd2b72aa8cf7420a2a03e743 /uui/source | |
parent | 98143564ddffd6deb19a11f84e07efd97ae68048 (diff) |
weld MasterPasswordCreateDialog and MasterPasswordDialog
Change-Id: I4c235546590046b06a1fea9b62d91cf2da664227
Diffstat (limited to 'uui/source')
-rw-r--r-- | uui/source/iahndl-authentication.cxx | 22 | ||||
-rw-r--r-- | uui/source/masterpasscrtdlg.cxx | 43 | ||||
-rw-r--r-- | uui/source/masterpasscrtdlg.hxx | 28 | ||||
-rw-r--r-- | uui/source/masterpassworddlg.cxx | 26 | ||||
-rw-r--r-- | uui/source/masterpassworddlg.hxx | 25 |
5 files changed, 56 insertions, 88 deletions
diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx index b9d88b92e056..673a6e441f52 100644 --- a/uui/source/iahndl-authentication.cxx +++ b/uui/source/iahndl-authentication.cxx @@ -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; diff --git a/uui/source/masterpasscrtdlg.cxx b/uui/source/masterpasscrtdlg.cxx index 42d4a053bd95..8505e2cf7bfd 100644 --- a/uui/source/masterpasscrtdlg.cxx +++ b/uui/source/masterpasscrtdlg.cxx @@ -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: */ diff --git a/uui/source/masterpasscrtdlg.hxx b/uui/source/masterpasscrtdlg.hxx index d0c29b541bf2..5969d5f27e1a 100644 --- a/uui/source/masterpasscrtdlg.hxx +++ b/uui/source/masterpasscrtdlg.hxx @@ -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 diff --git a/uui/source/masterpassworddlg.cxx b/uui/source/masterpassworddlg.cxx index 65146101ced7..5e62a85b879c 100644 --- a/uui/source/masterpassworddlg.cxx +++ b/uui/source/masterpassworddlg.cxx @@ -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: */ diff --git a/uui/source/masterpassworddlg.hxx b/uui/source/masterpassworddlg.hxx index bc709a3895e4..5e0af686ee24 100644 --- a/uui/source/masterpassworddlg.hxx +++ b/uui/source/masterpassworddlg.hxx @@ -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 |