diff options
| author | Eugene Popov <[email protected]> | 2023-04-25 13:05:39 +0000 |
|---|---|---|
| committer | Felix Ernst <[email protected]> | 2023-04-25 13:05:39 +0000 |
| commit | 7b6a67e520c04f56b4b05fa26b252177398df6df (patch) | |
| tree | 2932c1185b4fbd123327ff8d42afc0671bbce1ed /src/kitemviews/private | |
| parent | f186f694d4613c335184feed89e50f345c72f47c (diff) | |
Fix activating the Selection Mode with a keyboard shortcut
If a spacebar is used as a keyboard shortcut to activate the Selection Mode, then allow this shortcut to be triggered only if the view has a keyboard focus.
BUG: 465489
Diffstat (limited to 'src/kitemviews/private')
| -rw-r--r-- | src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp | 10 | ||||
| -rw-r--r-- | src/kitemviews/private/kitemlistkeyboardsearchmanager.h | 11 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp b/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp index b7318b344..c74ef1638 100644 --- a/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp +++ b/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp @@ -27,6 +27,11 @@ bool KItemListKeyboardSearchManager::shouldClearSearchIfInputTimeReached() return (keyboardInputTimeElapsed > m_timeout) || !keyboardTimeWasValid; } +bool KItemListKeyboardSearchManager::isSearchAsYouTypeActive() const +{ + return !m_searchedString.isEmpty() && !m_keyboardInputTime.hasExpired(m_timeout); +} + void KItemListKeyboardSearchManager::addKeys(const QString &keys) { if (shouldClearSearchIfInputTimeReached()) { @@ -63,11 +68,6 @@ void KItemListKeyboardSearchManager::addKeys(const QString &keys) m_keyboardInputTime.start(); } -bool KItemListKeyboardSearchManager::addKeyBeginsNewSearch() const -{ - return m_keyboardInputTime.hasExpired(m_timeout) || m_searchedString.isEmpty(); -} - void KItemListKeyboardSearchManager::setTimeout(qint64 milliseconds) { m_timeout = milliseconds; diff --git a/src/kitemviews/private/kitemlistkeyboardsearchmanager.h b/src/kitemviews/private/kitemlistkeyboardsearchmanager.h index d370bc9ba..981d98cd3 100644 --- a/src/kitemviews/private/kitemlistkeyboardsearchmanager.h +++ b/src/kitemviews/private/kitemlistkeyboardsearchmanager.h @@ -34,11 +34,6 @@ public: * Add \a keys to the text buffer used for searching. */ void addKeys(const QString &keys); - /** - * @returns true if the next call to addKeys() will trigger a new search. - * Returns false if the next added key char will be added to the search string that was used previously. - */ - bool addKeyBeginsNewSearch() const; /** * Sets the delay after which the search is cancelled to \a milliseconds. @@ -51,6 +46,11 @@ public: void cancelSearch(); + /** + * @return \c true if search as you type is active, or \c false otherwise. + */ + bool isSearchAsYouTypeActive() const; + public Q_SLOTS: void slotCurrentChanged(int current, int previous); @@ -71,7 +71,6 @@ Q_SIGNALS: private: bool shouldClearSearchIfInputTimeReached(); -private: QString m_searchedString; bool m_isSearchRestarted; /** Measures the time since the last key press. */ |
