-
Notifications
You must be signed in to change notification settings - Fork 0
/
inputhandling.h
54 lines (37 loc) · 1.02 KB
/
inputhandling.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef INPUTHANDLING_H
#define INPUTHANDLING_H
#include <QTimer>
#include <QObject>
#include <QHash>
#include <QSet>
/** Handles user input. Initially only keyboard input but
* might be extended for other types like knobs.
*/
class InputHandling : public QObject
{
Q_OBJECT
public:
InputHandling(QObject* parent = 0);
void setPossibleNumbers(const QSet<QString>& numbers);
protected:
bool eventFilter(QObject* object, QEvent* event);
Q_SIGNALS:
void changeToStation(const QString& station);
void stationUp();
void stationDown();
void volumeUp();
void volumeDown();
void powerOff();
private Q_SLOTS:
void finishedWritingStationNumber();
private:
int startsWith(const QString& text);
using SignalType = decltype(&InputHandling::stationUp);
QString loadKeys();
QHash<Qt::Key, SignalType> m_keyToSignal;
QHash<QString, SignalType> m_stringToSignal;
QSet<QString> m_possibleNumbers;
QString m_currentInput;
QTimer m_waitForKeys;
};
#endif // INPUTHANDLING_H