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 | |||
@@ -9,10 +9,6 @@ | |||
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 | ||
@@ -35,183 +31,2 @@ namespace Internal { | |||
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 | ||
@@ -242,3 +57,3 @@ public: | |||
242 | 57 | ||
243 | void insert( const QString& name, OKeyConfigManager* ); | 58 | void insert( const QString& name, Opie::Core::OKeyConfigManager* ); |
244 | 59 | ||
@@ -256,5 +71,5 @@ 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(); |
@@ -295,3 +110,3 @@ public: | |||
295 | 110 | ||
296 | OKeyPair keyPair()const; | 111 | Opie::Core::OKeyPair keyPair()const; |
297 | 112 | ||
@@ -311,3 +126,3 @@ private: | |||
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; |