summaryrefslogtreecommitdiff
path: root/basctl
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 /basctl
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 'basctl')
-rw-r--r--basctl/UIConfig_basicide.mk1
-rw-r--r--basctl/source/basicide/macrodlg.cxx33
-rw-r--r--basctl/source/basicide/macrodlg.hxx1
-rw-r--r--basctl/uiconfig/basicide/ui/sortmenu.ui42
4 files changed, 75 insertions, 2 deletions
diff --git a/basctl/UIConfig_basicide.mk b/basctl/UIConfig_basicide.mk
index 7593e5a83a62..2c23fbfb58af 100644
--- a/basctl/UIConfig_basicide.mk
+++ b/basctl/UIConfig_basicide.mk
@@ -53,6 +53,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/BasicIDE,\
basctl/uiconfig/basicide/ui/modulepage \
basctl/uiconfig/basicide/ui/newlibdialog \
basctl/uiconfig/basicide/ui/organizedialog \
+ basctl/uiconfig/basicide/ui/sortmenu \
))
# vim: set noet sw=4 ts=4:
diff --git a/basctl/source/basicide/macrodlg.cxx b/basctl/source/basicide/macrodlg.cxx
index 0ee787b970bf..24cb210ea7e3 100644
--- a/basctl/source/basicide/macrodlg.cxx
+++ b/basctl/source/basicide/macrodlg.cxx
@@ -39,6 +39,7 @@
#include <sfx2/request.hxx>
#include <sfx2/sfxsids.hrc>
#include <tools/debug.hxx>
+#include <vcl/commandevent.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
#include <osl/diagnose.h>
@@ -76,8 +77,6 @@ MacroChooser::MacroChooser(weld::Window* pParnt, const Reference< frame::XFrame
{
m_xBasicBox->set_size_request(m_xBasicBox->get_approximate_digit_width() * 30, m_xBasicBox->get_height_rows(18));
m_xMacroBox->set_size_request(m_xMacroBox->get_approximate_digit_width() * 30, m_xMacroBox->get_height_rows(18));
- // tdf#70813 The macros should be listed alphabetically
- m_xMacroBox->make_sorted();
m_aMacrosInTxtBaseStr = m_xMacrosInTxt->get_label();
@@ -102,6 +101,7 @@ MacroChooser::MacroChooser(weld::Window* pParnt, const Reference< frame::XFrame
m_xMacroBox->connect_row_activated( LINK( this, MacroChooser, MacroDoubleClickHdl ) );
m_xMacroBox->connect_changed( LINK( this, MacroChooser, MacroSelectHdl ) );
+ m_xMacroBox->connect_popup_menu( LINK( this, MacroChooser, ContextMenuHdl ) );
m_xBasicBox->SetMode( BrowseMode::Modules );
@@ -755,6 +755,35 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void)
}
}
+IMPL_LINK(MacroChooser, ContextMenuHdl, const CommandEvent&, rCEvt, bool)
+{
+ if (rCEvt.GetCommand() != CommandEventId::ContextMenu || !m_xMacroBox->n_children())
+ return false;
+
+ std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(m_xMacroBox.get(), "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", m_xMacroBox->get_sort_order());
+ xDropMenu->set_active("properorder", !m_xMacroBox->get_sort_order());
+
+ OString sCommand(xPopup->popup_at_rect(m_xMacroBox.get(), tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1))));
+ if (sCommand == "alphabetically")
+ {
+ m_xMacroBox->make_sorted();
+ }
+ else if (sCommand == "properorder")
+ {
+ m_xMacroBox->make_unsorted();
+ BasicSelectHdl(m_xBasicBox->get_widget());
+ }
+ else if (!sCommand.isEmpty())
+ {
+ SAL_WARN("basctl.basicide", "Unknown context menu action: " << sCommand );
+ }
+
+ return true;
+}
+
void MacroChooser::UpdateFields()
{
auto nMacroEntry = m_xMacroBox->get_selected_index();
diff --git a/basctl/source/basicide/macrodlg.hxx b/basctl/source/basicide/macrodlg.hxx
index 0d239477206a..0e50ee5de02b 100644
--- a/basctl/source/basicide/macrodlg.hxx
+++ b/basctl/source/basicide/macrodlg.hxx
@@ -58,6 +58,7 @@ private:
DECL_LINK(MacroDoubleClickHdl, weld::TreeView&, bool);
DECL_LINK(BasicSelectHdl, weld::TreeView&, void);
DECL_LINK(EditModifyHdl, weld::Entry&, void);
+ DECL_LINK(ContextMenuHdl, const CommandEvent&, bool);
DECL_LINK(ButtonHdl, weld::Button&, void);
void CheckButtons();
diff --git a/basctl/uiconfig/basicide/ui/sortmenu.ui b/basctl/uiconfig/basicide/ui/sortmenu.ui
new file mode 100644
index 000000000000..c82c5abb2186
--- /dev/null
+++ b/basctl/uiconfig/basicide/ui/sortmenu.ui
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.0 -->
+<interface domain="basctl">
+ <requires lib="gtk+" version="3.18"/>
+ <object class="GtkMenu" id="sortmenu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkMenuItem">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="sortmenu|macrosort">_Sorting</property>
+ <property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu" id="sortsubmenu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkRadioMenuItem" id="alphabetically">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="sortmenu|alphabetically">_Alphabetically</property>
+ <property name="use_underline">True</property>
+ <property name="draw_as_radio">True</property>
+ <property name="group">properorder</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkRadioMenuItem" id="properorder">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="sortmenu|properorder">_Proper order</property>
+ <property name="draw_as_radio">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface> \ No newline at end of file