Skip to content

Commit

Permalink
Implement "Insert" button in the Customize dialog
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mrkara authored and Katarina Behrens committed Aug 22, 2017
1 parent ce7db1f commit 3b5f4f9
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 4 deletions.
52 changes: 52 additions & 0 deletions cui/source/customize/SvxMenuConfigPage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand Down
37 changes: 37 additions & 0 deletions cui/source/customize/SvxToolbarConfigPage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
{
Expand Down
4 changes: 2 additions & 2 deletions cui/source/customize/cfg.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,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");
Expand All @@ -1144,6 +1143,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");
Expand Down Expand Up @@ -1178,9 +1178,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();
}
Expand Down
2 changes: 2 additions & 0 deletions cui/source/inc/SvxMenuConfigPage.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions cui/source/inc/SvxToolbarConfigPage.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion cui/source/inc/cfg.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ protected:

VclPtr<ListBox> m_pSaveInListBox;

VclPtr<SvxScriptSelectorDialog> m_pSelectorDlg;
VclPtr<MenuButton> m_pInsertBtn;

// Middle buttons
VclPtr<PushButton> m_pAddCommandButton;
Expand Down
22 changes: 21 additions & 1 deletion cui/uiconfig/ui/menuassignpage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>

0 comments on commit 3b5f4f9

Please sign in to comment.