diff options
author | Timothy Rae <perceptualchaos2@gmail.com> | 2016-05-22 23:20:04 +0900 |
---|---|---|
committer | Timothy Rae <perceptualchaos2@gmail.com> | 2017-01-07 10:22:41 +0900 |
commit | 64e7dd2854d56b0beb1a0ed2bbc59140c09d96d7 (patch) | |
tree | 052125bc1d9998409a3aff24507449d3185ffeb3 | |
parent | 673dff5de4c7ab194c70afbb1711eba5edb59915 (diff) |
Add new control SelectItemKnob
The new SelectItemKnob control selects either the next track or the next sidebar item, depending on which widget has focus
-rw-r--r-- | src/library/autodj/dlgautodj.cpp | 4 | ||||
-rw-r--r-- | src/library/autodj/dlgautodj.h | 1 | ||||
-rw-r--r-- | src/library/dlganalysis.cpp | 4 | ||||
-rw-r--r-- | src/library/dlganalysis.h | 1 | ||||
-rw-r--r-- | src/library/dlghidden.cpp | 4 | ||||
-rw-r--r-- | src/library/dlghidden.h | 1 | ||||
-rw-r--r-- | src/library/dlgmissing.cpp | 4 | ||||
-rw-r--r-- | src/library/dlgmissing.h | 1 | ||||
-rw-r--r-- | src/library/librarycontrol.cpp | 16 | ||||
-rw-r--r-- | src/library/librarycontrol.h | 2 | ||||
-rw-r--r-- | src/library/libraryview.h | 1 | ||||
-rw-r--r-- | src/library/recording/dlgrecording.cpp | 4 | ||||
-rw-r--r-- | src/library/recording/dlgrecording.h | 1 | ||||
-rw-r--r-- | src/widget/wlibrarytextbrowser.cpp | 4 | ||||
-rw-r--r-- | src/widget/wlibrarytextbrowser.h | 2 | ||||
-rw-r--r-- | src/widget/wtracktableview.cpp | 4 | ||||
-rw-r--r-- | src/widget/wtracktableview.h | 1 |
17 files changed, 54 insertions, 1 deletions
diff --git a/src/library/autodj/dlgautodj.cpp b/src/library/autodj/dlgautodj.cpp index 9b2197e422..5ed512d8bf 100644 --- a/src/library/autodj/dlgautodj.cpp +++ b/src/library/autodj/dlgautodj.cpp @@ -223,3 +223,7 @@ void DlgAutoDJ::updateSelectionInfo() { labelSelectionInfo->setEnabled(false); } } + +bool DlgAutoDJ::hasFocus() const { + return QWidget::hasFocus(); +} diff --git a/src/library/autodj/dlgautodj.h b/src/library/autodj/dlgautodj.h index fda36bcdcb..bcf07d6f80 100644 --- a/src/library/autodj/dlgautodj.h +++ b/src/library/autodj/dlgautodj.h @@ -26,6 +26,7 @@ class DlgAutoDJ : public QWidget, public Ui::DlgAutoDJ, public LibraryView { virtual ~DlgAutoDJ(); void onShow(); + bool hasFocus() const; void onSearch(const QString& text); void loadSelectedTrack(); void loadSelectedTrackToGroup(QString group, bool play); diff --git a/src/library/dlganalysis.cpp b/src/library/dlganalysis.cpp index 6d8ec9f380..56ea621766 100644 --- a/src/library/dlganalysis.cpp +++ b/src/library/dlganalysis.cpp @@ -72,6 +72,10 @@ void DlgAnalysis::onShow() { m_pAnalysisLibraryTableModel->select(); } +bool DlgAnalysis::hasFocus() const { + return QWidget::hasFocus(); +} + void DlgAnalysis::onSearch(const QString& text) { m_pAnalysisLibraryTableModel->search(text); } diff --git a/src/library/dlganalysis.h b/src/library/dlganalysis.h index 84520b38cf..32bf197db1 100644 --- a/src/library/dlganalysis.h +++ b/src/library/dlganalysis.h @@ -22,6 +22,7 @@ class DlgAnalysis : public QWidget, public Ui::DlgAnalysis, public virtual Libra virtual void onSearch(const QString& text); virtual void onShow(); + virtual bool hasFocus() const; virtual void loadSelectedTrack(); virtual void loadSelectedTrackToGroup(QString group, bool play); virtual void slotSendToAutoDJ(); diff --git a/src/library/dlghidden.cpp b/src/library/dlghidden.cpp index 9cddafb991..5335f5baa2 100644 --- a/src/library/dlghidden.cpp +++ b/src/library/dlghidden.cpp @@ -94,3 +94,7 @@ void DlgHidden::setTrackTableFont(const QFont& font) { void DlgHidden::setTrackTableRowHeight(int rowHeight) { m_pTrackTableView->setTrackTableRowHeight(rowHeight); } + +bool DlgHidden::hasFocus() const { + return QWidget::hasFocus(); +} diff --git a/src/library/dlghidden.h b/src/library/dlghidden.h index 6b78d85f1f..91c65c2d5c 100644 --- a/src/library/dlghidden.h +++ b/src/library/dlghidden.h @@ -21,6 +21,7 @@ class DlgHidden : public QWidget, public Ui::DlgHidden, public LibraryView { virtual ~DlgHidden(); void onShow(); + bool hasFocus() const; void onSearch(const QString& text); public slots: diff --git a/src/library/dlgmissing.cpp b/src/library/dlgmissing.cpp index 3f5918bfb3..e5207b4d44 100644 --- a/src/library/dlgmissing.cpp +++ b/src/library/dlgmissing.cpp @@ -87,3 +87,7 @@ void DlgMissing::setTrackTableFont(const QFont& font) { void DlgMissing::setTrackTableRowHeight(int rowHeight) { m_pTrackTableView->setTrackTableRowHeight(rowHeight); } + +bool DlgMissing::hasFocus() const { + return QWidget::hasFocus(); +} diff --git a/src/library/dlgmissing.h b/src/library/dlgmissing.h index fe287e8e8e..6b469dcd62 100644 --- a/src/library/dlgmissing.h +++ b/src/library/dlgmissing.h @@ -20,6 +20,7 @@ class DlgMissing : public QWidget, public Ui::DlgMissing, public LibraryView { virtual ~DlgMissing(); void onShow(); + bool hasFocus() const; void onSearch(const QString& text); public slots: diff --git a/src/library/librarycontrol.cpp b/src/library/librarycontrol.cpp index 577b9fac17..f7a36fade4 100644 --- a/src/library/librarycontrol.cpp +++ b/src/library/librarycontrol.cpp @@ -78,6 +78,11 @@ LibraryControl::LibraryControl(Library* pLibrary) connect(m_pSelectTrack, SIGNAL(valueChanged(double)), this, SLOT(slotSelectTrack(double))); + // Ignoring no-ops is important since this is for +/- tickers. + m_pSelectItem = new ControlObject(ConfigKey("[Playlist]","SelectItemKnob"), false); + connect(m_pSelectItem, SIGNAL(valueChanged(double)), + this, SLOT(slotSelectItem(double))); + m_pSelectNextSidebarItem = new ControlPushButton(ConfigKey("[Playlist]", "SelectNextPlaylist")); connect(m_pSelectNextSidebarItem, SIGNAL(valueChanged(double)), this, SLOT(slotSelectNextSidebarItem(double))); @@ -292,6 +297,17 @@ void LibraryControl::slotSelectTrack(double v) { activeView->moveSelection(i); } +void LibraryControl::slotSelectItem(double v) { + if (m_pLibraryWidget == NULL || m_pSidebarWidget == NULL) { + return; + } + // Select track if a LibraryView object has focus, otherwise select sidebar item + if (m_pLibraryWidget->getActiveView()->hasFocus()) { + return slotSelectTrack(v); + } + slotSelectSidebarItem(v); +} + void LibraryControl::slotSelectSidebarItem(double v) { if (m_pSidebarWidget == NULL) { return; diff --git a/src/library/librarycontrol.h b/src/library/librarycontrol.h index 7b449d9c5a..f197870c1f 100644 --- a/src/library/librarycontrol.h +++ b/src/library/librarycontrol.h @@ -48,6 +48,7 @@ class LibraryControl : public QObject { void slotSelectPrevTrack(double v); void slotSelectTrack(double v); void slotSelectSidebarItem(double v); + void slotSelectItem(double v); void slotSelectNextSidebarItem(double v); void slotSelectPrevSidebarItem(double v); void slotToggleSelectedSidebarItem(double v); @@ -72,6 +73,7 @@ class LibraryControl : public QObject { ControlObject* m_pSelectTrack; ControlObject* m_pSelectSidebarItem; + ControlObject* m_pSelectItem; ControlObject* m_pSelectPrevSidebarItem; ControlObject* m_pSelectNextSidebarItem; diff --git a/src/library/libraryview.h b/src/library/libraryview.h index 5ae34aee2f..1e5a5c03a2 100644 --- a/src/library/libraryview.h +++ b/src/library/libraryview.h @@ -14,6 +14,7 @@ class LibraryView { virtual ~LibraryView() {}; virtual void onShow() = 0; + virtual bool hasFocus() const = 0; // reimplement if LibraryView should be able to search virtual void onSearch(const QString& text) {Q_UNUSED(text);} diff --git a/src/library/recording/dlgrecording.cpp b/src/library/recording/dlgrecording.cpp index 043a9fffd1..0a6ea5c14a 100644 --- a/src/library/recording/dlgrecording.cpp +++ b/src/library/recording/dlgrecording.cpp @@ -69,6 +69,10 @@ void DlgRecording::onShow() { m_browseModel.setPath(m_recordingDir); } +bool DlgRecording::hasFocus() const { + return QWidget::hasFocus(); +} + void DlgRecording::refreshBrowseModel() { m_browseModel.setPath(m_recordingDir); } diff --git a/src/library/recording/dlgrecording.h b/src/library/recording/dlgrecording.h index 53b515bf32..7ce1a0ea69 100644 --- a/src/library/recording/dlgrecording.h +++ b/src/library/recording/dlgrecording.h @@ -26,6 +26,7 @@ class DlgRecording : public QWidget, public Ui::DlgRecording, public virtual Lib virtual void onSearch(const QString& text); virtual void onShow(); + virtual bool hasFocus() const; virtual void loadSelectedTrack(); virtual void slotSendToAutoDJ(); virtual void slotSendToAutoDJTop(); diff --git a/src/widget/wlibrarytextbrowser.cpp b/src/widget/wlibrarytextbrowser.cpp index a6dd786326..52b2951038 100644 --- a/src/widget/wlibrarytextbrowser.cpp +++ b/src/widget/wlibrarytextbrowser.cpp @@ -6,3 +6,7 @@ WLibraryTextBrowser::WLibraryTextBrowser(QWidget* parent) : QTextBrowser(parent) { } + +bool WLibraryTextBrowser::hasFocus() const { + return QWidget::hasFocus(); +} diff --git a/src/widget/wlibrarytextbrowser.h b/src/widget/wlibrarytextbrowser.h index 2fedfd0fba..e61c38efa0 100644 --- a/src/widget/wlibrarytextbrowser.h +++ b/src/widget/wlibrarytextbrowser.h @@ -12,8 +12,8 @@ class WLibraryTextBrowser : public QTextBrowser, public LibraryView { Q_OBJECT public: explicit WLibraryTextBrowser(QWidget* parent = nullptr); - void onShow() override {} + bool hasFocus() const override; }; #endif /* WLIBRARYTEXTBROWSER_H */ diff --git a/src/widget/wtracktableview.cpp b/src/widget/wtracktableview.cpp index 8f74136f77..da32692e72 100644 --- a/src/widget/wtracktableview.cpp +++ b/src/widget/wtracktableview.cpp @@ -1680,3 +1680,7 @@ void WTrackTableView::slotReloadCoverArt() { pCache->requestGuessCovers(selectedTracks); } } + +bool WTrackTableView::hasFocus() const { + return QWidget::hasFocus(); +} diff --git a/src/widget/wtracktableview.h b/src/widget/wtracktableview.h index 6e1172960a..0363e026e2 100644 --- a/src/widget/wtracktableview.h +++ b/src/widget/wtracktableview.h @@ -32,6 +32,7 @@ class WTrackTableView : public WLibraryTableView { void contextMenuEvent(QContextMenuEvent * event) override; void onSearch(const QString& text) override; void onShow() override; + bool hasFocus() const override; void keyPressEvent(QKeyEvent* event) override; void loadSelectedTrack() override; void loadSelectedTrackToGroup(QString group, bool play) override; |