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

AuthFallbackDlg

Change-Id: I69676dd437caefca63805e86f4707527183f622f
Reviewed-on: https://gerrit.libreoffice.org/54487Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst a55d164b
......@@ -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);
}
......@@ -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
......@@ -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( );
}
......
This diff is collapsed.
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