Sayonara Player
LibraryContextMenu.h
1 /* LibraryContextMenu.h */
2 
3 /* Copyright (C) 2011-2019 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef LIBRARYCONTEXTMENU_H
22 #define LIBRARYCONTEXTMENU_H
23 
24 #include "Gui/Utils/Widgets/WidgetTemplate.h"
25 #include "Gui/Utils/Shortcuts/ShortcutIdentifier.h"
26 #include "Utils/Pimpl.h"
27 
28 #include <QMenu>
29 
30 namespace Gui
31 {
32  class ExtensionSet;
33  class PreferenceAction;
34 }
35 
36 namespace Library
37 {
43  class ContextMenu :
44  public Gui::WidgetTemplate<QMenu>
45  {
46  Q_OBJECT
47  PIMPL(ContextMenu)
48 
49  public:
53  enum Entry
54  {
55  EntryNone=0,
56  EntryInfo=(1<<0),
57  EntryEdit=(1<<1),
58  EntryLyrics=(1<<2),
59  EntryRemove=(1<<3),
60  EntryDelete=(1<<4),
61  EntryPlayNext=(1<<5),
62  EntryAppend=(1<<6),
63  EntryRefresh=(1<<7),
64  EntryClear=(1<<8),
65  EntryCoverView=(1<<9),
66  EntryPlay=(1<<10),
67  EntryPlayNewTab=(1<<11),
68  EntryFilterExtension=(1<<12),
69  EntryReload=(1<<13),
70  EntryLast=(1<<14)
71  };
72 
73  using Entries=uint64_t;
74 
75  public:
76  explicit ContextMenu(QWidget *parent=nullptr);
77  virtual ~ContextMenu() override;
78 
79 
84  virtual ContextMenu::Entries get_entries() const;
85 
90  virtual void show_actions(ContextMenu::Entries entries);
91 
97  virtual void show_action(ContextMenu::Entry entry, bool visible);
98 
102  virtual void show_all();
103 
104  QAction* get_action(ContextMenu::Entry entry) const;
105  QAction* get_action_after(ContextMenu::Entry entry) const;
106 
107  QAction* add_preference_action(Gui::PreferenceAction* action);
108  QAction* before_preference_action() const;
109 
110  void set_action_shortcut(ContextMenu::Entry entry, const QString& shortcut);
111 
112  void set_extensions(const Gui::ExtensionSet& extensions);
113  void set_selection_count(int num_selections);
114 
115  QKeySequence shortcut(ContextMenu::Entry entry) const;
116 
117 
118  signals:
119  void sig_info_clicked();
120  void sig_edit_clicked();
121  void sig_lyrics_clicked();
122  void sig_remove_clicked();
123  void sig_delete_clicked();
124  void sig_play_clicked();
125  void sig_play_new_tab_clicked();
126  void sig_play_next_clicked();
127  void sig_append_clicked();
128  void sig_refresh_clicked();
129  void sig_clear_clicked();
130  void sig_filter_triggered(const QString& extension, bool b);
131  void sig_reload_clicked();
132 
133  private slots:
134  void show_cover_view_changed();
135  void show_filter_ext_bar_changed();
136  void show_cover_triggered(bool b);
137  void shortcut_changed(ShortcutIdentifier identifier);
138  void show_filter_extension_bar_triggered(bool b);
139  void skin_timer_timeout();
140 
141 
142  protected:
143  void skin_changed() override;
144  void language_changed() override;
145  };
146 }
147 
148 #endif // LIBRARYCONTEXTMENU_H
Context menu used for Library and playlist windows.
Definition: LibraryContextMenu.h:43
virtual void show_action(ContextMenu::Entry entry, bool visible)
show/hide a specific Entry
Entry
This enum indicates which entries should be visible.
Definition: LibraryContextMenu.h:53
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings.
Definition: WidgetTemplate.h:84
virtual void show_actions(ContextMenu::Entries entries)
show a specific amount of Entries
virtual ContextMenu::Entries get_entries() const
get all visible entries
A PreferenceAction can be added to each widget supporting QActions. When triggering this action,...
Definition: PreferenceAction.h:38
virtual void show_all()
show all possible entries
An interface class needed when implementing a library plugin.
Definition: LocalLibraryWatcher.h:32
Collection of extensions. Handles extensions currently active or inactive and the extension toolbar.
Definition: ExtensionSet.h:32