From be201bdd367b9b194b18dff7cfab1dc38ca3d3fe Mon Sep 17 00:00:00 2001 From: Lukas Waslowski Date: Fri, 26 Apr 2024 13:42:51 +0000 Subject: [PATCH] BasePlaylistFeature: Defer initActions invocation until bindLibraryWidget is called --- src/library/trackset/baseplaylistfeature.cpp | 12 ++++++++---- src/library/trackset/baseplaylistfeature.h | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/library/trackset/baseplaylistfeature.cpp b/src/library/trackset/baseplaylistfeature.cpp index 4f230f0ad54..ffd21fe1b4b 100644 --- a/src/library/trackset/baseplaylistfeature.cpp +++ b/src/library/trackset/baseplaylistfeature.cpp @@ -5,6 +5,7 @@ #include #include +#include "controllers/keyboard/keyboardeventfilter.h" #include "library/export/trackexportwizard.h" #include "library/library.h" #include "library/library_prefs.h" @@ -51,7 +52,6 @@ BasePlaylistFeature::BasePlaylistFeature( m_keepHiddenTracks(keepHiddenTracks) { pModel->setParent(this); - initActions(); connectPlaylistDAO(); connect(m_pLibrary, &Library::trackSelected, @@ -66,7 +66,7 @@ BasePlaylistFeature::BasePlaylistFeature( &BasePlaylistFeature::slotResetSelectedTrack); } -void BasePlaylistFeature::initActions() { +void BasePlaylistFeature::initActions(KeyboardEventFilter* pKeyboard) { m_pCreatePlaylistAction = new QAction(tr("Create New Playlist"), this); connect(m_pCreatePlaylistAction, &QAction::triggered, @@ -74,7 +74,11 @@ void BasePlaylistFeature::initActions() { &BasePlaylistFeature::slotCreatePlaylist); m_pRenamePlaylistAction = new QAction(tr("Rename"), this); - m_pRenamePlaylistAction->setShortcut(kRenameSidebarItemShortcutKey); + pKeyboard->registerActionForShortcut( + m_pRenamePlaylistAction, + ConfigKey("[Library]", "EditItem"), + QKeySequence(kRenameSidebarItemShortcutKey).toString(), + true); connect(m_pRenamePlaylistAction, &QAction::triggered, this, @@ -685,7 +689,7 @@ TreeItemModel* BasePlaylistFeature::sidebarModel() const { void BasePlaylistFeature::bindLibraryWidget(WLibrary* pLibraryWidget, KeyboardEventFilter* pKeyboard) { - Q_UNUSED(pKeyboard); + initActions(pKeyboard); WLibraryTextBrowser* pEdit = new WLibraryTextBrowser(pLibraryWidget); pEdit->setHtml(getRootViewHtml()); pEdit->setOpenLinks(false); diff --git a/src/library/trackset/baseplaylistfeature.h b/src/library/trackset/baseplaylistfeature.h index 095ae395dcb..3004b0ea042 100644 --- a/src/library/trackset/baseplaylistfeature.h +++ b/src/library/trackset/baseplaylistfeature.h @@ -124,7 +124,7 @@ class BasePlaylistFeature : public BaseTrackSetFeature { void slotResetSelectedTrack(); private: - void initActions(); + void initActions(KeyboardEventFilter* pKeyboard); void connectPlaylistDAO(); virtual QString getRootViewHtml() const = 0; void markTreeItem(TreeItem* pTreeItem);