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
This commit is contained in:
Sarper Akdemir
2020-02-28 18:32:54 +01:00
committed by Muhammet Kara
parent 531f078f33
commit d54202ff69
6 changed files with 222 additions and 0 deletions
+1
View File
@@ -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 \
@@ -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: */
@@ -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: */
+2
View File
@@ -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 );
+3
View File
@@ -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 );
+57
View File
@@ -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>