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;
40  public Gui::WidgetTemplate<QMenu>
41  {
42  Q_OBJECT
43  PIMPL(LibraryContextMenu)
44 
45  public:
49  enum Entry
50  {
51  EntryNone=0,
52  EntryInfo=(1<<0),
53  EntryEdit=(1<<1),
54  EntryLyrics=(1<<2),
55  EntryRemove=(1<<3),
56  EntryDelete=(1<<4),
57  EntryPlayNext=(1<<5),
58  EntryAppend=(1<<6),
59  EntryRefresh=(1<<7),
60  EntryClear=(1<<8),
61  EntryCoverView=(1<<9),
62  EntryPlay=(1<<10),
63  EntryPlayNewTab=(1<<11),
64  EntryFilterExtension=(1<<12),
65  EntryReload=(1<<13),
66  EntryLast=(1<<14)
67  };
68 
69  using Entries=uint64_t;
70 
71  public:
72  explicit LibraryContextMenu(QWidget *parent=nullptr);
73  virtual ~LibraryContextMenu();
74 
75 
80  virtual LibraryContextMenu::Entries get_entries() const;
81 
86  virtual void show_actions(LibraryContextMenu::Entries entries);
87 
93  virtual void show_action(LibraryContextMenu::Entry entry, bool visible);
94 
98  virtual void show_all();
99 
100  QAction* get_action(LibraryContextMenu::Entry entry) const;
101  QAction* get_action_after(LibraryContextMenu::Entry entry) const;
102 
103  QAction* add_preference_action(PreferenceAction* action);
104  QAction* before_preference_action() const;
105 
106  void set_action_shortcut(LibraryContextMenu::Entry entry, const QString& shortcut);
107 
108  void set_extensions(const ExtensionSet& extensions);
109  void set_selection_count(int num_selections);
110 
111  QKeySequence shortcut(LibraryContextMenu::Entry entry) const;
112 
113 
114  signals:
115  void sig_info_clicked();
116  void sig_edit_clicked();
117  void sig_lyrics_clicked();
118  void sig_remove_clicked();
119  void sig_delete_clicked();
120  void sig_play_clicked();
121  void sig_play_new_tab_clicked();
122  void sig_play_next_clicked();
123  void sig_append_clicked();
124  void sig_refresh_clicked();
125  void sig_clear_clicked();
126  void sig_filter_triggered(const QString& extension, bool b);
127  void sig_reload_clicked();
128 
129  private slots:
130  void show_cover_view_changed();
131  void show_filter_ext_bar_changed();
132  void show_cover_triggered(bool b);
133  void shortcut_changed(ShortcutIdentifier identifier);
134  void show_filter_extension_bar_triggered(bool b);
135  void skin_timer_timeout();
136 
137 
138  protected:
139  void skin_changed() override;
140  void language_changed() override;
141  };
142 }
143 
144 #endif // LIBRARYCONTEXTMENU_H
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings.
Definition: WidgetTemplate.h:84
virtual void show_all()
show all possible entries
Context menu used for Library and playlist windows.
Definition: LibraryContextMenu.h:39
virtual LibraryContextMenu::Entries get_entries() const
get all visible entries
Entry
This enum indicates which entries should be visible.
Definition: LibraryContextMenu.h:49
virtual void show_actions(LibraryContextMenu::Entries entries)
show a specific amount of Entries
virtual void show_action(LibraryContextMenu::Entry entry, bool visible)
show/hide a specific Entry
A PreferenceAction can be added to each widget supporting QActions. When triggering this action,...
Definition: PreferenceAction.h:38
Collection of extensions. Handles extensions currently active or inactive and the extension toolbar.
Definition: ExtensionSet.h:32