Sayonara Player
Loading...
Searching...
No Matches
ContextMenu.h
1/* ContextMenu.h */
2
3/* Copyright (C) 2011-2024 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 CONTEXTMENU_H
22#define CONTEXTMENU_H
23
24#include "Gui/Utils/Widgets/WidgetTemplate.h"
25#include "Utils/Pimpl.h"
26
27#include <QMenu>
28
29namespace Gui
30{
31 class PreferenceAction;
36 using ContextMenuEntries = uint16_t;
37
43 public Gui::WidgetTemplate<QMenu>
44 {
45 Q_OBJECT
46 PIMPL(ContextMenu)
47
48 public:
49
53 enum Entry
54 {
55 EntryNone = 0,
56 EntryNew = (1 << 0),
57 EntryEdit = (1 << 1),
58 EntryUndo = (1 << 2),
59 EntrySave = (1 << 3),
60 EntrySaveAs = (1 << 4),
61 EntryRename = (1 << 5),
62 EntryDelete = (1 << 6),
63 EntryOpen = (1 << 7),
64 EntryDefault = (1 << 8)
65 };
66
67 signals:
68 void sigNew();
69 void sigEdit();
70 void sigUndo();
71 void sigSave();
72 void sigSaveAs();
73 void sigRename();
74 void sigDelete();
75 void sigOpen();
76 void sigDefault();
77
78 private:
84 void showAction(bool b, QAction* action);
85
86 public:
87 explicit ContextMenu(QWidget* parent = nullptr);
88 virtual ~ContextMenu() override;
89
94 void registerAction(QAction* action);
95
101
107
108 protected:
109 void showEvent(QShowEvent* e) override;
110 void languageChanged() override;
111 void skinChanged() override;
112
113 public slots:
119
125 void showAction(ContextMenu::Entry entry, bool visible);
126
130 void showAll();
131
132 void addPreferenceAction(PreferenceAction* action);
133
134 private slots:
138 void timedOut();
139
140 };
141}
142
143#endif // CONTEXTMENU_H
A context menu with some standard actions.
Definition ContextMenu.h:44
ContextMenuEntries entries() const
get all visible entries
void showAction(ContextMenu::Entry entry, bool visible)
show/hide specific action
void registerAction(QAction *action)
register a custom action
Entry
The Entry enum.
Definition ContextMenu.h:54
void showActions(ContextMenuEntries entries)
show actions defined by ContextMenuEntry mask. Hide other actions
void showAll()
show all actions
bool hasActions()
query, if there are visible actions
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:86
uint16_t ContextMenuEntries
Combination of ContextMenu::Entry values.
Definition ContextMenu.h:36