diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-05-17 10:16:55 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-05-17 22:16:09 +0200 |
commit | bf09cd79d3414d88ea6c1d348ed191a77e8c413e (patch) | |
tree | 3491c3190176c3eb46f82d4d3594e94894dbccde /uui/source | |
parent | a55d164b2e2a5df61078bcbd018f2d20712c3388 (diff) |
AuthFallbackDlg
Change-Id: I69676dd437caefca63805e86f4707527183f622f
Reviewed-on: https://gerrit.libreoffice.org/54487
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'uui/source')
-rw-r--r-- | uui/source/authfallbackdlg.cxx | 69 | ||||
-rw-r--r-- | uui/source/authfallbackdlg.hxx | 36 | ||||
-rw-r--r-- | uui/source/iahndl-authentication.cxx | 8 |
3 files changed, 45 insertions, 68 deletions
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 <vcl/button.hxx> -#include <vcl/dialog.hxx> -#include <vcl/edit.hxx> -#include <vcl/vclmedit.hxx> -#include <vcl/fixed.hxx> -#include <vcl/layout.hxx> - -class AuthFallbackDlg : public ModalDialog +#include <vcl/weld.hxx> + +class AuthFallbackDlg : public weld::GenericDialogController { private: - VclPtr<VclMultiLineEdit> m_pTVInstructions; - VclPtr<Edit> m_pEDUrl; - VclPtr<Edit> m_pEDCode; - VclPtr<Edit> m_pEDGoogleCode; - VclPtr<PushButton> m_pBTOk; - VclPtr<PushButton> m_pBTCancel; - VclPtr<VclVBox> m_pGoogleBox; - VclPtr<VclVBox> m_pOneDriveBox; bool m_bGoogleMode; + std::unique_ptr<weld::Label> m_xTVInstructions; + std::unique_ptr<weld::Entry> m_xEDUrl; + std::unique_ptr<weld::Entry> m_xEDCode; + std::unique_ptr<weld::Entry> m_xEDGoogleCode; + std::unique_ptr<weld::Button> m_xBTOk; + std::unique_ptr<weld::Button> m_xBTCancel; + std::unique_ptr<weld::Widget> m_xGoogleBox; + std::unique_ptr<weld::Widget> 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<AuthFallbackDlg> dlg( pParent, instructions, url ); - int retCode = dlg->Execute( ); + uno::Reference<awt::XWindow> 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( ); } |