summaryrefslogtreecommitdiff
path: root/libopie2/opieui/okeyconfigwidget.h
Unidiff
Diffstat (limited to 'libopie2/opieui/okeyconfigwidget.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/okeyconfigwidget.h107
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
@@ -12,15 +12,24 @@
12 12
13#include <qstring.h> 13#include <qstring.h>
14#include <qpixmap.h> 14#include <qpixmap.h>
15#include <qbytearray.h> 15#include <qcstring.h>
16#include <qhbox.h> 16#include <qhbox.h>
17#include <qvaluelist.h> 17#include <qvaluelist.h>
18 18
19class QKeyEvent; 19class QKeyEvent;
20class QLabel;
21class QPushButton;
22class QListViewItem;
23class QRadioButton;
20 24
21namespace Opie { 25namespace Opie {
22namespace Ui { 26namespace Ui {
23 27namespace Private {
28 class OKeyConfigWidgetPrivate;
29 typedef QValueList<OKeyConfigWidgetPrivate> OKeyConfigWidgetPrivateList;
30}
31 class OListViewItem;
32 class OListView;
24 33
25/** 34/**
26 * \brief small class representing a Key with possible modifiers 35 * \brief small class representing a Key with possible modifiers
@@ -34,7 +43,7 @@ namespace Ui {
34 */ 43 */
35class OKeyPair { 44class OKeyPair {
36public: 45public:
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);
39 ~OKeyPair(); 48 ~OKeyPair();
40 49
@@ -55,11 +64,11 @@ public:
55 static OKeyPair upArrowKey(); 64 static OKeyPair upArrowKey();
56 static OKeyPair downArrowKey(); 65 static OKeyPair downArrowKey();
57 static OKeyPair emptyKey(); 66 static OKeyPair emptyKey();
58 static OKeyPairList hardwareKeys(); 67 static OKeyPair::List hardwareKeys();
59 68
60private: 69private:
61 int m_key = -1; 70 int m_key;
62 int m_mod = -1; 71 int m_mod;
63 class Private; 72 class Private;
64 Private* d; 73 Private* d;
65}; 74};
@@ -75,12 +84,12 @@ private:
75class OKeyConfigItem { 84class OKeyConfigItem {
76 friend class OKeyConfigManager; 85 friend class OKeyConfigManager;
77public: 86public:
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(),
80 const QPixmap& symbol = QPixmap(), 89 const QPixmap& symbol = QPixmap(),
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& );
85 ~OKeyConfigItem(); 94 ~OKeyConfigItem();
86 95
@@ -91,10 +100,13 @@ public:
91 QPixmap pixmap()const; 100 QPixmap pixmap()const;
92 int id()const; 101 int id()const;
93 102
103
104
94 OKeyPair keyPair()const; 105 OKeyPair keyPair()const;
95 OKeyPair defaultKeyPair()const; 106 OKeyPair defaultKeyPair()const;
96 QCString configKey()const; 107 QCString configKey()const;
97 108
109
98 void setText( const QString& text ); 110 void setText( const QString& text );
99 void setPixmap( const QPixmap& ); 111 void setPixmap( const QPixmap& );
100 void setKeyPair( const OKeyPair& ); 112 void setKeyPair( const OKeyPair& );
@@ -103,16 +115,20 @@ public:
103 bool isEmpty()const; 115 bool isEmpty()const;
104 116
105protected: 117protected:
118 QObject *object()const;
119 QCString slot()const;
106 void setId( int id ); 120 void setId( int id );
107 void setConfigKey( const QCString& ); 121 void setConfigKey( const QCString& );
108 122
109private: 123private:
110 int m_id;
111 QString m_text; 124 QString m_text;
112 QCString m_config; 125 QCString m_config;
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;
117 Private *d; 133 Private *d;
118}; 134};
@@ -131,17 +147,18 @@ private:
131 * You can either handle the QKeyEvent yourself and ask this class if it is 147 * You can either handle the QKeyEvent yourself and ask this class if it is
132 * handled by your action and let give you the action. Or you can install 148 * handled by your action and let give you the action. Or you can install
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 *
135 * @since 1.1.2 152 * @since 1.1.2
136 */ 153 */
137class OKeyConfigManager : public QObject { 154class OKeyConfigManager : public QObject {
138 Q_OBJECT 155 Q_OBJECT
139 typedef QMap<it, OKeyConfigItemList> OKeyMapConfigPrivate; 156 typedef QMap<int, OKeyConfigItem::List> OKeyMapConfigPrivate;
140public: 157public:
141 OKeyConfigManager(Opie::Core::OConfig *conf = 0, 158 OKeyConfigManager(Opie::Core::OConfig *conf = 0,
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 );
146 ~OKeyConfigManager(); 163 ~OKeyConfigManager();
147 164
@@ -158,22 +175,35 @@ public:
158 void addToBlackList( const OKeyPair& ); 175 void addToBlackList( const OKeyPair& );
159 void removeFromBlackList( const OKeyPair& ); 176 void removeFromBlackList( const OKeyPair& );
160 void clearBlackList(); 177 void clearBlackList();
161 OKeyPairList blackList()const; 178 OKeyPair::List blackList()const;
162 179
163 void handleWidget( QWidget* ); 180 void handleWidget( QWidget* );
164 181
165 bool eventFilter( QObject*, QEvent* ); 182 bool eventFilter( QObject*, QEvent* );
166signals: 183signals:
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
170private: 200private:
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;
175 Opie::Core::OConfig *m_conf; 204 Opie::Core::OConfig *m_conf;
176 QString m_group; 205 QString m_group;
206 OKeyPair::List m_blackKeys;
177 bool m_grab : 1; 207 bool m_grab : 1;
178 OKeyMapConfigPrivate *m_map; 208 OKeyMapConfigPrivate *m_map;
179 class Private; 209 class Private;
@@ -181,23 +211,52 @@ private:
181}; 211};
182 212
183 213
184class 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 */
224class OKeyConfigWidget : public QWidget {
185 Q_OBJECT 225 Q_OBJECT
226
186public: 227public:
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();
191 235
192 void setChangeMode( enum ChangeMode ); 236 void setChangeMode( enum ChangeMode );
193 ChangeMode changeMode()const; 237 ChangeMode changeMode()const;
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
244private slots:
245 void slotListViewItem( QListViewItem* );
246 void slotNoKey();
247 void slotDefaultKey();
248 void slotCustomKey();
249
250
199private: 251private:
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;
202 Private *d; 261 Private *d;
203}; 262};