author | zecke <zecke> | 2004-04-13 14:53:58 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-04-13 14:53:58 (UTC) |
commit | b51d88d7b0b517b71ae3b59d8228335f38ca9fc7 (patch) (unidiff) | |
tree | 302377973a897934c944c7a126e5e0a510694979 /libopie2/opieui/okeyconfigwidget.h | |
parent | c4c842558e1457f64d43b237f24f6ea1a4f9d76b (diff) | |
download | opie-b51d88d7b0b517b71ae3b59d8228335f38ca9fc7.zip opie-b51d88d7b0b517b71ae3b59d8228335f38ca9fc7.tar.gz opie-b51d88d7b0b517b71ae3b59d8228335f38ca9fc7.tar.bz2 |
Split the KeyConfig Manager and Widget into Ui and Core parts
Adjust the only user...
Don't add a 2nd example to core but mention the one for the classes
in opieui/okeyconfigwidget
Diffstat (limited to 'libopie2/opieui/okeyconfigwidget.h') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opieui/okeyconfigwidget.h | 199 |
1 files changed, 7 insertions, 192 deletions
diff --git a/libopie2/opieui/okeyconfigwidget.h b/libopie2/opieui/okeyconfigwidget.h index bb8eb6c..d11054c 100644 --- a/libopie2/opieui/okeyconfigwidget.h +++ b/libopie2/opieui/okeyconfigwidget.h | |||
@@ -4,20 +4,16 @@ | |||
4 | */ | 4 | */ |
5 | 5 | ||
6 | 6 | ||
7 | #ifndef ODP_KEY_CONFIG_WIDGET_H | 7 | #ifndef ODP_KEY_CONFIG_WIDGET_H |
8 | #define ODP_KEY_CONFIG_WIDGET_H | 8 | #define ODP_KEY_CONFIG_WIDGET_H |
9 | 9 | ||
10 | #include <opie2/oconfig.h> | 10 | #include <opie2/okeyconfigmanager.h> |
11 | #include <opie2/odevice.h> | ||
12 | 11 | ||
13 | #include <qstring.h> | ||
14 | #include <qpixmap.h> | ||
15 | #include <qcstring.h> | ||
16 | #include <qhbox.h> | 12 | #include <qhbox.h> |
17 | #include <qvaluelist.h> | 13 | |
18 | 14 | ||
19 | class QKeyEvent; | 15 | class QKeyEvent; |
20 | class QLabel; | 16 | class QLabel; |
21 | class QPushButton; | 17 | class QPushButton; |
22 | class QListViewItem; | 18 | class QListViewItem; |
23 | class QRadioButton; | 19 | class QRadioButton; |
@@ -30,193 +26,12 @@ namespace Internal { | |||
30 | typedef QValueList<OKeyConfigWidgetPrivate> OKeyConfigWidgetPrivateList; | 26 | typedef QValueList<OKeyConfigWidgetPrivate> OKeyConfigWidgetPrivateList; |
31 | class OKeyListViewItem; | 27 | class OKeyListViewItem; |
32 | } | 28 | } |
33 | class OListViewItem; | 29 | class OListViewItem; |
34 | class OListView; | 30 | class OListView; |
35 | 31 | ||
36 | /** | ||
37 | * \brief small class representing a Key with possible modifiers | ||
38 | * This class holds information about key code and possible | ||
39 | * modifier state. That is the lowest level of the key input | ||
40 | * functions. | ||
41 | * There are also static methods to get special keys. | ||
42 | * OKeyPair will be used with \see OKeyConfigItem | ||
43 | * | ||
44 | * @since 1.2 | ||
45 | */ | ||
46 | class OKeyPair { | ||
47 | public: | ||
48 | typedef QValueList<OKeyPair> List; | ||
49 | OKeyPair( int key = -1, int modifier = -1); | ||
50 | ~OKeyPair(); | ||
51 | |||
52 | bool operator==( const OKeyPair& )const; | ||
53 | bool operator!=( const OKeyPair& )const; | ||
54 | |||
55 | bool isEmpty()const; | ||
56 | |||
57 | int keycode()const; | ||
58 | int modifier()const; | ||
59 | |||
60 | void setKeycode( int ); | ||
61 | void setModifier( int ); | ||
62 | |||
63 | static OKeyPair returnKey(); | ||
64 | static OKeyPair leftArrowKey(); | ||
65 | static OKeyPair rightArrowKey(); | ||
66 | static OKeyPair upArrowKey(); | ||
67 | static OKeyPair downArrowKey(); | ||
68 | static OKeyPair emptyKey(); | ||
69 | static OKeyPair::List hardwareKeys(); | ||
70 | |||
71 | private: | ||
72 | int m_key; | ||
73 | int m_mod; | ||
74 | class Private; | ||
75 | Private* d; | ||
76 | }; | ||
77 | |||
78 | /** | ||
79 | * A class to represent an OKeyPair. | ||
80 | * It consists out of a Text exposed to the user, Config Key Item, | ||
81 | * Pixmap, A default OKeyPair and the set OKeyPair. | ||
82 | * You can also pass an id to it | ||
83 | * | ||
84 | * @since 1.1.2 | ||
85 | */ | ||
86 | class OKeyConfigItem { | ||
87 | friend class OKeyConfigManager; | ||
88 | public: | ||
89 | typedef QValueList<OKeyConfigItem> List; | ||
90 | OKeyConfigItem( const QString& text = QString::null , const QCString& config_key = QCString(), | ||
91 | const QPixmap& symbol = QPixmap(), | ||
92 | int id = -1, | ||
93 | const OKeyPair& def = OKeyPair::emptyKey(), | ||
94 | QObject *caller = 0, const char* slot = 0); | ||
95 | OKeyConfigItem( const Opie::Core::ODeviceButton& ); | ||
96 | ~OKeyConfigItem(); | ||
97 | |||
98 | bool operator==( const OKeyConfigItem& )const; | ||
99 | bool operator!=( const OKeyConfigItem& )const; | ||
100 | |||
101 | QString text()const; | ||
102 | QPixmap pixmap()const; | ||
103 | int id()const; | ||
104 | |||
105 | |||
106 | |||
107 | OKeyPair keyPair()const; | ||
108 | OKeyPair defaultKeyPair()const; | ||
109 | QCString configKey()const; | ||
110 | |||
111 | |||
112 | void setText( const QString& text ); | ||
113 | void setPixmap( const QPixmap& ); | ||
114 | void setKeyPair( const OKeyPair& ); | ||
115 | void setDefaultKeyPair( const OKeyPair& ); | ||
116 | |||
117 | bool isEmpty()const; | ||
118 | |||
119 | protected: | ||
120 | QObject *object()const; | ||
121 | QCString slot()const; | ||
122 | void setId( int id ); | ||
123 | void setConfigKey( const QCString& ); | ||
124 | |||
125 | private: | ||
126 | QString m_text; | ||
127 | QCString m_config; | ||
128 | QPixmap m_pix; | ||
129 | int m_id; | ||
130 | OKeyPair m_key; | ||
131 | OKeyPair m_def; | ||
132 | QObject *m_obj; | ||
133 | QCString m_str; | ||
134 | class Private; | ||
135 | Private *d; | ||
136 | }; | ||
137 | |||
138 | |||
139 | |||
140 | /** | ||
141 | * \brief A manager to load and save Key Actions and get notified | ||
142 | * This is the Manager for KeyActions. | ||
143 | * You can say from which config and group to read data, to grab the | ||
144 | * keyboard to handle hardware keys, you can supply a blacklist of | ||
145 | * keys which should not be used by allowed to be used. | ||
146 | * You can even pass this manager to a Widget to do the configuration for you. | ||
147 | * You need to add OKeyConfigItem for your keys and then issue a load() to | ||
148 | * read the Key information. | ||
149 | * You can either handle the QKeyEvent yourself and ask this class if it is | ||
150 | * handled by your action and let give you the action. Or you can install | ||
151 | * the event filter and get a signal. | ||
152 | * You need to load ans save yourself! | ||
153 | * | ||
154 | * @since 1.1.2 | ||
155 | */ | ||
156 | class OKeyConfigManager : public QObject { | ||
157 | Q_OBJECT | ||
158 | typedef QMap<int, OKeyConfigItem::List> OKeyMapConfigPrivate; | ||
159 | public: | ||
160 | OKeyConfigManager(Opie::Core::OConfig *conf = 0, | ||
161 | const QString& group = QString::null, | ||
162 | const OKeyPair::List &block = OKeyPair::List(), | ||
163 | bool grabkeyboard = false, QObject * par = 0, | ||
164 | const char* name = 0 ); | ||
165 | ~OKeyConfigManager(); | ||
166 | |||
167 | void load(); | ||
168 | void save(); | ||
169 | |||
170 | OKeyConfigItem handleKeyEvent( QKeyEvent* ); | ||
171 | int handleKeyEventId( QKeyEvent* ); | ||
172 | |||
173 | void addKeyConfig( const OKeyConfigItem& ); | ||
174 | void removeKeyConfig( const OKeyConfigItem& ); | ||
175 | void clearKeyConfig(); | ||
176 | |||
177 | void addToBlackList( const OKeyPair& ); | ||
178 | void removeFromBlackList( const OKeyPair& ); | ||
179 | void clearBlackList(); | ||
180 | OKeyPair::List blackList()const; | ||
181 | |||
182 | void handleWidget( QWidget* ); | ||
183 | |||
184 | bool eventFilter( QObject*, QEvent* ); | ||
185 | |||
186 | OKeyConfigItem::List keyConfigList()const; | ||
187 | signals: | ||
188 | /** | ||
189 | * The Signals are triggered on KeyPress and KeyRelease! | ||
190 | * You can check the isDown of the QKeyEvent | ||
191 | * @see QKeyEvent | ||
192 | */ | ||
193 | void actionActivated( QWidget*, QKeyEvent*, const Opie::Ui::OKeyConfigItem& ); | ||
194 | |||
195 | /** | ||
196 | * This Signal correspondents to the OKeyConfigItem slot | ||
197 | * and object | ||
198 | * | ||
199 | * @see OKeyConfigItem::slot | ||
200 | * @see OKeyConfigItem::object | ||
201 | */ | ||
202 | void actionActivated( QWidget* par, QKeyEvent* key); | ||
203 | |||
204 | private: | ||
205 | OKeyConfigItem::List keyList( int ); | ||
206 | OKeyConfigItem::List m_keys; | ||
207 | QValueList<QWidget*> m_widgets; | ||
208 | Opie::Core::OConfig *m_conf; | ||
209 | QString m_group; | ||
210 | OKeyPair::List m_blackKeys; | ||
211 | bool m_grab : 1; | ||
212 | OKeyMapConfigPrivate *m_map; | ||
213 | class Private; | ||
214 | Private *d; | ||
215 | }; | ||
216 | |||
217 | 32 | ||
218 | /** | 33 | /** |
219 | * With this Widget you can let the Keyboard Shortcuts | 34 | * With this Widget you can let the Keyboard Shortcuts |
220 | * be configured by the user. | 35 | * be configured by the user. |
221 | * There are two ways you can use this widget. Either in a tab were | 36 | * There are two ways you can use this widget. Either in a tab were |
222 | * all changes are immediately getting into effect or in a queue | 37 | * all changes are immediately getting into effect or in a queue |
@@ -237,13 +52,13 @@ public: | |||
237 | OKeyConfigWidget( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 52 | OKeyConfigWidget( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
238 | ~OKeyConfigWidget(); | 53 | ~OKeyConfigWidget(); |
239 | 54 | ||
240 | void setChangeMode( enum ChangeMode ); | 55 | void setChangeMode( enum ChangeMode ); |
241 | ChangeMode changeMode()const; | 56 | ChangeMode changeMode()const; |
242 | 57 | ||
243 | void insert( const QString& name, OKeyConfigManager* ); | 58 | void insert( const QString& name, Opie::Core::OKeyConfigManager* ); |
244 | 59 | ||
245 | void load(); | 60 | void load(); |
246 | void save(); | 61 | void save(); |
247 | 62 | ||
248 | private slots: | 63 | private slots: |
249 | void slotListViewItem( QListViewItem* ); | 64 | void slotListViewItem( QListViewItem* ); |
@@ -251,15 +66,15 @@ private slots: | |||
251 | void slotDefaultKey(); | 66 | void slotDefaultKey(); |
252 | void slotCustomKey(); | 67 | void slotCustomKey(); |
253 | void slotConfigure(); | 68 | void slotConfigure(); |
254 | 69 | ||
255 | private: | 70 | private: |
256 | static bool sanityCheck( Opie::Ui::Internal::OKeyListViewItem* man, | 71 | static bool sanityCheck( Opie::Ui::Internal::OKeyListViewItem* man, |
257 | const OKeyPair& newItem ); | 72 | const Opie::Core::OKeyPair& newItem ); |
258 | void updateItem( Opie::Ui::Internal::OKeyListViewItem* man, | 73 | void updateItem( Opie::Ui::Internal::OKeyListViewItem* man, |
259 | const OKeyPair& newItem); | 74 | const Opie::Core::OKeyPair& newItem); |
260 | void initUi(); | 75 | void initUi(); |
261 | Opie::Ui::OListView *m_view; | 76 | Opie::Ui::OListView *m_view; |
262 | Opie::Ui::Internal::OKeyConfigWidgetPrivateList m_list; | 77 | Opie::Ui::Internal::OKeyConfigWidgetPrivateList m_list; |
263 | QLabel *m_lbl; | 78 | QLabel *m_lbl; |
264 | QPushButton *m_btn; | 79 | QPushButton *m_btn; |
265 | QRadioButton *m_def, *m_cus, *m_none; | 80 | QRadioButton *m_def, *m_cus, *m_none; |
@@ -290,13 +105,13 @@ private: | |||
290 | class OKeyChooserConfigDialog : public QDialog { | 105 | class OKeyChooserConfigDialog : public QDialog { |
291 | Q_OBJECT | 106 | Q_OBJECT |
292 | public: | 107 | public: |
293 | OKeyChooserConfigDialog( QWidget* parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 ); | 108 | OKeyChooserConfigDialog( QWidget* parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 ); |
294 | ~OKeyChooserConfigDialog(); | 109 | ~OKeyChooserConfigDialog(); |
295 | 110 | ||
296 | OKeyPair keyPair()const; | 111 | Opie::Core::OKeyPair keyPair()const; |
297 | 112 | ||
298 | protected: | 113 | protected: |
299 | void keyPressEvent( QKeyEvent* ); | 114 | void keyPressEvent( QKeyEvent* ); |
300 | void keyReleaseEvent( QKeyEvent* ); | 115 | void keyReleaseEvent( QKeyEvent* ); |
301 | 116 | ||
302 | signals: | 117 | signals: |
@@ -306,13 +121,13 @@ private slots: | |||
306 | void slotTimeUp(); | 121 | void slotTimeUp(); |
307 | 122 | ||
308 | private: | 123 | private: |
309 | QTimer *m_timer; | 124 | QTimer *m_timer; |
310 | QLabel *m_lbl; | 125 | QLabel *m_lbl; |
311 | bool m_virtKey : 1; | 126 | bool m_virtKey : 1; |
312 | OKeyPair m_keyPair; | 127 | Opie::Core::OKeyPair m_keyPair; |
313 | int m_key, m_mod; | 128 | int m_key, m_mod; |
314 | class Private; | 129 | class Private; |
315 | Private *d; | 130 | Private *d; |
316 | }; | 131 | }; |
317 | 132 | ||
318 | } | 133 | } |