|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
17 * |
|
18 * Description: |
|
19 * |
|
20 */ |
|
21 |
|
22 #ifndef KeyCaptureTestApp_H |
|
23 #define KEYCAPTUREMAINWINDOW_H |
|
24 |
|
25 #include <QMainWindow> |
|
26 #include <QMap> |
|
27 #include <xqkeycapture.h> |
|
28 |
|
29 class QPlainTextEdit; |
|
30 class QAction; |
|
31 class QWidget; |
|
32 class QMenu; |
|
33 class XqKeyCapture; |
|
34 class CaptureRequest; |
|
35 |
|
36 |
|
37 class KeyCaptureTestApp : public QMainWindow |
|
38 { |
|
39 Q_OBJECT |
|
40 public: |
|
41 KeyCaptureTestApp(QWidget *parent = 0); |
|
42 ~KeyCaptureTestApp(); |
|
43 void addTextLine(QString); |
|
44 |
|
45 bool event(QEvent *event); |
|
46 bool eventFilter(QObject *, QEvent *); |
|
47 public slots: |
|
48 void triggered(QAction* aAction); |
|
49 void cleanLog(); |
|
50 private: |
|
51 void procesAction(CaptureRequest request); |
|
52 void processEvent(QEvent *event); |
|
53 private: |
|
54 QPlainTextEdit *mTextArea; |
|
55 |
|
56 XqKeyCapture *mKeyCapture; |
|
57 |
|
58 QMap<QString, Qt::Key> mKeysMap; |
|
59 QMenu* mKeysMenu; |
|
60 |
|
61 QMap<QString, XqKeyCapture::LongFlags> mLongFlagsMap; |
|
62 QMenu* mLongFlagsMenu; |
|
63 |
|
64 }; |
|
65 |
|
66 |
|
67 class CaptureRequest |
|
68 { |
|
69 public: |
|
70 CaptureRequest(); |
|
71 ~CaptureRequest(); |
|
72 |
|
73 enum RequestType { |
|
74 RequestTypeUndefined =-1, |
|
75 RequestTypeKey, |
|
76 RequestTypeLongKey, |
|
77 RequestTypeKeyUpAndDowns, |
|
78 RequestTypeCancelKey, |
|
79 RequestTypeCancelLongKey, |
|
80 RequestTypeCancelKeyUpAndDowns |
|
81 }; |
|
82 |
|
83 bool setType(QAction* action); |
|
84 bool setKey(QAction* action, QMap<QString, Qt::Key> *map); |
|
85 bool setLongFlags(QAction* action, QMap<QString, XqKeyCapture::LongFlags> *map); |
|
86 |
|
87 QString toString(); |
|
88 public: |
|
89 RequestType mRequestType; |
|
90 Qt::Key mKey; |
|
91 Qt::KeyboardModifier mModifiersMap; |
|
92 Qt::KeyboardModifier mModifier; |
|
93 XqKeyCapture::LongFlags mLongFlags; |
|
94 }; |
|
95 #endif // KEYCAPTUREMAINWINDOW_H |