From bf09cd79d3414d88ea6c1d348ed191a77e8c413e Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 17 May 2018 10:16:55 +0100 Subject: AuthFallbackDlg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I69676dd437caefca63805e86f4707527183f622f Reviewed-on: https://gerrit.libreoffice.org/54487 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- uui/source/authfallbackdlg.cxx | 69 ++++++++++++++---------------------- uui/source/authfallbackdlg.hxx | 36 ++++++++----------- uui/source/iahndl-authentication.cxx | 8 ++--- 3 files changed, 45 insertions(+), 68 deletions(-) (limited to 'uui/source') diff --git a/uui/source/authfallbackdlg.cxx b/uui/source/authfallbackdlg.cxx index b5d8b4f1c5a4..b7190107da2a 100644 --- a/uui/source/authfallbackdlg.cxx +++ b/uui/source/authfallbackdlg.cxx @@ -13,77 +13,60 @@ using namespace boost; -AuthFallbackDlg::AuthFallbackDlg(Window* pParent, const OUString& instructions, +AuthFallbackDlg::AuthFallbackDlg(weld::Window* pParent, const OUString& instructions, const OUString& url) - : ModalDialog(pParent, "AuthFallbackDlg", "uui/ui/authfallback.ui") + : GenericDialogController(pParent, "uui/ui/authfallback.ui", "AuthFallbackDlg") , m_bGoogleMode( false ) + , m_xTVInstructions(m_xBuilder->weld_label("instructions")) + , m_xEDUrl(m_xBuilder->weld_entry("url")) + , m_xEDCode(m_xBuilder->weld_entry("code")) + , m_xEDGoogleCode(m_xBuilder->weld_entry("google_code")) + , m_xBTOk(m_xBuilder->weld_button("ok")) + , m_xBTCancel(m_xBuilder->weld_button("cancel")) + , m_xGoogleBox(m_xBuilder->weld_widget("GDrive")) + , m_xOneDriveBox(m_xBuilder->weld_widget("OneDrive")) { - get( m_pTVInstructions, "instructions" ); - get( m_pEDUrl, "url" ); - get( m_pEDCode, "code" ); - get( m_pEDGoogleCode, "google_code" ); - get( m_pBTOk, "ok" ); - get( m_pBTCancel, "cancel" ); - get( m_pGoogleBox, "GDrive" ); - get( m_pOneDriveBox, "OneDrive" ); + m_xBTOk->connect_clicked( LINK( this, AuthFallbackDlg, OKHdl) ); + m_xBTCancel->connect_clicked( LINK( this, AuthFallbackDlg, CancelHdl) ); + m_xBTOk->set_sensitive(true); - m_pBTOk->SetClickHdl( LINK( this, AuthFallbackDlg, OKHdl) ); - m_pBTCancel->SetClickHdl( LINK( this, AuthFallbackDlg, CancelHdl) ); - m_pBTOk->Enable(); - - m_pTVInstructions->SetText( instructions ); - m_pTVInstructions->SetPaintTransparent(true); + m_xTVInstructions->set_label(instructions); if( url.isEmpty() ) { // Google 2FA m_bGoogleMode = true; - m_pGoogleBox->Show(); - m_pOneDriveBox->Hide(); - m_pEDUrl->Hide(); + m_xGoogleBox->show(); + m_xOneDriveBox->hide(); + m_xEDUrl->hide(); } else { // OneDrive m_bGoogleMode = false; - m_pGoogleBox->Hide(); - m_pOneDriveBox->Show(); - m_pEDUrl->SetText( url ); + m_xGoogleBox->hide(); + m_xOneDriveBox->show(); + m_xEDUrl->set_text( url ); } } AuthFallbackDlg::~AuthFallbackDlg() { - disposeOnce(); } OUString AuthFallbackDlg::GetCode() const { if( m_bGoogleMode ) - return m_pEDGoogleCode->GetText(); + return m_xEDGoogleCode->get_text(); else - return m_pEDCode->GetText(); -} - - -void AuthFallbackDlg::dispose() -{ - m_pTVInstructions.clear(); - m_pEDUrl.clear(); - m_pEDCode.clear(); - m_pEDGoogleCode.clear(); - m_pBTOk.clear(); - m_pBTCancel.clear(); - m_pGoogleBox.clear(); - m_pOneDriveBox.clear(); - ModalDialog::dispose(); + return m_xEDCode->get_text(); } -IMPL_LINK_NOARG ( AuthFallbackDlg, OKHdl, Button *, void) +IMPL_LINK_NOARG(AuthFallbackDlg, OKHdl, weld::Button&, void) { - EndDialog( RET_OK ); + m_xDialog->response(RET_OK); } -IMPL_LINK_NOARG ( AuthFallbackDlg, CancelHdl, Button *, void) +IMPL_LINK_NOARG(AuthFallbackDlg, CancelHdl, weld::Button&, void) { - EndDialog(); + m_xDialog->response(RET_CANCEL); } diff --git a/uui/source/authfallbackdlg.hxx b/uui/source/authfallbackdlg.hxx index ff10407265b5..206cd87274a7 100644 --- a/uui/source/authfallbackdlg.hxx +++ b/uui/source/authfallbackdlg.hxx @@ -10,38 +10,32 @@ #ifndef INCLUDED_SVTOOLS_AUTHFALLBACKDLG_HXX #define INCLUDED_SVTOOLS_AUTHFALLBACKDLG_HXX -#include -#include -#include -#include -#include -#include - -class AuthFallbackDlg : public ModalDialog +#include + +class AuthFallbackDlg : public weld::GenericDialogController { private: - VclPtr m_pTVInstructions; - VclPtr m_pEDUrl; - VclPtr m_pEDCode; - VclPtr m_pEDGoogleCode; - VclPtr m_pBTOk; - VclPtr m_pBTCancel; - VclPtr m_pGoogleBox; - VclPtr m_pOneDriveBox; bool m_bGoogleMode; + std::unique_ptr m_xTVInstructions; + std::unique_ptr m_xEDUrl; + std::unique_ptr m_xEDCode; + std::unique_ptr m_xEDGoogleCode; + std::unique_ptr m_xBTOk; + std::unique_ptr m_xBTCancel; + std::unique_ptr m_xGoogleBox; + std::unique_ptr m_xOneDriveBox; + public: - AuthFallbackDlg(Window* pParent, const OUString& instructions, + AuthFallbackDlg(weld::Window* pParent, const OUString& instructions, const OUString& url); virtual ~AuthFallbackDlg() override; - virtual void dispose() override; OUString GetCode() const; private: - - DECL_LINK ( OKHdl, Button *, void ); - DECL_LINK ( CancelHdl, Button *, void ); + DECL_LINK(OKHdl, weld::Button&, void); + DECL_LINK(CancelHdl, weld::Button&, void); }; #endif // INCLUDED_SVTOOLS_AUTHFALLBACKDLG_HXX diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx index 673a6e441f52..ddaaf10e5e52 100644 --- a/uui/source/iahndl-authentication.cxx +++ b/uui/source/iahndl-authentication.cxx @@ -728,16 +728,16 @@ UUIInteractionHelper::handleAuthFallbackRequest( OUString & instructions, OUString & url, uno::Sequence< uno::Reference< task::XInteractionContinuation > > const & rContinuations ) { - vcl::Window * pParent = getParentProperty( ); - VclPtrInstance dlg( pParent, instructions, url ); - int retCode = dlg->Execute( ); + uno::Reference xParent = getParentXWindow(); + AuthFallbackDlg dlg(Application::GetFrameWeld(xParent), instructions, url); + int retCode = dlg.run(); uno::Reference< task::XInteractionAbort > xAbort; uno::Reference< ucb::XInteractionAuthFallback > xAuthFallback; getContinuations(rContinuations, &xAbort, &xAuthFallback); if( retCode == RET_OK && xAuthFallback.is( ) ) { - xAuthFallback->setCode( dlg->GetCode( ) ); + xAuthFallback->setCode(dlg.GetCode()); xAuthFallback->select( ); } -- cgit