1 | /* |
---|
2 | * File: mythkeysequence.h |
---|
3 | * |
---|
4 | * Purpose: This implements the MythKeySequence class. QKeySequence cannot |
---|
5 | * be easily extended not to ignore 'remoteXXX' identifiers. |
---|
6 | * |
---|
7 | * This replacement class fixes that and removes the need for |
---|
8 | * some duplicate code in MythTV and the MythControls-plugin. |
---|
9 | * |
---|
10 | * History: |
---|
11 | * |
---|
12 | * 20060620 |
---|
13 | * - Renamed member routine 'keyNum()' to 'value()'. |
---|
14 | * - Bugfixed problem with 'F1,M,{,<' only assigning 3 keys. |
---|
15 | * - Max.length of sequence configurable through #define MYTHKEY_SEQLEN. |
---|
16 | */ |
---|
17 | |
---|
18 | #ifndef _KEYSEQ_H_ |
---|
19 | #define _KEYSEQ_H_ |
---|
20 | |
---|
21 | #include <QObject> |
---|
22 | /* #include <qobject.h> */ |
---|
23 | #include <QKeySequence> |
---|
24 | /* #include <qkeysequence.h> */ |
---|
25 | |
---|
26 | /* The #define's below define internal features; |
---|
27 | ***********************************************/ |
---|
28 | |
---|
29 | // Maximum length of KeySequence -- default same as QKeySequence: |
---|
30 | #ifndef MYTHKEY_SEQLEN |
---|
31 | |
---|
32 | #define MYTHKEY_SEQLEN 4 |
---|
33 | #else |
---|
34 | |
---|
35 | #warning MYTHKEY_SEQLEN is already defined -- skipping assignment. |
---|
36 | #endif |
---|
37 | |
---|
38 | |
---|
39 | /******************** MythKeySequence / MythKey classes **********************/ |
---|
40 | class MythKeySequence; |
---|
41 | |
---|
42 | class MythKey : public QObject |
---|
43 | { |
---|
44 | Q_OBJECT |
---|
45 | |
---|
46 | public: |
---|
47 | MythKey( ); |
---|
48 | MythKey( const int ); |
---|
49 | MythKey( const QString ); |
---|
50 | |
---|
51 | /* Assign the key */ |
---|
52 | bool setKey( const int ); |
---|
53 | bool setKey( const QString ); |
---|
54 | void clear( ); |
---|
55 | |
---|
56 | /* Text representation, ie. Ctrl+PgUp, or remoteGUIDE */ |
---|
57 | QString text( ); |
---|
58 | /* Numeric value, only valid if Keys */ |
---|
59 | int value( ); |
---|
60 | /* More query stuff */ |
---|
61 | bool isRemote( ); |
---|
62 | bool isAssigned( ); |
---|
63 | |
---|
64 | operator int(); |
---|
65 | |
---|
66 | private: |
---|
67 | bool key_assigned; /* .. */ |
---|
68 | int is_button; /* Key is a button, i.e. not coming from a keyboard */ |
---|
69 | |
---|
70 | int key_num; /* Integer representation of key (is 0 for remote buttons) */ |
---|
71 | QString key_str; /* Text representation of key / button */ |
---|
72 | |
---|
73 | friend class MythKeySequence; |
---|
74 | }; |
---|
75 | |
---|
76 | class MythKeySequence : public QObject |
---|
77 | { |
---|
78 | Q_OBJECT |
---|
79 | |
---|
80 | public: |
---|
81 | MythKeySequence( ); |
---|
82 | MythKeySequence( int k1, int k2=0, int k3=0, int k4=0 ); |
---|
83 | MythKeySequence( const QString & ); |
---|
84 | |
---|
85 | /* Assign multiple keys */ |
---|
86 | uint setKeys( const QString & ); |
---|
87 | |
---|
88 | /* Query stuff */ |
---|
89 | bool isEmpty( ); |
---|
90 | void clear( ); |
---|
91 | uint count( ); |
---|
92 | |
---|
93 | MythKey* operator[]( int index ); |
---|
94 | bool operator ==( const MythKeySequence & ); |
---|
95 | operator QString( ); |
---|
96 | |
---|
97 | MythKey keys[ MYTHKEY_SEQLEN ]; |
---|
98 | |
---|
99 | private: |
---|
100 | uint keys_assigned; |
---|
101 | }; |
---|
102 | |
---|
103 | #endif // _KEYSEQ_H_ |
---|