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

Muhammet Kara muhammet.kara at pardus.org.tr
Fri Aug 18 12:48:09 UTC 2017


 cui/source/customize/SvxMenuConfigPage.cxx    |   13 ++++++++++
 cui/source/customize/SvxToolbarConfigPage.cxx |   22 +++++++++++++----
 cui/source/customize/cfg.cxx                  |   33 ++++++++++++++++++++++++--
 cui/source/inc/SvxMenuConfigPage.hxx          |    3 ++
 cui/source/inc/SvxToolbarConfigPage.hxx       |    4 ++-
 cui/source/inc/cfg.hxx                        |    7 +++++
 6 files changed, 74 insertions(+), 8 deletions(-)

New commits:
commit a1a5526d268f632de0dfdf27546270391b325e54
Author: Muhammet Kara <muhammet.kara at pardus.org.tr>
Date:   Thu Aug 17 06:48:08 2017 +0300

    Implement "Add" button in the Customize dialog
    
    Now new commands can be added to Toolbars, Menus, and Context Menus
    by using the Add (right arrow) button which is between the commands list
    and the menu/toolbar entries list.
    
    Change-Id: I9c094a5142f82922c5e5bc3075a35442875a5fec
    Reviewed-on: https://gerrit.libreoffice.org/41240
    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 ec7c9e8dfad7..eafed333422f 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -124,6 +124,9 @@ SvxMenuConfigPage::SvxMenuConfigPage(vcl::Window *pParent, const SfxItemSet& rSe
 
     m_pMoveUpButton->SetClickHdl ( LINK( this, SvxConfigPage, MoveHdl) );
     m_pMoveDownButton->SetClickHdl ( LINK( this, SvxConfigPage, MoveHdl) );
+
+    m_pAddCommandButton->SetClickHdl( LINK( this, SvxMenuConfigPage, AddCommandHdl ) );
+    //m_pRemoveCommandButton->SetClickHdl( LINK( this, SvxMenuConfigPage, RemoveCommandHdl ) );
 }
 
 SvxMenuConfigPage::~SvxMenuConfigPage()
@@ -289,6 +292,16 @@ IMPL_LINK_NOARG( SvxMenuConfigPage, SelectCategory, ListBox&, void )
     m_pCommandCategoryListBox->categorySelected( m_pFunctions );
 }
 
+IMPL_LINK_NOARG( SvxMenuConfigPage, AddCommandHdl, Button *, void )
+{
+    AddFunction();
+}
+
+/*IMPL_LINK_NOARG( SvxMenuConfigPage, RemoveCommandHdl, Button *, void )
+{
+    //TODO:Implement
+}*/
+
 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 51f7d0485ae4..43bf0a5aaa60 100644
--- a/cui/source/customize/SvxToolbarConfigPage.cxx
+++ b/cui/source/customize/SvxToolbarConfigPage.cxx
@@ -135,6 +135,9 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(vcl::Window *pParent, const SfxItemSe
     m_pMoveDownButton->Enable();
     m_pMoveUpButton->Enable();
 
+    m_pAddCommandButton->SetClickHdl( LINK( this, SvxToolbarConfigPage, AddCommandHdl ) );
+    //m_pRemoveCommandButton->SetClickHdl( LINK( this, SvxToolbarConfigPage, RemoveCommandHdl ) );
+
     // default toolbar to select is standardbar unless a different one
     // has been passed in
     m_aURLToSelect = ITEM_TOOLBAR_URL;
@@ -321,6 +324,16 @@ IMPL_LINK_NOARG( SvxToolbarConfigPage, SelectCategory, ListBox&, void )
     m_pCommandCategoryListBox->categorySelected( m_pFunctions );
 }
 
+IMPL_LINK_NOARG( SvxToolbarConfigPage, AddCommandHdl, Button *, void )
+{
+    AddFunction();
+}
+
+/*IMPL_LINK_NOARG( SvxToolbarConfigPage, RemoveCommandHdl, Button *, void )
+{
+    //TODO:Implement
+}*/
+
 
 void SvxToolbarConfigPage::UpdateButtonStates()
 {
@@ -391,14 +404,10 @@ IMPL_LINK_NOARG( SvxToolbarConfigPage, SelectToolbar, ListBox&, void )
     UpdateButtonStates();
 }
 
-IMPL_LINK_NOARG( SvxToolbarConfigPage, AddFunctionHdl, SvxScriptSelectorDialog&, void )
-{
-    AddFunction();
-}
-
 void SvxToolbarConfigPage::AddFunction(
     SvTreeListEntry* pTarget, bool bFront )
 {
+    // Add the command to the contents listbox of the selected toolbar
     SvTreeListEntry* pNewLBEntry =
         SvxConfigPage::AddFunction( pTarget, bFront, true/*bAllowDuplicates*/ );
 
@@ -416,6 +425,9 @@ void SvxToolbarConfigPage::AddFunction(
             pNewLBEntry, SvButtonState::Tristate );
     }
 
+    // Changes are not visible on the toolbar until this point
+    // TODO: Figure out a way to show the changes on the toolbar, but revert if
+    //       the dialog is closed by pressing "Cancel"
     // get currently selected toolbar and apply change
     SvxConfigEntry* pToolbar = GetTopLevelSelection();
 
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 018921953be9..dba72f22101b 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -1135,6 +1135,9 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet)
     get(m_pCommandCategoryListBox, "commandcategorylist");
     get(m_pFunctions, "functions");
 
+    get(m_pAddCommandButton, "add");
+    get(m_pRemoveCommandButton, "remove");
+
     get(m_pTopLevelListBox, "toplevellist");
     get(m_pContents, "contents");
     get(m_pMoveUpButton, "up");
@@ -1165,6 +1168,8 @@ void SvxConfigPage::dispose()
     m_pContents.clear();
     m_pEntries.clear();
     m_pFunctions.clear();
+    m_pAddCommandButton.clear();
+    m_pRemoveCommandButton.clear();
     m_pMoveUpButton.clear();
     m_pMoveDownButton.clear();
     m_pSaveInListBox.clear();
@@ -1441,6 +1446,30 @@ OUString SvxConfigPage::GetFrameWithDefaultAndIdentify( uno::Reference< frame::X
     return sModuleID;
 }
 
+OUString SvxConfigPage::GetScriptURL() const
+{
+    OUString result;
+
+    SvTreeListEntry *pEntry = m_pFunctions->FirstSelected();
+    if ( pEntry )
+    {
+        SfxGroupInfo_Impl *pData = static_cast<SfxGroupInfo_Impl*>(pEntry->GetUserData());
+        if  (   ( pData->nKind == SfxCfgKind::FUNCTION_SLOT ) ||
+                ( pData->nKind == SfxCfgKind::FUNCTION_SCRIPT ) ||
+                ( pData->nKind == SfxCfgKind::GROUP_STYLES )    )
+        {
+            result = pData->sCommand;
+        }
+    }
+
+    return result;
+}
+
+OUString SvxConfigPage::GetSelectedDisplayName()
+{
+    return m_pFunctions->GetEntryText( m_pFunctions->FirstSelected() );
+}
+
 bool SvxConfigPage::FillItemSet( SfxItemSet* )
 {
     bool result = false;
@@ -1554,7 +1583,7 @@ SvxEntries* SvxConfigPage::FindParentForChild(
 SvTreeListEntry* SvxConfigPage::AddFunction(
     SvTreeListEntry* pTarget, bool bFront, bool bAllowDuplicates )
 {
-    OUString aURL = m_pSelectorDlg->GetScriptURL();
+    OUString aURL = GetScriptURL();
 
     if ( aURL.isEmpty() )
     {
@@ -1576,7 +1605,7 @@ SvTreeListEntry* SvxConfigPage::AddFunction(
     pNewEntryData->SetUserDefined();
 
     if ( aDisplayName.isEmpty() )
-        pNewEntryData->SetName( m_pSelectorDlg->GetSelectedDisplayName() );
+        pNewEntryData->SetName( GetSelectedDisplayName() );
 
     // check that this function is not already in the menu
     SvxConfigEntry* pParent = GetTopLevelSelection();
diff --git a/cui/source/inc/SvxMenuConfigPage.hxx b/cui/source/inc/SvxMenuConfigPage.hxx
index 73165ed140f7..9110edeeaf9d 100644
--- a/cui/source/inc/SvxMenuConfigPage.hxx
+++ b/cui/source/inc/SvxMenuConfigPage.hxx
@@ -56,6 +56,9 @@ private:
 
     DECL_LINK( SelectCategory, ListBox&, void );
 
+    DECL_LINK( AddCommandHdl, Button *, void );
+    //DECL_LINK( RemoveCommandHdl, Button *, 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 21d63fbe81ff..e4721553477f 100644
--- a/cui/source/inc/SvxToolbarConfigPage.hxx
+++ b/cui/source/inc/SvxToolbarConfigPage.hxx
@@ -53,11 +53,13 @@ private:
 
     DECL_LINK( SelectToolbar, ListBox&, void );
     DECL_LINK( SelectToolbarEntry, SvTreeListBox*, void );
-    DECL_LINK( AddFunctionHdl, SvxScriptSelectorDialog&, void );
     DECL_LINK( MoveHdl, Button *, void );
 
     DECL_LINK( SelectCategory, ListBox&, void );
 
+    DECL_LINK( AddCommandHdl, Button *, void );
+    //DECL_LINK( RemoveCommandHdl, Button *, 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 f8058b362c61..c568cab194cd 100644
--- a/cui/source/inc/cfg.hxx
+++ b/cui/source/inc/cfg.hxx
@@ -403,6 +403,10 @@ protected:
 
     VclPtr<SvxScriptSelectorDialog>            m_pSelectorDlg;
 
+    // Middle buttons
+    VclPtr<PushButton>                         m_pAddCommandButton;
+    VclPtr<PushButton>                         m_pRemoveCommandButton;
+
     /// the ResourceURL to select when opening the dialog
     OUString                                   m_aURLToSelect;
 
@@ -479,6 +483,9 @@ public:
     */
     static OUString
         GetFrameWithDefaultAndIdentify( css::uno::Reference< css::frame::XFrame >& _inout_rxFrame );
+
+    OUString    GetScriptURL() const;
+    OUString    GetSelectedDisplayName();
 };
 
 class SvxMainMenuOrganizerDialog : public ModalDialog


More information about the Libreoffice-commits mailing list