diff options
author | Muhammet Kara <muhammet.kara@pardus.org.tr> | 2017-06-13 11:44:22 +0300 |
---|---|---|
committer | Muhammet Kara <muhammet.kara@pardus.org.tr> | 2017-06-28 18:52:43 +0200 |
commit | 1ec4082d7adb1cbce0b4eed3c45fe2fcba258333 (patch) | |
tree | f79a8a9c54d27364db5e9739b4b0c6356c927926 /cui | |
parent | b9587cdb099f24d36e4f81685ef4cd0efef0bdba (diff) |
Implement search feature in the Kayboard tab
of the Customize dialog.
Once you type a search term in the box, non-matching functions
are filtered out in the current category. The filter operation
takes place, and updates as you type.
If user changes category while there is still a search term
in the box, the filter is also applied to the newly selected
category.
Change-Id: I5ef086af60e0f339af6a113fa6a52555d4f765d9
Reviewed-on: https://gerrit.libreoffice.org/38814
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
(cherry picked from commit 3667beb986e8c03c925566a585b0504c7943fede)
Reviewed-on: https://gerrit.libreoffice.org/39356
Reviewed-by: Muhammet Kara <muhammet.kara@pardus.org.tr>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/customize/acccfg.cxx | 71 | ||||
-rw-r--r-- | cui/source/inc/acccfg.hxx | 69 | ||||
-rw-r--r-- | cui/uiconfig/ui/accelconfigpage.ui | 196 |
3 files changed, 209 insertions, 127 deletions
diff --git a/cui/source/customize/acccfg.cxx b/cui/source/customize/acccfg.cxx index 23bb736d3319..ce1c0d552004 100644 --- a/cui/source/customize/acccfg.cxx +++ b/cui/source/customize/acccfg.cxx @@ -58,6 +58,11 @@ #include <com/sun/star/ui/XUIConfigurationManager.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> +// include search util +#include <com/sun/star/util/SearchFlags.hpp> +#include <com/sun/star/util/SearchAlgorithms2.hpp> +#include <unotools/textsearch.hxx> + // include other projects #include <comphelper/processfactory.hxx> #include <svtools/acceleratorexecute.hxx> @@ -753,6 +758,7 @@ SfxAcceleratorConfigPage::SfxAcceleratorConfigPage( vcl::Window* pParent, const aSize = LogicToPixel(Size(80, 91), MapUnit::MapAppFont); m_pKeyBox->set_width_request(aSize.Width()); m_pKeyBox->set_height_request(aSize.Height()); + get(m_pSearchEdit, "searchEntry"); aFilterAllStr = SfxResId( STR_SFX_FILTERNAME_ALL ); @@ -769,6 +775,9 @@ SfxAcceleratorConfigPage::SfxAcceleratorConfigPage( vcl::Window* pParent, const m_pOfficeButton->SetClickHdl( LINK( this, SfxAcceleratorConfigPage, RadioHdl )); m_pModuleButton->SetClickHdl( LINK( this, SfxAcceleratorConfigPage, RadioHdl )); + m_pSearchEdit->SetUpdateDataHdl ( LINK( this, SfxAcceleratorConfigPage, SearchUpdateHdl )); + m_pSearchEdit->EnableUpdateData(); + // initialize Entriesbox m_pEntriesBox->SetStyle(m_pEntriesBox->GetStyle()|WB_HSCROLL|WB_CLIPCHILDREN); m_pEntriesBox->SetSelectionMode(SelectionMode::Single); @@ -790,6 +799,11 @@ SfxAcceleratorConfigPage::SfxAcceleratorConfigPage( vcl::Window* pParent, const nNewTab = nNewTab + 5; // additional space m_pEntriesBox->SetTab( 1, nNewTab ); + //Initialize search util + m_options.AlgorithmType2 = util::SearchAlgorithms2::ABSOLUTE; + m_options.transliterateFlags |= TransliterationFlags::IGNORE_CASE; + m_options.searchFlag |= (util::SearchFlags::REG_NOT_BEGINOFLINE | + util::SearchFlags::REG_NOT_ENDOFLINE); // initialize GroupBox m_pGroupLBox->SetFunctionListBox(m_pFunctionBox); @@ -835,6 +849,7 @@ void SfxAcceleratorConfigPage::dispose() m_pGroupLBox.clear(); m_pFunctionBox.clear(); m_pKeyBox.clear(); + m_pSearchEdit.clear(); m_pLoadButton.clear(); m_pSaveButton.clear(); m_pResetButton.clear(); @@ -1031,6 +1046,11 @@ void SfxAcceleratorConfigPage::ResetConfig() m_pEntriesBox->Clear(); } +IMPL_LINK_NOARG(SfxAcceleratorConfigPage, SearchUpdateHdl, Edit&, void) +{ + m_pGroupLBox->GetSelectHdl().Call( m_pGroupLBox ); +} + IMPL_LINK_NOARG(SfxAcceleratorConfigPage, Load, Button*, void) { // ask for filename, where we should load the new config data from @@ -1109,6 +1129,19 @@ IMPL_LINK( SfxAcceleratorConfigPage, SelectHdl, SvTreeListBox*, pListBox, void ) else if ( pListBox == m_pGroupLBox ) { m_pGroupLBox->GroupSelected(); + + // Pause redraw (Do not redraw at each removal) + m_pFunctionBox->SetUpdateMode(false); + // Apply the search filter to the functions list + OUString aSearchTerm( m_pSearchEdit->GetText() ); + SvTreeListEntry* aMatchFound = applySearchFilter(aSearchTerm, m_pFunctionBox); + // Resume redraw + m_pFunctionBox->SetUpdateMode(true); + if (aMatchFound) + m_pFunctionBox->Select(aMatchFound); + else + m_pKeyBox->Clear(); + if ( !m_pFunctionBox->FirstSelected() ) m_pChangeButton->Enable( false ); } @@ -1486,4 +1519,42 @@ OUString SfxAcceleratorConfigPage::GetLabel4Command(const OUString& sCommand) return sCommand; } +/* + * Remove entries which doesn't contain the search term + */ +SvTreeListEntry* SfxAcceleratorConfigPage::applySearchFilter(OUString& rSearchTerm, SvTreeListBox* rListBox) +{ + if ( rSearchTerm.isEmpty() || !rListBox ) + { + return nullptr; + } + + SvTreeListEntry* pFirstMatch = nullptr; + SvTreeListEntry* pEntry = rListBox->First(); + + m_options.searchString = rSearchTerm; + utl::TextSearch textSearch( m_options ); + + while(pEntry) + { + OUString aStr = rListBox->GetEntryText(pEntry); + SvTreeListEntry* pNextEntry = rListBox->Next(pEntry); + sal_Int32 aStartPos = 0; + sal_Int32 aEndPos = aStr.getLength(); + + if (!textSearch.SearchForward( aStr, &aStartPos, &aEndPos )) + { + rListBox->GetModel()->Remove(pEntry); + } + else if (!pFirstMatch) + { + pFirstMatch = pEntry; + } + + pEntry = pNextEntry; + } + + return pFirstMatch; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/inc/acccfg.hxx b/cui/source/inc/acccfg.hxx index 1239e65363bb..62480db4e7c7 100644 --- a/cui/source/inc/acccfg.hxx +++ b/cui/source/inc/acccfg.hxx @@ -40,6 +40,7 @@ #include <svtools/treelistbox.hxx> #include <sfx2/tabdlg.hxx> #include <sfx2/basedlgs.hxx> +#include <i18nutil/searchopt.hxx> #include "cfgutil.hxx" class SfxMacroInfoItem; @@ -109,47 +110,53 @@ private: const SfxMacroInfoItem* m_pMacroInfoItem; sfx2::FileDialogHelper* m_pFileDlg; - VclPtr<SfxAccCfgTabListBox_Impl> m_pEntriesBox; - VclPtr<RadioButton> m_pOfficeButton; - VclPtr<RadioButton> m_pModuleButton; - VclPtr<PushButton> m_pChangeButton; - VclPtr<PushButton> m_pRemoveButton; - VclPtr<SfxConfigGroupListBox> m_pGroupLBox; - VclPtr<SfxConfigFunctionListBox> m_pFunctionBox; - VclPtr<SvTreeListBox> m_pKeyBox; - VclPtr<PushButton> m_pLoadButton; - VclPtr<PushButton> m_pSaveButton; - VclPtr<PushButton> m_pResetButton; - OUString aLoadAccelConfigStr; - OUString aSaveAccelConfigStr; - OUString aFilterAllStr; - OUString aFilterCfgStr; - SfxStylesInfo_Impl m_aStylesInfo; - bool m_bStylesInfoInitialized; - - css::uno::Reference< css::uno::XComponentContext > m_xContext; - css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xGlobal; - css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xModule; - css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xAct; - css::uno::Reference< css::container::XNameAccess > m_xUICmdDescription; - css::uno::Reference< css::frame::XFrame > m_xFrame; + VclPtr<SfxAccCfgTabListBox_Impl> m_pEntriesBox; + VclPtr<RadioButton> m_pOfficeButton; + VclPtr<RadioButton> m_pModuleButton; + VclPtr<PushButton> m_pChangeButton; + VclPtr<PushButton> m_pRemoveButton; + VclPtr<SfxConfigGroupListBox> m_pGroupLBox; + VclPtr<SfxConfigFunctionListBox> m_pFunctionBox; + VclPtr<SvTreeListBox> m_pKeyBox; + VclPtr<Edit> m_pSearchEdit; + VclPtr<PushButton> m_pLoadButton; + VclPtr<PushButton> m_pSaveButton; + VclPtr<PushButton> m_pResetButton; + OUString aLoadAccelConfigStr; + OUString aSaveAccelConfigStr; + OUString aFilterAllStr; + OUString aFilterCfgStr; + SfxStylesInfo_Impl m_aStylesInfo; + bool m_bStylesInfoInitialized; + + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xGlobal; + css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xModule; + css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xAct; + css::uno::Reference< css::container::XNameAccess > m_xUICmdDescription; + css::uno::Reference< css::frame::XFrame > m_xFrame; OUString m_sModuleLongName; OUString m_sModuleShortName; OUString m_sModuleUIName; - DECL_LINK(ChangeHdl, Button *, void); - DECL_LINK(RemoveHdl, Button *, void); - DECL_LINK(SelectHdl, SvTreeListBox*, void ); - DECL_LINK(Save, Button *, void); - DECL_LINK(Load, Button *, void); - DECL_LINK(Default, Button *, void); - DECL_LINK(RadioHdl, Button *, void); + // For search + i18nutil::SearchOptions2 m_options; + + DECL_LINK(ChangeHdl, Button *, void); + DECL_LINK(RemoveHdl, Button *, void); + DECL_LINK(SelectHdl, SvTreeListBox*, void); + DECL_LINK(SearchUpdateHdl, Edit&, void); + DECL_LINK(Save, Button *, void); + DECL_LINK(Load, Button *, void); + DECL_LINK(Default, Button *, void); + DECL_LINK(RadioHdl, Button *, void); DECL_LINK(LoadHdl, sfx2::FileDialogHelper *, void); DECL_LINK(SaveHdl, sfx2::FileDialogHelper *, void); OUString GetLabel4Command(const OUString& rCommand); + SvTreeListEntry* applySearchFilter(OUString& rSearchTerm, SvTreeListBox* rListBox); void InitAccCfg(); sal_uLong MapKeyCodeToPos( const vcl::KeyCode &rCode ) const; void StartFileDialog( WinBits nBits, const OUString& rTitle ); diff --git a/cui/uiconfig/ui/accelconfigpage.ui b/cui/uiconfig/ui/accelconfigpage.ui index a66e293f889a..68e17b4b01c6 100644 --- a/cui/uiconfig/ui/accelconfigpage.ui +++ b/cui/uiconfig/ui/accelconfigpage.ui @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.16.1 --> +<!-- Generated with glade 3.20.0 --> <interface> <requires lib="gtk+" version="3.10"/> - <!-- interface-requires LibreOffice 1.0 --> + <requires lib="LibreOffice" version="1.0"/> <object class="GtkGrid" id="AccelConfigPage"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -60,8 +60,6 @@ <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -211,16 +209,12 @@ <packing> <property name="left_attach">1</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -240,110 +234,122 @@ <property name="top_padding">6</property> <property name="left_padding">12</property> <child> - <object class="GtkGrid" id="grid1"> + <object class="GtkBox"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> - <property name="row_spacing">6</property> - <property name="column_spacing">12</property> - <child> - <object class="GtkLabel" id="label23"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Category</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">category:border</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> + <property name="orientation">vertical</property> <child> - <object class="GtkLabel" id="label24"> + <object class="GtkEntry" id="searchEntry"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Function</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">function:border</property> + <property name="can_focus">True</property> + <property name="placeholder_text" translatable="yes">Type to search</property> </object> <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> </packing> </child> <child> - <object class="GtkLabel" id="label25"> + <object class="GtkGrid" id="grid1"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Keys</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">keys:border</property> - </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="cuilo-SfxConfigGroupListBox" id="category:border"> - <property name="visible">True</property> - <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="ConfigGroup ListBox-selection"/> + <property name="row_spacing">6</property> + <property name="column_spacing">12</property> + <child> + <object class="GtkLabel" id="label23"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Category</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">category:border</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> </child> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="cuilo-SfxConfigFunctionListBox" id="function:border"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="ConfigGroupFunction ListBox-selection"/> + <child> + <object class="GtkLabel" id="label24"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Function</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">function:border</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> </child> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="svtlo-SvTreeListBox" id="keys:border"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="Tree List-selection"/> + <child> + <object class="GtkLabel" id="label25"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Keys</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">keys:border</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="cuilo-SfxConfigGroupListBox" id="category:border"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="ConfigGroup ListBox-selection"/> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="cuilo-SfxConfigFunctionListBox" id="function:border"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="ConfigGroupFunction ListBox-selection"/> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="svtlo-SvTreeListBox" id="keys:border"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="Tree List-selection"/> + </child> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">1</property> + </packing> </child> </object> <packing> - <property name="left_attach">2</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> </packing> </child> </object> @@ -364,8 +370,6 @@ <packing> <property name="left_attach">0</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> |