summaryrefslogtreecommitdiff
path: root/cui/source
diff options
context:
space:
mode:
authorAndreas Heinisch <andreas.heinisch@yahoo.de>2020-07-14 19:45:51 +0200
committerMaxim Monastirsky <momonasmon@gmail.com>2020-09-21 01:39:22 +0200
commit327091048c8cbcad0178dfd8e06813153e861e5e (patch)
treef48cff9b847f81c53526e37faddcbbd347314aeb /cui/source
parentd3c870fcbfed4bbbcbc5d943c2526b353ad396c6 (diff)
tdf#134331 - Added possibility to sort macros via context menu
The user now has the possibility to sort the entries in various macro dialogs either alphabetically or in document order using a context menu. Change-Id: I064947daa9f9bca05cb28e4b2f65ff1c92689ae9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98783 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'cui/source')
-rw-r--r--cui/source/customize/cfgutil.cxx32
-rw-r--r--cui/source/inc/cfgutil.hxx2
2 files changed, 34 insertions, 0 deletions
diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx
index 13203e0926a9..f1c5ccef7221 100644
--- a/cui/source/customize/cfgutil.cxx
+++ b/cui/source/customize/cfgutil.cxx
@@ -49,6 +49,7 @@
#include <osl/diagnose.h>
#include <dialmgr.hxx>
#include <tools/diagnose_ex.h>
+#include <vcl/commandevent.hxx>
#include <vcl/commandinfoprovider.hxx>
#include <vcl/help.hxx>
#include <vcl/svapp.hxx>
@@ -1105,6 +1106,7 @@ SvxScriptSelectorDialog::SvxScriptSelectorDialog(
LINK( this, SvxScriptSelectorDialog, SelectHdl ) );
m_xCommands->connect_changed( LINK( this, SvxScriptSelectorDialog, SelectHdl ) );
m_xCommands->connect_row_activated( LINK( this, SvxScriptSelectorDialog, FunctionDoubleClickHdl ) );
+ m_xCommands->connect_popup_menu( LINK( this, SvxScriptSelectorDialog, ContextMenuHdl ) );
m_xOKButton->connect_clicked( LINK( this, SvxScriptSelectorDialog, ClickHdl ) );
m_xCancelButton->connect_clicked( LINK( this, SvxScriptSelectorDialog, ClickHdl ) );
@@ -1145,6 +1147,36 @@ IMPL_LINK_NOARG(SvxScriptSelectorDialog, FunctionDoubleClickHdl, weld::TreeView&
return true;
}
+IMPL_LINK(SvxScriptSelectorDialog, ContextMenuHdl, const CommandEvent&, rCEvt, bool)
+{
+ weld::TreeView& xTreeView = m_xCommands->get_widget();
+ if (rCEvt.GetCommand() != CommandEventId::ContextMenu || !xTreeView.n_children())
+ return false;
+
+ std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(&xTreeView, "modules/BasicIDE/ui/sortmenu.ui"));
+ std::unique_ptr<weld::Menu> xPopup(xBuilder->weld_menu("sortmenu"));
+ std::unique_ptr<weld::Menu> xDropMenu(xBuilder->weld_menu("sortsubmenu"));
+ xDropMenu->set_active("alphabetically", xTreeView.get_sort_order());
+ xDropMenu->set_active("properorder", !xTreeView.get_sort_order());
+
+ OString sCommand(xPopup->popup_at_rect(&xTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1))));
+ if (sCommand == "alphabetically")
+ {
+ xTreeView.make_sorted();
+ }
+ else if (sCommand == "properorder")
+ {
+ xTreeView.make_unsorted();
+ m_xCategories->GroupSelected();
+ }
+ else if (!sCommand.isEmpty())
+ {
+ SAL_WARN("cui.customize", "Unknown context menu action: " << sCommand );
+ }
+
+ return true;
+}
+
// Check if command is selected and enable the OK button accordingly
// Grab the help text for this id if available and update the description field
void
diff --git a/cui/source/inc/cfgutil.hxx b/cui/source/inc/cfgutil.hxx
index b9ee13450422..c4d50e2aeb12 100644
--- a/cui/source/inc/cfgutil.hxx
+++ b/cui/source/inc/cfgutil.hxx
@@ -111,6 +111,7 @@ public:
CuiConfigFunctionListBox(std::unique_ptr<weld::TreeView> xTreeView);
void set_sensitive(bool bSensitive) { m_xTreeView->set_sensitive(bSensitive); }
void connect_changed(const Link<weld::TreeView&, void>& rLink) { m_xTreeView->connect_changed(rLink); }
+ void connect_popup_menu(const Link<const CommandEvent&, bool>& rLink) { m_xTreeView->connect_popup_menu(rLink); }
void connect_row_activated(const Link<weld::TreeView&, bool>& rLink) { m_xTreeView->connect_row_activated(rLink); }
void freeze() { m_xTreeView->freeze(); }
void thaw() { m_xTreeView->thaw(); }
@@ -245,6 +246,7 @@ class SvxScriptSelectorDialog : public weld::GenericDialogController
DECL_LINK(ClickHdl, weld::Button&, void);
DECL_LINK(SelectHdl, weld::TreeView&, void);
DECL_LINK(FunctionDoubleClickHdl, weld::TreeView&, bool);
+ DECL_LINK(ContextMenuHdl, const CommandEvent&, bool);
void UpdateUI();