[krunner] Bring back history
Review Request #123888 - Created May 23, 2015 and submitted
|Kai Uwe Broulik|
This turns KRunner's TextField into an editable ComboBox to provide a history.
When a result is invoked, the query string is prepended to the history, query strings are only added once. ComboBox provides letter-by-letter auto completion.
Somehow I have a feeling it doesn't always save the history or nukes it at times. It also has some shortcomings due to ComboBox:
1.) You cannot use the arrow keys to cycle between entries (when the popup's not opened) because arrow keys navigate through results
2.) forceActiveFocus() on the ComboBox will not activate the embedded TextField - when you had opened the popup there's a slight chance the input field won't get focussed I'll prepare a Qt patch for this.
3.) Before Qt 5.4.2 (not sure if my patch ended up in 5.4.1) pressing space in the edit combobox will open the popup, not insert a space (nasty show stopper)
4.) Plasma's edtiable ComboBox looks a bit strange imho
5.) Plasma's editable ComboBox doesn't support clearButtonShown
6.) Plasma's ComboBox has strange bullets and margins in it, that's probably a bug in Plasma Style (need to look what Desktop style does differently from us)
7.) ComboBox doesn't have a cursorPosition, I'll prepare a Qt patch for this.
|const QStringList &history() const; Saves a copy and prevents users from manipulating this object. You do manipulate this, but that ...||Mark Gaiser|
|We need the cursor position to be updated for runners which change the query string. You can test this out ...||Vishesh Handa|
const QStringList &history() const;
Saves a copy and prevents users from manipulating this object.
Or i'm wrong... In that case you can ignore this comment :)
Hmm, this looks interesting.
Suppose my history looks like this:
now imagine i type "plasma". It should then show:
Thus far it probably works fine.
Now imagine i clear whatever i typed (so a clean inputfield). All without closing krunner! When i clear it the history probably shows one entry:
What happened to the other two?
Well, you've rewritten history when i typed a search query.
And because you call "runnerWindow.history = history" it will call the C++ setHistory method which will overwrite your history value in the config.. Ouch!
I could be wrong, but this is how i think it behaves when reading the code.
I think you should use something with a tree. A radix tree would be the easiest, fastest and cheapest in memory, but that doesn't exist in Qt nor the C++ STL.
I'm curious (since i don't see that code here). Where do you add items to your history?
It's not intuitive to type 'pla' and get a list (with radio buttons!) that contains 'dolphin'. Expanding the dropdown without content should show previous search items and 'pla' could prioritize stuff from the history. And I'm wondering how this option is configured by the user.
Good work! Let me try it out myself and see how it feels.
history feature itself works fine here.
only thing one sees how ugly the combobox is, but unfortunately most of its theming (at least the frame area) is private api, so would be possible to theme more precisely but risky
Introduce workaround for Qt bug (fixed in 5.4.2 but we don't want to break earlier versions)
With 5.4.2 it works fine, with 5.4.1 it still works fine except that when pressing space the dropdown button lights up briefly but whatever.
Revision 3 (+58 -8)
Show history when opening KRunner (whenever no query is typed in) instead of a ComboBox, as suggested by the Usability team. It has the following advantages:
- No conflicting arrow key vs tab navigation with two vertically scrolling lists (results and combobox)
- You can see the history immediately
- You can click the history immediately
- Using arrows to navigate the history like you would with results
Revision 4 (+82 -2)