summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-12-10 12:45:16 +0000
committerCaolán McNamara <caolanm@redhat.com>2021-12-10 15:10:49 +0100
commita25a573d5714ab196bbcdbd3a8dcb6d6d7814882 (patch)
treedb08ac7f61c5aedf7afbbfc95bdea7b6db8e0a4e /sc
parent0f17661e045e3e3732cec6e493cd20ac65dbe451 (diff)
Related: tdf#146018 allow user to grow/shrink autofilter checklist by a row
Change-Id: If337f62032a8db6d1d01c66ae851a1111ad8b0bd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126636 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/cctrl/checklistmenu.cxx37
-rw-r--r--sc/source/ui/inc/checklistmenu.hxx6
-rw-r--r--sc/uiconfig/scalc/ui/filterdropdown.ui20
3 files changed, 61 insertions, 2 deletions
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx
index cc16644dd72c..8615fee77cfe 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -22,9 +22,9 @@
#include <globstr.hrc>
#include <scresid.hxx>
+#include <vcl/commandevent.hxx>
#include <vcl/decoview.hxx>
#include <vcl/event.hxx>
-#include <vcl/dockwin.hxx>
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
#include <vcl/virdev.hxx>
@@ -478,9 +478,11 @@ ScCheckListMenuControl::ScCheckListMenuControl(weld::Widget* pParent, ScViewData
, mxButtonBox(mxBuilder->weld_box("buttonbox"))
, mxBtnOk(mxBuilder->weld_button("ok"))
, mxBtnCancel(mxBuilder->weld_button("cancel"))
+ , mxContextMenu(mxBuilder->weld_menu("contextmenu"))
, mxDropDown(mxMenu->create_virtual_device())
, mnCheckWidthReq(-1)
, mnWndWidth(0)
+ , mnCheckListVisibleRows(nCheckListVisibleRows)
, mePrevToggleAllState(TRISTATE_INDET)
, mnSelectedMenu(MENU_NOT_SELECTED)
, mrViewData(rViewData)
@@ -499,6 +501,8 @@ ScCheckListMenuControl::ScCheckListMenuControl(weld::Widget* pParent, ScViewData
mxEdSearch->connect_mouse_move(LINK(this, ScCheckListMenuControl, MouseEnterHdl));
mxListChecks->connect_mouse_move(LINK(this, ScCheckListMenuControl, MouseEnterHdl));
mxTreeChecks->connect_mouse_move(LINK(this, ScCheckListMenuControl, MouseEnterHdl));
+ mxListChecks->connect_popup_menu(LINK(this, ScCheckListMenuControl, CommandHdl));
+ mxTreeChecks->connect_popup_menu(LINK(this, ScCheckListMenuControl, CommandHdl));
mxChkToggleAll->connect_mouse_move(LINK(this, ScCheckListMenuControl, MouseEnterHdl));
mxBtnSelectSingle->connect_mouse_move(LINK(this, ScCheckListMenuControl, MouseEnterHdl));
mxBtnUnselectSingle->connect_mouse_move(LINK(this, ScCheckListMenuControl, MouseEnterHdl));
@@ -521,7 +525,7 @@ ScCheckListMenuControl::ScCheckListMenuControl(weld::Widget* pParent, ScViewData
mpChecks = mxListChecks.get();
}
- int nChecksHeight = mxTreeChecks->get_height_rows(nCheckListVisibleRows);
+ int nChecksHeight = mxTreeChecks->get_height_rows(mnCheckListVisibleRows);
if (nWidth != -1)
{
mnCheckWidthReq = nWidth - nBorderWidth * 2 - 4;
@@ -631,6 +635,35 @@ void ScCheckListMenuControl::selectCurrentMemberOnly(bool bSet)
mpChecks->set_toggle(*xEntry, bSet ? TRISTATE_TRUE : TRISTATE_FALSE);
}
+IMPL_LINK(ScCheckListMenuControl, CommandHdl, const CommandEvent&, rCEvt, bool)
+{
+ if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
+ return false;
+
+ mxContextMenu->set_sensitive("less", mnCheckListVisibleRows > 4);
+ mxContextMenu->set_sensitive("more", mnCheckListVisibleRows < 42);
+
+ OString sCommand = mxContextMenu->popup_at_rect(mpChecks, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1)));
+ if (sCommand.isEmpty())
+ return true;
+
+ if (sCommand == "more")
+ ++mnCheckListVisibleRows;
+ else if (sCommand == "less")
+ --mnCheckListVisibleRows;
+ ResizeToRequest();
+
+ return true;
+}
+
+void ScCheckListMenuControl::ResizeToRequest()
+{
+ int nChecksHeight = mxTreeChecks->get_height_rows(mnCheckListVisibleRows);
+ mxTreeChecks->set_size_request(mnCheckWidthReq, nChecksHeight);
+ mxListChecks->set_size_request(mnCheckWidthReq, nChecksHeight);
+ mxPopover->resize_to_request();
+}
+
IMPL_LINK(ScCheckListMenuControl, ButtonHdl, weld::Button&, rBtn, void)
{
if (&rBtn == mxBtnOk.get())
diff --git a/sc/source/ui/inc/checklistmenu.hxx b/sc/source/ui/inc/checklistmenu.hxx
index e414a224b150..87a3e4325e45 100644
--- a/sc/source/ui/inc/checklistmenu.hxx
+++ b/sc/source/ui/inc/checklistmenu.hxx
@@ -251,6 +251,10 @@ private:
DECL_LINK(SetDropdownPosHdl, void*, void);
+ DECL_LINK(CommandHdl, const CommandEvent&, bool);
+
+ void ResizeToRequest();
+
private:
std::unique_ptr<weld::Builder> mxBuilder;
std::unique_ptr<weld::Popover> mxPopover;
@@ -271,6 +275,7 @@ private:
std::unique_ptr<weld::Box> mxButtonBox;
std::unique_ptr<weld::Button> mxBtnOk;
std::unique_ptr<weld::Button> mxBtnCancel;
+ std::unique_ptr<weld::Menu> mxContextMenu;
ScopedVclPtr<VirtualDevice> mxDropDown;
@@ -286,6 +291,7 @@ private:
Size maAllocatedSize;
int mnCheckWidthReq; /// matching width request for mxChecks
int mnWndWidth; /// whole window width.
+ int mnCheckListVisibleRows;
TriState mePrevToggleAllState;
size_t mnSelectedMenu;
diff --git a/sc/uiconfig/scalc/ui/filterdropdown.ui b/sc/uiconfig/scalc/ui/filterdropdown.ui
index caa4506aa453..a6ca98f9169a 100644
--- a/sc/uiconfig/scalc/ui/filterdropdown.ui
+++ b/sc/uiconfig/scalc/ui/filterdropdown.ui
@@ -2,6 +2,26 @@
<!-- Generated with glade 3.38.2 -->
<interface domain="sc">
<requires lib="gtk+" version="3.20"/>
+ <object class="GtkMenu" id="contextmenu">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <child>
+ <object class="GtkMenuItem" id="more">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes" context="filterdropdown|more">Add row</property>
+ <property name="use-underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="less">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes" context="filterdropdown|less">Remove row</property>
+ <property name="use-underline">True</property>
+ </object>
+ </child>
+ </object>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can-focus">False</property>