tdf#148101 don't autocomplete remote files dialog entry on delete/backspace

Change-Id: Ieddb41eb37e7090416a418afeffb76ce0eddf90a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133009
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2022-04-14 12:05:49 +01:00
parent ae0e7e3918
commit 3f79346581
3 changed files with 27 additions and 1 deletions

View File

@@ -7,21 +7,44 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <vcl/event.hxx>
#include "autocmpledit.hxx"
AutocompleteEdit::AutocompleteEdit(std::unique_ptr<weld::Entry> xEntry)
: m_xEntry(std::move(xEntry))
, m_aChangedIdle("fpicker::AutocompleteEdit m_aChangedIdle")
, m_nLastCharCode(0)
{
m_xEntry->connect_changed(LINK(this, AutocompleteEdit, ChangedHdl));
m_xEntry->connect_key_press(LINK(this, AutocompleteEdit, KeyInputHdl));
m_aChangedIdle.SetInvokeHandler(LINK(this, AutocompleteEdit, TryAutoComplete));
}
IMPL_LINK(AutocompleteEdit, KeyInputHdl, const KeyEvent&, rKEvt, bool)
{
m_nLastCharCode = rKEvt.GetKeyCode().GetCode();
return false;
}
IMPL_LINK_NOARG(AutocompleteEdit, ChangedHdl, weld::Entry&, void)
{
m_aChangeHdl.Call(*m_xEntry);
m_aChangedIdle.Start(); //launch this to happen on idle after cursor position will have been set
switch (m_nLastCharCode)
{
case css::awt::Key::DELETE_WORD_BACKWARD:
case css::awt::Key::DELETE_WORD_FORWARD:
case css::awt::Key::DELETE_TO_BEGIN_OF_LINE:
case css::awt::Key::DELETE_TO_END_OF_LINE:
case KEY_BACKSPACE:
case KEY_DELETE:
m_aChangedIdle.Stop();
break;
default:
m_aChangedIdle.Start(); //launch this to happen on idle after cursor position will have been set
break;
}
}
void AutocompleteEdit::AddEntry( const OUString& rEntry )

View File

@@ -22,7 +22,9 @@ private:
std::vector<OUString> m_aMatching;
Idle m_aChangedIdle;
Link<weld::Entry&, void> m_aChangeHdl;
sal_uInt16 m_nLastCharCode;
DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
DECL_LINK(ChangedHdl, weld::Entry&, void);
DECL_LINK(TryAutoComplete, Timer*, void);

View File

@@ -475,6 +475,7 @@ IMPL_LINK_NOARG(IndexTabPage_Impl, EntryChangeHdl, weld::Entry&, void)
case css::awt::Key::DELETE_TO_END_OF_LINE:
case KEY_BACKSPACE:
case KEY_DELETE:
aAutoCompleteIdle.Stop();
break;
default:
aAutoCompleteIdle.Start();