Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSearchLineEdit: Add options to disable auto-completion and history #10942

Merged
merged 11 commits into from
Jan 18, 2023

Conversation

fwcd
Copy link
Member

@fwcd fwcd commented Oct 6, 2022

Fixes #10634

This adds two options (that are enabled by default) to configure whether search completions and history (including up/down keyboard shortcuts) should be enabled:

image

@fwcd
Copy link
Member Author

fwcd commented Oct 6, 2022

Hm, the build failure is strange, is setAutoCompletion not available on all platforms?

@daschuer
Copy link
Member

daschuer commented Oct 6, 2022

Can you explain your use case a bit more?
I assume that this is a solution for a usability issue and not an issue that you never want the feature...

@fwcd
Copy link
Member Author

fwcd commented Oct 6, 2022

It's mostly minor things that I find a bit inconvenient:

  • The completions kicking in too quickly, as you've described in the issue
  • Accidentally hitting up/down or turning the track selection knob on the controller (while the search bar is focused) now moves through the history. While this of course is the intended behavior, I find it a bit irritating since I now have to seek back through the history and figure out what I previously wanted to type
  • I don't really use the feature, so being able to disable it makes the UI a bit less noisy

@ronso0
Copy link
Member

ronso0 commented Oct 6, 2022

Just a side note, the new options should be in the Library page.

@ronso0 ronso0 changed the title Interface: Add options to disable search completions and history WSearchLineEdit: Add options to disable auto-completion and history Oct 6, 2022
@ronso0
Copy link
Member

ronso0 commented Oct 6, 2022

Figure out why setAutoCompletion doesn't compile on all platforms

Use setCompleter(completer*)?
Either completer* is a valid QCompleter or a nullptr (disables auto-completion as described in the doc).

Also, instead of parsing the config on each Up/Down/Space press, why not use a static functions to set bools, like the one setting the debounce timeout?
void WSearchLineEdit::setDebouncingTimeoutMillis(int debouncingTimeoutMillis)

Furthermore, I'm not comfortable with removing the history function altogether (which is not the case now btw, queries are still saved and restored, though not accessible).
Isn't it sufficient for your use case to suppress the emulated keystrokes sent by librarycontrol, i.e. still allow regular hotkeys (Up, Down, Ctrl+Space) and keep the expand button?

@fwcd
Copy link
Member Author

fwcd commented Oct 7, 2022

I've moved the settings as per your suggestion to the Library page (see the updated screenshot in the PR description) and renamed the history setting to 'Enable search history shortcuts' to clarify that it only affects the shortcuts and not the history itself.

Suppressing the emulated keystrokes in LibraryControl would probably work but IMO feels a bit like the wrong place to model this (if we consider the search history to be an implementation detail of the search bar, we should also handle it there and not swallow the key events at a higher level). On the other hand, the generated keys are already somewhat tied to the search bar's semantics. Not sure about this one.

Regarding the static functions: While this may work for the history shortcuts (since we only need to read the value during key events), setSearchCompletionsEnabled cannot really be static if we want to to swap the completer based on whether search completions are enabled. The todo comment mentions that this also is more of a workaround currently and that it would be better to wire up the config changes with signals and slots. Since we would have access to the WSearchLineEdit instance that way, this would also solve the aforementioned issue.

Since I'm not that familiar with the data flow of configuration changes yet, do you have some pointers on how to do cleanly propagate config changes to WSearchLineEdit?

@ronso0
Copy link
Member

ronso0 commented Oct 8, 2022

setSearchCompletionsEnabled cannot really be static if we want to to swap the completer based on whether search completions are enabled.

You could check if this bool changed in the focusInEvent()

@ronso0
Copy link
Member

ronso0 commented Oct 8, 2022

Anyways, I assume this setting is changed rarely, so applying this after start / skin change/reload may be sufficient IMO

fwcd added a commit to fwcd/mixxx that referenced this pull request Oct 11, 2022
@fwcd fwcd marked this pull request as ready for review October 11, 2022 17:31
@fwcd
Copy link
Member Author

fwcd commented Oct 11, 2022

I've now wired up the settings as static bools as you suggested. Also, WSearchLineEdit now creates a custom owned QCompleter that is set depending on whether search completions are enabled.

One thing that struck me as slightly odd is that some settings are updated differently: For example, the debounce time is updated immediately when the user changes the widget whereas most other settings are first applied when the user clicks 'Apply'. This feels a bit inconsistent (but is probably a topic for another PR). With these new settings, I've tried to match the original semantics (i.e. first update the config when 'Apply' is clicked).

In the longer term, we'd probably want to find a clean way to notify WSearchLineEdit about config changes, the updating-static-variables feels like a workaround to a deeper architectural issue currently.

@ywwg
Copy link
Member

ywwg commented Oct 22, 2022

I support this feature, I do not personally like the autocomplete / history but I understand others may find it useful.

Copy link
Member

@ronso0 ronso0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry you had to wait so long, this was kinda pushed off the table.

It's working nicely, thanks. Just some nitpicks.
I guess it doesn't matter that the completer is always created even if it will never actually be loaded to lineEdit->completer.

src/preferences/dialog/dlgprefinterface.cpp Outdated Show resolved Hide resolved
src/widget/wsearchlineedit.cpp Outdated Show resolved Hide resolved
src/widget/wsearchlineedit.h Outdated Show resolved Hide resolved
src/widget/wsearchlineedit.h Outdated Show resolved Hide resolved
src/preferences/dialog/dlgpreflibrarydlg.ui Show resolved Hide resolved
src/widget/wsearchlineedit.h Outdated Show resolved Hide resolved
@ronso0
Copy link
Member

ronso0 commented Nov 22, 2022

I think it works also with without the "Search history:" label (also we need less space and thereby potentially avoid horizontal scrollbars for long translations)
image

  • Enable search history keyboard shortcuts ?

@fwcd
Copy link
Member Author

fwcd commented Nov 25, 2022

I've updated the branch with your suggestions

#include <QAbstractItemView>
#include <QApplication>
#include <QCompleter>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, during my previous review I didn't notice this is already included in wsearchlineedit.h
Please remove it here, git commit --amend (maybe name it more explicitely) and push one last time.

FYI rebasing after a review without approval is not appreciated since that means someone has to review again, instead of just checking the last commits. Here, it's not much of a drama because the change set is rather small and can be verified by manual testing.

Copy link
Member Author

@fwcd fwcd Nov 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI rebasing after a review without approval is not appreciated

Ah sorry, I'll try to keep that in mind for the next time (in this case the rebase was useful since the row numbering in dlgpreflibraryui changed upstream and would have silently merged without a conflict)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't neither review again nor test manually, so if you like to --fixup previous commits with the latest changes and squash.. feel free.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with amending for now, most of these are just small stylistic changes anyway

@ronso0 ronso0 added this to the 2.4.0 milestone Dec 4, 2022
@fwcd
Copy link
Member Author

fwcd commented Jan 4, 2023

Any updates on this?

@daschuer
Copy link
Member

After #11207 is merged, the completion is no longer applied immediately. It requires "→" or "⏎" to take effect.

This means the

The completions kicking in too quickly, as you've described in the issue

part will be solved.

Can we reduce this to only add the "EnableSearchHistoryShortcuts" preferences option for less clutter in the preferences?

@fwcd
Copy link
Member Author

fwcd commented Jan 18, 2023

I still think having the option to disable auto-completion would be cool, if only to reduce visual noise

Comment on lines 26 to 27
static constexpr bool kEnableCompletionsByDefault = true;
static constexpr bool kEnableHistoryShortcutsByDefault = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a function name, how about

Suggested change
static constexpr bool kEnableCompletionsByDefault = true;
static constexpr bool kEnableHistoryShortcutsByDefault = true;
static constexpr bool kDefaultSearchCompletionsEnabled = true;
static constexpr bool kDefaultSearchHistoryShortcutsEnabled = true;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I preferred to remove the redundant 'search' string, so let's name these
kCompletionsEnabledDefault
kHistoryShortcutsEnabledDefault
?

@@ -495,6 +513,15 @@ void DlgPrefLibrary::slotSearchDebouncingTimeoutMillisChanged(int searchDebounci
WSearchLineEdit::setDebouncingTimeoutMillis(searchDebouncingTimeoutMillis);
}

void DlgPrefLibrary::searchHistoryOptionsChanged() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is not a slot, name the function according to what it does, not when it is called.

Suggested change
void DlgPrefLibrary::searchHistoryOptionsChanged() {
void DlgPrefLibrary::updateSearchLineEditHistoryOptions() {

@daschuer
Copy link
Member

I still think having the option to disable auto-completion would be cool, if only to reduce visual noise

OK

@daschuer daschuer changed the base branch from main to 2.4 January 18, 2023 11:08
Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thank you.

@daschuer daschuer merged commit 89f5860 into mixxxdj:2.4 Jan 18, 2023
@fwcd fwcd deleted the configurable-search-bar branch January 18, 2023 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to disable search completions
4 participants