From 033300d65909ead5ca601cf3043f200d98580fa4 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Wed, 19 Jun 2019 23:26:15 +0200 Subject: [PATCH] Disable remove favorites from context menu in internetsongsview --- src/internet/internetcollectionview.cpp | 18 ++++++++++++++---- src/internet/internetcollectionview.h | 3 ++- src/internet/internetsongsview.cpp | 2 +- src/internet/internettabsview.cpp | 6 +++--- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/internet/internetcollectionview.cpp b/src/internet/internetcollectionview.cpp index 0f78ee111..59ac3eb57 100644 --- a/src/internet/internetcollectionview.cpp +++ b/src/internet/internetcollectionview.cpp @@ -51,11 +51,18 @@ InternetCollectionView::InternetCollectionView(QWidget *parent) collection_backend_(nullptr), collection_model_(nullptr), filter_(nullptr), + favorite_(false), total_song_count_(0), total_artist_count_(0), total_album_count_(0), nomusic_(":/pictures/nomusic.png"), context_menu_(nullptr), + load_(nullptr), + add_to_playlist_(nullptr), + add_to_playlist_enqueue_(nullptr), + add_to_playlist_enqueue_next_(nullptr), + open_in_new_playlist_(nullptr), + remove_songs_(nullptr), is_in_keyboard_search_(false) { @@ -74,11 +81,12 @@ InternetCollectionView::InternetCollectionView(QWidget *parent) InternetCollectionView::~InternetCollectionView() {} -void InternetCollectionView::Init(Application *app, CollectionBackend *backend, CollectionModel *model) { +void InternetCollectionView::Init(Application *app, CollectionBackend *backend, CollectionModel *model, const bool favorite) { app_ = app; collection_backend_ = backend; collection_model_ = model; + favorite_ = favorite; collection_model_->set_pretty_covers(true); collection_model_->set_show_dividers(true); @@ -301,8 +309,10 @@ void InternetCollectionView::contextMenuEvent(QContextMenuEvent *e) { context_menu_->addSeparator(); - remove_songs_ = context_menu_->addAction(IconLoader::Load("edit-delete"), tr("Remove from favorites"), this, SLOT(RemoveSongs())); - context_menu_->addSeparator(); + if (favorite_) { + remove_songs_ = context_menu_->addAction(IconLoader::Load("edit-delete"), tr("Remove from favorites"), this, SLOT(RemoveSongs())); + context_menu_->addSeparator(); + } if (filter_) context_menu_->addMenu(filter_->menu()); @@ -320,7 +330,7 @@ void InternetCollectionView::contextMenuEvent(QContextMenuEvent *e) { add_to_playlist_->setEnabled(songs_selected); open_in_new_playlist_->setEnabled(songs_selected); add_to_playlist_enqueue_->setEnabled(songs_selected); - remove_songs_->setEnabled(songs_selected); + if (remove_songs_) remove_songs_->setEnabled(songs_selected); context_menu_->popup(e->globalPos()); diff --git a/src/internet/internetcollectionview.h b/src/internet/internetcollectionview.h index ec12a758c..effd86b9d 100644 --- a/src/internet/internetcollectionview.h +++ b/src/internet/internetcollectionview.h @@ -55,7 +55,7 @@ class InternetCollectionView : public AutoExpandingTreeView { InternetCollectionView(QWidget *parent = nullptr); ~InternetCollectionView(); - void Init(Application *app, CollectionBackend *backend, CollectionModel *model); + void Init(Application *app, CollectionBackend *backend, CollectionModel *model, const bool favorite = false); // Returns Songs currently selected in the collection view. // Please note that the selection is recursive meaning that if for example an album is selected this will return all of it's songs. @@ -115,6 +115,7 @@ class InternetCollectionView : public AutoExpandingTreeView { CollectionBackend *collection_backend_; CollectionModel*collection_model_; CollectionFilterWidget *filter_; + bool favorite_; int total_song_count_; int total_artist_count_; diff --git a/src/internet/internetsongsview.cpp b/src/internet/internetsongsview.cpp index 64b34a575..1760bab12 100644 --- a/src/internet/internetsongsview.cpp +++ b/src/internet/internetsongsview.cpp @@ -45,7 +45,7 @@ InternetSongsView::InternetSongsView(Application *app, InternetService *service, ui_->setupUi(this); ui_->stacked->setCurrentWidget(ui_->internetcollection_page); - ui_->view->Init(app_, service_->songs_collection_backend(), service_->songs_collection_model()); + ui_->view->Init(app_, service_->songs_collection_backend(), service_->songs_collection_model(), false); ui_->view->setModel(service_->songs_collection_sort_model()); ui_->view->SetFilter(ui_->filter); ui_->filter->SetSettingsGroup(settings_group); diff --git a/src/internet/internettabsview.cpp b/src/internet/internettabsview.cpp index 3b29ff6c9..c7543b47a 100644 --- a/src/internet/internettabsview.cpp +++ b/src/internet/internettabsview.cpp @@ -52,7 +52,7 @@ InternetTabsView::InternetTabsView(Application *app, InternetService *service, I if (service_->artists_collection_model()) { ui_->artists_collection->stacked()->setCurrentWidget(ui_->artists_collection->internetcollection_page()); - ui_->artists_collection->view()->Init(app_, service_->artists_collection_backend(), service_->artists_collection_model()); + ui_->artists_collection->view()->Init(app_, service_->artists_collection_backend(), service_->artists_collection_model(), true); ui_->artists_collection->view()->setModel(service_->artists_collection_sort_model()); ui_->artists_collection->view()->SetFilter(ui_->artists_collection->filter()); ui_->artists_collection->filter()->SetSettingsGroup(settings_group); @@ -84,7 +84,7 @@ InternetTabsView::InternetTabsView(Application *app, InternetService *service, I if (service_->albums_collection_model()) { ui_->albums_collection->stacked()->setCurrentWidget(ui_->albums_collection->internetcollection_page()); - ui_->albums_collection->view()->Init(app_, service_->albums_collection_backend(), service_->albums_collection_model()); + ui_->albums_collection->view()->Init(app_, service_->albums_collection_backend(), service_->albums_collection_model(), true); ui_->albums_collection->view()->setModel(service_->albums_collection_sort_model()); ui_->albums_collection->view()->SetFilter(ui_->albums_collection->filter()); ui_->albums_collection->filter()->SetSettingsGroup(settings_group); @@ -116,7 +116,7 @@ InternetTabsView::InternetTabsView(Application *app, InternetService *service, I if (service_->songs_collection_model()) { ui_->songs_collection->stacked()->setCurrentWidget(ui_->songs_collection->internetcollection_page()); - ui_->songs_collection->view()->Init(app_, service_->songs_collection_backend(), service_->songs_collection_model()); + ui_->songs_collection->view()->Init(app_, service_->songs_collection_backend(), service_->songs_collection_model(), true); ui_->songs_collection->view()->setModel(service_->songs_collection_sort_model()); ui_->songs_collection->view()->SetFilter(ui_->songs_collection->filter()); ui_->songs_collection->filter()->SetSettingsGroup(settings_group);