[Libreoffice-commits] core.git: cui/source cui/uiconfig

Muhammet Kara muhammet.kara at pardus.org.tr
Mon Sep 5 09:28:43 UTC 2016


 cui/source/customize/cfg.cxx      |   53 +++++--
 cui/source/customize/cfg.hrc      |    2 
 cui/source/customize/cfg.src      |    9 -
 cui/source/inc/cfg.hxx            |    4 
 cui/uiconfig/ui/menuassignpage.ui |  260 ++++++++++++++++++++++++--------------
 5 files changed, 209 insertions(+), 119 deletions(-)

New commits:
commit 4aca836a468bb0e2a7aae0800164e2b81f96243f
Author: Muhammet Kara <muhammet.kara at pardus.org.tr>
Date:   Thu Sep 1 12:09:43 2016 +0300

    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 at libreoffice.org>
    Tested-by: Yousuf Philips <philipz85 at hotmail.com>
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 828f46e..ff6a74c 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 6a83713..496b8cf 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 a354c24..fd0b565 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 1b6cfa1..f17175e 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 );
 
diff --git a/cui/uiconfig/ui/menuassignpage.ui b/cui/uiconfig/ui/menuassignpage.ui
index aafe87c..f131925 100644
--- a/cui/uiconfig/ui/menuassignpage.ui
+++ b/cui/uiconfig/ui/menuassignpage.ui
@@ -38,78 +38,78 @@
                 <property name="can_focus">False</property>
                 <property name="column_spacing">12</property>
                 <child>
-                  <object class="GtkButtonBox" id="buttonbox1">
+                  <object class="GtkGrid" id="grid2">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="orientation">vertical</property>
-                    <property name="spacing">6</property>
-                    <property name="layout_style">start</property>
+                    <property name="hexpand">True</property>
+                    <property name="column_spacing">12</property>
                     <child>
-                      <object class="GtkButton" id="toplevelbutton">
-                        <property name="label" translatable="yes">New...</property>
+                      <object class="GtkLabel" id="toplevelft">
                         <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Menu</property>
                         <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">toplevellist</property>
+                        <property name="xalign">0</property>
                       </object>
                       <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkButton" id="menuedit:menu">
-                        <property name="label" translatable="yes">Menu</property>
+                      <object class="GtkComboBoxText" id="toplevellist">
                         <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
+                        <property name="can_focus">False</property>
                       </object>
                       <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
                       </packing>
                     </child>
                   </object>
                   <packing>
-                    <property name="left_attach">1</property>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">0</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkGrid" id="grid2">
+                  <object class="GtkButtonBox" id="buttonbox1">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="column_spacing">12</property>
+                    <property name="orientation">vertical</property>
+                    <property name="spacing">6</property>
+                    <property name="layout_style">start</property>
                     <child>
-                      <object class="GtkLabel" id="toplevelft">
+                      <object class="GtkButton" id="toplevelbutton">
+                        <property name="label" translatable="yes">New...</property>
                         <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="label" translatable="yes">Menu</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
                         <property name="use_underline">True</property>
-                        <property name="mnemonic_widget">toplevellist</property>
-                        <property name="xalign">0</property>
                       </object>
                       <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">0</property>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkComboBoxText" id="toplevellist">
+                      <object class="GtkButton" id="menuedit:menu">
+                        <property name="label" translatable="yes">Menu</property>
                         <property name="visible">True</property>
-                        <property name="can_focus">False</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
                       </object>
                       <packing>
-                        <property name="left_attach">1</property>
-                        <property name="top_attach">0</property>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
                       </packing>
                     </child>
                   </object>
                   <packing>
-                    <property name="left_attach">0</property>
+                    <property name="left_attach">1</property>
                     <property name="top_attach">0</property>
                   </packing>
                 </child>
@@ -158,60 +158,6 @@
                 <property name="vexpand">True</property>
                 <property name="column_spacing">12</property>
                 <child>
-                  <object class="GtkButtonBox" id="buttonbox2">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="orientation">vertical</property>
-                    <property name="spacing">6</property>
-                    <property name="layout_style">start</property>
-                    <child>
-                      <object class="GtkButton" id="add">
-                        <property name="label" translatable="yes">Add...</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="use_underline">True</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkButton" id="modify:modmenu">
-                        <property name="label" translatable="yes">Modify</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkButton" id="deletebtn">
-                        <property name="label" translatable="yes">Remove</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="use_underline">True</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">2</property>
-                      </packing>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="top_attach">0</property>
-                  </packing>
-                </child>
-                <child>
                   <object class="GtkGrid" id="grid4">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
@@ -305,6 +251,30 @@
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
@@ -317,6 +287,112 @@
                     <property name="top_attach">0</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkGrid" id="grid6">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkButtonBox" id="buttonbox5">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">6</property>
+                        <property name="layout_style">start</property>
+                        <child>
+                          <object class="GtkButton" id="resetbtn">
+                            <property name="label" translatable="yes">Reset</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButtonBox" id="buttonbox4">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin_bottom">24</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">6</property>
+                        <property name="layout_style">start</property>
+                        <child>
+                          <object class="GtkButton" id="modify:modmenu">
+                            <property name="label" translatable="yes">Modify</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkButton" id="deletebtn">
+                            <property name="label" translatable="yes">Remove</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButtonBox" id="buttonbox3">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin_bottom">24</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">6</property>
+                        <property name="layout_style">start</property>
+                        <child>
+                          <object class="GtkButton" id="add">
+                            <property name="label" translatable="yes">Add...</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">0</property>
+                  </packing>
+                </child>
               </object>
             </child>
           </object>
@@ -389,8 +465,12 @@
   </object>
   <object class="GtkSizeGroup" id="sizegroup1">
     <widgets>
-      <widget name="buttonbox1"/>
-      <widget name="buttonbox2"/>
+      <widget name="toplevelbutton"/>
+      <widget name="menuedit:menu"/>
+      <widget name="add"/>
+      <widget name="modify:modmenu"/>
+      <widget name="deletebtn"/>
+      <widget name="resetbtn"/>
     </widgets>
   </object>
   <object class="GtkSizeGroup" id="sizegroup2">


More information about the Libreoffice-commits mailing list