[Libreoffice-commits] core.git: Branch 'feature/gsoc17-revamp-customize-dialog' - cui/source cui/uiconfig

Muhammet Kara muhammet.kara at pardus.org.tr
Tue Aug 22 12:27:30 UTC 2017


 cui/source/customize/SvxMenuConfigPage.cxx    |   52 ++++++++++++++++++++++++++
 cui/source/customize/SvxToolbarConfigPage.cxx |   37 ++++++++++++++++++
 cui/source/customize/cfg.cxx                  |    4 +-
 cui/source/inc/SvxMenuConfigPage.hxx          |    2 +
 cui/source/inc/SvxToolbarConfigPage.hxx       |    2 +
 cui/source/inc/cfg.hxx                        |    2 -
 cui/uiconfig/ui/menuassignpage.ui             |   22 ++++++++++-
 7 files changed, 117 insertions(+), 4 deletions(-)

New commits:
commit 3b5f4f90e27d354d059b0fdb3a16bc21b005e774
Author: Muhammet Kara <muhammet.kara at pardus.org.tr>
Date:   Sun Aug 20 12:55:45 2017 +0300

    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 at libreoffice.org>
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index 3031973dbe12..32eb77e83a6c 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 39d5393afdad..c9a87a4b0e23 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 af9c832ba482..3b30221b8450 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -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");
@@ -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");
@@ -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();
 }
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 32efcc717b1f..9bd115bd64b3 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>


More information about the Libreoffice-commits mailing list