Sayonara Player
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Gui
Utils
Shortcuts
Shortcut.h
1
/* Shortcut.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 SHORTCUT_H
22
#define SHORTCUT_H
23
24
#include "ShortcutIdentifier.h"
25
#include "Utils/Pimpl.h"
26
27
#include <QShortcut>
28
29
#define ShortcutHandlerPrivate private
30
31
class
QKeySequence;
32
class
QWidget;
41
class
Shortcut
42
{
43
private
:
44
PIMPL(Shortcut)
45
46
Shortcut();
47
54
QList<QShortcut*>
initQtShortcut(QWidget* parent, Qt::ShortcutContext context);
55
56
friend
class
ShortcutHandler;
57
ShortcutHandlerPrivate:
58
void
setQtShortcuts(
const
QList<QShortcut*>
& qshortcuts);
59
void
removeQtShortcut(QShortcut* qshortcut);
60
QList<QShortcut*>
qtShortcuts()
const
;
61
62
public
:
69
Shortcut
(ShortcutIdentifier
identifier
,
const
QString&
defaultShortcut
);
70
77
Shortcut
(ShortcutIdentifier
identifier
,
const
QStringList& defaultShortcuts);
78
83
Shortcut
(
const
Shortcut& other);
84
85
Shortcut& operator=(
const
Shortcut& other);
86
87
~Shortcut();
88
93
static
Shortcut
getInvalid
();
94
99
void
changeShortcut
(
const
QStringList&
shortcuts
);
100
105
QString
name
()
const
;
106
111
QStringList
defaultShortcut
()
const
;
112
117
QList<QKeySequence>
sequences
()
const
;
118
QKeySequence sequence()
const
;
119
124
const
QStringList&
shortcuts
()
const
;
125
130
ShortcutIdentifier
identifier
()
const
;
131
QString databaseKey()
const
;
132
137
bool
isValid
()
const
;
138
139
template
<
typename
T>
145
void
connect
(QWidget* parent, T func, Qt::ShortcutContext context = Qt::WindowShortcut)
146
{
147
QList<QShortcut*>
shortcuts
= initQtShortcut(parent, context);
148
for
(QShortcut* sc:
shortcuts
)
149
{
150
QObject::connect(sc, &QShortcut::activated, parent, func);
151
}
152
}
153
160
void
161
connect
(QWidget* parent, QObject* receiver,
const
char
* slot, Qt::ShortcutContext context = Qt::WindowShortcut);
162
};
163
164
#endif
// SHORTCUT_H
QList
Definition
EngineUtils.h:33
Shortcut::isValid
bool isValid() const
Check if the shortcut is valid or if it was retrieved via getInvalid().
Shortcut::connect
void connect(QWidget *parent, T func, Qt::ShortcutContext context=Qt::WindowShortcut)
create a qt shortcut for a widget
Definition
Shortcut.h:145
Shortcut::changeShortcut
void changeShortcut(const QStringList &shortcuts)
Shortcut::name
QString name() const
get the human-readable name of the shortcut
Shortcut::connect
void connect(QWidget *parent, QObject *receiver, const char *slot, Qt::ShortcutContext context=Qt::WindowShortcut)
create a qt shortcut for a widget
Shortcut::defaultShortcut
QStringList defaultShortcut() const
get a human-readable list of mapped default shortcuts
Shortcut::getInvalid
static Shortcut getInvalid()
get a raw and invalid shortcut. This function is used instead of the default constructor
Shortcut::Shortcut
Shortcut(const Shortcut &other)
Copy constructor.
Shortcut::identifier
ShortcutIdentifier identifier() const
get the unique identifier
Shortcut::shortcuts
const QStringList & shortcuts() const
get a human-readable list of mapped shortcuts
Shortcut::Shortcut
Shortcut(ShortcutIdentifier identifier, const QStringList &defaultShortcuts)
Shortcut.
Shortcut::Shortcut
Shortcut(ShortcutIdentifier identifier, const QString &defaultShortcut)
Shortcut.
Shortcut::sequences
QList< QKeySequence > sequences() const
get a list key squences mapped to this shortcut
Generated on
for Sayonara Player by
1.17.0