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

Revise librarycontrol // FocusWidget #4618

Merged
merged 7 commits into from
Feb 21, 2022

Conversation

ronso0
Copy link
Member

@ronso0 ronso0 commented Jan 14, 2022

While testing #4465 I was looking for a way to reliably navigate the track menu with a push encoder, and it turned out my FocusWidget approach in #4369 is complicated and not extendable to cover menus and dialogs.

Here I revise the focus control:

  • hook up to QApplication's focusChanged and focusWindowChanged signals. These are emitted every time the focused widget changes or when a new window/popup/menu is ready to receive keyboard presses, thus I could remove almost the entire former implementation.
  • these signals both invoke updateFocusedWidgetControls()
  • this identifies the currently focused Mixxx widget, QDialog or QMenu, and stores the FocusWidget type, as well as the respective new state of [Library],focused_widget.
  • this FocusWidget is now used by a few library controls to trigger context-specific actions -- this and LibraryControl::emitKeyEvent is now much simpler, faster and less error-prone I reckon

Updated enum values of [Library],focused_widget:

0  None        r
1  Searchbar   rw
2  Sidebar     rw
3  TracksTable rw  // or a feature root view (WLibraryTextBrowser)
4  ContextMenu r   // any context menu + main menu bar
                   // effect selector popup + AutoDJ transition mode popup
5  Dialog      r   // any file or error dialog, CoverArt, key wheel window, preferences, About
6  Unknown     r   // Unknown skin widget or unknown window

TESTING

with controller:
Every [Library] control should still work as expected.
For testing the menu navigation, manually open a context menu or one in the main menu bar, then use [Library],MoveVertical to move the selection, [Library],GoToItem to activate items and confirm dialogs. Or put https://github.com/ronso0/mixxx/tree/open-track-menu-control on top of this branch.
It's also possible to handle error messages and some compact dialogs with these controls, too.

without controller:
open developer tools, find focused_widget, then click around in the main GUI and watch how the value changes accordingly, see enum above.

@ronso0 ronso0 marked this pull request as draft January 14, 2022 01:13
@ronso0 ronso0 force-pushed the focus-widget-library-control branch 8 times, most recently from b1504a2 to 63ee935 Compare January 15, 2022 23:40
@ronso0 ronso0 marked this pull request as ready for review January 15, 2022 23:41
@ronso0
Copy link
Member Author

ronso0 commented Jan 15, 2022

Alright, I tested all controls that were touched by this PR, as well as navigating menus and dialogs.
Everything works as expected 🎉

@ronso0 ronso0 force-pushed the focus-widget-library-control branch from 63ee935 to ca34bfe Compare January 16, 2022 00:32
@daschuer
Copy link
Member

There seems to be a kind of loop when the Mixxx window receives the focus, resulting in a flashing focus border.
Is this intended?

@daschuer
Copy link
Member

The rest works nice. Please give a hint when you consider this a ready for merge.

@ronso0
Copy link
Member Author

ronso0 commented Jan 16, 2022

There seems to be a kind of loop when the Mixxx window receives the focus, resulting in a flashing focus border. Is this intended?

Not intended at all, and I can't reproduce.
I only hook up to the focus signals, not override focusEvents, so I don't know how the flashing is related to my changes (alternating focusIn/focusOut events). Mixxx itself does not set focus itself -- setLibraryFocus(FocusWidget) is only called when you press Esc in the sidebar or in the search box.

Can you describe your scenario and which widget is flashing?

@ronso0 ronso0 force-pushed the focus-widget-library-control branch from ca34bfe to 92fff33 Compare January 16, 2022 15:24
@Swiftb0y
Copy link
Member

There seems to be a kind of loop when the Mixxx window receives the focus, resulting in a flashing focus border. Is this intended?

fwiw, I can't reproduce this either.

@daschuer
Copy link
Member

Oh I have just notice that other Qt Apps are affected as well. So this it probably a Qt issue.

@ronso0 ronso0 force-pushed the focus-widget-library-control branch from 5ed1f3b to f87361f Compare January 19, 2022 21:10
@ronso0
Copy link
Member Author

ronso0 commented Jan 19, 2022

Please let me know when someone starts a code review.
Until then I may still force-push with cosmetic changes / fixups not worth separate commits.

@ronso0 ronso0 force-pushed the focus-widget-library-control branch from f87361f to 3037d5d Compare January 22, 2022 00:00
@@ -35,7 +34,7 @@ class WTrackTableView : public WLibraryTableView {
bool hasFocus() const override;
void setFocus() override;
void keyPressEvent(QKeyEvent* event) override;
void loadSelectedTrack() override;
void doubleClickSelectedTrack() override;
Copy link
Member

@Holzhaus Holzhaus Jan 22, 2022

Choose a reason for hiding this comment

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

We shouldn't name signals like that. Double clicking only works computers with a mouse. It does not work on touchscreens (double tapping), it does not work on controllers (long press?).

How about something like triggerSelectedTrackSecondaryAction() or something like that?

Note: This is not a code review, feel free to force-push.

Copy link
Member

Choose a reason for hiding this comment

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

Or is this a non-issue because this signal will never be emitted by using a touchscreen or a controller?

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 simply adjusted to the wording in Preferences > Library > Track Double-Click Action so that the connection is clear for developers.

Copy link
Member

Choose a reason for hiding this comment

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

suggestion: activateSelectedTrack

Copy link
Member Author

Choose a reason for hiding this comment

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

yup, perfect!

@ronso0 ronso0 force-pushed the focus-widget-library-control branch from 3037d5d to a60dcad Compare January 22, 2022 23:52
@ronso0 ronso0 added this to the 2.4.0 milestone Jan 26, 2022
Emulated Shift+Tab sent to QApplication::focusWidget() moves the focus,
THOUGH it also makes Shift get stuck for this widget.
Actually, this wouldn't matter because Shift is released as soon as this
widget receives any keyEvent with Qt::NoModifier.
Though, [Playlist],selectTrackKnob doesn't use keyEvents, thus using it
directly after [Library],MoveFocusBackward would expand the selection...

Simply use BackTab key :)
@ronso0 ronso0 force-pushed the focus-widget-library-control branch from a60dcad to 98033e6 Compare January 29, 2022 21:18
@ronso0
Copy link
Member Author

ronso0 commented Feb 17, 2022

For testing without controllers you can put abd1520 on top to have some debug output and skin feedback for FocusWidget.

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, And works as expected. Thank you.

@daschuer daschuer merged commit 4ed8721 into mixxxdj:main Feb 21, 2022
@ronso0 ronso0 deleted the focus-widget-library-control branch February 22, 2022 09:09
@ronso0
Copy link
Member Author

ronso0 commented Feb 22, 2022

Great, I'll add the documentation when I'm back home.

@ronso0 ronso0 added the changelog This PR should be included in the changelog label Apr 10, 2022
@ronso0
Copy link
Member Author

ronso0 commented Oct 15, 2022

fixup 4f45dbe
Thanks @JosepMaJAZ for spotting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog This PR should be included in the changelog library ui
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants