diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-02-23 14:12:46 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-02-23 20:18:21 +0100 |
commit | b627cb4e9af7dbb43dfc41adfc549c67dd1756c5 (patch) | |
tree | 6e243d7458a384ef36ee26fe20e3bc8348046710 /extensions | |
parent | 6e01d697ef58155ea9133e2ff19df0442d30a2eb (diff) |
weld bibliography autofilter menu
Change-Id: I3abacb0b14897f144c213496161b94d431f51b88
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111404
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/UIConfig_sbibliography.mk | 1 | ||||
-rw-r--r-- | extensions/source/bibliography/toolbar.cxx | 44 | ||||
-rw-r--r-- | extensions/source/bibliography/toolbar.hxx | 5 | ||||
-rw-r--r-- | extensions/uiconfig/sbibliography/ui/autofiltermenu.ui | 9 |
4 files changed, 38 insertions, 21 deletions
diff --git a/extensions/UIConfig_sbibliography.mk b/extensions/UIConfig_sbibliography.mk index cf4835829262..7b4056380912 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/autofiltermenu \ extensions/uiconfig/sbibliography/ui/choosedatasourcedialog \ extensions/uiconfig/sbibliography/ui/combobox \ extensions/uiconfig/sbibliography/ui/editbox \ diff --git a/extensions/source/bibliography/toolbar.cxx b/extensions/source/bibliography/toolbar.cxx index ea8ae0eeaee8..5ef3a8d5030c 100644 --- a/extensions/source/bibliography/toolbar.cxx +++ b/extensions/source/bibliography/toolbar.cxx @@ -34,9 +34,9 @@ #include <svtools/imgdef.hxx> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> -#include <vcl/menu.hxx> #include <vcl/mnemonic.hxx> #include <vcl/event.hxx> +#include <vcl/weldutils.hxx> #include <bitmaps.hlst> #include "bibtools.hxx" @@ -228,9 +228,9 @@ BibToolBar::BibToolBar(vcl::Window* pParent, Link<void*,void> aLink) , pLbSource(xSource->get_widget()) , xQuery(VclPtr<EditControl>::Create(this)) , pEdQuery(xQuery->get_widget()) - , pPopupMenu(VclPtr<PopupMenu>::Create()) + , xBuilder(Application::CreateBuilder(nullptr, "modules/sbibliography/ui/autofiltermenu.ui")) + , xPopupMenu(xBuilder->weld_menu("menu")) , nMenuId(0) - , nSelMenuItem(0) , aLayoutManager(aLink) , nSymbolsSize(SFX_SYMBOLS_SIZE_SMALL) { @@ -280,6 +280,8 @@ void BibToolBar::dispose() xQuery.disposeAndClear(); pLbSource = nullptr; xSource.disposeAndClear(); + xPopupMenu.reset(); + xBuilder.reset(); ToolBox::dispose(); } @@ -411,21 +413,23 @@ void BibToolBar::Click() void BibToolBar::ClearFilterMenu() { - pPopupMenu->Clear(); + xPopupMenu->clear(); nMenuId=0; } -sal_uInt16 BibToolBar::InsertFilterItem(const OUString& aMenuEntry) + +sal_uInt16 BibToolBar::InsertFilterItem(const OUString& rMenuEntry) { nMenuId++; - pPopupMenu->InsertItem(nMenuId,aMenuEntry); - + xPopupMenu->append_check(OUString::number(nMenuId), rMenuEntry); return nMenuId; } -void BibToolBar::SelectFilterItem(sal_uInt16 nId) + +void BibToolBar::SelectFilterItem(sal_uInt16 nId) { - pPopupMenu->CheckItem(nId); - nSelMenuItem=nId; - aQueryField = MnemonicGenerator::EraseAllMnemonicChars( pPopupMenu->GetItemText(nId) ); + OString sId = OString::number(nId); + xPopupMenu->set_active(sId, true); + sSelMenuItem = sId; + aQueryField = MnemonicGenerator::EraseAllMnemonicChars(xPopupMenu->get_label(sId)); } void BibToolBar::EnableSourceList(bool bFlag) @@ -510,24 +514,26 @@ IMPL_LINK_NOARG( BibToolBar, SendSelHdl, Timer*, void ) SendDispatch(nTBC_SOURCE, aPropVal); } -IMPL_LINK_NOARG( BibToolBar, MenuHdl, ToolBox*, void) +IMPL_LINK_NOARG(BibToolBar, MenuHdl, ToolBox*, void) { - sal_uInt16 nId=GetCurItemId(); + sal_uInt16 nId = GetCurItemId(); if (nId != nTBC_BT_AUTOFILTER) return; EndSelection(); // before SetDropMode (SetDropMode calls SetItemImage) SetItemDown(nTBC_BT_AUTOFILTER, true); - nId = pPopupMenu->Execute(this, GetItemRect(nTBC_BT_AUTOFILTER)); + tools::Rectangle aRect(GetItemRect(nTBC_BT_AUTOFILTER)); + weld::Window* pParent = weld::GetPopupParent(*this, aRect); + OString sId = xPopupMenu->popup_at_rect(pParent, aRect); - if(nId>0) + if (!sId.isEmpty()) { - pPopupMenu->CheckItem(nSelMenuItem,false); - pPopupMenu->CheckItem(nId); - nSelMenuItem=nId; - aQueryField = MnemonicGenerator::EraseAllMnemonicChars( pPopupMenu->GetItemText(nId) ); + xPopupMenu->set_active(sSelMenuItem, false); + xPopupMenu->set_active(sId, true); + sSelMenuItem = sId; + aQueryField = MnemonicGenerator::EraseAllMnemonicChars(xPopupMenu->get_label(sId)); Sequence<PropertyValue> aPropVal(2); PropertyValue* pPropertyVal = const_cast<PropertyValue*>(aPropVal.getConstArray()); pPropertyVal[0].Name = "QueryText"; diff --git a/extensions/source/bibliography/toolbar.hxx b/extensions/source/bibliography/toolbar.hxx index afd1bd3ace38..ee4b58274e9e 100644 --- a/extensions/source/bibliography/toolbar.hxx +++ b/extensions/source/bibliography/toolbar.hxx @@ -148,9 +148,10 @@ class BibToolBar: public ToolBox weld::ComboBox* pLbSource; VclPtr<EditControl> xQuery; weld::Entry* pEdQuery; - ScopedVclPtr<PopupMenu> pPopupMenu; + std::unique_ptr<weld::Builder> xBuilder; + std::unique_ptr<weld::Menu> xPopupMenu; sal_uInt16 nMenuId; - sal_uInt16 nSelMenuItem; + OString sSelMenuItem; OUString aQueryField; Link<void*,void> aLayoutManager; sal_Int16 nSymbolsSize; diff --git a/extensions/uiconfig/sbibliography/ui/autofiltermenu.ui b/extensions/uiconfig/sbibliography/ui/autofiltermenu.ui new file mode 100644 index 000000000000..aa496513f25e --- /dev/null +++ b/extensions/uiconfig/sbibliography/ui/autofiltermenu.ui @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.38.2 --> +<interface domain="pcr"> + <requires lib="gtk+" version="3.20"/> + <object class="GtkMenu" id="menu"> + <property name="visible">True</property> + <property name="can-focus">False</property> + </object> +</interface> |