Skip to content

Commit

Permalink
BasePlaylistFeature: Defer initActions invocation until bindLibraryWi…
Browse files Browse the repository at this point in the history
…dget is called
  • Loading branch information
cr7pt0gr4ph7 committed Apr 26, 2024
1 parent 0f52127 commit be201bd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/library/trackset/baseplaylistfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <QInputDialog>
#include <QList>

#include "controllers/keyboard/keyboardeventfilter.h"
#include "library/export/trackexportwizard.h"
#include "library/library.h"
#include "library/library_prefs.h"
Expand Down Expand Up @@ -51,7 +52,6 @@ BasePlaylistFeature::BasePlaylistFeature(
m_keepHiddenTracks(keepHiddenTracks) {
pModel->setParent(this);

initActions();
connectPlaylistDAO();
connect(m_pLibrary,
&Library::trackSelected,
Expand All @@ -66,15 +66,19 @@ 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,
this,
&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,
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/library/trackset/baseplaylistfeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit be201bd

Please sign in to comment.