Kaydet (Commit) 4aca836a authored tarafından Muhammet Kara's avatar Muhammet Kara Kaydeden (comit) Samuel Mehrbrodt

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/28621Tested-by: 's avatarJenkins <ci@libreoffice.org>
Tested-by: 's avatarYousuf Philips <philipz85@hotmail.com>
Reviewed-by: 's avatarSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
üst cbe43883
...@@ -1751,6 +1751,7 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet) ...@@ -1751,6 +1751,7 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet)
get(m_pAddCommandsButton, "add"); get(m_pAddCommandsButton, "add");
get(m_pModifyCommandButton, "modify"); get(m_pModifyCommandButton, "modify");
get(m_pDeleteCommandButton, "deletebtn"); get(m_pDeleteCommandButton, "deletebtn");
get(m_pResetTopLevelButton, "resetbtn");
get(m_pMoveUpButton, "up"); get(m_pMoveUpButton, "up");
get(m_pMoveDownButton, "down"); get(m_pMoveDownButton, "down");
get(m_pSaveInListBox, "savein"); get(m_pSaveInListBox, "savein");
...@@ -1763,6 +1764,10 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet) ...@@ -1763,6 +1764,10 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet)
m_pDescriptionField->SetControlBackground( GetSettings().GetStyleSettings().GetDialogColor() ); m_pDescriptionField->SetControlBackground( GetSettings().GetStyleSettings().GetDialogColor() );
m_pDescriptionField->EnableCursor( false ); m_pDescriptionField->EnableCursor( false );
// This button is applicable only for the toolbar config tab
m_pResetTopLevelButton->Enable( false );
m_pResetTopLevelButton->Hide();
} }
SvxConfigPage::~SvxConfigPage() SvxConfigPage::~SvxConfigPage()
...@@ -1783,6 +1788,7 @@ void SvxConfigPage::dispose() ...@@ -1783,6 +1788,7 @@ void SvxConfigPage::dispose()
m_pAddCommandsButton.clear(); m_pAddCommandsButton.clear();
m_pModifyCommandButton.clear(); m_pModifyCommandButton.clear();
m_pDeleteCommandButton.clear(); m_pDeleteCommandButton.clear();
m_pResetTopLevelButton.clear();
m_pMoveUpButton.clear(); m_pMoveUpButton.clear();
m_pMoveDownButton.clear(); m_pMoveDownButton.clear();
m_pSaveInListBox.clear(); m_pSaveInListBox.clear();
...@@ -3101,6 +3107,9 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(vcl::Window *pParent, const SfxItemSe ...@@ -3101,6 +3107,9 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(vcl::Window *pParent, const SfxItemSe
m_pContents->set_label(CUI_RES(RID_SVXSTR_TOOLBAR_CONTENT)); m_pContents->set_label(CUI_RES(RID_SVXSTR_TOOLBAR_CONTENT));
m_pContentsLabel->SetText( CUI_RES( RID_SVXSTR_COMMANDS ) ); 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( m_pTopLevelListBox->SetSelectHdl(
LINK( this, SvxToolbarConfigPage, SelectToolbar ) ); LINK( this, SvxToolbarConfigPage, SelectToolbar ) );
m_pContentsListBox->SetSelectHdl( m_pContentsListBox->SetSelectHdl(
...@@ -3115,6 +3124,9 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(vcl::Window *pParent, const SfxItemSe ...@@ -3115,6 +3124,9 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(vcl::Window *pParent, const SfxItemSe
m_pDeleteCommandButton->SetClickHdl ( m_pDeleteCommandButton->SetClickHdl (
LINK( this, SvxToolbarConfigPage, DeleteCommandHdl ) ); LINK( this, SvxToolbarConfigPage, DeleteCommandHdl ) );
m_pResetTopLevelButton->SetClickHdl (
LINK( this, SvxToolbarConfigPage, ResetTopLevelHdl ) );
m_pMoveUpButton->SetClickHdl ( LINK( this, SvxToolbarConfigPage, MoveHdl) ); m_pMoveUpButton->SetClickHdl ( LINK( this, SvxToolbarConfigPage, MoveHdl) );
m_pMoveDownButton->SetClickHdl ( LINK( this, SvxToolbarConfigPage, MoveHdl) ); m_pMoveDownButton->SetClickHdl ( LINK( this, SvxToolbarConfigPage, MoveHdl) );
// Always enable Up and Down buttons // Always enable Up and Down buttons
...@@ -3309,23 +3321,6 @@ IMPL_LINK_TYPED( SvxToolbarConfigPage, ToolbarSelectHdl, MenuButton *, pButton, ...@@ -3309,23 +3321,6 @@ IMPL_LINK_TYPED( SvxToolbarConfigPage, ToolbarSelectHdl, MenuButton *, pButton,
} }
break; 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: case ID_ICONS_ONLY:
{ {
pToolbar->SetStyle( 0 ); pToolbar->SetStyle( 0 );
...@@ -4543,6 +4538,7 @@ IMPL_LINK_NOARG_TYPED( SvxToolbarConfigPage, SelectToolbar, ListBox&, void ) ...@@ -4543,6 +4538,7 @@ IMPL_LINK_NOARG_TYPED( SvxToolbarConfigPage, SelectToolbar, ListBox&, void )
m_pModifyCommandButton->Enable( false ); m_pModifyCommandButton->Enable( false );
m_pAddCommandsButton->Enable( false ); m_pAddCommandsButton->Enable( false );
m_pDeleteCommandButton->Enable( false ); m_pDeleteCommandButton->Enable( false );
m_pResetTopLevelButton->Enable( false );
return; return;
} }
...@@ -4550,12 +4546,12 @@ IMPL_LINK_NOARG_TYPED( SvxToolbarConfigPage, SelectToolbar, ListBox&, void ) ...@@ -4550,12 +4546,12 @@ IMPL_LINK_NOARG_TYPED( SvxToolbarConfigPage, SelectToolbar, ListBox&, void )
m_pModifyTopLevelButton->Enable(); m_pModifyTopLevelButton->Enable();
m_pModifyCommandButton->Enable(); m_pModifyCommandButton->Enable();
m_pAddCommandsButton->Enable(); m_pAddCommandsButton->Enable();
m_pResetTopLevelButton->Enable( !pToolbar->IsRenamable() );
PopupMenu* pPopup = m_pModifyTopLevelButton->GetPopupMenu(); PopupMenu* pPopup = m_pModifyTopLevelButton->GetPopupMenu();
pPopup->EnableItem( ID_DELETE, pToolbar->IsDeletable() ); pPopup->EnableItem( ID_DELETE, pToolbar->IsDeletable() );
pPopup->EnableItem( ID_RENAME, pToolbar->IsRenamable() ); pPopup->EnableItem( ID_RENAME, pToolbar->IsRenamable() );
pPopup->EnableItem( ID_DEFAULT_STYLE, !pToolbar->IsRenamable() );
switch( pToolbar->GetStyle() ) switch( pToolbar->GetStyle() )
{ {
...@@ -4686,6 +4682,27 @@ IMPL_LINK_NOARG_TYPED( SvxToolbarConfigPage, DeleteCommandHdl, Button *, void ) ...@@ -4686,6 +4682,27 @@ IMPL_LINK_NOARG_TYPED( SvxToolbarConfigPage, DeleteCommandHdl, Button *, void )
DeleteSelectedContent(); 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 ) IMPL_LINK_NOARG_TYPED( SvxToolbarConfigPage, AddFunctionHdl, SvxScriptSelectorDialog&, void )
{ {
AddFunction(); AddFunction();
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#define ID_DELETE (44 + CFG_OFFSET) #define ID_DELETE (44 + CFG_OFFSET)
#define ID_BEGIN_GROUP (46 + 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_ONLY (48 + CFG_OFFSET)
#define ID_ICONS_AND_TEXT (49 + CFG_OFFSET) #define ID_ICONS_AND_TEXT (49 + CFG_OFFSET)
#define ID_ICON_ONLY (50 + CFG_OFFSET) #define ID_ICON_ONLY (50 + CFG_OFFSET)
......
...@@ -45,15 +45,6 @@ Menu MODIFY_TOOLBAR ...@@ -45,15 +45,6 @@ Menu MODIFY_TOOLBAR
Separator = TRUE ; Separator = TRUE ;
}; };
MenuItem MenuItem
{
Identifier = ID_DEFAULT_STYLE ;
Text [ en-US ] = "Restore Default Settings" ;
};
MenuItem
{
Separator = TRUE ;
};
MenuItem
{ {
Identifier = ID_ICONS_ONLY ; Identifier = ID_ICONS_ONLY ;
RadioCheck = TRUE ; RadioCheck = TRUE ;
......
...@@ -376,8 +376,9 @@ protected: ...@@ -376,8 +376,9 @@ protected:
VclPtr<PushButton> m_pAddCommandsButton; VclPtr<PushButton> m_pAddCommandsButton;
VclPtr<MenuButton> m_pModifyCommandButton; VclPtr<MenuButton> m_pModifyCommandButton;
VclPtr<PushButton> m_pDeleteCommandButton; VclPtr<PushButton> m_pDeleteCommandButton;
// Resets the top level toolbar to default settings
VclPtr<PushButton> m_pResetTopLevelButton;
VclPtr<PushButton> m_pMoveUpButton; VclPtr<PushButton> m_pMoveUpButton;
VclPtr<PushButton> m_pMoveDownButton; VclPtr<PushButton> m_pMoveDownButton;
...@@ -570,6 +571,7 @@ private: ...@@ -570,6 +571,7 @@ private:
DECL_LINK_TYPED( NewToolbarHdl, Button *, void ); DECL_LINK_TYPED( NewToolbarHdl, Button *, void );
DECL_LINK_TYPED( AddCommandsHdl, Button *, void ); DECL_LINK_TYPED( AddCommandsHdl, Button *, void );
DECL_LINK_TYPED( DeleteCommandHdl, Button *, void ); DECL_LINK_TYPED( DeleteCommandHdl, Button *, void );
DECL_LINK_TYPED( ResetTopLevelHdl, Button *, void );
DECL_LINK_TYPED( AddFunctionHdl, SvxScriptSelectorDialog&, void ); DECL_LINK_TYPED( AddFunctionHdl, SvxScriptSelectorDialog&, void );
DECL_LINK_TYPED( MoveHdl, Button *, void ); DECL_LINK_TYPED( MoveHdl, Button *, void );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment