summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorSarper Akdemir <q.sarperakdemir@gmail.com>2020-02-14 13:17:46 +0300
committerMuhammet Kara <muhammet.kara@collabora.com>2020-02-28 18:32:54 +0100
commitd54202ff690e4e97e018461cc6dc3dfadd36a702 (patch)
tree5f60f9c473b30e0f59bbf13a6f773595e1e4e759 /cui
parent531f078f3371e909b03b358bc5c9d70df083555f (diff)
tdf#112135: Provide controls through context menu in lists of Customize dialog
Introduced two new handlers to SvxMenuConfigPage and SvxToolbarConfigPage. Each handler is connected to connect_popup_menu() call of corresponding list. All of the context menus use entrycontextmenu.ui Change-Id: I309672c41631b7acb58209b01efbe24c0bb0d947 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88676 Reviewed-by: PhD. Ayhan YALÇINSOY <ayhanyalcinsoy@pisilinux.org> Reviewed-by: Muhammet Kara <muhammet.kara@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'cui')
-rw-r--r--cui/UIConfig_cui.mk1
-rw-r--r--cui/source/customize/SvxMenuConfigPage.cxx80
-rw-r--r--cui/source/customize/SvxToolbarConfigPage.cxx79
-rw-r--r--cui/source/inc/SvxMenuConfigPage.hxx2
-rw-r--r--cui/source/inc/SvxToolbarConfigPage.hxx3
-rw-r--r--cui/uiconfig/ui/entrycontextmenu.ui57
6 files changed, 222 insertions, 0 deletions
diff --git a/cui/UIConfig_cui.mk b/cui/UIConfig_cui.mk
index fb243e4eb3c5..ca8911310c2c 100644
--- a/cui/UIConfig_cui.mk
+++ b/cui/UIConfig_cui.mk
@@ -53,6 +53,7 @@ $(eval $(call gb_UIConfig_add_uifiles,cui,\
cui/uiconfig/ui/editdictionarydialog \
cui/uiconfig/ui/editmodulesdialog \
cui/uiconfig/ui/embossdialog \
+ cui/uiconfig/ui/entrycontextmenu \
cui/uiconfig/ui/eventassigndialog \
cui/uiconfig/ui/eventassignpage \
cui/uiconfig/ui/fontfragment \
diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index bb4ebbf51cae..d2cd438d4e35 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -22,6 +22,7 @@
#include <vcl/weld.hxx>
#include <vcl/svapp.hxx>
+#include <vcl/commandevent.hxx>
#include <strings.hrc>
#include <helpids.h>
@@ -55,6 +56,10 @@ SvxMenuConfigPage::SvxMenuConfigPage(weld::Container* pPage, weld::DialogControl
rTreeView.connect_changed(
LINK( this, SvxMenuConfigPage, SelectMenuEntry ) );
+ rTreeView.connect_popup_menu( LINK( this, SvxMenuConfigPage, ContentContextMenuHdl ) );
+
+ m_xFunctions->get_widget().connect_popup_menu(
+ LINK( this, SvxMenuConfigPage, FunctionContextMenuHdl ) );
m_xGearBtn->connect_selected(LINK(this, SvxMenuConfigPage, GearHdl));
@@ -515,4 +520,79 @@ SaveInData* SvxMenuConfigPage::CreateSaveInData(
return static_cast< SaveInData* >( new MenuSaveInData( xCfgMgr, xParentCfgMgr, aModuleId, bDocConfig ) );
}
+IMPL_LINK( SvxMenuConfigPage, ContentContextMenuHdl, const CommandEvent&, rCEvt, bool )
+{
+ if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
+ return false;
+
+ weld::TreeView& rTreeView = m_xContentsListBox->get_widget();
+
+ // Select clicked entry
+ std::unique_ptr<weld::TreeIter> rIter(rTreeView.make_iterator());
+ rTreeView.get_dest_row_at_pos( rCEvt.GetMousePosPixel(), &*rIter );
+ rTreeView.select(*rIter);
+ SelectMenuEntry( rTreeView );
+
+ int nSelectIndex = m_xContentsListBox->get_selected_index();
+
+ bool bIsSeparator =
+ nSelectIndex != -1 && reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nSelectIndex).toInt64())->IsSeparator();
+ bool bIsValidSelection =
+ !( m_xContentsListBox->n_children() == 0 || nSelectIndex == -1 );
+
+ std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder( &rTreeView, "cui/ui/entrycontextmenu.ui" ) );
+ auto xContextMenu = xBuilder->weld_menu("menu");
+ xContextMenu->set_visible("add", false);
+ xContextMenu->set_visible("remove", bIsValidSelection);
+ xContextMenu->set_visible("rename", bIsValidSelection && !bIsSeparator);
+ xContextMenu->set_visible("changeIcon", false);
+ xContextMenu->set_visible("resetIcon", false);
+ xContextMenu->set_visible("restoreDefault", false);
+ OString sCommand(xContextMenu->popup_at_rect( &rTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1) ) ) );
+
+ if ( sCommand == "remove")
+ {
+ RemoveCommandHdl( *m_xRemoveCommandButton );
+ }
+ else if ( sCommand == "rename" )
+ {
+ ModifyItemHdl( "renameItem" );
+ }
+ else if ( !sCommand.isEmpty() )
+ SAL_WARN("cui.customize", "Unknown context menu action: " << sCommand );
+ return true;
+}
+
+IMPL_LINK( SvxMenuConfigPage, FunctionContextMenuHdl, const CommandEvent&, rCEvt, bool )
+{
+ if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
+ return false;
+
+ weld::TreeView& rTreeView = m_xFunctions->get_widget();
+
+ // Select clicked entry
+ std::unique_ptr<weld::TreeIter> rIter(rTreeView.make_iterator());
+ rTreeView.get_dest_row_at_pos( rCEvt.GetMousePosPixel(), &*rIter );
+ rTreeView.select(*rIter);
+ SelectFunctionHdl( rTreeView );
+
+ std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder( &rTreeView, "cui/ui/entrycontextmenu.ui" ) );
+ auto xContextMenu = xBuilder->weld_menu("menu");
+ xContextMenu->set_visible("add", true);
+ xContextMenu->set_visible("remove", false);
+ xContextMenu->set_visible("rename", false);
+ xContextMenu->set_visible("changeIcon", false);
+ xContextMenu->set_visible("resetIcon", false);
+ xContextMenu->set_visible("restoreDefault", false);
+ OString sCommand(xContextMenu->popup_at_rect( &rTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1) ) ) );
+
+ if ( sCommand == "add")
+ {
+ AddCommandHdl( *m_xAddCommandButton );
+ }
+ else if ( !sCommand.isEmpty() )
+ SAL_WARN("cui.customize", "Unknown context menu action: " << sCommand );
+ return true;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/customize/SvxToolbarConfigPage.cxx b/cui/source/customize/SvxToolbarConfigPage.cxx
index 372840d91287..6fa173e958a1 100644
--- a/cui/source/customize/SvxToolbarConfigPage.cxx
+++ b/cui/source/customize/SvxToolbarConfigPage.cxx
@@ -23,6 +23,7 @@
#include <vcl/event.hxx>
#include <vcl/weld.hxx>
#include <vcl/svapp.hxx>
+#include <vcl/commandevent.hxx>
#include <sfx2/sfxsids.hrc>
#include <svl/stritem.hxx>
@@ -82,6 +83,10 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(weld::Container* pPage, weld::DialogC
rTreeView.connect_changed(
LINK( this, SvxToolbarConfigPage, SelectToolbarEntry ) );
+ rTreeView.connect_popup_menu( LINK( this, SvxToolbarConfigPage, ContentContextMenuHdl ) );
+
+ m_xFunctions->get_widget().connect_popup_menu(
+ LINK( this, SvxToolbarConfigPage, FunctionContextMenuHdl ) );
m_xTopLevelListBox->set_help_id ( HID_SVX_TOPLEVELLISTBOX );
m_xSaveInListBox->set_help_id( HID_SVX_SAVE_IN );
@@ -882,4 +887,78 @@ IMPL_LINK(SvxToolbarEntriesListBox, KeyInputHdl, const KeyEvent&, rKeyEvent, boo
return SvxMenuEntriesListBox::KeyInputHdl(rKeyEvent);
}
+IMPL_LINK( SvxToolbarConfigPage, ContentContextMenuHdl, const CommandEvent&, rCEvt, bool )
+{
+ if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
+ return false;
+
+ weld::TreeView& rTreeView = m_xContentsListBox->get_widget();
+
+ // Select clicked entry
+ std::unique_ptr<weld::TreeIter> rIter(rTreeView.make_iterator());
+ rTreeView.get_dest_row_at_pos( rCEvt.GetMousePosPixel(), &*rIter );
+ rTreeView.select(*rIter);
+ SelectToolbarEntry( rTreeView );
+
+ int nSelectIndex = m_xContentsListBox->get_selected_index();
+
+ bool bIsSeparator =
+ nSelectIndex != -1 && reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nSelectIndex).toInt64())->IsSeparator();
+ bool bIsValidSelection =
+ !( m_xContentsListBox->n_children() == 0 || nSelectIndex == -1 );
+
+ std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder( &rTreeView, "cui/ui/entrycontextmenu.ui" ) );
+ auto xContextMenu = xBuilder->weld_menu("menu");
+ xContextMenu->set_visible("add", false);
+ xContextMenu->set_visible("remove", bIsValidSelection);
+ xContextMenu->set_visible("rename", bIsValidSelection && !bIsSeparator);
+ xContextMenu->set_visible("changeIcon", bIsValidSelection && !bIsSeparator);
+ xContextMenu->set_visible("resetIcon", bIsValidSelection && !bIsSeparator);
+ xContextMenu->set_visible("restoreDefault", bIsValidSelection && !bIsSeparator);
+ OString sCommand(xContextMenu->popup_at_rect( &rTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1) ) ) );
+
+ if ( sCommand == "remove")
+ RemoveCommandHdl( *m_xRemoveCommandButton );
+ else if ( sCommand == "rename" )
+ ModifyItemHdl( "renameItem" );
+ else if ( sCommand == "changeIcon" )
+ ModifyItemHdl( "changeIcon" );
+ else if ( sCommand == "resetIcon" )
+ ModifyItemHdl( "resetIcon" );
+ else if ( sCommand == "restoreDefault" )
+ ModifyItemHdl( "restoreItem" );
+ else if ( !sCommand.isEmpty() )
+ SAL_WARN("cui.customize", "Unknown context menu action: " << sCommand );
+ return true;
+}
+
+IMPL_LINK( SvxToolbarConfigPage, FunctionContextMenuHdl, const CommandEvent&, rCEvt, bool )
+{
+ if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
+ return false;
+
+ weld::TreeView& rTreeView = m_xFunctions->get_widget();
+
+ // Select clicked entry
+ std::unique_ptr<weld::TreeIter> rIter(rTreeView.make_iterator());
+ rTreeView.get_dest_row_at_pos( rCEvt.GetMousePosPixel(), &*rIter );
+ rTreeView.select(*rIter);
+ SelectFunctionHdl( rTreeView );
+ std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder( &rTreeView, "cui/ui/entrycontextmenu.ui" ) );
+ auto xContextMenu = xBuilder->weld_menu("menu");
+ xContextMenu->set_visible("add", true);
+ xContextMenu->set_visible("remove", false);
+ xContextMenu->set_visible("rename", false);
+ xContextMenu->set_visible("changeIcon", false);
+ xContextMenu->set_visible("resetIcon", false);
+ xContextMenu->set_visible("restoreDefault", false);
+ OString sCommand(xContextMenu->popup_at_rect( &rTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1) ) ) );
+
+ if ( sCommand == "add")
+ AddCommandHdl( *m_xAddCommandButton );
+ else if ( !sCommand.isEmpty() )
+ SAL_WARN("cui.customize", "Unknown context menu action: " << sCommand );
+ return true;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/inc/SvxMenuConfigPage.hxx b/cui/source/inc/SvxMenuConfigPage.hxx
index 9c98daee86ef..b5b09b726419 100644
--- a/cui/source/inc/SvxMenuConfigPage.hxx
+++ b/cui/source/inc/SvxMenuConfigPage.hxx
@@ -30,6 +30,8 @@ private:
bool m_bIsMenuBar;
DECL_LINK( SelectMenuEntry, weld::TreeView&, void );
+ DECL_LINK( ContentContextMenuHdl, const CommandEvent&, bool );
+ DECL_LINK( FunctionContextMenuHdl, const CommandEvent&, bool );
DECL_LINK( GearHdl, const OString&, void );
diff --git a/cui/source/inc/SvxToolbarConfigPage.hxx b/cui/source/inc/SvxToolbarConfigPage.hxx
index 5c13b4595f53..f367fea9ed5f 100644
--- a/cui/source/inc/SvxToolbarConfigPage.hxx
+++ b/cui/source/inc/SvxToolbarConfigPage.hxx
@@ -37,6 +37,9 @@ private:
DECL_LINK( SelectCategory, weld::ComboBox&, void );
+ DECL_LINK( ContentContextMenuHdl, const CommandEvent&, bool );
+ DECL_LINK( FunctionContextMenuHdl, const CommandEvent&, bool );
+
DECL_LINK( AddCommandHdl, weld::Button&, void );
DECL_LINK( RemoveCommandHdl, weld::Button&, void );
diff --git a/cui/uiconfig/ui/entrycontextmenu.ui b/cui/uiconfig/ui/entrycontextmenu.ui
new file mode 100644
index 000000000000..dabc290980c1
--- /dev/null
+++ b/cui/uiconfig/ui/entrycontextmenu.ui
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.0 -->
+<interface domain="svt">
+ <requires lib="gtk+" version="3.18"/>
+ <object class="GtkMenu" id="menu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkMenuItem" id="remove">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="entrycontextmenu|remove">_Remove</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="rename">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="entrycontextmenu|rename">R_ename...</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="add">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="entrycontextmenu|add">_Add</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="changeIcon">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="entrycontextmenu|changeIcon">_Change Icon...</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="resetIcon">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="entrycontextmenu|resetIcon">Re_set Icon</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="restoreDefault">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="entrycontextmenu|restoreDefault">Restore _Default Command</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ </object>
+</interface>