internet/core: Move core ShowContextMenu to base class
Move CloudFileService::ShowContextMenu to the base class so that all services can utilize the pattern established in CloudFileService. ShowContextMenu creates the menu if it doesn't exist then calls an overridable method to populate the content. It then calls an update method before showing the menu.
This commit is contained in:
parent
5ebd6d1e6b
commit
05e450c3c3
@ -107,15 +107,6 @@ void CloudFileService::PopulateContextMenu() {
|
||||
SLOT(ShowSettingsDialog()));
|
||||
}
|
||||
|
||||
void CloudFileService::ShowContextMenu(const QPoint& global_pos) {
|
||||
if (!context_menu_) {
|
||||
context_menu_.reset(new QMenu);
|
||||
PopulateContextMenu();
|
||||
}
|
||||
UpdateContextMenu();
|
||||
context_menu_->popup(global_pos);
|
||||
}
|
||||
|
||||
void CloudFileService::ShowCoverManager() {
|
||||
if (!cover_manager_) {
|
||||
cover_manager_.reset(new AlbumCoverManager(app_, library_backend_.get()));
|
||||
|
@ -45,7 +45,6 @@ class CloudFileService : public InternetService {
|
||||
// InternetService
|
||||
virtual QStandardItem* CreateRootItem();
|
||||
virtual void LazyPopulate(QStandardItem* item);
|
||||
virtual void ShowContextMenu(const QPoint& point);
|
||||
|
||||
virtual bool has_credentials() const = 0;
|
||||
bool is_indexing() const { return indexing_task_id_ != -1; }
|
||||
@ -68,9 +67,7 @@ class CloudFileService : public InternetService {
|
||||
void AbortReadTagsReplies();
|
||||
|
||||
// Called once when context menu is created
|
||||
virtual void PopulateContextMenu();
|
||||
// Called every time context menu is shown
|
||||
virtual void UpdateContextMenu(){};
|
||||
virtual void PopulateContextMenu() override;
|
||||
|
||||
protected slots:
|
||||
void ShowCoverManager();
|
||||
|
@ -88,6 +88,15 @@ void InternetService::ShowUrlBox(const QString& title, const QString& url) {
|
||||
}
|
||||
}
|
||||
|
||||
void InternetService::ShowContextMenu(const QPoint& global_pos) {
|
||||
if (!context_menu_) {
|
||||
context_menu_.reset(new QMenu);
|
||||
PopulateContextMenu();
|
||||
}
|
||||
UpdateContextMenu();
|
||||
context_menu_->popup(global_pos);
|
||||
}
|
||||
|
||||
QList<QAction*> InternetService::GetPlaylistActions() {
|
||||
return QList<QAction*>() << GetAppendToPlaylistAction()
|
||||
<< GetReplacePlaylistAction()
|
||||
|
@ -64,7 +64,8 @@ class InternetService : public QObject {
|
||||
virtual void LazyPopulate(QStandardItem* parent) = 0;
|
||||
virtual bool has_initial_load_settings() const { return false; }
|
||||
virtual void InitialLoadSettings() {}
|
||||
virtual void ShowContextMenu(const QPoint& global_pos) {}
|
||||
virtual void ShowContextMenu(const QPoint& global_pos);
|
||||
|
||||
// Create a generator for smart playlists
|
||||
virtual smart_playlists::GeneratorPtr CreateGenerator(QStandardItem* item) {
|
||||
return smart_playlists::GeneratorPtr();
|
||||
@ -103,6 +104,11 @@ class InternetService : public QObject {
|
||||
void OpenInNewPlaylist();
|
||||
|
||||
protected:
|
||||
// Called once when context menu is created
|
||||
virtual void PopulateContextMenu(){};
|
||||
// Called every time context menu is shown
|
||||
virtual void UpdateContextMenu(){};
|
||||
|
||||
// Returns all the playlist insertion related QActions (see below).
|
||||
QList<QAction*> GetPlaylistActions();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user