Sayonara Player
LibraryContextMenu.h
1/* LibraryContextMenu.h */
2
3/* Copyright (C) 2011-2020 Michael Lugmair (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
30namespace Gui
31{
32 class ExtensionSet;
33 class PreferenceAction;
34}
35
36namespace Library
37{
39 public Gui::WidgetTemplate<QMenu>
40 {
41 Q_OBJECT
42 PIMPL(ContextMenu)
43
44 signals:
45 void sigFilterTriggered(const QString& extension, bool b);
46
47 public:
48 enum Entry
49 {
50 EntryNone = 0,
51 EntryInfo = (1 << 0),
52 EntryEdit = (1 << 1),
53 EntryLyrics = (1 << 2),
54 EntryRemove = (1 << 3),
55 EntryDelete = (1 << 4),
56 EntryPlayNext = (1 << 5),
57 EntryAppend = (1 << 6),
58 EntryRefresh = (1 << 7),
59 EntryClear = (1 << 8),
60 EntryPlay = (1 << 9),
61 EntryPlayNewTab = (1 << 10),
62 EntryFilterExtension = (1 << 11),
63 EntryReload = (1 << 12),
64 EntryViewType = (1 << 13),
65 EntryLast = (1 << 14)
66 };
67
68 using Entries = uint64_t;
69
70 public: // NOLINT(readability-redundant-access-specifiers)
71 explicit ContextMenu(QWidget* parent = nullptr);
72 ~ContextMenu() override;
73
74 [[nodiscard]] virtual ContextMenu::Entries entries() const;
75 virtual void showActions(ContextMenu::Entries entries);
76 virtual void showAction(ContextMenu::Entry entry, bool visible);
77 virtual void showAll();
78
79 [[nodiscard]] QAction* action(ContextMenu::Entry entry) const;
80 [[nodiscard]] QAction* actionAfter(ContextMenu::Entry entry) const;
81
82 QAction* addPreferenceAction(Gui::PreferenceAction* action);
83 [[nodiscard]] QAction* beforePreferenceAction() const;
84
85 void setExtensions(const Gui::ExtensionSet& extensions);
86 void setSelectionCount(int selectionSount);
87
88 [[nodiscard]] QKeySequence shortcut(ContextMenu::Entry entry) const;
89
90 private slots:
91 void showFilterExtensionBarChanged();
92 void showFilterExtensionBarTriggered(bool b);
93 void libraryViewTypeChanged();
94 void libraryViewTypeTriggered(bool b);
95 void shortcutChanged(ShortcutIdentifier identifier);
96
97 protected:
98 void skinChanged() override;
99 void languageChanged() override;
100 };
101}
102
103#endif // LIBRARYCONTEXTMENU_H
Collection of extensions. Handles extensions currently active or inactive and the extension toolbar.
Definition: ExtensionSet.h:33
A PreferenceAction can be added to each widget supporting QActions. When triggering this action,...
Definition: PreferenceAction.h:40
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings.
Definition: WidgetTemplate.h:87
Definition: LibraryContextMenu.h:40
An interface class needed when implementing a library plugin.
Definition: LocalLibraryWatcher.h:31