summaryrefslogtreecommitdiff
path: root/libopie2/opieui/okeyconfigwidget.h
authorzecke <zecke>2004-04-13 14:53:58 (UTC)
committer zecke <zecke>2004-04-13 14:53:58 (UTC)
commitb51d88d7b0b517b71ae3b59d8228335f38ca9fc7 (patch) (unidiff)
tree302377973a897934c944c7a126e5e0a510694979 /libopie2/opieui/okeyconfigwidget.h
parentc4c842558e1457f64d43b237f24f6ea1a4f9d76b (diff)
downloadopie-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.h199
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
@@ -7,14 +7,10 @@
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
19class QKeyEvent; 15class QKeyEvent;
20class QLabel; 16class QLabel;
@@ -33,187 +29,6 @@ namespace Internal {
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 */
46class OKeyPair {
47public:
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
71private:
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 */
86class OKeyConfigItem {
87 friend class OKeyConfigManager;
88public:
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
119protected:
120 QObject *object()const;
121 QCString slot()const;
122 void setId( int id );
123 void setConfigKey( const QCString& );
124
125private:
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 */
156class OKeyConfigManager : public QObject {
157 Q_OBJECT
158 typedef QMap<int, OKeyConfigItem::List> OKeyMapConfigPrivate;
159public:
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;
187signals:
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
204private:
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
@@ -240,7 +55,7 @@ public:
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();
@@ -254,9 +69,9 @@ private slots:
254 69
255private: 70private:
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;
@@ -293,7 +108,7 @@ 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
298protected: 113protected:
299 void keyPressEvent( QKeyEvent* ); 114 void keyPressEvent( QKeyEvent* );
@@ -309,7 +124,7 @@ 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;