summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-02-26 16:53:37 +0000
committerCaolán McNamara <caolanm@redhat.com>2018-02-27 11:22:49 +0100
commit082e69fefb7439fd4f3d543f0c402039e94c1e9c (patch)
tree8348cacdc54a15dae722b93fc198995756924fc0 /cui
parentf41a08183504a59d6ffc7a00ed7f24e6b19995ab (diff)
convert various MessBox to weld::MessageDialog
Change-Id: I4d2d0393c753114aeb9bb7e646dfdc810f6caa38 Reviewed-on: https://gerrit.libreoffice.org/50398 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 'cui')
-rw-r--r--cui/source/customize/cfg.cxx89
-rw-r--r--cui/source/inc/cfg.hxx15
2 files changed, 40 insertions, 64 deletions
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 6f6ec630d613..9b96ccc0e7e4 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -3242,6 +3242,42 @@ bool SvxIconSelectorDialog::ReplaceGraphicItem(
return bResult;
}
+namespace
+{
+ OUString ReplaceIconName(const OUString& rMessage)
+ {
+ OUString name;
+ OUString message = CuiResId( RID_SVXSTR_REPLACE_ICON_WARNING );
+ OUString placeholder("%ICONNAME" );
+ sal_Int32 pos = message.indexOf( placeholder );
+ if ( pos != -1 )
+ {
+ name = message.replaceAt(
+ pos, placeholder.getLength(), rMessage );
+ }
+ return name;
+ }
+
+ class SvxIconReplacementDialog
+ {
+ private:
+ std::unique_ptr<weld::MessageDialog> m_xQueryBox;
+ public:
+ SvxIconReplacementDialog(weld::Window *pParent, const OUString& rMessage, bool bYestoAll)
+ : m_xQueryBox(Application::CreateMessageDialog(pParent, VclMessageType::Warning, VclButtonsType::NONE, ReplaceIconName(rMessage)))
+ {
+ m_xQueryBox->set_title(CuiResId(RID_SVXSTR_REPLACE_ICON_CONFIRM));
+ m_xQueryBox->add_button(Button::GetStandardText(StandardButtonType::Yes), 2);
+ if (bYestoAll)
+ m_xQueryBox->add_button(CuiResId(RID_SVXSTR_YESTOALL), 5);
+ m_xQueryBox->add_button(Button::GetStandardText(StandardButtonType::No), 4);
+ m_xQueryBox->add_button(Button::GetStandardText(StandardButtonType::Cancel), 6);
+ m_xQueryBox->set_default_response(2);
+ }
+ short run() { return m_xQueryBox->run(); }
+ };
+}
+
void SvxIconSelectorDialog::ImportGraphics(
const uno::Sequence< OUString >& rPaths )
{
@@ -3260,7 +3296,8 @@ void SvxIconSelectorDialog::ImportGraphics(
{
aIndex = rPaths[0].lastIndexOf( '/' );
aIconName = rPaths[0].copy( aIndex+1 );
- ret = ScopedVclPtrInstance<SvxIconReplacementDialog>(this, aIconName)->ShowDialog();
+ SvxIconReplacementDialog aDlg(GetFrameWeld(), aIconName, false);
+ ret = aDlg.run();
if ( ret == 2 )
{
ReplaceGraphicItem( rPaths[0] );
@@ -3288,7 +3325,8 @@ void SvxIconSelectorDialog::ImportGraphics(
{
aIndex = rPaths[i].lastIndexOf( '/' );
aIconName = rPaths[i].copy( aIndex+1 );
- ret = ScopedVclPtrInstance<SvxIconReplacementDialog>(this, aIconName, true)->ShowDialog();
+ SvxIconReplacementDialog aDlg(GetFrameWeld(), aIconName, true);
+ ret = aDlg.run();
if ( ret == 2 )
{
ReplaceGraphicItem( aPath );
@@ -3420,53 +3458,6 @@ bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL )
/*******************************************************************************
*
-* The SvxIconReplacementDialog class
-*
-*******************************************************************************/
-SvxIconReplacementDialog::SvxIconReplacementDialog(
- vcl::Window *pWindow, const OUString& aMessage, bool /*bYestoAll*/ )
- :
-MessBox( pWindow, MessBoxStyle::DefaultYes, 0, CuiResId( RID_SVXSTR_REPLACE_ICON_CONFIRM ), CuiResId( RID_SVXSTR_REPLACE_ICON_WARNING ) )
-
-{
- SetImage( GetStandardWarningBoxImage() );
- SetMessText( ReplaceIconName( aMessage ) );
- RemoveButton( 1 );
- AddButton( StandardButtonType::Yes, 2);
- AddButton( CuiResId( RID_SVXSTR_YESTOALL ), 5);
- AddButton( StandardButtonType::No, 3);
- AddButton( StandardButtonType::Cancel, 4);
-}
-
-SvxIconReplacementDialog::SvxIconReplacementDialog(
- vcl::Window *pWindow, const OUString& aMessage )
- : MessBox( pWindow, MessBoxStyle::YesNoCancel, 0, CuiResId( RID_SVXSTR_REPLACE_ICON_CONFIRM ), CuiResId( RID_SVXSTR_REPLACE_ICON_WARNING ) )
-{
- SetImage( GetStandardWarningBoxImage() );
- SetMessText( ReplaceIconName( aMessage ));
-}
-
-OUString SvxIconReplacementDialog::ReplaceIconName( const OUString& rMessage )
-{
- OUString name;
- OUString message = CuiResId( RID_SVXSTR_REPLACE_ICON_WARNING );
- OUString placeholder("%ICONNAME" );
- sal_Int32 pos = message.indexOf( placeholder );
- if ( pos != -1 )
- {
- name = message.replaceAt(
- pos, placeholder.getLength(), rMessage );
- }
- return name;
-}
-
-sal_uInt16 SvxIconReplacementDialog::ShowDialog()
-{
- Execute();
- return GetCurButtonId();
-}
-/*******************************************************************************
-*
* The SvxIconChangeDialog class added for issue83555
*
*******************************************************************************/
diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx
index d69da888059e..52bb3facb3c9 100644
--- a/cui/source/inc/cfg.hxx
+++ b/cui/source/inc/cfg.hxx
@@ -635,21 +635,6 @@ public:
DECL_LINK( DeleteHdl, Button *, void );
};
-class SvxIconReplacementDialog : public MessBox
-{
-public:
- SvxIconReplacementDialog(
- vcl::Window *pWindow,
- const OUString& aMessage,
- bool aYestoAll);
-
- SvxIconReplacementDialog(
- vcl::Window *pWindow,
- const OUString& aMessage );
-
- static OUString ReplaceIconName( const OUString& );
- sal_uInt16 ShowDialog();
-};
//added for issue83555
class SvxIconChangeDialog : public ModalDialog
{