summaryrefslogtreecommitdiffstats
path: root/src/library
diff options
context:
space:
mode:
authorBe <be@mixxx.org>2020-04-26 14:50:30 -0500
committerGitHub <noreply@github.com>2020-04-26 14:50:30 -0500
commit46596a18b6b815ab7934fe17166495668c170861 (patch)
treec33e9822c5c656db812f4f15da2d949b6345edd8 /src/library
parentc615baec715c5bd56e8b8b823f99b9bf1c183b45 (diff)
parent93d3b59b2eb1c5b862f7c6b43118dc8418eb417c (diff)
Merge pull request #2599 from ronso0/fix-activeView-hasFocus
fix library navigation & focus issues
Diffstat (limited to 'src/library')
-rw-r--r--src/library/autodj/dlgautodj.cpp2
-rw-r--r--src/library/dlganalysis.cpp2
-rw-r--r--src/library/dlghidden.cpp2
-rw-r--r--src/library/dlgmissing.cpp2
-rw-r--r--src/library/librarycontrol.cpp21
-rw-r--r--src/library/recording/dlgrecording.cpp2
6 files changed, 21 insertions, 10 deletions
diff --git a/src/library/autodj/dlgautodj.cpp b/src/library/autodj/dlgautodj.cpp
index c0f32ea068..b80465998b 100644
--- a/src/library/autodj/dlgautodj.cpp
+++ b/src/library/autodj/dlgautodj.cpp
@@ -362,5 +362,5 @@ void DlgAutoDJ::updateSelectionInfo() {
}
bool DlgAutoDJ::hasFocus() const {
- return QWidget::hasFocus();
+ return m_pTrackTableView->hasFocus();
}
diff --git a/src/library/dlganalysis.cpp b/src/library/dlganalysis.cpp
index bd1b064112..a3f9a1bf34 100644
--- a/src/library/dlganalysis.cpp
+++ b/src/library/dlganalysis.cpp
@@ -105,7 +105,7 @@ void DlgAnalysis::onShow() {
}
bool DlgAnalysis::hasFocus() const {
- return QWidget::hasFocus();
+ return m_pAnalysisLibraryTableView->hasFocus();
}
void DlgAnalysis::onSearch(const QString& text) {
diff --git a/src/library/dlghidden.cpp b/src/library/dlghidden.cpp
index 77dfcd94e9..8b4807f3b4 100644
--- a/src/library/dlghidden.cpp
+++ b/src/library/dlghidden.cpp
@@ -120,5 +120,5 @@ void DlgHidden::selectionChanged(const QItemSelection &selected,
}
bool DlgHidden::hasFocus() const {
- return QWidget::hasFocus();
+ return m_pTrackTableView->hasFocus();
}
diff --git a/src/library/dlgmissing.cpp b/src/library/dlgmissing.cpp
index d2d1240f3e..30bb96d379 100644
--- a/src/library/dlgmissing.cpp
+++ b/src/library/dlgmissing.cpp
@@ -89,5 +89,5 @@ void DlgMissing::selectionChanged(const QItemSelection &selected,
}
bool DlgMissing::hasFocus() const {
- return QWidget::hasFocus();
+ return m_pTrackTableView->hasFocus();
}
diff --git a/src/library/librarycontrol.cpp b/src/library/librarycontrol.cpp
index feacf2baa0..6947453c84 100644
--- a/src/library/librarycontrol.cpp
+++ b/src/library/librarycontrol.cpp
@@ -485,7 +485,7 @@ void LibraryControl::slotMoveFocus(double v) {
}
void LibraryControl::emitKeyEvent(QKeyEvent&& event) {
- // Ensure a valid library widget has the keyboard focus.
+ // Ensure there's a valid library widget that can receive keyboard focus.
// QApplication::focusWidget() is not sufficient here because it
// would return any focused widget like WOverview, WWaveform, QSpinBox
VERIFY_OR_DEBUG_ASSERT(m_pSidebarWidget) {
@@ -494,14 +494,25 @@ void LibraryControl::emitKeyEvent(QKeyEvent&& event) {
VERIFY_OR_DEBUG_ASSERT(m_pLibraryWidget) {
return;
}
- if (!m_pLibraryWidget->hasFocus() && !m_pSidebarWidget->hasFocus()) {
+ if (!QApplication::focusWindow()) {
+ qDebug() << "Mixxx window is not focused, don't send key events";
+ return;
+ }
+
+ bool keyIsTab = event.key() == static_cast<int>(Qt::Key_Tab);
+
+ // If the main window has focus, any widget can receive Tab.
+ // Other keys should be sent to library widgets only to not
+ // accidentally alter spinboxes etc.
+ if (!keyIsTab && !m_pSidebarWidget->hasFocus()
+ && !m_pLibraryWidget->getActiveView()->hasFocus()) {
setLibraryFocus();
}
- auto focusWidget = QApplication::focusWidget();
- VERIFY_OR_DEBUG_ASSERT(focusWidget) {
- return;
+ if (keyIsTab && !QApplication::focusWidget()){
+ setLibraryFocus();
}
// Send the event pointer to the currently focused widget
+ auto focusWidget = QApplication::focusWidget();
for (auto i = 0; i < event.count(); ++i) {
QApplication::sendEvent(focusWidget, &event);
}
diff --git a/src/library/recording/dlgrecording.cpp b/src/library/recording/dlgrecording.cpp
index 8a6e698eeb..86acf6d293 100644
--- a/src/library/recording/dlgrecording.cpp
+++ b/src/library/recording/dlgrecording.cpp
@@ -107,7 +107,7 @@ void DlgRecording::onShow() {
}
bool DlgRecording::hasFocus() const {
- return QWidget::hasFocus();
+ return m_pTrackTableView->hasFocus();
}
void DlgRecording::refreshBrowseModel() {