┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/private
diff options
context:
space:
mode:
authorFelix Ernst <[email protected]>2023-01-02 16:01:49 +0100
committerFelix Ernst <[email protected]>2023-01-11 15:49:20 +0100
commit44c82a16b3e2fc2d40601fd70f8253dce40dda86 (patch)
tree5aa435a07b30c8b42593a7508ee222076c308d89 /src/kitemviews/private
parenteab9205c311d96f6787eda1cbb9e1207f288a885 (diff)
Make space shortcut for selection mode view-local instead of global
Before this commit, the "Space" keyboard shortcut was bound to triggering selection mode by default. After this commit, pressing "Space" will only trigger selection mode when the file view area has keyboard focus. Pros: + Other buttons in the UI can be triggered with Space once again just like it is expected from an accessibility point of view. + "Type-ahead" searching works once more when typing the space char for file names containing such a space char. Cons: - "Space" can no longer be used to add the currently underlined item to the selection. Instead "Ctrl+Space" needs to be used. (However, this is the current status anyway unless a user has manually unbound "Space" as a shortcut from Selection Mode.) - The Selection Mode action will no longer show "Space" as its shortcut in menus. Overall, I see solutions to all of these problems, but they seem over-engineered for the issues they are trying to solve, so I believe this somewhat small commit is the best solution for now. BUG: 458282 BUG: 458281 CCBUG: 463048 FIXED-IN: 23.04
Diffstat (limited to 'src/kitemviews/private')
-rw-r--r--src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp5
-rw-r--r--src/kitemviews/private/kitemlistkeyboardsearchmanager.h11
2 files changed, 15 insertions, 1 deletions
diff --git a/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp b/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp
index 0e6280ede..e646a6249 100644
--- a/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp
+++ b/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp
@@ -63,6 +63,11 @@ 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 72f5695ce..80caea2ed 100644
--- a/src/kitemviews/private/kitemlistkeyboardsearchmanager.h
+++ b/src/kitemviews/private/kitemlistkeyboardsearchmanager.h
@@ -35,6 +35,11 @@ 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.
@@ -46,7 +51,6 @@ public:
qint64 timeout() const;
void cancelSearch();
- bool shouldClearSearchIfInputTimeReached();
public Q_SLOTS:
@@ -66,9 +70,14 @@ Q_SIGNALS:
void changeCurrentItem(const QString& string, bool searchFromNextItem);
private:
+ bool shouldClearSearchIfInputTimeReached();
+
+private:
QString m_searchedString;
bool m_isSearchRestarted;
+ /** Measures the time since the last key press. */
QElapsedTimer m_keyboardInputTime;
+ /** Time in milliseconds in which a key press is considered as a continuation of the previous search input. */
qint64 m_timeout;
};