summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorMuhammet Kara <muhammet.kara@pardus.org.tr>2017-08-20 12:55:45 +0300
committerKatarina Behrens <Katarina.Behrens@cib.de>2017-09-04 22:39:47 +0200
commit7e0ecdecb1131bffd263d0e51583a25991b9a878 (patch)
treea2f3d5fdf2672cccd757b6fa7fa035b01d904cb8 /cui
parent0114ef64fc357a0faa8b32cb1e79c0ed789d0de4 (diff)
Implement "Insert" button in the Customize dialog
Now the Insert button allows the user to insert separators to the toolbars, and separators and submenus to the menus and context menus. Change-Id: Ic520c78dee2152a0294e86d3bc7098a29155e4b9 Reviewed-on: https://gerrit.libreoffice.org/41360 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/customize/SvxMenuConfigPage.cxx52
-rw-r--r--cui/source/customize/SvxToolbarConfigPage.cxx37
-rw-r--r--cui/source/customize/cfg.cxx4
-rw-r--r--cui/source/inc/SvxMenuConfigPage.hxx2
-rw-r--r--cui/source/inc/SvxToolbarConfigPage.hxx2
-rw-r--r--cui/source/inc/cfg.hxx2
-rw-r--r--cui/uiconfig/ui/menuassignpage.ui22
7 files changed, 117 insertions, 4 deletions
diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index 3d0bdff25f73..4b3a69f6e2db 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -127,6 +127,9 @@ SvxMenuConfigPage::SvxMenuConfigPage(vcl::Window *pParent, const SfxItemSet& rSe
m_pAddCommandButton->SetClickHdl( LINK( this, SvxMenuConfigPage, AddCommandHdl ) );
m_pRemoveCommandButton->SetClickHdl( LINK( this, SvxMenuConfigPage, RemoveCommandHdl ) );
+
+ m_pInsertBtn->SetSelectHdl(
+ LINK( this, SvxMenuConfigPage, InsertHdl ) );
}
SvxMenuConfigPage::~SvxMenuConfigPage()
@@ -308,6 +311,55 @@ IMPL_LINK_NOARG( SvxMenuConfigPage, RemoveCommandHdl, Button *, void )
}
}
+IMPL_LINK( SvxMenuConfigPage, InsertHdl, MenuButton *, pButton, void )
+{
+ OString sIdent = pButton->GetCurItemIdent();
+
+ if (sIdent == "insertseparator")
+ {
+ SvxConfigEntry* pNewEntryData = new SvxConfigEntry;
+ pNewEntryData->SetUserDefined();
+ InsertEntry( pNewEntryData );
+ }
+ else if (sIdent == "insertsubmenu")
+ {
+ OUString aNewName;
+ OUString aDesc = CuiResId( RID_SVXSTR_SUBMENU_NAME );
+
+ VclPtrInstance< SvxNameDialog > pNameDialog( this, aNewName, aDesc );
+ pNameDialog->SetHelpId( HID_SVX_CONFIG_NAME_SUBMENU );
+ pNameDialog->SetText( CuiResId( RID_SVXSTR_ADD_SUBMENU ) );
+
+ if ( pNameDialog->Execute() == RET_OK )
+ {
+ pNameDialog->GetName(aNewName);
+
+ SvxConfigEntry* pNewEntryData =
+ new SvxConfigEntry( aNewName, aNewName, true );
+ pNewEntryData->SetName( aNewName );
+ pNewEntryData->SetUserDefined();
+
+ InsertEntry( pNewEntryData );
+
+ ReloadTopLevelListBox();
+
+ GetSaveInData()->SetModified();
+ }
+
+ }
+ else
+ {
+ //This block should never be reached
+ SAL_WARN("cui.customize", "Unknown insert option: " << sIdent);
+ return;
+ }
+
+ if ( GetSaveInData()->IsModified() )
+ {
+ UpdateButtonStates();
+ }
+}
+
SaveInData* SvxMenuConfigPage::CreateSaveInData(
const css::uno::Reference< css::ui::XUIConfigurationManager >& xCfgMgr,
const css::uno::Reference< css::ui::XUIConfigurationManager >& xParentCfgMgr,
diff --git a/cui/source/customize/SvxToolbarConfigPage.cxx b/cui/source/customize/SvxToolbarConfigPage.cxx
index 76a29b8acced..848c68980607 100644
--- a/cui/source/customize/SvxToolbarConfigPage.cxx
+++ b/cui/source/customize/SvxToolbarConfigPage.cxx
@@ -138,6 +138,13 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(vcl::Window *pParent, const SfxItemSe
m_pAddCommandButton->SetClickHdl( LINK( this, SvxToolbarConfigPage, AddCommandHdl ) );
m_pRemoveCommandButton->SetClickHdl( LINK( this, SvxToolbarConfigPage, RemoveCommandHdl ) );
+ m_pInsertBtn->SetSelectHdl(
+ LINK( this, SvxToolbarConfigPage, InsertHdl ) );
+ // "Insert Submenu" is irrelevant to the toolbars
+ PopupMenu* pPopup = m_pInsertBtn->GetPopupMenu();
+ pPopup->EnableItem(OString( "insertsubmenu"), false );
+ pPopup->RemoveDisabledEntries();
+
// default toolbar to select is standardbar unless a different one
// has been passed in
m_aURLToSelect = ITEM_TOOLBAR_URL;
@@ -336,6 +343,36 @@ IMPL_LINK_NOARG( SvxToolbarConfigPage, RemoveCommandHdl, Button *, void )
DeleteSelectedContent();
}
+IMPL_LINK( SvxToolbarConfigPage, InsertHdl, MenuButton *, pButton, void )
+{
+ OString sIdent = pButton->GetCurItemIdent();
+
+ if (sIdent == "insertseparator")
+ {
+ // Get the currently selected toolbar
+ SvxConfigEntry* pToolbar = GetTopLevelSelection();
+
+ SvxConfigEntry* pNewEntryData = new SvxConfigEntry;
+ pNewEntryData->SetUserDefined();
+
+ SvTreeListEntry* pNewLBEntry = InsertEntry( pNewEntryData );
+
+ m_pContentsListBox->SetCheckButtonInvisible( pNewLBEntry );
+ m_pContentsListBox->SetCheckButtonState(
+ pNewLBEntry, SvButtonState::Tristate );
+
+ static_cast<ToolbarSaveInData*>( GetSaveInData())->ApplyToolbar( pToolbar );
+
+ UpdateButtonStates();
+ }
+ else
+ {
+ //This block should never be reached
+ SAL_WARN("cui.customize", "Unknown insert option: " << sIdent);
+ return;
+ }
+}
+
void SvxToolbarConfigPage::UpdateButtonStates()
{
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 7883a3c13444..8e0989810b1d 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -1131,7 +1131,6 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet)
, bInitialised(false)
, pCurrentSaveInData(nullptr)
, m_pContentsListBox(nullptr)
- , m_pSelectorDlg(nullptr)
{
get(m_pSearchEdit, "searchEntry");
get(m_pCommandCategoryListBox, "commandcategorylist");
@@ -1145,6 +1144,7 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet)
get(m_pMoveUpButton, "up");
get(m_pMoveDownButton, "down");
get(m_pSaveInListBox, "savein");
+ get(m_pInsertBtn, "insert");
get(m_pDescriptionField, "desc");
m_pDescriptionField->set_height_request(m_pDescriptionField->GetTextHeight()*4);
get(m_pEntries, "entries");
@@ -1179,9 +1179,9 @@ void SvxConfigPage::dispose()
m_pMoveUpButton.clear();
m_pMoveDownButton.clear();
m_pSaveInListBox.clear();
+ m_pInsertBtn.clear();
m_pDescriptionField.clear();
- m_pSelectorDlg.disposeAndClear();
m_pContentsListBox.disposeAndClear();
SfxTabPage::dispose();
}
diff --git a/cui/source/inc/SvxMenuConfigPage.hxx b/cui/source/inc/SvxMenuConfigPage.hxx
index 162adc94c198..a0ba3abd1cbe 100644
--- a/cui/source/inc/SvxMenuConfigPage.hxx
+++ b/cui/source/inc/SvxMenuConfigPage.hxx
@@ -59,6 +59,8 @@ private:
DECL_LINK( AddCommandHdl, Button *, void );
DECL_LINK( RemoveCommandHdl, Button *, void );
+ DECL_LINK( InsertHdl, MenuButton *, void );
+
void Init() override;
void UpdateButtonStates() override;
short QueryReset() override;
diff --git a/cui/source/inc/SvxToolbarConfigPage.hxx b/cui/source/inc/SvxToolbarConfigPage.hxx
index 29e48078b596..2f7e0e48331e 100644
--- a/cui/source/inc/SvxToolbarConfigPage.hxx
+++ b/cui/source/inc/SvxToolbarConfigPage.hxx
@@ -60,6 +60,8 @@ private:
DECL_LINK( AddCommandHdl, Button *, void );
DECL_LINK( RemoveCommandHdl, Button *, void );
+ DECL_LINK( InsertHdl, MenuButton *, void );
+
void UpdateButtonStates() override;
short QueryReset() override;
void Init() override;
diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx
index f951acc8a137..555dba9ee30b 100644
--- a/cui/source/inc/cfg.hxx
+++ b/cui/source/inc/cfg.hxx
@@ -403,7 +403,7 @@ protected:
VclPtr<ListBox> m_pSaveInListBox;
- VclPtr<SvxScriptSelectorDialog> m_pSelectorDlg;
+ VclPtr<MenuButton> m_pInsertBtn;
// Middle buttons
VclPtr<PushButton> m_pAddCommandButton;
diff --git a/cui/uiconfig/ui/menuassignpage.ui b/cui/uiconfig/ui/menuassignpage.ui
index 9ad40abc03c9..1a0393941fb6 100644
--- a/cui/uiconfig/ui/menuassignpage.ui
+++ b/cui/uiconfig/ui/menuassignpage.ui
@@ -149,7 +149,7 @@
<property name="hexpand">True</property>
<property name="layout_style">start</property>
<child>
- <object class="GtkButton">
+ <object class="GtkButton" id="insert:insertmenu">
<property name="label" translatable="yes">Insert</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -556,6 +556,26 @@
</packing>
</child>
</object>
+ <object class="GtkMenu" id="insertmenu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkMenuItem" id="insertseparator">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Insert Separator</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="insertsubmenu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Insert Submenu</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ </object>
<object class="GtkSizeGroup" id="sizegroup1"/>
<object class="GtkSizeGroup" id="sizegroup2"/>
</interface>