author | hash <hash> | 2002-08-19 19:27:19 (UTC) |
---|---|---|
committer | hash <hash> | 2002-08-19 19:27:19 (UTC) |
commit | fc58f8b2dea3629fdd486852b74e425a3da29b52 (patch) (unidiff) | |
tree | 6d3393d5f04c2a5447d3d2ca489e4bd74a7e8df4 | |
parent | aaa640a47a707b4d4e6aff37bf78c11bfc903b3c (diff) | |
download | opie-fc58f8b2dea3629fdd486852b74e425a3da29b52.zip opie-fc58f8b2dea3629fdd486852b74e425a3da29b52.tar.gz opie-fc58f8b2dea3629fdd486852b74e425a3da29b52.tar.bz2 |
added a 'key repeat' toggle button
-rw-r--r-- | inputmethods/multikey/configdlg.cpp | 31 | ||||
-rw-r--r-- | inputmethods/multikey/configdlg.h | 3 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 39 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.h | 2 |
4 files changed, 57 insertions, 18 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp index 59a290b..566b2b9 100644 --- a/inputmethods/multikey/configdlg.cpp +++ b/inputmethods/multikey/configdlg.cpp | |||
@@ -90,112 +90,133 @@ ConfigDlg::ConfigDlg () : QTabWidget () | |||
90 | keymaps->setSelected(map_dir.count() + i + 1, true); | 90 | keymaps->setSelected(map_dir.count() + i + 1, true); |
91 | } | 91 | } |
92 | } | 92 | } |
93 | } | 93 | } |
94 | 94 | ||
95 | // have to "+1" because the "current language" listItem... remember? | 95 | // have to "+1" because the "current language" listItem... remember? |
96 | 96 | ||
97 | connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); | 97 | connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); |
98 | 98 | ||
99 | 99 | ||
100 | QGrid *add_remove_grid = new QGrid(2, map_group); | 100 | QGrid *add_remove_grid = new QGrid(2, map_group); |
101 | add_remove_grid->setMargin(3); | 101 | add_remove_grid->setMargin(3); |
102 | add_remove_grid->setSpacing(3); | 102 | add_remove_grid->setSpacing(3); |
103 | 103 | ||
104 | add_button = new QPushButton(tr("Add"), add_remove_grid); | 104 | add_button = new QPushButton(tr("Add"), add_remove_grid); |
105 | add_button->setFlat((bool)1); | 105 | add_button->setFlat((bool)1); |
106 | connect(add_button, SIGNAL(clicked()), SLOT(addMap())); | 106 | connect(add_button, SIGNAL(clicked()), SLOT(addMap())); |
107 | 107 | ||
108 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); | 108 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); |
109 | remove_button->setFlat((bool)1); | 109 | remove_button->setFlat((bool)1); |
110 | if ((int)map_dir.count() >= keymaps->currentItem()) | 110 | if ((int)map_dir.count() >= keymaps->currentItem()) |
111 | remove_button->setDisabled(true); | 111 | remove_button->setDisabled(true); |
112 | connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); | 112 | connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); |
113 | 113 | ||
114 | pick_button = new QCheckBox(tr("Pickboard"), gen_box); | 114 | // make a box that will contain the buttons on the bottom |
115 | QGrid *other_grid = new QGrid(2, gen_box); | ||
116 | pick_button = new QCheckBox(tr("Pickboard"), other_grid); | ||
115 | 117 | ||
116 | config.setGroup ("pickboard"); | 118 | config.setGroup ("general"); |
117 | bool pick_open = config.readBoolEntry ("open", "0"); // default closed | 119 | bool pick_open = config.readBoolEntry ("usePickboard", (bool)0); // default closed |
118 | if (pick_open) { | 120 | if (pick_open) { |
119 | 121 | ||
120 | pick_button->setChecked(true); | 122 | pick_button->setChecked(true); |
121 | } | 123 | } |
122 | 124 | ||
123 | // by connecting it after checking it, the signal isn't emmited | 125 | // by connecting it after checking it, the signal isn't emmited |
124 | connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); | 126 | connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); |
125 | 127 | ||
128 | repeat_button = new QCheckBox(tr("Key Repeat"), other_grid); | ||
129 | bool repeat_on = config.readBoolEntry ("useRepeat", (bool)1); | ||
130 | |||
131 | if (repeat_on) { | ||
132 | |||
133 | repeat_button->setChecked(true); | ||
134 | } | ||
135 | connect (repeat_button, SIGNAL(clicked()), this, SLOT(repeatTog())); | ||
136 | |||
137 | |||
126 | /* | 138 | /* |
127 | * 'color' tab | 139 | * 'color' tab |
128 | */ | 140 | */ |
129 | 141 | ||
130 | QGrid *color_box = new QGrid(2, this); | 142 | QGrid *color_box = new QGrid(2, this); |
131 | color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); | 143 | color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); |
132 | color_box->setMargin(3); | 144 | color_box->setMargin(3); |
133 | color_box->setSpacing(3); | 145 | color_box->setSpacing(3); |
134 | addTab(color_box, tr("Colors")); | 146 | addTab(color_box, tr("Colors")); |
135 | 147 | ||
136 | QLabel *label; | 148 | QLabel *label; |
137 | QStringList color; | 149 | QStringList color; |
138 | 150 | ||
139 | label = new QLabel(tr("Key Color"), color_box); | 151 | label = new QLabel(tr("Key Color"), color_box); |
140 | key_color_button = new QPushButton(color_box); | 152 | key_color_button = new QPushButton(color_box); |
141 | connect(key_color_button, SIGNAL(clicked()), SLOT(keyColorButtonClicked())); | 153 | connect(key_color_button, SIGNAL(clicked()), SLOT(keyColorButtonClicked())); |
142 | key_color_button->setFlat((bool)1); | 154 | key_color_button->setFlat((bool)1); |
143 | 155 | ||
144 | config.setGroup("colors"); | 156 | config.setGroup("colors"); |
145 | color = config.readListEntry("keycolor", QChar(',')); | 157 | color = config.readListEntry("keycolor", QChar(',')); |
146 | if (color.isEmpty()) { | 158 | if (color.isEmpty()) { |
147 | color = QStringList::split(",", "240,240,240"); | 159 | color = QStringList::split(",", "240,240,240"); |
148 | config.writeEntry("keycolor", color.join(",")); | 160 | config.writeEntry("keycolor", color.join(",")); |
149 | 161 | ||
150 | } | 162 | } |
151 | key_color_button->setBackgroundColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); | 163 | key_color_button->setBackgroundColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); |
152 | 164 | ||
153 | 165 | ||
154 | label = new QLabel(tr("Key Pressed Color"), color_box); | 166 | label = new QLabel(tr("Key Pressed Color"), color_box); |
155 | QPushButton *button = new QPushButton(color_box); | 167 | QPushButton *button = new QPushButton(color_box); |
156 | button->setFlat((bool)1); | 168 | button->setFlat((bool)1); |
157 | label = new QLabel(tr("Line Color"), color_box); | 169 | label = new QLabel(tr("Line Color"), color_box); |
158 | button = new QPushButton(color_box); | 170 | button = new QPushButton(color_box); |
159 | button->setFlat((bool)1); | 171 | button->setFlat((bool)1); |
160 | label = new QLabel(tr("Text Color"), color_box); | 172 | label = new QLabel(tr("Text Color"), color_box); |
161 | button = new QPushButton(color_box); | 173 | button = new QPushButton(color_box); |
162 | button->setFlat((bool)1); | 174 | button->setFlat((bool)1); |
163 | 175 | ||
164 | label = new QLabel("", color_box); // a spacer so the above buttons dont expand | 176 | label = new QLabel("", color_box); // a spacer so the above buttons dont expand |
165 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); | 177 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
166 | 178 | ||
167 | } | 179 | } |
168 | 180 | ||
169 | void ConfigDlg::pickTog() { | 181 | void ConfigDlg::pickTog() { |
170 | 182 | ||
171 | Config config ("multikey"); | 183 | Config config ("multikey"); |
172 | config.setGroup ("pickboard"); | 184 | config.setGroup ("general"); |
173 | config.writeEntry ("open", pick_button->isChecked()); // default closed | 185 | config.writeEntry ("usePickboard", pick_button->isChecked()); // default closed |
174 | 186 | ||
175 | emit pickboardToggled(pick_button->isChecked()); | 187 | emit pickboardToggled(pick_button->isChecked()); |
176 | } | 188 | } |
177 | 189 | ||
190 | void ConfigDlg::repeatTog() { | ||
191 | |||
192 | Config config ("multikey"); | ||
193 | config.setGroup ("general"); | ||
194 | config.writeEntry ("useRepeat", repeat_button->isChecked()); // default closed | ||
195 | |||
196 | emit repeatToggled(repeat_button->isChecked()); | ||
197 | } | ||
198 | |||
178 | /* | 199 | /* |
179 | * the index is kinda screwy, because in the config file, index 0 is just the | 200 | * the index is kinda screwy, because in the config file, index 0 is just the |
180 | * first element in the QStringList, but here it's the "Current Language" | 201 | * first element in the QStringList, but here it's the "Current Language" |
181 | * listItem. therefor you have to minus one to the index before you access it. | 202 | * listItem. therefor you have to minus one to the index before you access it. |
182 | * | 203 | * |
183 | */ | 204 | */ |
184 | 205 | ||
185 | // ConfigDlg::setMap {{{1 | 206 | // ConfigDlg::setMap {{{1 |
186 | void ConfigDlg::setMap(int index) { | 207 | void ConfigDlg::setMap(int index) { |
187 | 208 | ||
188 | if (index == 0) { | 209 | if (index == 0) { |
189 | 210 | ||
190 | remove_button->setDisabled(true); | 211 | remove_button->setDisabled(true); |
191 | emit setMapToDefault(); | 212 | emit setMapToDefault(); |
192 | } | 213 | } |
193 | else if ((uint)index <= default_maps.count()) { | 214 | else if ((uint)index <= default_maps.count()) { |
194 | 215 | ||
195 | remove_button->setDisabled(true); | 216 | remove_button->setDisabled(true); |
196 | emit setMapToFile(keymaps->text(index)); | 217 | emit setMapToFile(keymaps->text(index)); |
197 | 218 | ||
198 | } else { | 219 | } else { |
199 | 220 | ||
200 | remove_button->setEnabled(true); | 221 | remove_button->setEnabled(true); |
201 | emit setMapToFile(keymaps->text(index)); | 222 | emit setMapToFile(keymaps->text(index)); |
diff --git a/inputmethods/multikey/configdlg.h b/inputmethods/multikey/configdlg.h index ae7afe2..a000e60 100644 --- a/inputmethods/multikey/configdlg.h +++ b/inputmethods/multikey/configdlg.h | |||
@@ -1,47 +1,50 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
2 | #include <qtabwidget.h> | 2 | #include <qtabwidget.h> |
3 | #include <qcheckbox.h> | 3 | #include <qcheckbox.h> |
4 | #include <qlistbox.h> | 4 | #include <qlistbox.h> |
5 | #include <qpushbutton.h> | 5 | #include <qpushbutton.h> |
6 | 6 | ||
7 | #ifndef CONFIGDLG_H | 7 | #ifndef CONFIGDLG_H |
8 | #define CONFIGDLG_H | 8 | #define CONFIGDLG_H |
9 | 9 | ||
10 | class ConfigDlg : public QTabWidget | 10 | class ConfigDlg : public QTabWidget |
11 | { | 11 | { |
12 | Q_OBJECT | 12 | Q_OBJECT |
13 | 13 | ||
14 | public: | 14 | public: |
15 | ConfigDlg (); | 15 | ConfigDlg (); |
16 | 16 | ||
17 | signals: | 17 | signals: |
18 | void pickboardToggled(bool on_off); | 18 | void pickboardToggled(bool on_off); |
19 | void repeatToggled(bool on_off); | ||
19 | void setMapToDefault(); | 20 | void setMapToDefault(); |
20 | void setMapToFile(QString map); | 21 | void setMapToFile(QString map); |
21 | void reloadKeyboard(); | 22 | void reloadKeyboard(); |
22 | 23 | ||
23 | private slots: | 24 | private slots: |
24 | void pickTog(); | 25 | void pickTog(); |
26 | void repeatTog(); | ||
25 | void setMap(int index); | 27 | void setMap(int index); |
26 | void addMap(); | 28 | void addMap(); |
27 | void removeMap(); | 29 | void removeMap(); |
28 | 30 | ||
29 | // all those required slots for the color push buttons | 31 | // all those required slots for the color push buttons |
30 | void keyColorButtonClicked(); | 32 | void keyColorButtonClicked(); |
31 | 33 | ||
32 | private: | 34 | private: |
33 | QCheckBox *pick_button; | 35 | QCheckBox *pick_button; |
36 | QCheckBox *repeat_button; | ||
34 | QListBox *keymaps; | 37 | QListBox *keymaps; |
35 | QPushButton *add_button; | 38 | QPushButton *add_button; |
36 | QPushButton *remove_button; | 39 | QPushButton *remove_button; |
37 | 40 | ||
38 | 41 | ||
39 | QStringList default_maps; // the maps in your share/multikey/ dir | 42 | QStringList default_maps; // the maps in your share/multikey/ dir |
40 | QStringList custom_maps; // maps you added with the 'add' button | 43 | QStringList custom_maps; // maps you added with the 'add' button |
41 | 44 | ||
42 | /* color buttons */ | 45 | /* color buttons */ |
43 | QPushButton *key_color_button; | 46 | QPushButton *key_color_button; |
44 | 47 | ||
45 | }; | 48 | }; |
46 | 49 | ||
47 | #endif | 50 | #endif |
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 8280297..7334c1c 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -18,70 +18,70 @@ | |||
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "keyboard.h" | 21 | #include "keyboard.h" |
22 | #include "configdlg.h" | 22 | #include "configdlg.h" |
23 | 23 | ||
24 | #include <qpe/global.h> | 24 | #include <qpe/global.h> |
25 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
26 | 26 | ||
27 | #include <qwindowsystem_qws.h> | 27 | #include <qwindowsystem_qws.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | #include <qfontmetrics.h> | 29 | #include <qfontmetrics.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | #include <ctype.h> | 33 | #include <ctype.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qstringlist.h> | 36 | #include <qstringlist.h> |
37 | #include <iostream.h> | 37 | #include <iostream.h> |
38 | 38 | ||
39 | #include <sys/utsname.h> | 39 | #include <sys/utsname.h> |
40 | 40 | ||
41 | 41 | ||
42 | #define USE_SMALL_BACKSPACE | ||
43 | |||
44 | /* Keyboard::Keyboard {{{1 */ | 42 | /* Keyboard::Keyboard {{{1 */ |
45 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | 43 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : |
46 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), | 44 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), |
47 | alt(0), useLargeKeys(TRUE), usePicks(0), pressedKeyRow(-1), pressedKeyCol(-1), | 45 | alt(0), useLargeKeys(TRUE), usePicks(0), useRepeat(0), pressedKeyRow(-1), pressedKeyCol(-1), |
48 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), | 46 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), |
49 | configdlg(0) | 47 | configdlg(0) |
50 | 48 | ||
51 | { | 49 | { |
52 | 50 | ||
53 | // get the default font | 51 | // get the default font |
54 | Config *config = new Config( "qpe" ); | 52 | Config *config = new Config( "qpe" ); |
55 | config->setGroup( "Appearance" ); | 53 | config->setGroup( "Appearance" ); |
56 | QString familyStr = config->readEntry( "FontFamily", "fixed" ); | 54 | QString familyStr = config->readEntry( "FontFamily", "fixed" ); |
57 | delete config; | 55 | delete config; |
58 | 56 | ||
59 | config = new Config("multikey"); | 57 | config = new Config("multikey"); |
60 | config->setGroup ("pickboard"); | 58 | config->setGroup ("general"); |
61 | usePicks = config->readBoolEntry ("open", "0"); // default closed | 59 | usePicks = config->readBoolEntry ("usePickboard", "0"); // default closed |
60 | useRepeat = config->readBoolEntry ("useRepeat", "1"); | ||
62 | delete config; | 61 | delete config; |
63 | 62 | ||
63 | |||
64 | setFont( QFont( familyStr, 10 ) ); | 64 | setFont( QFont( familyStr, 10 ) ); |
65 | 65 | ||
66 | picks = new KeyboardPicks( this ); | 66 | picks = new KeyboardPicks( this ); |
67 | picks->setFont( QFont( familyStr, 10 ) ); | 67 | picks->setFont( QFont( familyStr, 10 ) ); |
68 | picks->initialise(); | 68 | picks->initialise(); |
69 | if (usePicks) { | 69 | if (usePicks) { |
70 | 70 | ||
71 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 71 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
72 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 72 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
73 | 73 | ||
74 | } else picks->hide(); | 74 | } else picks->hide(); |
75 | 75 | ||
76 | loadKeyboardColors(); | 76 | loadKeyboardColors(); |
77 | 77 | ||
78 | keys = new Keys(); | 78 | keys = new Keys(); |
79 | 79 | ||
80 | repeatTimer = new QTimer( this ); | 80 | repeatTimer = new QTimer( this ); |
81 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); | 81 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); |
82 | 82 | ||
83 | } | 83 | } |
84 | 84 | ||
85 | Keyboard::~Keyboard() { | 85 | Keyboard::~Keyboard() { |
86 | 86 | ||
87 | if ( configdlg ) { | 87 | if ( configdlg ) { |
@@ -263,54 +263,56 @@ void Keyboard::mousePressEvent(QMouseEvent *e) | |||
263 | for (int w = 0; e->x() >= w; col++) | 263 | for (int w = 0; e->x() >= w; col++) |
264 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys | 264 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys |
265 | w += keys->width(row,col) * defaultKeyWidth; | 265 | w += keys->width(row,col) * defaultKeyWidth; |
266 | else break; | 266 | else break; |
267 | 267 | ||
268 | col --; // rewind one... | 268 | col --; // rewind one... |
269 | 269 | ||
270 | qkeycode = keys->qcode(row, col); | 270 | qkeycode = keys->qcode(row, col); |
271 | unicode = keys->uni(row, col); | 271 | unicode = keys->uni(row, col); |
272 | 272 | ||
273 | // might need to repaint if two or more of the same keys. | 273 | // might need to repaint if two or more of the same keys. |
274 | // should be faster if just paint one key even though multiple keys exist. | 274 | // should be faster if just paint one key even though multiple keys exist. |
275 | bool need_repaint = FALSE; | 275 | bool need_repaint = FALSE; |
276 | 276 | ||
277 | if (unicode == 0) { // either Qt char, or nothing | 277 | if (unicode == 0) { // either Qt char, or nothing |
278 | 278 | ||
279 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard | 279 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard |
280 | 280 | ||
281 | if ( configdlg ) { | 281 | if ( configdlg ) { |
282 | delete (ConfigDlg *) configdlg; | 282 | delete (ConfigDlg *) configdlg; |
283 | configdlg = 0; | 283 | configdlg = 0; |
284 | } | 284 | } |
285 | else { | 285 | else { |
286 | configdlg = new ConfigDlg (); | 286 | configdlg = new ConfigDlg (); |
287 | connect(configdlg, SIGNAL(pickboardToggled(bool)), | ||
288 | this, SLOT(togglePickboard(bool))); | ||
289 | connect(configdlg, SIGNAL(setMapToDefault()), | 287 | connect(configdlg, SIGNAL(setMapToDefault()), |
290 | this, SLOT(setMapToDefault())); | 288 | this, SLOT(setMapToDefault())); |
291 | connect(configdlg, SIGNAL(setMapToFile(QString)), | 289 | connect(configdlg, SIGNAL(setMapToFile(QString)), |
292 | this, SLOT(setMapToFile(QString))); | 290 | this, SLOT(setMapToFile(QString))); |
291 | connect(configdlg, SIGNAL(pickboardToggled(bool)), | ||
292 | this, SLOT(togglePickboard(bool))); | ||
293 | connect(configdlg, SIGNAL(repeatToggled(bool)), | ||
294 | this, SLOT(toggleRepeat(bool))); | ||
293 | connect(configdlg, SIGNAL(reloadKeyboard()), | 295 | connect(configdlg, SIGNAL(reloadKeyboard()), |
294 | this, SLOT(reloadKeyboard())); | 296 | this, SLOT(reloadKeyboard())); |
295 | configdlg->showMaximized(); | 297 | configdlg->showMaximized(); |
296 | configdlg->show(); | 298 | configdlg->show(); |
297 | configdlg->raise(); | 299 | configdlg->raise(); |
298 | } | 300 | } |
299 | 301 | ||
300 | } else if (qkeycode == Qt::Key_Control) { | 302 | } else if (qkeycode == Qt::Key_Control) { |
301 | ctrl = keys->pressedPtr(row, col); | 303 | ctrl = keys->pressedPtr(row, col); |
302 | need_repaint = TRUE; | 304 | need_repaint = TRUE; |
303 | *ctrl = !keys->pressed(row, col); | 305 | *ctrl = !keys->pressed(row, col); |
304 | 306 | ||
305 | } else if (qkeycode == Qt::Key_Alt) { | 307 | } else if (qkeycode == Qt::Key_Alt) { |
306 | alt = keys->pressedPtr(row, col); | 308 | alt = keys->pressedPtr(row, col); |
307 | need_repaint = TRUE; | 309 | need_repaint = TRUE; |
308 | *alt = !keys->pressed(row, col); | 310 | *alt = !keys->pressed(row, col); |
309 | 311 | ||
310 | } else if (qkeycode == Qt::Key_Shift) { | 312 | } else if (qkeycode == Qt::Key_Shift) { |
311 | need_repaint = TRUE; | 313 | need_repaint = TRUE; |
312 | 314 | ||
313 | if (shift) { | 315 | if (shift) { |
314 | *shift = 0; | 316 | *shift = 0; |
315 | shift = 0; | 317 | shift = 0; |
316 | } | 318 | } |
@@ -374,96 +376,101 @@ void Keyboard::mousePressEvent(QMouseEvent *e) | |||
374 | dc->add(QString(QChar(unicode))); | 376 | dc->add(QString(QChar(unicode))); |
375 | dc->incBackspaces(); | 377 | dc->incBackspaces(); |
376 | } | 378 | } |
377 | } | 379 | } |
378 | picks->repaint(); | 380 | picks->repaint(); |
379 | } | 381 | } |
380 | 382 | ||
381 | 383 | ||
382 | // painting | 384 | // painting |
383 | pressed = TRUE; | 385 | pressed = TRUE; |
384 | 386 | ||
385 | pressedKeyRow = row; | 387 | pressedKeyRow = row; |
386 | pressedKeyCol = col; | 388 | pressedKeyCol = col; |
387 | 389 | ||
388 | if (need_repaint) repaint(FALSE); | 390 | if (need_repaint) repaint(FALSE); |
389 | else { // just paint the one key pressed | 391 | else { // just paint the one key pressed |
390 | 392 | ||
391 | 393 | ||
392 | 394 | ||
393 | QPainter p(this); | 395 | QPainter p(this); |
394 | drawKeyboard(p, row, col); | 396 | drawKeyboard(p, row, col); |
395 | 397 | ||
396 | } | 398 | } |
397 | 399 | ||
398 | pressTid = startTimer(80); | 400 | if (useRepeat) repeatTimer->start( 800 ); |
401 | //pressTid = startTimer(80); | ||
399 | 402 | ||
400 | } | 403 | } |
401 | 404 | ||
402 | 405 | ||
403 | /* Keyboard::mouseReleaseEvent {{{1 */ | 406 | /* Keyboard::mouseReleaseEvent {{{1 */ |
404 | void Keyboard::mouseReleaseEvent(QMouseEvent*) | 407 | void Keyboard::mouseReleaseEvent(QMouseEvent*) |
405 | { | 408 | { |
406 | pressed = FALSE; | 409 | pressed = FALSE; |
407 | if ( pressTid == 0 ) | 410 | //if ( pressTid == 0 ) |
408 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 411 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
409 | if ( unicode != -1 ) { | 412 | if ( unicode != -1 ) { |
410 | emit key( unicode, qkeycode, modifiers, false, false ); | 413 | emit key( unicode, qkeycode, modifiers, false, false ); |
411 | repeatTimer->stop(); | 414 | repeatTimer->stop(); |
412 | } | 415 | } |
413 | #endif | 416 | #endif |
414 | if (shift && unicode != 0) { | 417 | if (shift && unicode != 0) { |
415 | 418 | ||
416 | 419 | ||
417 | *shift = 0; // unpress shift key | 420 | *shift = 0; // unpress shift key |
418 | shift = 0; // reset the shift pointer | 421 | shift = 0; // reset the shift pointer |
419 | repaint(FALSE); | 422 | repaint(FALSE); |
420 | 423 | ||
421 | } | 424 | } |
422 | else | 425 | else |
423 | 426 | ||
424 | clearHighlight(); | 427 | clearHighlight(); |
425 | } | 428 | } |
426 | 429 | ||
427 | /* Keyboard::timerEvent {{{1 */ | 430 | /* Keyboard::timerEvent {{{1 */ |
428 | /* | 431 | |
429 | void Keyboard::timerEvent(QTimerEvent* e) | 432 | /* dont know what this does, but i think it is here so that if your screen |
433 | * sticks (like on an ipaq) then it will stop repeating if you click another | ||
434 | * key... but who knows what anything does in this thing anyway? | ||
435 | |||
436 | void Keyboard::timerEvent(QTimerEvent* e) | ||
430 | { | 437 | { |
431 | if ( e->timerId() == pressTid ) { | 438 | if ( e->timerId() == pressTid ) { |
432 | killTimer(pressTid); | 439 | killTimer(pressTid); |
433 | pressTid = 0; | 440 | pressTid = 0; |
434 | if ( !pressed ) | 441 | if ( !pressed ) |
435 | cout << "calling clearHighlight from timerEvent\n"; | 442 | cout << "calling clearHighlight from timerEvent\n"; |
436 | clearHighlight(); | 443 | //clearHighlight(); |
437 | } | 444 | } |
438 | } | 445 | } |
439 | */ | 446 | */ |
440 | 447 | ||
441 | void Keyboard::repeat() | 448 | void Keyboard::repeat() |
442 | { | 449 | { |
443 | 450 | ||
444 | repeatTimer->start( 200 ); | 451 | repeatTimer->start( 200 ); |
445 | emit key( unicode, 0, modifiers, true, true ); | 452 | emit key( unicode, qkeycode, modifiers, true, true ); |
446 | } | 453 | } |
447 | 454 | ||
448 | void Keyboard::clearHighlight() | 455 | void Keyboard::clearHighlight() |
449 | { | 456 | { |
450 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { | 457 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { |
451 | int tmpRow = pressedKeyRow; | 458 | int tmpRow = pressedKeyRow; |
452 | int tmpCol = pressedKeyCol; | 459 | int tmpCol = pressedKeyCol; |
453 | 460 | ||
454 | pressedKeyRow = -1; | 461 | pressedKeyRow = -1; |
455 | pressedKeyCol = -1; | 462 | pressedKeyCol = -1; |
456 | 463 | ||
457 | QPainter p(this); | 464 | QPainter p(this); |
458 | drawKeyboard(p, tmpRow, tmpCol); | 465 | drawKeyboard(p, tmpRow, tmpCol); |
459 | } | 466 | } |
460 | } | 467 | } |
461 | 468 | ||
462 | 469 | ||
463 | /* Keyboard::sizeHint {{{1 */ | 470 | /* Keyboard::sizeHint {{{1 */ |
464 | QSize Keyboard::sizeHint() const | 471 | QSize Keyboard::sizeHint() const |
465 | { | 472 | { |
466 | QFontMetrics fm=fontMetrics(); | 473 | QFontMetrics fm=fontMetrics(); |
467 | int keyHeight = fm.lineSpacing() + 2; | 474 | int keyHeight = fm.lineSpacing() + 2; |
468 | 475 | ||
469 | return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); | 476 | return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); |
@@ -482,48 +489,54 @@ void Keyboard::togglePickboard(bool on_off) | |||
482 | usePicks = on_off; | 489 | usePicks = on_off; |
483 | if (usePicks) { | 490 | if (usePicks) { |
484 | picks->show(); | 491 | picks->show(); |
485 | //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send | 492 | //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send |
486 | //adjustSize(); | 493 | //adjustSize(); |
487 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 494 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
488 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 495 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
489 | } else { | 496 | } else { |
490 | 497 | ||
491 | picks->hide(); | 498 | picks->hide(); |
492 | picks->resetState(); | 499 | picks->resetState(); |
493 | //move(x(), y() + picks->height()); | 500 | //move(x(), y() + picks->height()); |
494 | //adjustSize(); | 501 | //adjustSize(); |
495 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 502 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
496 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 503 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
497 | 504 | ||
498 | } | 505 | } |
499 | /* | 506 | /* |
500 | * this closes && opens the input method | 507 | * this closes && opens the input method |
501 | */ | 508 | */ |
502 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); | 509 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); |
503 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); | 510 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); |
504 | } | 511 | } |
505 | 512 | ||
513 | void Keyboard::toggleRepeat(bool on) { | ||
514 | |||
515 | useRepeat = on; | ||
516 | cout << "setting useRepeat to: " << useRepeat << "\n"; | ||
517 | } | ||
518 | |||
506 | /* Keyboard::setMapTo ... {{{1 */ | 519 | /* Keyboard::setMapTo ... {{{1 */ |
507 | void Keyboard::setMapToDefault() { | 520 | void Keyboard::setMapToDefault() { |
508 | 521 | ||
509 | 522 | ||
510 | /* load current locale language map */ | 523 | /* load current locale language map */ |
511 | Config *config = new Config("locale"); | 524 | Config *config = new Config("locale"); |
512 | config->setGroup( "Language" ); | 525 | config->setGroup( "Language" ); |
513 | QString l = config->readEntry( "Language" , "en" ); | 526 | QString l = config->readEntry( "Language" , "en" ); |
514 | delete config; | 527 | delete config; |
515 | 528 | ||
516 | QString key_map = QPEApplication::qpeDir() + "/share/multikey/" | 529 | QString key_map = QPEApplication::qpeDir() + "/share/multikey/" |
517 | + l + ".keymap"; | 530 | + l + ".keymap"; |
518 | 531 | ||
519 | /* save change to multikey config file */ | 532 | /* save change to multikey config file */ |
520 | config = new Config("multikey"); | 533 | config = new Config("multikey"); |
521 | config->setGroup ("keymaps"); | 534 | config->setGroup ("keymaps"); |
522 | config->writeEntry ("current", key_map); // default closed | 535 | config->writeEntry ("current", key_map); // default closed |
523 | delete config; | 536 | delete config; |
524 | 537 | ||
525 | delete keys; | 538 | delete keys; |
526 | keys = new Keys(key_map); | 539 | keys = new Keys(key_map); |
527 | 540 | ||
528 | // have to repaint the keyboard | 541 | // have to repaint the keyboard |
529 | repaint(FALSE); | 542 | repaint(FALSE); |
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h index 6e577ab..dc50e55 100644 --- a/inputmethods/multikey/keyboard.h +++ b/inputmethods/multikey/keyboard.h | |||
@@ -91,64 +91,66 @@ private: | |||
91 | class Keyboard : public QFrame | 91 | class Keyboard : public QFrame |
92 | { | 92 | { |
93 | Q_OBJECT | 93 | Q_OBJECT |
94 | public: | 94 | public: |
95 | Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 95 | Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
96 | ~Keyboard(); | 96 | ~Keyboard(); |
97 | 97 | ||
98 | void resetState(); | 98 | void resetState(); |
99 | 99 | ||
100 | void mousePressEvent(QMouseEvent*); | 100 | void mousePressEvent(QMouseEvent*); |
101 | void mouseReleaseEvent(QMouseEvent*); | 101 | void mouseReleaseEvent(QMouseEvent*); |
102 | void resizeEvent(QResizeEvent*); | 102 | void resizeEvent(QResizeEvent*); |
103 | void paintEvent(QPaintEvent* e); | 103 | void paintEvent(QPaintEvent* e); |
104 | //void timerEvent(QTimerEvent* e); | 104 | //void timerEvent(QTimerEvent* e); |
105 | void drawKeyboard( QPainter &p, int row = -1, int col = -1); | 105 | void drawKeyboard( QPainter &p, int row = -1, int col = -1); |
106 | 106 | ||
107 | QSize sizeHint() const; | 107 | QSize sizeHint() const; |
108 | 108 | ||
109 | signals: | 109 | signals: |
110 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); | 110 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); |
111 | 111 | ||
112 | private slots: | 112 | private slots: |
113 | void repeat(); | 113 | void repeat(); |
114 | void togglePickboard(bool on_off); | 114 | void togglePickboard(bool on_off); |
115 | void toggleRepeat(bool on_off); | ||
115 | void setMapToDefault(); | 116 | void setMapToDefault(); |
116 | void setMapToFile(QString map); | 117 | void setMapToFile(QString map); |
117 | 118 | ||
118 | // used to redraw keyboard after edited colors | 119 | // used to redraw keyboard after edited colors |
119 | void reloadKeyboard(); | 120 | void reloadKeyboard(); |
120 | 121 | ||
121 | private: | 122 | private: |
122 | int getKey( int &w, int j = -1 ); | 123 | int getKey( int &w, int j = -1 ); |
123 | void clearHighlight(); | 124 | void clearHighlight(); |
124 | 125 | ||
125 | bool *shift; | 126 | bool *shift; |
126 | bool *lock; | 127 | bool *lock; |
127 | bool *ctrl; | 128 | bool *ctrl; |
128 | bool *alt; | 129 | bool *alt; |
129 | uint useLargeKeys:1; | 130 | uint useLargeKeys:1; |
130 | uint usePicks:1; | 131 | uint usePicks:1; |
132 | uint useRepeat:1; | ||
131 | 133 | ||
132 | int pressedKeyRow; | 134 | int pressedKeyRow; |
133 | int pressedKeyCol; | 135 | int pressedKeyCol; |
134 | 136 | ||
135 | KeyboardPicks *picks; | 137 | KeyboardPicks *picks; |
136 | 138 | ||
137 | int keyHeight; | 139 | int keyHeight; |
138 | int defaultKeyWidth; | 140 | int defaultKeyWidth; |
139 | int xoffs; | 141 | int xoffs; |
140 | 142 | ||
141 | int unicode; | 143 | int unicode; |
142 | int qkeycode; | 144 | int qkeycode; |
143 | int modifiers; | 145 | int modifiers; |
144 | 146 | ||
145 | int pressTid; | 147 | int pressTid; |
146 | bool pressed; | 148 | bool pressed; |
147 | 149 | ||
148 | Keys *keys; | 150 | Keys *keys; |
149 | 151 | ||
150 | /* for korean input */ | 152 | /* for korean input */ |
151 | ushort schar, mchar, echar; | 153 | ushort schar, mchar, echar; |
152 | ushort parseKoreanInput(ushort c); | 154 | ushort parseKoreanInput(ushort c); |
153 | ushort combineKoreanChars(const ushort s, const ushort m, const ushort e); | 155 | ushort combineKoreanChars(const ushort s, const ushort m, const ushort e); |
154 | ushort constoe(const ushort c); | 156 | ushort constoe(const ushort c); |