Diffstat (limited to 'libopie2/opieui/okeyconfigwidget.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opieui/okeyconfigwidget.h | 107 |
1 files changed, 83 insertions, 24 deletions
diff --git a/libopie2/opieui/okeyconfigwidget.h b/libopie2/opieui/okeyconfigwidget.h index 414ee7e..b3309af 100644 --- a/libopie2/opieui/okeyconfigwidget.h +++ b/libopie2/opieui/okeyconfigwidget.h | |||
@@ -14,3 +14,3 @@ | |||
14 | #include <qpixmap.h> | 14 | #include <qpixmap.h> |
15 | #include <qbytearray.h> | 15 | #include <qcstring.h> |
16 | #include <qhbox.h> | 16 | #include <qhbox.h> |
@@ -19,2 +19,6 @@ | |||
19 | class QKeyEvent; | 19 | class QKeyEvent; |
20 | class QLabel; | ||
21 | class QPushButton; | ||
22 | class QListViewItem; | ||
23 | class QRadioButton; | ||
20 | 24 | ||
@@ -22,3 +26,8 @@ namespace Opie { | |||
22 | namespace Ui { | 26 | namespace Ui { |
23 | 27 | namespace Private { | |
28 | class OKeyConfigWidgetPrivate; | ||
29 | typedef QValueList<OKeyConfigWidgetPrivate> OKeyConfigWidgetPrivateList; | ||
30 | } | ||
31 | class OListViewItem; | ||
32 | class OListView; | ||
24 | 33 | ||
@@ -36,3 +45,3 @@ class OKeyPair { | |||
36 | public: | 45 | public: |
37 | typedef QValueList<OKeyPair> OKeyPairList; | 46 | typedef QValueList<OKeyPair> List; |
38 | OKeyPair( int key = -1, int modifier = -1); | 47 | OKeyPair( int key = -1, int modifier = -1); |
@@ -57,7 +66,7 @@ public: | |||
57 | static OKeyPair emptyKey(); | 66 | static OKeyPair emptyKey(); |
58 | static OKeyPairList hardwareKeys(); | 67 | static OKeyPair::List hardwareKeys(); |
59 | 68 | ||
60 | private: | 69 | private: |
61 | int m_key = -1; | 70 | int m_key; |
62 | int m_mod = -1; | 71 | int m_mod; |
63 | class Private; | 72 | class Private; |
@@ -77,3 +86,3 @@ class OKeyConfigItem { | |||
77 | public: | 86 | public: |
78 | typedef QValueList<OKeyConfigItem> OKeyConfigItemList; | 87 | typedef QValueList<OKeyConfigItem> List; |
79 | OKeyConfigItem( const QString& text = QString::null , const QCString& config_key = QCString(), | 88 | OKeyConfigItem( const QString& text = QString::null , const QCString& config_key = QCString(), |
@@ -81,4 +90,4 @@ public: | |||
81 | int id = -1, | 90 | int id = -1, |
82 | const OKeyPair& set = OKeyPair::emptyKey(), | 91 | const OKeyPair& def = OKeyPair::emptyKey(), |
83 | const OKeyPair& def = OKeyPair::emptyKey() ); | 92 | QObject *caller = 0, const char* slot = 0); |
84 | OKeyConfigItem( const Opie::Core::ODeviceButton& ); | 93 | OKeyConfigItem( const Opie::Core::ODeviceButton& ); |
@@ -93,2 +102,4 @@ public: | |||
93 | 102 | ||
103 | |||
104 | |||
94 | OKeyPair keyPair()const; | 105 | OKeyPair keyPair()const; |
@@ -97,2 +108,3 @@ public: | |||
97 | 108 | ||
109 | |||
98 | void setText( const QString& text ); | 110 | void setText( const QString& text ); |
@@ -105,2 +117,4 @@ public: | |||
105 | protected: | 117 | protected: |
118 | QObject *object()const; | ||
119 | QCString slot()const; | ||
106 | void setId( int id ); | 120 | void setId( int id ); |
@@ -109,3 +123,2 @@ protected: | |||
109 | private: | 123 | private: |
110 | int m_id; | ||
111 | QString m_text; | 124 | QString m_text; |
@@ -113,4 +126,7 @@ private: | |||
113 | QPixmap m_pix; | 126 | QPixmap m_pix; |
127 | int m_id; | ||
114 | OKeyPair m_key; | 128 | OKeyPair m_key; |
115 | OKeyPair m_def; | 129 | OKeyPair m_def; |
130 | QObject *m_obj; | ||
131 | QCString m_str; | ||
116 | class Private; | 132 | class Private; |
@@ -133,2 +149,3 @@ private: | |||
133 | * the event filter and get a signal. | 149 | * the event filter and get a signal. |
150 | * You need to load ans save yourself! | ||
134 | * | 151 | * |
@@ -138,3 +155,3 @@ class OKeyConfigManager : public QObject { | |||
138 | Q_OBJECT | 155 | Q_OBJECT |
139 | typedef QMap<it, OKeyConfigItemList> OKeyMapConfigPrivate; | 156 | typedef QMap<int, OKeyConfigItem::List> OKeyMapConfigPrivate; |
140 | public: | 157 | public: |
@@ -142,4 +159,4 @@ public: | |||
142 | const QString& group = QString::null, | 159 | const QString& group = QString::null, |
143 | OKeyPairList &block = OKeyPairList(), | 160 | const OKeyPair::List &block = OKeyPair::List(), |
144 | bool grabkeyboard = false, QObject *= 0, | 161 | bool grabkeyboard = false, QObject * par = 0, |
145 | const char* name = 0 ); | 162 | const char* name = 0 ); |
@@ -160,3 +177,3 @@ public: | |||
160 | void clearBlackList(); | 177 | void clearBlackList(); |
161 | OKeyPairList blackList()const; | 178 | OKeyPair::List blackList()const; |
162 | 179 | ||
@@ -166,9 +183,21 @@ public: | |||
166 | signals: | 183 | signals: |
167 | void keyConfigChanged( Opie::Ui::OKeyConfigManager* ); | 184 | /** |
185 | * The Signals are triggered on KeyPress and KeyRelease! | ||
186 | * You can check the isDown of the QKeyEvent | ||
187 | * @see QKeyEvent | ||
188 | */ | ||
168 | void actionActivated( QWidget*, QKeyEvent*, const Opie::Ui::OKeyConfigItem& ); | 189 | void actionActivated( QWidget*, QKeyEvent*, const Opie::Ui::OKeyConfigItem& ); |
169 | 190 | ||
191 | /** | ||
192 | * This Signal correspondents to the OKeyConfigItem slot | ||
193 | * and object | ||
194 | * | ||
195 | * @see OKeyConfigItem::slot | ||
196 | * @see OKeyConfigItem::object | ||
197 | */ | ||
198 | void actionActivated( QWidget* par, QKeyEvent* key); | ||
199 | |||
170 | private: | 200 | private: |
171 | OKeyConfigItemList keyList( int ); | 201 | OKeyConfigItem::List keyList( int ); |
172 | OKeyPairList m_blackKeys; | 202 | OKeyConfigItem::List m_keys; |
173 | OKeyConfigItemList m_keys; | ||
174 | QValueList<QWidget*> m_widgets; | 203 | QValueList<QWidget*> m_widgets; |
@@ -176,2 +205,3 @@ private: | |||
176 | QString m_group; | 205 | QString m_group; |
206 | OKeyPair::List m_blackKeys; | ||
177 | bool m_grab : 1; | 207 | bool m_grab : 1; |
@@ -183,8 +213,22 @@ private: | |||
183 | 213 | ||
184 | class OKeyConfigWidget : public QHBox { | 214 | /** |
215 | * With this Widget you can let the Keyboard Shortcuts | ||
216 | * be configured by the user. | ||
217 | * There are two ways you can use this widget. Either in a tab were | ||
218 | * all changes are immediately getting into effect or in a queue | ||
219 | * were you ask for saving. Save won't write the data but only set | ||
220 | * it to the OKeyConfigManager | ||
221 | * | ||
222 | * @since 1.2 | ||
223 | */ | ||
224 | class OKeyConfigWidget : public QWidget { | ||
185 | Q_OBJECT | 225 | Q_OBJECT |
226 | |||
186 | public: | 227 | public: |
187 | enum ChangeMode { Imediate, Queu }; | 228 | /** |
229 | * Immediate Apply the change directly to the underlying OKeyConfigManager | ||
230 | * Queue Save all items and then apply when you save() | ||
231 | */ | ||
232 | enum ChangeMode { Imediate, Queue }; | ||
188 | OKeyConfigWidget( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 233 | OKeyConfigWidget( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
189 | OKeyConfigWidget( OKeyConfigManager *, QWidget* parent = 0, const char* = 0, WFlags = 0 ); | ||
190 | ~OKeyConfigWidget(); | 234 | ~OKeyConfigWidget(); |
@@ -194,8 +238,23 @@ public: | |||
194 | 238 | ||
195 | void setKeyConfig( OKeyConfigManager* ); | 239 | void insert( const QString& name, OKeyConfigManager* ); |
196 | 240 | ||
197 | void reload(); | 241 | void load(); |
198 | void save(); | 242 | void save(); |
243 | |||
244 | private slots: | ||
245 | void slotListViewItem( QListViewItem* ); | ||
246 | void slotNoKey(); | ||
247 | void slotDefaultKey(); | ||
248 | void slotCustomKey(); | ||
249 | |||
250 | |||
199 | private: | 251 | private: |
200 | OKeyConfigManager* m_manager; | 252 | void initUi(); |
253 | Opie::Ui::OListView *m_view; | ||
254 | Opie::Ui::Private::OKeyConfigWidgetPrivateList m_list; | ||
255 | QLabel *m_lbl; | ||
256 | QPushButton *m_btn; | ||
257 | QRadioButton *m_def, *m_cus, *m_none; | ||
258 | QWidget* m_box; | ||
259 | ChangeMode m_mode; | ||
201 | class Private; | 260 | class Private; |