From 751bf03c109f634fc238fac36403aae4196cbca5 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Mon, 4 Nov 2019 15:24:40 +0100 Subject: bind sidebar widget to all library features, make binding iterator more compact use the widget as parent for right-click menus on sidebar items --- src/library/browse/browsefeature.cpp | 8 +++++++- src/library/browse/browsefeature.h | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/library/browse') diff --git a/src/library/browse/browsefeature.cpp b/src/library/browse/browsefeature.cpp index f7632e60f7..89c1a7ca09 100644 --- a/src/library/browse/browsefeature.cpp +++ b/src/library/browse/browsefeature.cpp @@ -20,6 +20,7 @@ #include "util/sandbox.h" #include "widget/wlibrary.h" #include "widget/wlibrarytextbrowser.h" +#include "widget/wlibrarysidebar.h" const QString kQuickLinksSeparator = "-+-"; @@ -226,6 +227,11 @@ void BrowseFeature::bindLibraryWidget(WLibrary* libraryWidget, libraryWidget->registerView("BROWSEHOME", edit); } +void BrowseFeature::bindSidebarWidget(WLibrarySidebar* pSidebarWidget) { + // store the sidebar widget pointer for later use in onRightClickChild + m_pSidebarWidget = pSidebarWidget; +} + void BrowseFeature::activate() { emit(switchToView("BROWSEHOME")); emit disableSearch(); @@ -275,7 +281,7 @@ void BrowseFeature::onRightClickChild(const QPoint& globalPos, QModelIndex index return; } - QMenu menu(NULL); + QMenu menu(m_pSidebarWidget); if (item->parent()->getData().toString() == QUICK_LINK_NODE) { menu.addAction(m_pRemoveQuickLinkAction); menu.exec(globalPos); diff --git a/src/library/browse/browsefeature.h b/src/library/browse/browsefeature.h index dcbf845701..1bf005c662 100644 --- a/src/library/browse/browsefeature.h +++ b/src/library/browse/browsefeature.h @@ -24,6 +24,7 @@ class Library; class TrackCollection; +class WLibrarySidebar; class BrowseFeature : public LibraryFeature { Q_OBJECT @@ -39,6 +40,7 @@ class BrowseFeature : public LibraryFeature { void bindLibraryWidget(WLibrary* libraryWidget, KeyboardEventFilter* keyboard); + void bindSidebarWidget(WLibrarySidebar* pSidebarWidget); TreeItemModel* getChildModel(); @@ -77,6 +79,7 @@ class BrowseFeature : public LibraryFeature { TreeItem* m_pQuickLinkItem; QStringList m_quickLinkList; QIcon m_icon; + QPointer m_pSidebarWidget; }; #endif // BROWSEFEATURE_H -- cgit v1.2.3