diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-12-21 13:31:33 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-12-21 22:03:20 +0100 |
commit | b01310567d93d2cea068c55ff8e2ce0582d0fd3a (patch) | |
tree | 7f00de643b55f7e0339086da3255c2a48ca7c069 | |
parent | 6060632f6f042e9ca742529074b24234e9f29b97 (diff) |
weld pagelistmenu
Change-Id: I2d3e5a448f03e424e7dad661c550f7e1ff31d808
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108112
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sc/UIConfig_scalc.mk | 1 | ||||
-rw-r--r-- | sc/source/ui/view/tabcont.cxx | 33 | ||||
-rw-r--r-- | sc/uiconfig/scalc/ui/pagelistmenu.ui | 9 |
3 files changed, 28 insertions, 15 deletions
diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk index f1a6f4fe902f..5d1121242788 100644 --- a/sc/UIConfig_scalc.mk +++ b/sc/UIConfig_scalc.mk @@ -183,6 +183,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\ sc/uiconfig/scalc/ui/optimalcolwidthdialog \ sc/uiconfig/scalc/ui/optimalrowheightdialog \ sc/uiconfig/scalc/ui/optsortlists \ + sc/uiconfig/scalc/ui/pagelistmenu \ sc/uiconfig/scalc/ui/pagetemplatedialog \ sc/uiconfig/scalc/ui/pastespecial \ sc/uiconfig/scalc/ui/paradialog \ diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx index a85a2ae5295a..2bb97d065cf8 100644 --- a/sc/source/ui/view/tabcont.cxx +++ b/sc/source/ui/view/tabcont.cxx @@ -22,8 +22,8 @@ #include <sfx2/docfile.hxx> #include <tools/urlobj.hxx> #include <vcl/commandevent.hxx> -#include <vcl/menu.hxx> #include <vcl/svapp.hxx> +#include <vcl/weldutils.hxx> #include <tabcont.hxx> #include <tabvwsh.hxx> #include <docsh.hxx> @@ -91,7 +91,10 @@ ScTabControl::ScTabControl( vcl::Window* pParent, ScViewData* pData ) IMPL_LINK(ScTabControl, ShowPageList, const CommandEvent &, rEvent, void) { - ScopedVclPtrInstance<PopupMenu> aPopup; + tools::Rectangle aRect(rEvent.GetMousePosPixel(), Size(1, 1)); + weld::Window* pPopupParent = weld::GetPopupParent(*this, aRect); + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pPopupParent, "modules/scalc/ui/pagelistmenu.ui")); + std::unique_ptr<weld::Menu> xPopup(xBuilder->weld_menu("menu")); sal_uInt16 nCurPageId = GetCurPageId(); @@ -99,21 +102,21 @@ IMPL_LINK(ScTabControl, ShowPageList, const CommandEvent &, rEvent, void) SCTAB nCount = rDoc.GetTableCount(); for (SCTAB i=0; i<nCount; ++i) { - if (rDoc.IsVisible(i)) - { - OUString aString; - if (rDoc.GetName(i, aString)) - { - sal_uInt16 nId = static_cast<sal_uInt16>(i)+1; - aPopup->InsertItem(nId, aString, MenuItemBits::CHECKABLE); - if (nId == nCurPageId) - aPopup->CheckItem(nId); - } - } + if (!rDoc.IsVisible(i)) + continue; + OUString aString; + if (!rDoc.GetName(i, aString)) + continue; + sal_uInt16 nId = static_cast<sal_uInt16>(i)+1; + OUString sId = OUString::number(nId); + xPopup->append_radio(sId, aString); + if (nId == nCurPageId) + xPopup->set_active(sId.toUtf8(), true); } - sal_uInt16 nItemId = aPopup->Execute( this, rEvent.GetMousePosPixel() ); - SwitchToPageId(nItemId); + OString sIdent(xPopup->popup_at_rect(pPopupParent, aRect)); + if (!sIdent.isEmpty()) + SwitchToPageId(sIdent.toUInt32()); } ScTabControl::~ScTabControl() diff --git a/sc/uiconfig/scalc/ui/pagelistmenu.ui b/sc/uiconfig/scalc/ui/pagelistmenu.ui new file mode 100644 index 000000000000..93bc5ea590d6 --- /dev/null +++ b/sc/uiconfig/scalc/ui/pagelistmenu.ui @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.38.1 --> +<interface domain="sc"> + <requires lib="gtk+" version="3.20"/> + <object class="GtkMenu" id="menu"> + <property name="visible">True</property> + <property name="can-focus">False</property> + </object> +</interface> |