diff options
author | Muhammet Kara <muhammet.kara@pardus.org.tr> | 2016-09-01 12:09:43 +0300 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-09-05 09:28:01 +0000 |
commit | 4aca836a468bb0e2a7aae0800164e2b81f96243f (patch) | |
tree | de8e5ff552f7972467b763f97d41c3baefc87e0f /cui/source | |
parent | cbe43883e465336da55c96665f9bb7672ffa3bb0 (diff) |
tdf#82840 Add 'Reset' button to toolbar customization
Add 'Reset' button to the toolbar customization dialog,
and remove the 'Restore Default Settings' item from the
'Toolbar' menu.
Note that this 'Reset' button does not only reset
the selected item but also restores the selected
top-level toolbar to default settings.
Since there is no 'Restore Default Settings' option
in the other tabs of the config dialog, the button is
disabled and hidded in the parent class ctor, then
made visible again in the child class ctor.
In the following commits, more widgets will be added
and moved around to achieve the suggested appearance
and functionality in the related bug report.
Change-Id: I028c082daf423761e3511101069a0dc842743e3b
Reviewed-on: https://gerrit.libreoffice.org/28621
Tested-by: Jenkins <ci@libreoffice.org>
Tested-by: Yousuf Philips <philipz85@hotmail.com>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'cui/source')
-rw-r--r-- | cui/source/customize/cfg.cxx | 53 | ||||
-rw-r--r-- | cui/source/customize/cfg.hrc | 2 | ||||
-rw-r--r-- | cui/source/customize/cfg.src | 9 | ||||
-rw-r--r-- | cui/source/inc/cfg.hxx | 4 |
4 files changed, 39 insertions, 29 deletions
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index 828f46e7f063..ff6a74cdd98c 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -1751,6 +1751,7 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet) get(m_pAddCommandsButton, "add"); get(m_pModifyCommandButton, "modify"); get(m_pDeleteCommandButton, "deletebtn"); + get(m_pResetTopLevelButton, "resetbtn"); get(m_pMoveUpButton, "up"); get(m_pMoveDownButton, "down"); get(m_pSaveInListBox, "savein"); @@ -1763,6 +1764,10 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet) m_pDescriptionField->SetControlBackground( GetSettings().GetStyleSettings().GetDialogColor() ); m_pDescriptionField->EnableCursor( false ); + + // This button is applicable only for the toolbar config tab + m_pResetTopLevelButton->Enable( false ); + m_pResetTopLevelButton->Hide(); } SvxConfigPage::~SvxConfigPage() @@ -1783,6 +1788,7 @@ void SvxConfigPage::dispose() m_pAddCommandsButton.clear(); m_pModifyCommandButton.clear(); m_pDeleteCommandButton.clear(); + m_pResetTopLevelButton.clear(); m_pMoveUpButton.clear(); m_pMoveDownButton.clear(); m_pSaveInListBox.clear(); @@ -3101,6 +3107,9 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(vcl::Window *pParent, const SfxItemSe m_pContents->set_label(CUI_RES(RID_SVXSTR_TOOLBAR_CONTENT)); m_pContentsLabel->SetText( CUI_RES( RID_SVXSTR_COMMANDS ) ); + // The reset button will be used in the toolbar config tab + m_pResetTopLevelButton->Show(); + m_pTopLevelListBox->SetSelectHdl( LINK( this, SvxToolbarConfigPage, SelectToolbar ) ); m_pContentsListBox->SetSelectHdl( @@ -3115,6 +3124,9 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(vcl::Window *pParent, const SfxItemSe m_pDeleteCommandButton->SetClickHdl ( LINK( this, SvxToolbarConfigPage, DeleteCommandHdl ) ); + m_pResetTopLevelButton->SetClickHdl ( + LINK( this, SvxToolbarConfigPage, ResetTopLevelHdl ) ); + m_pMoveUpButton->SetClickHdl ( LINK( this, SvxToolbarConfigPage, MoveHdl) ); m_pMoveDownButton->SetClickHdl ( LINK( this, SvxToolbarConfigPage, MoveHdl) ); // Always enable Up and Down buttons @@ -3309,23 +3321,6 @@ IMPL_LINK_TYPED( SvxToolbarConfigPage, ToolbarSelectHdl, MenuButton *, pButton, } break; } - case ID_DEFAULT_STYLE: - { - ScopedVclPtrInstance<MessageDialog> qbox(this, - CUI_RES(RID_SVXSTR_CONFIRM_RESTORE_DEFAULT), VclMessageType::Question, VCL_BUTTONS_YES_NO); - - if ( qbox->Execute() == RET_YES ) - { - ToolbarSaveInData* pSaveInData_ = - static_cast<ToolbarSaveInData*>(GetSaveInData()); - - pSaveInData_->RestoreToolbar( pToolbar ); - - m_pTopLevelListBox->GetSelectHdl().Call( *m_pTopLevelListBox ); - } - - break; - } case ID_ICONS_ONLY: { pToolbar->SetStyle( 0 ); @@ -4543,6 +4538,7 @@ IMPL_LINK_NOARG_TYPED( SvxToolbarConfigPage, SelectToolbar, ListBox&, void ) m_pModifyCommandButton->Enable( false ); m_pAddCommandsButton->Enable( false ); m_pDeleteCommandButton->Enable( false ); + m_pResetTopLevelButton->Enable( false ); return; } @@ -4550,12 +4546,12 @@ IMPL_LINK_NOARG_TYPED( SvxToolbarConfigPage, SelectToolbar, ListBox&, void ) m_pModifyTopLevelButton->Enable(); m_pModifyCommandButton->Enable(); m_pAddCommandsButton->Enable(); + m_pResetTopLevelButton->Enable( !pToolbar->IsRenamable() ); PopupMenu* pPopup = m_pModifyTopLevelButton->GetPopupMenu(); pPopup->EnableItem( ID_DELETE, pToolbar->IsDeletable() ); pPopup->EnableItem( ID_RENAME, pToolbar->IsRenamable() ); - pPopup->EnableItem( ID_DEFAULT_STYLE, !pToolbar->IsRenamable() ); switch( pToolbar->GetStyle() ) { @@ -4686,6 +4682,27 @@ IMPL_LINK_NOARG_TYPED( SvxToolbarConfigPage, DeleteCommandHdl, Button *, void ) DeleteSelectedContent(); } +IMPL_LINK_NOARG_TYPED( SvxToolbarConfigPage, ResetTopLevelHdl, Button *, void ) +{ + sal_Int32 nSelectionPos = m_pTopLevelListBox->GetSelectEntryPos(); + + SvxConfigEntry* pToolbar = + static_cast<SvxConfigEntry*>(m_pTopLevelListBox->GetEntryData( nSelectionPos )); + + ScopedVclPtrInstance<MessageDialog> qbox(this, + CUI_RES(RID_SVXSTR_CONFIRM_RESTORE_DEFAULT), VclMessageType::Question, VCL_BUTTONS_YES_NO); + + if ( qbox->Execute() == RET_YES ) + { + ToolbarSaveInData* pSaveInData_ = + static_cast<ToolbarSaveInData*>(GetSaveInData()); + + pSaveInData_->RestoreToolbar( pToolbar ); + + m_pTopLevelListBox->GetSelectHdl().Call( *m_pTopLevelListBox ); + } +} + IMPL_LINK_NOARG_TYPED( SvxToolbarConfigPage, AddFunctionHdl, SvxScriptSelectorDialog&, void ) { AddFunction(); diff --git a/cui/source/customize/cfg.hrc b/cui/source/customize/cfg.hrc index 6a837139e858..496b8cff44d3 100644 --- a/cui/source/customize/cfg.hrc +++ b/cui/source/customize/cfg.hrc @@ -24,7 +24,7 @@ #define ID_DELETE (44 + CFG_OFFSET) #define ID_BEGIN_GROUP (46 + CFG_OFFSET) -#define ID_DEFAULT_STYLE (47 + CFG_OFFSET) +// There is a gap here #define ID_ICONS_ONLY (48 + CFG_OFFSET) #define ID_ICONS_AND_TEXT (49 + CFG_OFFSET) #define ID_ICON_ONLY (50 + CFG_OFFSET) diff --git a/cui/source/customize/cfg.src b/cui/source/customize/cfg.src index a354c2425dbd..fd0b5654a40b 100644 --- a/cui/source/customize/cfg.src +++ b/cui/source/customize/cfg.src @@ -46,15 +46,6 @@ Menu MODIFY_TOOLBAR }; MenuItem { - Identifier = ID_DEFAULT_STYLE ; - Text [ en-US ] = "Restore Default Settings" ; - }; - MenuItem - { - Separator = TRUE ; - }; - MenuItem - { Identifier = ID_ICONS_ONLY ; RadioCheck = TRUE ; AutoCheck = TRUE ; diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx index 1b6cfa179b7c..f17175eb0ceb 100644 --- a/cui/source/inc/cfg.hxx +++ b/cui/source/inc/cfg.hxx @@ -376,8 +376,9 @@ protected: VclPtr<PushButton> m_pAddCommandsButton; VclPtr<MenuButton> m_pModifyCommandButton; - VclPtr<PushButton> m_pDeleteCommandButton; + // Resets the top level toolbar to default settings + VclPtr<PushButton> m_pResetTopLevelButton; VclPtr<PushButton> m_pMoveUpButton; VclPtr<PushButton> m_pMoveDownButton; @@ -570,6 +571,7 @@ private: DECL_LINK_TYPED( NewToolbarHdl, Button *, void ); DECL_LINK_TYPED( AddCommandsHdl, Button *, void ); DECL_LINK_TYPED( DeleteCommandHdl, Button *, void ); + DECL_LINK_TYPED( ResetTopLevelHdl, Button *, void ); DECL_LINK_TYPED( AddFunctionHdl, SvxScriptSelectorDialog&, void ); DECL_LINK_TYPED( MoveHdl, Button *, void ); |