Skip to content

Commit

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

#include "analyzer/analyzerscheduledtrack.h"
#include "controllers/keyboard/keyboardeventfilter.h"
#include "library/export/trackexportwizard.h"
#include "library/library.h"
#include "library/library_prefs.h"
Expand Down Expand Up @@ -50,8 +51,6 @@ CrateFeature::CrateFeature(Library* pLibrary,
m_lockedCrateIcon(":/images/library/ic_library_locked_tracklist.svg"),
m_pTrackCollection(pLibrary->trackCollectionManager()->internalCollection()),
m_crateTableModel(this, pLibrary->trackCollectionManager()) {
initActions();

// construct child model
m_pSidebarModel->setRootItem(TreeItem::newRoot(this));
rebuildChildModel();
Expand All @@ -60,15 +59,19 @@ CrateFeature::CrateFeature(Library* pLibrary,
connectTrackCollection();
}

void CrateFeature::initActions() {
void CrateFeature::initActions(KeyboardEventFilter* pKeyboard) {
m_pCreateCrateAction = make_parented<QAction>(tr("Create New Crate"), this);
connect(m_pCreateCrateAction.get(),
&QAction::triggered,
this,
&CrateFeature::slotCreateCrate);

m_pRenameCrateAction = make_parented<QAction>(tr("Rename"), this);
m_pRenameCrateAction->setShortcut(kRenameSidebarItemShortcutKey);
pKeyboard->registerActionForShortcut(
m_pRenameCrateAction,
ConfigKey("[Library]", "EditItem"),
QKeySequence(kRenameSidebarItemShortcutKey).toString(),
true);
connect(m_pRenameCrateAction.get(),
&QAction::triggered,
this,
Expand Down Expand Up @@ -272,7 +275,7 @@ bool CrateFeature::dragMoveAcceptChild(const QModelIndex& index, const QUrl& url

void CrateFeature::bindLibraryWidget(
WLibrary* libraryWidget, KeyboardEventFilter* keyboard) {
Q_UNUSED(keyboard);
initActions(keyboard);
WLibraryTextBrowser* edit = new WLibraryTextBrowser(libraryWidget);
edit->setHtml(formatRootViewHtml());
edit->setOpenLinks(false);
Expand Down
2 changes: 1 addition & 1 deletion src/library/trackset/crate/cratefeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class CrateFeature : public BaseTrackSetFeature {
void slotUpdateCrateLabels(const QSet<CrateId>& updatedCrateIds);

private:
void initActions();
void initActions(KeyboardEventFilter* pKeyboard);
void connectLibrary(Library* pLibrary);
void connectTrackCollection();

Expand Down

0 comments on commit efc7cd1

Please sign in to comment.