From cd211e8485eb94ea4a1783f0b8404cae2cd106a4 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 12 May 2020 20:39:28 +0100 Subject: weld bibliography ComboBox control ItemWindow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I6d944225188d2c4bdf36b5a9c730ab770d07a246 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94096 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- extensions/UIConfig_sbibliography.mk | 1 + extensions/source/bibliography/toolbar.cxx | 77 ++++++++++++++---------- extensions/source/bibliography/toolbar.hxx | 33 +++++++--- extensions/uiconfig/sbibliography/ui/combobox.ui | 40 ++++++++++++ extensions/uiconfig/sbibliography/ui/toolbar.ui | 15 +---- 5 files changed, 113 insertions(+), 53 deletions(-) create mode 100644 extensions/uiconfig/sbibliography/ui/combobox.ui diff --git a/extensions/UIConfig_sbibliography.mk b/extensions/UIConfig_sbibliography.mk index 00375d9fae1e..ad359f8dee25 100644 --- a/extensions/UIConfig_sbibliography.mk +++ b/extensions/UIConfig_sbibliography.mk @@ -14,6 +14,7 @@ $(eval $(call gb_UIConfig_add_menubarfiles,modules/sbibliography,\ )) $(eval $(call gb_UIConfig_add_uifiles,modules/sbibliography,\ + extensions/uiconfig/sbibliography/ui/combobox \ extensions/uiconfig/sbibliography/ui/choosedatasourcedialog \ extensions/uiconfig/sbibliography/ui/generalpage \ extensions/uiconfig/sbibliography/ui/querydialog \ diff --git a/extensions/source/bibliography/toolbar.cxx b/extensions/source/bibliography/toolbar.cxx index 740b6984ec88..ccdc2476e884 100644 --- a/extensions/source/bibliography/toolbar.cxx +++ b/extensions/source/bibliography/toolbar.cxx @@ -171,10 +171,33 @@ void BibTBEditListener::statusChanged(const frame::FeatureStateEvent& rEvt) } } +ComboBoxControl::ComboBoxControl(vcl::Window* pParent) + : InterimItemWindow(pParent, "modules/sbibliography/ui/combobox.ui", "ComboBox") + , m_xFtSource(m_xBuilder->weld_label("label")) + , m_xLBSource(m_xBuilder->weld_combo_box("combobox")) +{ + m_xFtSource->set_toolbar_background(); + m_xLBSource->set_toolbar_background(); + m_xLBSource->set_size_request(100, -1); + SetSizePixel(get_preferred_size()); +} + +void ComboBoxControl::dispose() +{ + m_xLBSource.reset(); + m_xFtSource.reset(); + InterimItemWindow::dispose(); +} + +ComboBoxControl::~ComboBoxControl() +{ + disposeOnce(); +} + BibToolBar::BibToolBar(vcl::Window* pParent, Link aLink) : ToolBox(pParent, "toolbar", "modules/sbibliography/ui/toolbar.ui") - , aFtSource(VclPtr::Create(this,WB_VCENTER)) - , aLBSource(VclPtr::Create(this,WB_DROPDOWN)) + , xSource(VclPtr::Create(this)) + , pLbSource(xSource->get_widget()) , aFtQuery(VclPtr::Create(this,WB_VCENTER)) , aEdQuery(VclPtr::Create(this)) , pPopupMenu(VclPtr::Create()) @@ -189,12 +212,8 @@ BibToolBar::BibToolBar(vcl::Window* pParent, Link aLink) nOutStyle = aSvtMiscOptions.GetToolboxStyle(); SetOutStyle(TOOLBOX_STYLE_FLAT); - Size a2Size(GetOutputSizePixel()); - a2Size.setWidth(100 ); - aLBSource->SetSizePixel(a2Size); - aLBSource->SetDropDownLineCount(9); - aLBSource->Show(); - aLBSource->SetSelectHdl(LINK( this, BibToolBar, SelHdl)); + xSource->Show(); + pLbSource->connect_changed(LINK( this, BibToolBar, SelHdl)); SvtMiscOptions().AddListenerLink( LINK( this, BibToolBar, OptionsChanged_Impl ) ); Application::AddEventListener( LINK( this, BibToolBar, SettingsChanged_Impl ) ); @@ -204,11 +223,10 @@ BibToolBar::BibToolBar(vcl::Window* pParent, Link aLink) SetDropdownClickHdl( LINK( this, BibToolBar, MenuHdl)); - aEdQuery->SetSizePixel(aLBSource->GetSizePixel()); + aEdQuery->SetSizePixel(pLbSource->get_preferred_size()); aEdQuery->Show(); - nTBC_FT_SOURCE = GetItemId("TBC_FT_SOURCE"); - nTBC_LB_SOURCE = GetItemId(".uno:Bib/source"); + nTBC_SOURCE = GetItemId(".uno:Bib/source"); nTBC_FT_QUERY = GetItemId("TBC_FT_QUERY"); nTBC_ED_QUERY = GetItemId(".uno:Bib/query"); nTBC_BT_AUTOFILTER = GetItemId(".uno:Bib/autoFilter"); @@ -217,18 +235,12 @@ BibToolBar::BibToolBar(vcl::Window* pParent, Link aLink) nTBC_BT_FILTERCRIT = GetItemId(".uno:Bib/standardFilter"); nTBC_BT_REMOVEFILTER = GetItemId(".uno:Bib/removeFilter"); - OUString aStr = GetItemText(nTBC_FT_SOURCE); - aFtSource->SetText(aStr); - aFtSource->SetSizePixel(aFtSource->get_preferred_size()); - aFtSource->SetBackground(Wallpaper( COL_TRANSPARENT )); - - aStr=GetItemText(nTBC_FT_QUERY); + OUString aStr=GetItemText(nTBC_FT_QUERY); aFtQuery->SetText(aStr); aFtQuery->SetSizePixel(aFtQuery->get_preferred_size()); aFtQuery->SetBackground(Wallpaper( COL_TRANSPARENT )); - SetItemWindow(nTBC_FT_SOURCE, aFtSource.get()); - SetItemWindow(nTBC_LB_SOURCE, aLBSource.get()); + SetItemWindow(nTBC_SOURCE, xSource.get()); SetItemWindow(nTBC_FT_QUERY , aFtQuery.get()); SetItemWindow(nTBC_ED_QUERY , aEdQuery.get()); @@ -247,10 +259,9 @@ void BibToolBar::dispose() SvtMiscOptions().RemoveListenerLink( LINK( this, BibToolBar, OptionsChanged_Impl ) ); Application::RemoveEventListener( LINK( this, BibToolBar, SettingsChanged_Impl ) ); ::bib::RemoveFromTaskPaneList( this ); - aFtSource.disposeAndClear(); aFtQuery.disposeAndClear(); aEdQuery.disposeAndClear(); - aLBSource.disposeAndClear(); + xSource.disposeAndClear(); ToolBox::dispose(); } @@ -272,7 +283,7 @@ void BibToolBar::InitListener() for(ToolBox::ImplToolItems::size_type nPos=0;nPosparseStrict( aURL ); css::uno::Reference< css::frame::XStatusListener> xListener; - if (nId == nTBC_LB_SOURCE) + if (nId == nTBC_SOURCE) { xListener=new BibTBListBoxListener(this,aURL.Complete,nId); } @@ -401,28 +412,30 @@ void BibToolBar::SelectFilterItem(sal_uInt16 nId) void BibToolBar::EnableSourceList(bool bFlag) { - aFtSource->Enable(bFlag); - aLBSource->Enable(bFlag); + xSource->set_sensitive(bFlag); } void BibToolBar::ClearSourceList() { - aLBSource->Clear(); + pLbSource->clear(); } void BibToolBar::UpdateSourceList(bool bFlag) { - aLBSource->SetUpdateMode(bFlag); + if (bFlag) + pLbSource->thaw(); + else + pLbSource->freeze(); } void BibToolBar::InsertSourceEntry(const OUString& aEntry) { - aLBSource->InsertEntry(aEntry); + pLbSource->append_text(aEntry); } void BibToolBar::SelectSourceEntry(const OUString& aStr) { - aLBSource->SelectEntry(aStr); + pLbSource->set_active_text(aStr); } void BibToolBar::EnableQuery(bool bFlag) @@ -466,7 +479,7 @@ bool BibToolBar::PreNotify( NotifyEvent& rNEvt ) return bResult; } -IMPL_LINK_NOARG( BibToolBar, SelHdl, ListBox&, void ) +IMPL_LINK_NOARG( BibToolBar, SelHdl, weld::ComboBox&, void ) { aIdle.Start(); } @@ -476,9 +489,9 @@ IMPL_LINK_NOARG( BibToolBar, SendSelHdl, Timer*, void ) Sequence aPropVal(1); PropertyValue* pPropertyVal = const_cast(aPropVal.getConstArray()); pPropertyVal[0].Name = "DataSourceName"; - OUString aEntry( MnemonicGenerator::EraseAllMnemonicChars( aLBSource->GetSelectedEntry() ) ); + OUString aEntry( MnemonicGenerator::EraseAllMnemonicChars( pLbSource->get_active_text() ) ); pPropertyVal[0].Value <<= aEntry; - SendDispatch(nTBC_LB_SOURCE, aPropVal); + SendDispatch(nTBC_SOURCE, aPropVal); } IMPL_LINK_NOARG( BibToolBar, MenuHdl, ToolBox*, void) diff --git a/extensions/source/bibliography/toolbar.hxx b/extensions/source/bibliography/toolbar.hxx index 810445e85c7e..34a4db9a867b 100644 --- a/extensions/source/bibliography/toolbar.hxx +++ b/extensions/source/bibliography/toolbar.hxx @@ -23,9 +23,8 @@ #include #include - +#include #include -#include #include #include #include @@ -98,6 +97,27 @@ public: typedef std::vector< css::uno::Reference< css::frame::XStatusListener> > BibToolBarListenerArr; +class ComboBoxControl final : public InterimItemWindow +{ +public: + ComboBoxControl(vcl::Window* pParent); + virtual ~ComboBoxControl() override; + virtual void dispose() override; + + weld::ComboBox* get_widget() { return m_xLBSource.get(); } + + void set_sensitive(bool bSensitive) + { + m_xFtSource->set_sensitive(bSensitive); + m_xLBSource->set_sensitive(bSensitive); + Enable(bSensitive); + } + +private: + std::unique_ptr m_xFtSource; + std::unique_ptr m_xLBSource; +}; + class BibToolBar: public ToolBox { private: @@ -105,8 +125,8 @@ class BibToolBar: public ToolBox BibToolBarListenerArr aListenerArr; css::uno::Reference< css::frame::XController > xController; Idle aIdle; - VclPtr aFtSource; - VclPtr aLBSource; + VclPtr xSource; + weld::ComboBox* pLbSource; VclPtr aFtQuery; VclPtr aEdQuery; ScopedVclPtr pPopupMenu; @@ -117,8 +137,7 @@ class BibToolBar: public ToolBox sal_Int16 nSymbolsSize; sal_Int16 nOutStyle; - sal_uInt16 nTBC_FT_SOURCE; - sal_uInt16 nTBC_LB_SOURCE; + sal_uInt16 nTBC_SOURCE; sal_uInt16 nTBC_FT_QUERY; sal_uInt16 nTBC_ED_QUERY; sal_uInt16 nTBC_BT_AUTOFILTER; @@ -128,7 +147,7 @@ class BibToolBar: public ToolBox sal_uInt16 nTBC_BT_REMOVEFILTER; BibDataManager* pDatMan; - DECL_LINK( SelHdl, ListBox&, void ); + DECL_LINK( SelHdl, weld::ComboBox&, void ); DECL_LINK( SendSelHdl, Timer*, void ); DECL_LINK( MenuHdl, ToolBox*, void ); DECL_LINK( OptionsChanged_Impl, LinkParamNone*, void ); diff --git a/extensions/uiconfig/sbibliography/ui/combobox.ui b/extensions/uiconfig/sbibliography/ui/combobox.ui new file mode 100644 index 000000000000..ff2e4b47d367 --- /dev/null +++ b/extensions/uiconfig/sbibliography/ui/combobox.ui @@ -0,0 +1,40 @@ + + + + + + True + False + 6 + 6 + 6 + + + True + False + center + Table + True + combobox + + + False + True + 0 + + + + + True + False + center + True + + + True + True + 1 + + + + diff --git a/extensions/uiconfig/sbibliography/ui/toolbar.ui b/extensions/uiconfig/sbibliography/ui/toolbar.ui index 87eed09f0a8a..748ff95e69e4 100644 --- a/extensions/uiconfig/sbibliography/ui/toolbar.ui +++ b/extensions/uiconfig/sbibliography/ui/toolbar.ui @@ -7,20 +7,7 @@ False False - - True - False - TBC_FT_SOURCE - Table - True - - - False - True - - - - + True False .uno:Bib/source -- cgit