diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-02-21 21:20:15 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-02-25 20:03:26 +0100 |
commit | d75144cf44779a8f6cc9bccf9b0a6328b94a5b90 (patch) | |
tree | 25b9f3c677c50ad715e1a0bc6bef3d5bf79ef957 /svtools | |
parent | 8d42909cd326cb26d8ba1fb383b5578f820c72ed (diff) |
convert remaining InfoBox to weld::MessageDialog
Change-Id: I91d828e38d96264cf4a76f30940942556b8f78d8
Reviewed-on: https://gerrit.libreoffice.org/50205
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/graphic/provider.cxx | 2 | ||||
-rw-r--r-- | svtools/source/misc/ehdl.cxx | 80 |
2 files changed, 45 insertions, 37 deletions
diff --git a/svtools/source/graphic/provider.cxx b/svtools/source/graphic/provider.cxx index f0dddfc5610c..3cbbd6ba752b 100644 --- a/svtools/source/graphic/provider.cxx +++ b/svtools/source/graphic/provider.cxx @@ -198,7 +198,7 @@ uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadStandardImage( co OUString sImageName( rResourceURL.copy( nIndex ) ); if ( sImageName == "info" ) { - xRet = Graphic(InfoBox::GetStandardImage().GetBitmapEx()).GetXGraphic(); + xRet = Graphic(GetStandardInfoBoxImage().GetBitmapEx()).GetXGraphic(); } else if ( sImageName == "warning" ) { diff --git a/svtools/source/misc/ehdl.cxx b/svtools/source/misc/ehdl.cxx index dfd28ac168d6..3ab4c7cedb9c 100644 --- a/svtools/source/misc/ehdl.cxx +++ b/svtools/source/misc/ehdl.cxx @@ -18,9 +18,9 @@ */ #include <unotools/resmgr.hxx> -#include <tools/wintypes.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/button.hxx> #include <vcl/svapp.hxx> +#include <vcl/weld.hxx> #include <vcl/settings.hxx> #include <svtools/ehdl.hxx> @@ -33,7 +33,7 @@ #include <strings.hxx> static DialogMask aWndFunc( - vcl::Window *pWin, // Parent of the dialog + weld::Window *pWin, // Parent of the dialog DialogMask nFlags, const OUString &rErr, // error text const OUString &rAction) // action text @@ -52,33 +52,17 @@ static DialogMask aWndFunc( SolarMutexGuard aGuard; // determine necessary WinBits from the flags - MessBoxStyle eBits = MessBoxStyle::NONE; + VclButtonsType eButtonsType = VclButtonsType::NONE; + bool bAddRetry = false; if ( (nFlags & (DialogMask::ButtonsCancel | DialogMask::ButtonsRetry)) == (DialogMask::ButtonsCancel | DialogMask::ButtonsRetry)) - eBits = MessBoxStyle::RetryCancel; - else if ( (nFlags & DialogMask::ButtonsOk) == DialogMask::ButtonsOk ) - eBits = MessBoxStyle::Ok; - else if ( (nFlags & DialogMask::ButtonsYesNo) == DialogMask::ButtonsYesNo ) - eBits = MessBoxStyle::YesNo; - - switch(nFlags & DialogMask(0x0f00)) { - case DialogMask::ButtonDefaultsOk: - eBits |= MessBoxStyle::DefaultOk; - break; - - case DialogMask::ButtonDefaultsCancel: - eBits |= MessBoxStyle::DefaultCancel; - break; - - case DialogMask::ButtonDefaultsYes: - eBits |= MessBoxStyle::DefaultYes; - break; - - case DialogMask::ButtonDefaultsNo: - eBits |= MessBoxStyle::DefaultNo; - break; - default: break; + bAddRetry = true; + eButtonsType = VclButtonsType::Cancel; } + else if ( (nFlags & DialogMask::ButtonsOk) == DialogMask::ButtonsOk ) + eButtonsType = VclButtonsType::Ok; + else if ( (nFlags & DialogMask::ButtonsYesNo) == DialogMask::ButtonsYesNo ) + eButtonsType = VclButtonsType::YesNo; OUString aErr("$(ACTION)$(ERROR)"); OUString aAction(rAction); @@ -87,19 +71,19 @@ static DialogMask aWndFunc( aErr = aErr.replaceAll("$(ACTION)", aAction); aErr = aErr.replaceAll("$(ERROR)", rErr); - VclPtr<MessBox> pBox; - switch ( nFlags & DialogMask(0xf000) ) + VclMessageType eMessageType; + switch (nFlags & DialogMask(0xf000)) { case DialogMask::MessageError: - pBox.reset(VclPtr<ErrorBox>::Create(pWin, eBits, aErr)); + eMessageType = VclMessageType::Error; break; case DialogMask::MessageWarning: - pBox.reset(VclPtr<WarningBox>::Create(pWin, eBits, aErr)); + eMessageType = VclMessageType::Warning; break; case DialogMask::MessageInfo: - pBox.reset(VclPtr<InfoBox>::Create(pWin, aErr)); + eMessageType = VclMessageType::Info; break; default: @@ -109,8 +93,32 @@ static DialogMask aWndFunc( } } + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pWin, + eMessageType, eButtonsType, aErr)); + + if (bAddRetry) + xBox->add_button(Button::GetStandardText(StandardButtonType::Retry), RET_RETRY); + + switch(nFlags & DialogMask(0x0f00)) + { + case DialogMask::ButtonDefaultsOk: + xBox->set_default_response(RET_OK); + break; + case DialogMask::ButtonDefaultsCancel: + xBox->set_default_response(RET_CANCEL); + break; + case DialogMask::ButtonDefaultsYes: + xBox->set_default_response(RET_YES); + break; + case DialogMask::ButtonDefaultsNo: + xBox->set_default_response(RET_NO); + break; + default: + break; + } + DialogMask nRet = DialogMask::NONE; - switch ( pBox->Execute() ) + switch (xBox->run()) { case RET_OK: nRet = DialogMask::ButtonsOk; @@ -131,7 +139,7 @@ static DialogMask aWndFunc( SAL_WARN( "svtools.misc", "Unknown MessBox return value" ); break; } - pBox.disposeAndClear(); + return nRet; } @@ -234,7 +242,7 @@ bool SfxErrorHandler::GetErrorString(ErrCode lErrId, OUString &rStr) const } SfxErrorContext::SfxErrorContext( - sal_uInt16 nCtxIdP, vcl::Window *pWindow, const ErrMsgCode* pIdsP, const std::locale& rResLocaleP) + sal_uInt16 nCtxIdP, weld::Window *pWindow, const ErrMsgCode* pIdsP, const std::locale& rResLocaleP) : ErrorContext(pWindow), nCtxId(nCtxIdP), pIds(pIdsP), aResLocale(rResLocaleP) { if (!pIds) @@ -243,7 +251,7 @@ SfxErrorContext::SfxErrorContext( SfxErrorContext::SfxErrorContext( - sal_uInt16 nCtxIdP, const OUString &aArg1P, vcl::Window *pWindow, + sal_uInt16 nCtxIdP, const OUString &aArg1P, weld::Window *pWindow, const ErrMsgCode* pIdsP, const std::locale& rResLocaleP) : ErrorContext(pWindow), nCtxId(nCtxIdP), pIds(pIdsP), aResLocale(rResLocaleP), aArg1(aArg1P) |