-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Refocus library #11767
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
Merged
Merged
Refocus library #11767
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,7 +57,8 @@ void LoadToGroupController::slotLoadToGroupAndPlay(double v) { | |
| LibraryControl::LibraryControl(Library* pLibrary) | ||
| : QObject(pLibrary), | ||
| m_pLibrary(pLibrary), | ||
| m_pFocusedWidget(FocusWidget::None), | ||
| m_focusedWidget(FocusWidget::None), | ||
| m_prevFocusedWidget(FocusWidget::None), | ||
| m_pLibraryWidget(nullptr), | ||
| m_pSidebarWidget(nullptr), | ||
| m_pSearchbox(nullptr), | ||
|
|
@@ -172,6 +173,17 @@ LibraryControl::LibraryControl(Library* pLibrary) | |
| }); | ||
| #endif | ||
|
|
||
| // Pure trigger control. Alternative for signal/slot since widgets that want | ||
| // to call refocusPrevLibraryWidget() are cumbersome to connect to. | ||
| // This CO is never actually set or read so the value just needs to be not 0 | ||
| m_pRefocusPrevWidgetCO = std::make_unique<ControlPushButton>( | ||
| ConfigKey("[Library]", "refocus_prev_widget")); | ||
| m_pRefocusPrevWidgetCO->setButtonMode(ControlPushButton::TRIGGER); | ||
| #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the reason to not connect it in Qt 6?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. QML. No legacy library widgets, so it's guarded like the other functions that work with these widgets. |
||
| m_pRefocusPrevWidgetCO->connectValueChangeRequest(this, | ||
| &LibraryControl::refocusPrevLibraryWidget); | ||
| #endif | ||
|
|
||
| // Control to "goto" the currently selected item in focused widget (context dependent) | ||
| m_pGoToItem = std::make_unique<ControlPushButton>(ConfigKey("[Library]", "GoToItem")); | ||
| #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) | ||
|
|
@@ -411,7 +423,7 @@ LibraryControl::LibraryControl(Library* pLibrary) | |
| connect(app, | ||
| &QApplication::focusChanged, | ||
| this, | ||
| &LibraryControl::updateFocusedWidgetControls); | ||
| &LibraryControl::slotFocusedWidgetChanged); | ||
| // Also update controls if the window focus changed. | ||
| // Even though any new menu window has focus and will receive keypress events | ||
| // it does NOT have a focused widget before the first click or keypress. | ||
|
|
@@ -628,7 +640,7 @@ void LibraryControl::slotMoveVertical(double v) { | |
| return; | ||
| } | ||
|
|
||
| switch (m_pFocusedWidget) { | ||
| switch (m_focusedWidget) { | ||
| case FocusWidget::Sidebar: { | ||
| int i = static_cast<int>(v); | ||
| slotSelectSidebarItem(i); | ||
|
|
@@ -747,11 +759,8 @@ void LibraryControl::emitKeyEvent(QKeyEvent&& event) { | |
| return; | ||
| } | ||
|
|
||
| switch (m_pFocusedWidget) { | ||
| case FocusWidget::None: | ||
| if (m_focusedWidget == FocusWidget::None) { | ||
| return setLibraryFocus(FocusWidget::TracksTable); | ||
| default: | ||
| break; | ||
| } | ||
|
|
||
| // Send the event pointer to the currently focused widget | ||
|
|
@@ -818,7 +827,7 @@ void LibraryControl::setLibraryFocus(FocusWidget newFocusWidget) { | |
| } | ||
|
|
||
| // ignore no-op | ||
| if (newFocusWidget == m_pFocusedWidget) { | ||
| if (newFocusWidget == m_focusedWidget) { | ||
| return; | ||
| } | ||
|
|
||
|
|
@@ -850,13 +859,32 @@ void LibraryControl::setLibraryFocus(FocusWidget newFocusWidget) { | |
| // to update [Library],focused_widget | ||
| } | ||
|
|
||
| void LibraryControl::slotFocusedWidgetChanged(QWidget* oldW, QWidget* newW) { | ||
| Q_UNUSED(newW); | ||
|
|
||
| // If one of the library widgets had focus store it so we can return to it, | ||
| // for example when we finish editing a WBeatSizeSpinBox. | ||
| if (m_pSearchbox && oldW == m_pSearchbox) { | ||
| m_prevFocusedWidget = FocusWidget::Searchbar; | ||
| } else if (m_pSidebarWidget && oldW == m_pSidebarWidget) { | ||
| m_prevFocusedWidget = FocusWidget::Sidebar; | ||
| } else if (m_pLibraryWidget && oldW == m_pLibraryWidget->currentWidget()) { | ||
| m_prevFocusedWidget = FocusWidget::TracksTable; | ||
| } | ||
| updateFocusedWidgetControls(); | ||
| } | ||
|
|
||
| void LibraryControl::updateFocusedWidgetControls() { | ||
| m_pFocusedWidget = getFocusedWidget(); | ||
| m_focusedWidget = getFocusedWidget(); | ||
| // Update "[Library], focused_widget" control | ||
| double newVal = static_cast<double>(m_pFocusedWidget); | ||
| double newVal = static_cast<double>(m_focusedWidget); | ||
| m_pFocusedWidgetCO->setAndConfirm(newVal); | ||
| } | ||
|
|
||
| void LibraryControl::refocusPrevLibraryWidget() { | ||
| setLibraryFocus(m_prevFocusedWidget); | ||
| } | ||
|
|
||
| void LibraryControl::slotSelectSidebarItem(double v) { | ||
| if (!m_pSidebarWidget) { | ||
| return; | ||
|
|
@@ -895,7 +923,7 @@ void LibraryControl::slotGoToItem(double v) { | |
| return; | ||
| } | ||
|
|
||
| switch (m_pFocusedWidget) { | ||
| switch (m_focusedWidget) { | ||
| case FocusWidget::Sidebar: | ||
| // Focus the library if this is a leaf node in the tree | ||
| // Note that Tracks and AutoDJ always return 'false': | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should work when connecting to keyboard or controllers. Probably not a use case, but this would make it complete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting! Will try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jup, works. Thanks.