Sayonara Player
src
Gui
Utils
ContextMenu
ContextMenu.h
1
/* ContextMenu.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 CONTEXTMENU_H
22
#define CONTEXTMENU_H
23
24
#include "Gui/Utils/Widgets/WidgetTemplate.h"
25
#include "Utils/Pimpl.h"
26
27
#include <QMenu>
28
29
30
namespace
Gui
31
{
32
class
PreferenceAction;
37
using
ContextMenuEntries
=uint16_t;
38
43
class
ContextMenu
:
44
public
Gui::WidgetTemplate
<QMenu>
45
{
46
Q_OBJECT
47
PIMPL(
ContextMenu
)
48
49
public
:
50
54
enum
Entry
55
{
56
EntryNone =0,
57
EntryNew =(1<<0),
58
EntryEdit =(1<<1),
59
EntryUndo =(1<<2),
60
EntrySave =(1<<3),
61
EntrySaveAs =(1<<4),
62
EntryRename =(1<<5),
63
EntryDelete =(1<<6),
64
EntryOpen =(1<<7),
65
EntryDefault=(1<<8)
66
};
67
68
signals:
69
void
sig_new();
70
void
sig_edit();
71
void
sig_undo();
72
void
sig_save();
73
void
sig_save_as();
74
void
sig_rename();
75
void
sig_delete();
76
void
sig_open();
77
void
sig_default();
78
79
80
private
:
86
void
show_action(
bool
b, QAction* action);
87
88
89
public
:
90
explicit
ContextMenu
(QWidget *parent=
nullptr
);
91
virtual
~
ContextMenu
();
92
97
void
register_action
(QAction* action);
98
103
bool
has_actions
();
104
109
ContextMenuEntries
get_entries
()
const
;
110
111
112
protected
:
113
void
showEvent(QShowEvent* e)
override
;
114
void
language_changed()
override
;
115
void
skin_changed()
override
;
116
117
118
public
slots:
123
void
show_actions
(
ContextMenuEntries
entries);
124
130
void
show_action(
ContextMenu::Entry
entry,
bool
visible);
131
135
void
show_all
();
136
137
void
add_preference_action(
PreferenceAction
* action);
138
139
140
private
slots:
144
void
timed_out();
145
146
};
147
}
148
149
#endif // CONTEXTMENU_H
Gui::ContextMenu::show_actions
void show_actions(ContextMenuEntries entries)
show actions defined by ContextMenuEntry mask. Hide other actions
Gui::ContextMenu::Entry
Entry
The Entry enum.
Definition:
ContextMenu.h:54
Gui::ContextMenuEntries
uint16_t ContextMenuEntries
Combination of ContextMenu::Entry values.
Definition:
ContextMenu.h:37
Gui::ContextMenu::show_all
void show_all()
show all actions
Gui::WidgetTemplate
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings.
Definition:
WidgetTemplate.h:84
Gui::ContextMenu::register_action
void register_action(QAction *action)
register a custom action
Gui::PreferenceAction
A PreferenceAction can be added to each widget supporting QActions. When triggering this action,...
Definition:
PreferenceAction.h:38
Gui::ContextMenu
A context menu with some standard actions.
Definition:
ContextMenu.h:43
Gui::ContextMenu::has_actions
bool has_actions()
query, if there are visible actions
Gui::ContextMenu::get_entries
ContextMenuEntries get_entries() const
get all visible entries
Generated on Sun Nov 17 2019 00:00:00 for Sayonara Player by
1.8.16