From 7b8556729629ceaf633f60c86f0114e4427d2b4a Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 14 May 2018 12:52:37 +0100 Subject: weld GalleryIdDialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I214afef7668eaf5082683f1c77b08aa0c5107619 Reviewed-on: https://gerrit.libreoffice.org/54317 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- cui/source/dialogs/cuigaldlg.cxx | 47 +++++++++++++++------------------------- cui/source/factory/dlgfact.cxx | 16 +++++++++----- cui/source/factory/dlgfact.hxx | 14 ++++++++---- cui/source/inc/cuigaldlg.hxx | 15 ++++++------- 4 files changed, 44 insertions(+), 48 deletions(-) (limited to 'cui/source') diff --git a/cui/source/dialogs/cuigaldlg.cxx b/cui/source/dialogs/cuigaldlg.cxx index 1e39d5b1055b..6729b7fcd912 100644 --- a/cui/source/dialogs/cuigaldlg.cxx +++ b/cui/source/dialogs/cuigaldlg.cxx @@ -503,41 +503,29 @@ TitleDialog::~TitleDialog() { } -GalleryIdDialog::GalleryIdDialog( vcl::Window* pParent, GalleryTheme* _pThm ) - : ModalDialog(pParent, "GalleryThemeIDDialog", "cui/ui/gallerythemeiddialog.ui") - , pThm(_pThm ) +GalleryIdDialog::GalleryIdDialog(weld::Window* pParent, GalleryTheme* _pThm) + : GenericDialogController(pParent, "cui/ui/gallerythemeiddialog.ui", "GalleryThemeIDDialog") + , m_pThm(_pThm) + , m_xBtnOk(m_xBuilder->weld_button("ok")) + , m_xLbResName(m_xBuilder->weld_combo_box_text("entry")) { - get(m_pBtnOk, "ok"); - get(m_pLbResName, "entry"); + m_xLbResName->append_text("!!! No Id !!!"); - m_pLbResName->InsertEntry( OUString( "!!! No Id !!!" ) ); + GalleryTheme::InsertAllThemes(*m_xLbResName); - GalleryTheme::InsertAllThemes(*m_pLbResName); + m_xLbResName->set_active(m_pThm->GetId()); + m_xLbResName->grab_focus(); - m_pLbResName->SelectEntryPos( static_cast(pThm->GetId()) ); - m_pLbResName->GrabFocus(); - - m_pBtnOk->SetClickHdl( LINK( this, GalleryIdDialog, ClickOkHdl ) ); + m_xBtnOk->connect_clicked(LINK(this, GalleryIdDialog, ClickOkHdl)); } - GalleryIdDialog::~GalleryIdDialog() { - disposeOnce(); -} - - -void GalleryIdDialog::dispose() -{ - m_pBtnOk.clear(); - m_pLbResName.clear(); - ModalDialog::dispose(); } - -IMPL_LINK_NOARG(GalleryIdDialog, ClickOkHdl, Button*, void) +IMPL_LINK_NOARG(GalleryIdDialog, ClickOkHdl, weld::Button&, void) { - Gallery* pGal = pThm->GetParent(); + Gallery* pGal = m_pThm->GetParent(); const sal_uLong nId = GetId(); bool bDifferentThemeExists = false; @@ -545,26 +533,25 @@ IMPL_LINK_NOARG(GalleryIdDialog, ClickOkHdl, Button*, void) { const GalleryThemeEntry* pInfo = pGal->GetThemeInfo( i ); - if( ( pInfo->GetId() == nId ) && ( pInfo->GetThemeName() != pThm->GetName() ) ) + if ((pInfo->GetId() == nId) && (pInfo->GetThemeName() != m_pThm->GetName())) { OUString aStr( CuiResId( RID_SVXSTR_GALLERY_ID_EXISTS ) ); aStr += " (" + pInfo->GetThemeName() + ")"; - std::unique_ptr xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), + std::unique_ptr xInfoBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Info, VclButtonsType::Ok, aStr)); xInfoBox->run(); - m_pLbResName->GrabFocus(); + m_xLbResName->grab_focus(); bDifferentThemeExists = true; } } - if( !bDifferentThemeExists ) - EndDialog( RET_OK ); + if (!bDifferentThemeExists) + m_xDialog->response(RET_OK); } - GalleryThemeProperties::GalleryThemeProperties(vcl::Window* pParent, ExchangeData* _pData, SfxItemSet const * pItemSet) : SfxTabDialog( pParent, "GalleryThemeDialog", diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx index 283bd1a651d1..a5c76ef405ab 100644 --- a/cui/source/factory/dlgfact.cxx +++ b/cui/source/factory/dlgfact.cxx @@ -117,7 +117,12 @@ short AbstractTitleDialog_Impl::Execute() } IMPL_ABSTDLG_BASE(AbstractScriptSelectorDialog_Impl); -IMPL_ABSTDLG_BASE(AbstractGalleryIdDialog_Impl); + +short AbstractGalleryIdDialog_Impl::Execute() +{ + return m_xDlg->run(); +} + IMPL_ABSTDLG_BASE(AbstractURLDlg_Impl); short AbstractSvxSearchSimilarityDialog_Impl::Execute() @@ -518,7 +523,7 @@ OUString AbstractTitleDialog_Impl::GetTitle() const sal_uInt32 AbstractGalleryIdDialog_Impl::GetId() const { - return pDlg->GetId(); + return m_xDlg->GetId(); } void VclAbstractRefreshableDialog_Impl::Update() @@ -1084,11 +1089,10 @@ VclPtr AbstractDialogFactory_Impl::CreateTitleDialog(weld:: return VclPtr::Create(new TitleDialog(pParent, rOldText)); } -VclPtr AbstractDialogFactory_Impl::CreateGalleryIdDialog( vcl::Window* pParent, - GalleryTheme* pThm ) +VclPtr AbstractDialogFactory_Impl::CreateGalleryIdDialog(weld::Window* pParent, + GalleryTheme* pThm) { - VclPtrInstance pDlg( pParent, pThm); - return VclPtr::Create( pDlg ); + return VclPtr::Create(new GalleryIdDialog(pParent, pThm)); } VclPtr AbstractDialogFactory_Impl::CreateGalleryThemePropertiesDialog(vcl::Window* pParent, diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx index 7d75a69b9d98..3c4e3dac1bb0 100644 --- a/cui/source/factory/dlgfact.hxx +++ b/cui/source/factory/dlgfact.hxx @@ -256,9 +256,15 @@ class AbstractScriptSelectorDialog_Impl : public AbstractScriptSelectorDialog class GalleryIdDialog; class AbstractGalleryIdDialog_Impl : public AbstractGalleryIdDialog { - DECL_ABSTDLG_BASE(AbstractGalleryIdDialog_Impl,GalleryIdDialog) - - virtual sal_uInt32 GetId() const override; +protected: + std::unique_ptr m_xDlg; +public: + explicit AbstractGalleryIdDialog_Impl(GalleryIdDialog* p) + : m_xDlg(p) + { + } + virtual short Execute() override; + virtual sal_uInt32 GetId() const override; }; class URLDlg; @@ -674,7 +680,7 @@ public: virtual VclPtr CreateActualizeProgressDialog( vcl::Window* pParent, GalleryTheme* pThm ) override; virtual VclPtr CreateTitleDialog(weld::Window* pParent, const OUString& rOldText) override; - virtual VclPtr CreateGalleryIdDialog( vcl::Window* pParent, + virtual VclPtr CreateGalleryIdDialog(weld::Window* pParent, GalleryTheme* pThm) override; virtual VclPtr CreateGalleryThemePropertiesDialog(vcl::Window* pParent, ExchangeData* pData, diff --git a/cui/source/inc/cuigaldlg.hxx b/cui/source/inc/cuigaldlg.hxx index c316fb6b7e95..a2089ed6ee53 100644 --- a/cui/source/inc/cuigaldlg.hxx +++ b/cui/source/inc/cuigaldlg.hxx @@ -178,19 +178,18 @@ public: OUString GetTitle() const { return m_xEdit->get_text(); } }; -class GalleryIdDialog : public ModalDialog +class GalleryIdDialog : public weld::GenericDialogController { private: - VclPtr m_pBtnOk; - VclPtr m_pLbResName; - GalleryTheme* pThm; + GalleryTheme* m_pThm; + std::unique_ptr m_xBtnOk; + std::unique_ptr m_xLbResName; - DECL_LINK( ClickOkHdl, Button*, void ); + DECL_LINK(ClickOkHdl, weld::Button&, void); public: - GalleryIdDialog( vcl::Window* pParent, GalleryTheme* pThm ); + GalleryIdDialog(weld::Window* pParent, GalleryTheme* pThm); virtual ~GalleryIdDialog() override; - virtual void dispose() override; - sal_uInt32 GetId() const { return m_pLbResName->GetSelectedEntryPos(); } + sal_uInt32 GetId() const { return m_xLbResName->get_active(); } }; class GalleryThemeProperties : public SfxTabDialog -- cgit