From f3d2d7d0320cad694cff046811181c10b2e9a34f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nino=20Mi=C5=A1ki=C4=87-Pletenac?= Date: Sun, 27 Feb 2022 02:22:20 +0100 Subject: [PATCH 1/9] WTrackMenu: Add ability to select/highlight loaded track in library --- src/library/library.cpp | 1 + src/library/library.h | 1 + src/widget/wtrackmenu.cpp | 17 +++++++++++++++++ src/widget/wtrackmenu.h | 7 ++++++- src/widget/wtrackproperty.cpp | 3 ++- src/widget/wtracktableview.h | 4 ++++ 6 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/library/library.cpp b/src/library/library.cpp index 44da525af38..5b5f49e1e7a 100644 --- a/src/library/library.cpp +++ b/src/library/library.cpp @@ -400,6 +400,7 @@ void Library::bindLibraryWidget( &Library::restoreModelState, pTrackTableView, &WTrackTableView::slotRestoreCurrentViewState); + connect(this, &Library::selectTrack, pTrackTableView, &WTrackTableView::slotSelectTrack); connect(pTrackTableView, &WTrackTableView::trackSelected, this, diff --git a/src/library/library.h b/src/library/library.h index a1596dd1154..8c9f20caa3b 100644 --- a/src/library/library.h +++ b/src/library/library.h @@ -127,6 +127,7 @@ class Library: public QObject { void disableSearch(); // emit this signal to enable/disable the cover art widget void enableCoverArtDisplay(bool); + void selectTrack(const TrackId&); void trackSelected(TrackPointer pTrack); #ifdef __ENGINEPRIME__ void exportLibrary(); diff --git a/src/widget/wtrackmenu.cpp b/src/widget/wtrackmenu.cpp index 31567cbd0df..6e0b442f9ca 100644 --- a/src/widget/wtrackmenu.cpp +++ b/src/widget/wtrackmenu.cpp @@ -263,6 +263,11 @@ void WTrackMenu::createActions() { connect(m_pFileBrowserAct, &QAction::triggered, this, &WTrackMenu::slotOpenInFileBrowser); } + if (featureIsEnabled(Feature::SelectInLibrary)) { + m_pSelectInLibraryAct = new QAction(tr("Select in Library"), this); + connect(m_pSelectInLibraryAct, &QAction::triggered, this, &WTrackMenu::slotSelectInLibrary); + } + if (featureIsEnabled(Feature::Metadata)) { m_pImportMetadataFromFileAct = new QAction(tr("Import From File Tags"), m_pMetadataMenu); @@ -562,6 +567,10 @@ void WTrackMenu::setupActions() { addAction(m_pFileBrowserAct); } + if (featureIsEnabled(Feature::SelectInLibrary)) { + addAction(m_pSelectInLibraryAct); + } + if (featureIsEnabled(Feature::Properties)) { addSeparator(); addAction(m_pPropertiesAct); @@ -970,6 +979,12 @@ void WTrackMenu::slotOpenInFileBrowser() { mixxx::DesktopHelper::openInFileBrowser(locations); } +void WTrackMenu::slotSelectInLibrary() { + if (m_pTrack) { + m_pLibrary->selectTrack(m_pTrack->getId()); + } +} + namespace { class ImportMetadataFromFileTagsTrackPointerOperation : public mixxx::TrackPointerOperation { @@ -2134,6 +2149,8 @@ bool WTrackMenu::featureIsEnabled(Feature flag) const { return m_pTrackModel->hasCapabilities(TrackModel::Capability::EditMetadata); case Feature::SearchRelated: return m_pLibrary != nullptr; + case Feature::SelectInLibrary: + return m_pTrack != nullptr; default: DEBUG_ASSERT(!"unreachable"); return false; diff --git a/src/widget/wtrackmenu.h b/src/widget/wtrackmenu.h index d8deb81f8e2..a685d2db266 100644 --- a/src/widget/wtrackmenu.h +++ b/src/widget/wtrackmenu.h @@ -50,10 +50,11 @@ class WTrackMenu : public QMenu { Properties = 1 << 12, SearchRelated = 1 << 13, UpdateReplayGainFromPregain = 1 << 14, + SelectInLibrary = 1 << 15, TrackModelFeatures = Remove | HideUnhidePurge, All = AutoDJ | LoadTo | Playlist | Crate | Remove | Metadata | Reset | BPM | Color | HideUnhidePurge | RemoveFromDisk | FileBrowser | - Properties | SearchRelated | UpdateReplayGainFromPregain + Properties | SearchRelated | UpdateReplayGainFromPregain | SelectInLibrary }; Q_DECLARE_FLAGS(Features, Feature) @@ -88,6 +89,7 @@ class WTrackMenu : public QMenu { private slots: // File void slotOpenInFileBrowser(); + void slotSelectInLibrary(); // Row color void slotColorPicked(const mixxx::RgbColor::optional_t& color); @@ -253,6 +255,9 @@ class WTrackMenu : public QMenu { // Open file in default file browser QAction* m_pFileBrowserAct{}; + // Select track in library + QAction* m_pSelectInLibraryAct{}; + // BPM feature QAction* m_pBpmLockAction{}; QAction* m_pBpmUnlockAction{}; diff --git a/src/widget/wtrackproperty.cpp b/src/widget/wtrackproperty.cpp index 2b0ac29f8de..dab489ca8d4 100644 --- a/src/widget/wtrackproperty.cpp +++ b/src/widget/wtrackproperty.cpp @@ -21,7 +21,8 @@ constexpr WTrackMenu::Features kTrackMenuFeatures = WTrackMenu::Feature::RemoveFromDisk | WTrackMenu::Feature::FileBrowser | WTrackMenu::Feature::Properties | - WTrackMenu::Feature::UpdateReplayGainFromPregain; + WTrackMenu::Feature::UpdateReplayGainFromPregain | + WTrackMenu::Feature::SelectInLibrary; } // namespace WTrackProperty::WTrackProperty( diff --git a/src/widget/wtracktableview.h b/src/widget/wtracktableview.h index 8001c5d318f..8b2e46eb6df 100644 --- a/src/widget/wtracktableview.h +++ b/src/widget/wtracktableview.h @@ -73,6 +73,10 @@ class WTrackTableView : public WLibraryTableView { bool slotRestoreCurrentViewState() { return restoreCurrentViewState(); }; + void slotSelectTrack(const TrackId& trackId) { + setCurrentTrackId(trackId); + setSelectedTracks({trackId}); + } private slots: void doSortByColumn(int headerSection, Qt::SortOrder sortOrder); From 1bc6bab65b3b02ef299fce9bb5894e6a1b4a3fe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nino=20Mi=C5=A1ki=C4=87-Pletenac?= Date: Mon, 28 Feb 2022 00:50:00 +0100 Subject: [PATCH 2/9] WTrackMenu: Add missing emit keyword --- src/widget/wtrackmenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widget/wtrackmenu.cpp b/src/widget/wtrackmenu.cpp index 6e0b442f9ca..27472b10106 100644 --- a/src/widget/wtrackmenu.cpp +++ b/src/widget/wtrackmenu.cpp @@ -981,7 +981,7 @@ void WTrackMenu::slotOpenInFileBrowser() { void WTrackMenu::slotSelectInLibrary() { if (m_pTrack) { - m_pLibrary->selectTrack(m_pTrack->getId()); + emit m_pLibrary->selectTrack(m_pTrack->getId()); } } From 8a36ea996aa630e5cfe274386d538cc59fe105e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nino=20Mi=C5=A1ki=C4=87-Pletenac?= Date: Sun, 13 Mar 2022 00:30:00 +0100 Subject: [PATCH 3/9] WTrackTableView: Move implementation of slotSelectTrack() to .cpp file --- src/widget/wtracktableview.cpp | 5 +++++ src/widget/wtracktableview.h | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/widget/wtracktableview.cpp b/src/widget/wtracktableview.cpp index d3ba4262afd..4dba8e24fb9 100644 --- a/src/widget/wtracktableview.cpp +++ b/src/widget/wtracktableview.cpp @@ -1034,6 +1034,11 @@ void WTrackTableView::slotAddToAutoDJReplace() { addToAutoDJ(PlaylistDAO::AutoDJSendLoc::REPLACE); } +void WTrackTableView::slotSelectTrack(const TrackId& trackId) { + setCurrentTrackId(trackId); + setSelectedTracks({trackId}); +} + void WTrackTableView::doSortByColumn(int headerSection, Qt::SortOrder sortOrder) { TrackModel* trackModel = getTrackModel(); QAbstractItemModel* itemModel = model(); diff --git a/src/widget/wtracktableview.h b/src/widget/wtracktableview.h index 8b2e46eb6df..4b2cb11d740 100644 --- a/src/widget/wtracktableview.h +++ b/src/widget/wtracktableview.h @@ -73,10 +73,7 @@ class WTrackTableView : public WLibraryTableView { bool slotRestoreCurrentViewState() { return restoreCurrentViewState(); }; - void slotSelectTrack(const TrackId& trackId) { - setCurrentTrackId(trackId); - setSelectedTracks({trackId}); - } + void slotSelectTrack(const TrackId&); private slots: void doSortByColumn(int headerSection, Qt::SortOrder sortOrder); From 6d6a36ac4190ee9a4ecec1d1312d893bf6ced49e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nino=20Mi=C5=A1ki=C4=87-Pletenac?= Date: Sun, 24 Apr 2022 01:00:00 +0200 Subject: [PATCH 4/9] WTrackTableView: Scroll to selected track --- src/widget/wtracktableview.cpp | 9 +++++++-- src/widget/wtracktableview.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/widget/wtracktableview.cpp b/src/widget/wtracktableview.cpp index 4dba8e24fb9..32095e496b7 100644 --- a/src/widget/wtracktableview.cpp +++ b/src/widget/wtracktableview.cpp @@ -973,7 +973,7 @@ void WTrackTableView::setSelectedTracks(const QList& trackIds) { } } -bool WTrackTableView::setCurrentTrackId(const TrackId& trackId, int column) { +bool WTrackTableView::setCurrentTrackId(const TrackId& trackId, int column, bool scrollToTrack) { QItemSelectionModel* pSelectionModel = selectionModel(); VERIFY_OR_DEBUG_ASSERT(pSelectionModel != nullptr) { qWarning() << "No selected tracks available"; @@ -998,6 +998,11 @@ bool WTrackTableView::setCurrentTrackId(const TrackId& trackId, int column) { selectRow(idx.row()); pSelectionModel->setCurrentIndex(idx, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Select); + + if (scrollToTrack) { + scrollTo(idx); + } + return true; } @@ -1035,7 +1040,7 @@ void WTrackTableView::slotAddToAutoDJReplace() { } void WTrackTableView::slotSelectTrack(const TrackId& trackId) { - setCurrentTrackId(trackId); + setCurrentTrackId(trackId, 0, true); setSelectedTracks({trackId}); } diff --git a/src/widget/wtracktableview.h b/src/widget/wtracktableview.h index 4b2cb11d740..433a97e5f6e 100644 --- a/src/widget/wtracktableview.h +++ b/src/widget/wtracktableview.h @@ -42,7 +42,7 @@ class WTrackTableView : public WLibraryTableView { QList getSelectedTrackIds() const; void setSelectedTracks(const QList& tracks); TrackId getCurrentTrackId() const; - bool setCurrentTrackId(const TrackId& trackId, int column = 0); + bool setCurrentTrackId(const TrackId& trackId, int column = 0, bool scrollToTrack = false); double getBackgroundColorOpacity() const { return m_backgroundColorOpacity; From 4f0a86f4296a5fb556fc2a1134a34d2cdf67b660 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Mon, 9 May 2022 10:55:44 +0200 Subject: [PATCH 5/9] DlgRecording: remove irrelevant forward declaration --- src/library/recording/dlgrecording.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/library/recording/dlgrecording.h b/src/library/recording/dlgrecording.h index 14c732a5287..06f5fd58cf6 100644 --- a/src/library/recording/dlgrecording.h +++ b/src/library/recording/dlgrecording.h @@ -11,7 +11,6 @@ #include "recording/recordingmanager.h" #include "track/track_decl.h" -class PlaylistTableModel; class WLibrary; class WTrackTableView; From c3431d7f34d274d76c1e8d438bfeba53fccbf82f Mon Sep 17 00:00:00 2001 From: ronso0 Date: Mon, 9 May 2022 11:09:24 +0200 Subject: [PATCH 6/9] WTrackMenu: disable 'Select track...' if track can't be selected --- src/library/library.cpp | 29 ++++++++++++++++++++------- src/library/library.h | 3 +++ src/widget/wlibrary.cpp | 36 ++++++++++++++++++++++++++++++++++ src/widget/wlibrary.h | 7 +++++++ src/widget/wtrackmenu.cpp | 8 ++++++++ src/widget/wtracktableview.cpp | 17 ++++++++++++++-- src/widget/wtracktableview.h | 1 + 7 files changed, 92 insertions(+), 9 deletions(-) diff --git a/src/library/library.cpp b/src/library/library.cpp index 5b5f49e1e7a..9835bc11bdf 100644 --- a/src/library/library.cpp +++ b/src/library/library.cpp @@ -74,6 +74,7 @@ Library::Library( m_pTrackCollectionManager(pTrackCollectionManager), m_pSidebarModel(make_parented(this)), m_pLibraryControl(make_parented(this)), + m_pLibraryWidget(nullptr), m_pMixxxLibraryFeature(nullptr), m_pPlaylistFeature(nullptr), m_pCrateFeature(nullptr), @@ -103,6 +104,7 @@ Library::Library( #endif addFeature(new AutoDJFeature(this, m_pConfig, pPlayerManager)); + m_pPlaylistFeature = new PlaylistFeature(this, UserSettingsPointer(m_pConfig)); addFeature(m_pPlaylistFeature); @@ -138,6 +140,7 @@ Library::Library( addFeature(browseFeature); addFeature(new RecordingFeature(this, m_pConfig, pRecordingManager)); + addFeature(new SetlogFeature(this, UserSettingsPointer(m_pConfig))); m_pAnalysisFeature = new AnalysisFeature(this, m_pConfig); @@ -368,10 +371,11 @@ void Library::bindSidebarWidget(WLibrarySidebar* pSidebarWidget) { void Library::bindLibraryWidget( WLibrary* pLibraryWidget, KeyboardEventFilter* pKeyboard) { - WTrackTableView* pTrackTableView = new WTrackTableView(pLibraryWidget, + m_pLibraryWidget = pLibraryWidget; + WTrackTableView* pTrackTableView = new WTrackTableView(m_pLibraryWidget, m_pConfig, this, - pLibraryWidget->getTrackTableBackgroundColorOpacity(), + m_pLibraryWidget->getTrackTableBackgroundColorOpacity(), true); pTrackTableView->installEventFilter(pKeyboard); connect(this, @@ -386,11 +390,11 @@ void Library::bindLibraryWidget( &WTrackTableView::loadTrackToPlayer, this, &Library::slotLoadTrackToPlayer); - pLibraryWidget->registerView(m_sTrackViewName, pTrackTableView); + m_pLibraryWidget->registerView(m_sTrackViewName, pTrackTableView); connect(this, &Library::switchToView, - pLibraryWidget, + m_pLibraryWidget, &WLibrary::switchToView); connect(this, &Library::saveModelState, @@ -400,7 +404,10 @@ void Library::bindLibraryWidget( &Library::restoreModelState, pTrackTableView, &WTrackTableView::slotRestoreCurrentViewState); - connect(this, &Library::selectTrack, pTrackTableView, &WTrackTableView::slotSelectTrack); + connect(this, + &Library::selectTrack, + m_pLibraryWidget, + &WLibrary::slotSelectTrackInActiveTrackView); connect(pTrackTableView, &WTrackTableView::trackSelected, this, @@ -419,7 +426,7 @@ void Library::bindLibraryWidget( pTrackTableView, &WTrackTableView::setSelectedClick); - m_pLibraryControl->bindLibraryWidget(pLibraryWidget, pKeyboard); + m_pLibraryControl->bindLibraryWidget(m_pLibraryWidget, pKeyboard); connect(m_pLibraryControl, &LibraryControl::showHideTrackMenu, @@ -431,7 +438,7 @@ void Library::bindLibraryWidget( &LibraryControl::slotUpdateTrackMenuControl); for (const auto& feature : qAsConst(m_features)) { - feature->bindLibraryWidget(pLibraryWidget, pKeyboard); + feature->bindLibraryWidget(m_pLibraryWidget, pKeyboard); } // Set the current font and row height on all the WTrackTableViews that were @@ -669,6 +676,14 @@ std::unique_ptr Library::makeLibraryExporter( } #endif +bool Library::isTrackIdInCurrentLibraryView(const TrackId& trackId) { + if (m_pLibraryWidget) { + return m_pLibraryWidget->isTrackInCurrentView(trackId); + } else { + return false; + } +} + LibraryTableModel* Library::trackTableModel() const { VERIFY_OR_DEBUG_ASSERT(m_pMixxxLibraryFeature) { return nullptr; diff --git a/src/library/library.h b/src/library/library.h index 8c9f20caa3b..b51143c32a9 100644 --- a/src/library/library.h +++ b/src/library/library.h @@ -79,6 +79,8 @@ class Library: public QObject { /// Needed for exposing models to QML LibraryTableModel* trackTableModel() const; + bool isTrackIdInCurrentLibraryView(const TrackId& trackId); + int getTrackTableRowHeight() const { return m_iTrackTableRowHeight; } @@ -158,6 +160,7 @@ class Library: public QObject { QList m_features; const static QString m_sTrackViewName; const static QString m_sAutoDJViewName; + WLibrary* m_pLibraryWidget; MixxxLibraryFeature* m_pMixxxLibraryFeature; PlaylistFeature* m_pPlaylistFeature; CrateFeature* m_pCrateFeature; diff --git a/src/widget/wlibrary.cpp b/src/widget/wlibrary.cpp index 918a707f1e3..8767d93f129 100644 --- a/src/widget/wlibrary.cpp +++ b/src/widget/wlibrary.cpp @@ -92,6 +92,42 @@ LibraryView* WLibrary::getActiveView() const { return dynamic_cast(currentWidget()); } +bool WLibrary::isTrackInCurrentView(const TrackId& trackId) { + //qDebug() << "WLibrary::isTrackInCurrentView" << trackId; + QWidget* current = currentWidget(); + WTrackTableView* tracksView = qobject_cast(current); + if (!tracksView) { + // This view is no tracks view, but maybe a special tracks view with a + // controls row (AutoDJ, Recording)? + //qDebug() << " view is no tracks view. look for tracks view child"; + tracksView = current->findChild(); + } + if (tracksView) { + //qDebug() << " tracks view found"; + return tracksView->isTrackInCurrentView(trackId); + } else { + // No tracks view, this is probably a root view WLibraryTextBrowser + //qDebug() << " no tracks view found"; + return false; + } +} + +void WLibrary::slotSelectTrackInActiveTrackView(const TrackId& trackId) { + //qDebug() << "WLibrary::slotSelectTrackInActiveTrackView" << trackId; + QWidget* current = currentWidget(); + WTrackTableView* tracksView = qobject_cast(current); + if (!tracksView) { + //qDebug() << " view is no tracks view. look for tracks view child"; + tracksView = current->findChild(); + } + if (tracksView) { + //qDebug() << " tracks view found"; + tracksView->slotSelectTrack(trackId); + } else { + //qDebug() << " no tracks view found"; + } +} + bool WLibrary::event(QEvent* pEvent) { if (pEvent->type() == QEvent::ToolTip) { updateTooltip(); diff --git a/src/widget/wlibrary.h b/src/widget/wlibrary.h index 7290acb6add..bfe4acb0e0d 100644 --- a/src/widget/wlibrary.h +++ b/src/widget/wlibrary.h @@ -29,6 +29,12 @@ class WLibrary : public QStackedWidget, public WBaseWidget { LibraryView* getActiveView() const; + // This returns true if the current view is or has a WTracksTableView and + // contains trackId, otherwise false. + // This is primarily used to disable the "Select track in library" track menu action + // to avoid unintended behaviour if the current view has no tracks table. + bool isTrackInCurrentView(const TrackId& trackId); + // Alpha value for row color background static constexpr double kDefaultTrackTableBackgroundColorOpacity = 0.125; // 12.5% opacity static constexpr double kMinTrackTableBackgroundColorOpacity = 0.0; // 0% opacity @@ -47,6 +53,7 @@ class WLibrary : public QStackedWidget, public WBaseWidget { // view is the specified view, or if the name does not specify any // registered view. void switchToView(const QString& name); + void slotSelectTrackInActiveTrackView(const TrackId& trackId); void search(const QString&); diff --git a/src/widget/wtrackmenu.cpp b/src/widget/wtrackmenu.cpp index 27472b10106..b21985dc435 100644 --- a/src/widget/wtrackmenu.cpp +++ b/src/widget/wtrackmenu.cpp @@ -827,6 +827,14 @@ void WTrackMenu::updateMenus() { } } + if (featureIsEnabled(Feature::SelectInLibrary)) { + bool enabled = false; + if (m_pTrack) { + enabled = m_pLibrary->isTrackIdInCurrentLibraryView(m_pTrack->getId()); + } + m_pSelectInLibraryAct->setEnabled(enabled); + } + if (featureIsEnabled(Feature::Properties)) { m_pPropertiesAct->setEnabled(singleTrackSelected); } diff --git a/src/widget/wtracktableview.cpp b/src/widget/wtracktableview.cpp index 32095e496b7..6214ffadfe3 100644 --- a/src/widget/wtracktableview.cpp +++ b/src/widget/wtracktableview.cpp @@ -950,6 +950,18 @@ TrackId WTrackTableView::getCurrentTrackId() const { return {}; } +bool WTrackTableView::isTrackInCurrentView(const TrackId& trackId) { + //qDebug() << "WTrackTableView::isTrackInCurrentView" << trackId; + TrackModel* pTrackModel = getTrackModel(); + VERIFY_OR_DEBUG_ASSERT(pTrackModel != nullptr) { + qWarning() << "No track model"; + return false; + } + const QVector trackRows = pTrackModel->getTrackRows(trackId); + //qDebug() << " track found?" << !trackRows.empty(); + return !trackRows.empty(); +} + void WTrackTableView::setSelectedTracks(const QList& trackIds) { QItemSelectionModel* pSelectionModel = selectionModel(); VERIFY_OR_DEBUG_ASSERT(pSelectionModel != nullptr) { @@ -1040,8 +1052,9 @@ void WTrackTableView::slotAddToAutoDJReplace() { } void WTrackTableView::slotSelectTrack(const TrackId& trackId) { - setCurrentTrackId(trackId, 0, true); - setSelectedTracks({trackId}); + if (setCurrentTrackId(trackId, 0, true)) { + setSelectedTracks({trackId}); + } } void WTrackTableView::doSortByColumn(int headerSection, Qt::SortOrder sortOrder) { diff --git a/src/widget/wtracktableview.h b/src/widget/wtracktableview.h index 433a97e5f6e..041c66e96c6 100644 --- a/src/widget/wtracktableview.h +++ b/src/widget/wtracktableview.h @@ -40,6 +40,7 @@ class WTrackTableView : public WLibraryTableView { void assignPreviousTrackColor() override; TrackModel::SortColumnId getColumnIdFromCurrentIndex() override; QList getSelectedTrackIds() const; + bool isTrackInCurrentView(const TrackId& trackId); void setSelectedTracks(const QList& tracks); TrackId getCurrentTrackId() const; bool setCurrentTrackId(const TrackId& trackId, int column = 0, bool scrollToTrack = false); From e9b6f3f741dca15dfcf26f72df90884d2eb4fe2b Mon Sep 17 00:00:00 2001 From: ronso0 Date: Mon, 9 May 2022 11:11:09 +0200 Subject: [PATCH 7/9] show 'Select Track...' also in WTrackWidgetGroup --- src/widget/wtrackwidgetgroup.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/widget/wtrackwidgetgroup.cpp b/src/widget/wtrackwidgetgroup.cpp index b27305b15cd..0087823fdac 100644 --- a/src/widget/wtrackwidgetgroup.cpp +++ b/src/widget/wtrackwidgetgroup.cpp @@ -24,7 +24,8 @@ constexpr WTrackMenu::Features kTrackMenuFeatures = WTrackMenu::Feature::Color | WTrackMenu::Feature::FileBrowser | WTrackMenu::Feature::Properties | - WTrackMenu::Feature::UpdateReplayGainFromPregain; + WTrackMenu::Feature::UpdateReplayGainFromPregain | + WTrackMenu::Feature::SelectInLibrary; } // anonymous namespace From 54deccf7c3548f8a2e20d747adf73585d7d9e2a8 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Mon, 9 May 2022 11:11:35 +0200 Subject: [PATCH 8/9] WLibrary/WTrackTableView: fix & tweak some debug messages --- src/widget/wlibrary.cpp | 13 +++++++------ src/widget/wtracktableview.cpp | 9 +++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/widget/wlibrary.cpp b/src/widget/wlibrary.cpp index 8767d93f129..f87fc1f3eb2 100644 --- a/src/widget/wlibrary.cpp +++ b/src/widget/wlibrary.cpp @@ -32,13 +32,14 @@ void WLibrary::setup(const QDomNode& node, const SkinContext& context) { } bool WLibrary::registerView(const QString& name, QWidget* view) { + //qDebug() << "WLibrary::registerView" << name; const auto lock = lockMutex(&m_mutex); if (m_viewMap.contains(name)) { return false; } if (dynamic_cast(view) == nullptr) { - qDebug() << "WARNING: Attempted to register a view with WLibrary " - << "that does not implement the LibraryView interface. " + qDebug() << "WARNING: Attempted to register view" << name << "with WLibrary " + << "which does not implement the LibraryView interface. " << "Ignoring."; return false; } @@ -58,8 +59,8 @@ void WLibrary::switchToView(const QString& name) { if (widget != nullptr) { LibraryView * lview = dynamic_cast(widget); if (lview == nullptr) { - qDebug() << "WARNING: Attempted to register a view with WLibrary " - << "that does not implement the LibraryView interface. " + qDebug() << "WARNING: Attempted to switch to view" << name << "with WLibrary " + << "which does not implement the LibraryView interface. " << "Ignoring."; return; } @@ -80,8 +81,8 @@ void WLibrary::search(const QString& name) { QWidget* current = currentWidget(); LibraryView* view = dynamic_cast(current); if (view == nullptr) { - qDebug() << "WARNING: Attempted to register a view with WLibrary " - << "that does not implement the LibraryView interface. Ignoring."; + qDebug() << "WARNING: Attempted to search in view" << name << "with WLibrary " + << "which does not implement the LibraryView interface. Ignoring."; return; } lock.unlock(); diff --git a/src/widget/wtracktableview.cpp b/src/widget/wtracktableview.cpp index 6214ffadfe3..1f804706745 100644 --- a/src/widget/wtracktableview.cpp +++ b/src/widget/wtracktableview.cpp @@ -965,13 +965,13 @@ bool WTrackTableView::isTrackInCurrentView(const TrackId& trackId) { void WTrackTableView::setSelectedTracks(const QList& trackIds) { QItemSelectionModel* pSelectionModel = selectionModel(); VERIFY_OR_DEBUG_ASSERT(pSelectionModel != nullptr) { - qWarning() << "No selected tracks available"; + qWarning() << "No selection model"; return; } TrackModel* pTrackModel = getTrackModel(); VERIFY_OR_DEBUG_ASSERT(pTrackModel != nullptr) { - qWarning() << "No selected tracks available"; + qWarning() << "No track model"; return; } @@ -988,17 +988,18 @@ void WTrackTableView::setSelectedTracks(const QList& trackIds) { bool WTrackTableView::setCurrentTrackId(const TrackId& trackId, int column, bool scrollToTrack) { QItemSelectionModel* pSelectionModel = selectionModel(); VERIFY_OR_DEBUG_ASSERT(pSelectionModel != nullptr) { - qWarning() << "No selected tracks available"; + qWarning() << "No selection model"; return false; } TrackModel* pTrackModel = getTrackModel(); VERIFY_OR_DEBUG_ASSERT(pTrackModel != nullptr) { - qWarning() << "No selected tracks available"; + qWarning() << "No track model"; return false; } const QVector trackRows = pTrackModel->getTrackRows(trackId); if (trackRows.empty()) { + qDebug() << "WTrackTableView: track" << trackId << "is not in current view"; return false; } From 7d5aa8b91f72dd1820112f6f6648275de376ff44 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Sun, 15 May 2022 13:20:09 +0200 Subject: [PATCH 9/9] WTrackMenu: move 'Select in Library' up, below 'Search related..' --- src/widget/wtrackmenu.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/widget/wtrackmenu.cpp b/src/widget/wtrackmenu.cpp index b21985dc435..49af1ce56b1 100644 --- a/src/widget/wtrackmenu.cpp +++ b/src/widget/wtrackmenu.cpp @@ -420,6 +420,14 @@ void WTrackMenu::createActions() { void WTrackMenu::setupActions() { if (featureIsEnabled(Feature::SearchRelated)) { addMenu(m_pSearchRelatedMenu); + } + + if (featureIsEnabled(Feature::SelectInLibrary)) { + addAction(m_pSelectInLibraryAct); + } + + if (featureIsEnabled(Feature::SearchRelated) || + featureIsEnabled(Feature::SelectInLibrary)) { addSeparator(); } @@ -567,10 +575,6 @@ void WTrackMenu::setupActions() { addAction(m_pFileBrowserAct); } - if (featureIsEnabled(Feature::SelectInLibrary)) { - addAction(m_pSelectInLibraryAct); - } - if (featureIsEnabled(Feature::Properties)) { addSeparator(); addAction(m_pPropertiesAct);