summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/configdlg.cpp11
-rw-r--r--inputmethods/multikey/configdlg.h3
-rw-r--r--inputmethods/multikey/keyboard.cpp323
-rw-r--r--inputmethods/multikey/keyboard.h11
4 files changed, 299 insertions, 49 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp
index 26c9233..a8206b7 100644
--- a/inputmethods/multikey/configdlg.cpp
+++ b/inputmethods/multikey/configdlg.cpp
@@ -1,421 +1,428 @@
1/* 1/*
2 * TODO 2 * TODO
3 * make a font selection thing (size too) 3 * make a font selection thing (size too)
4 * make vertical keys possible
5 * make a keymap editor 4 * make a keymap editor
5 * make keys translucent
6 * make vertical keys possible
6 * 7 *
7 * 8 *
8 */ 9 */
9 10
10#include <qpe/qpeapplication.h> 11#include <qpe/qpeapplication.h>
11#include <qpe/config.h> 12#include <qpe/config.h>
12 13
13#include <qwidget.h> 14#include <qwidget.h>
14#include <qdialog.h> 15#include <qdialog.h>
15#include <qtabwidget.h> 16#include <qtabwidget.h>
16#include <qvbox.h> 17#include <qvbox.h>
17#include <qgrid.h> 18#include <qgrid.h>
18#include <qgroupbox.h> 19#include <qgroupbox.h>
19#include <qlabel.h> 20#include <qlabel.h>
20#include <qcheckbox.h> 21#include <qcheckbox.h>
21#include <qsizepolicy.h> 22#include <qsizepolicy.h>
22#include <qpushbutton.h> 23#include <qpushbutton.h>
23#include <qlistbox.h> 24#include <qlistbox.h>
24#include <qstringlist.h> 25#include <qstringlist.h>
25#include <opie/ofiledialog.h> 26#include <opie/ofiledialog.h>
26#include <opie/colordialog.h> 27#include <opie/colordialog.h>
27#include <qdir.h> 28#include <qdir.h>
28#include <qfileinfo.h> 29#include <qfileinfo.h>
29#include "configdlg.h" 30#include "configdlg.h"
30#include "keyboard.h" 31#include "keyboard.h"
31 32
32// ConfigDlg::ConfigDlg() {{{1 33// ConfigDlg::ConfigDlg() {{{1
33ConfigDlg::ConfigDlg () : QTabWidget () 34ConfigDlg::ConfigDlg () : QTabWidget ()
34{ 35{
35 setCaption( tr("Multikey Configuration") ); 36 setCaption( tr("Multikey Configuration") );
36 Config config ("multikey"); 37 Config config ("multikey");
37 config.setGroup("keymaps"); 38 config.setGroup("keymaps");
38 QString current_map = config.readEntry("current", 0); 39 QString current_map = config.readEntry("current", 0);
39 40
40 /* 41 /*
41 * 'general config' tab 42 * 'general config' tab
42 */ 43 */
43 44
44 QVBox *gen_box = new QVBox (this); 45 QVBox *gen_box = new QVBox (this);
45 gen_box->setMargin(3); 46 gen_box->setMargin(3);
46 addTab(gen_box, tr("General Settings")); 47 addTab(gen_box, tr("General Settings"));
47 48
48 QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); 49 QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box);
49 50
50 keymaps = new QListBox (map_group); 51 keymaps = new QListBox (map_group);
51 keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); 52 keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
52 53
53 QString cur(tr("Current Language")); 54 QString cur(tr("Current Language"));
54 keymaps->insertItem(cur); 55 keymaps->insertItem(cur);
55 keymaps->setSelected(0, true); 56 keymaps->setSelected(0, true);
56 57
57 QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap"); 58 QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap");
58 default_maps = map_dir.entryList(); // so i can access it in other places 59 default_maps = map_dir.entryList(); // so i can access it in other places
59 60
60 for (uint i = 0; i < map_dir.count(); i++) { 61 for (uint i = 0; i < map_dir.count(); i++) {
61 62
62 QFile map (map_dir.absPath() + "/" + map_dir[i]); 63 QFile map (map_dir.absPath() + "/" + map_dir[i]);
63 if (map.open(IO_ReadOnly)) { 64 if (map.open(IO_ReadOnly)) {
64 65
65 QString line; bool found = 0; 66 QString line; bool found = 0;
66 67
67 map.readLine(line, 1024); 68 map.readLine(line, 1024);
68 while (!map.atEnd()) { 69 while (!map.atEnd()) {
69 70
70 if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { 71 if (line.find(QRegExp("^title\\s*=\\s*")) != -1) {
71 72
72 keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); 73 keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace());
73 found = 1; 74 found = 1;
74 break; 75 break;
75 } 76 }
76 map.readLine(line, 1024); 77 map.readLine(line, 1024);
77 } 78 }
78 if (!found) keymaps->insertItem(map_dir.absPath() + "/" + map_dir[i]); 79 if (!found) keymaps->insertItem(map_dir.absPath() + "/" + map_dir[i]);
79 80
80 map.close(); 81 map.close();
81 } 82 }
82 if (map_dir.absPath() + "/" + map_dir[i] == current_map) { 83 if (map_dir.absPath() + "/" + map_dir[i] == current_map) {
83 84
84 keymaps->setSelected(i + 1, true); 85 keymaps->setSelected(i + 1, true);
85 } 86 }
86 87
87 } 88 }
88 89
89 custom_maps = config.readListEntry("maps", QChar('|')); 90 custom_maps = config.readListEntry("maps", QChar('|'));
90 91
91 for (uint i = 0; i < custom_maps.count(); i++) { 92 for (uint i = 0; i < custom_maps.count(); i++) {
92 93
93 if (map_dir.exists(QFileInfo(custom_maps[i]).fileName(), false) 94 if (map_dir.exists(QFileInfo(custom_maps[i]).fileName(), false)
94 || !QFile::exists(custom_maps[i])) { 95 || !QFile::exists(custom_maps[i])) {
95 96
96 custom_maps.remove(custom_maps.at(i)); 97 custom_maps.remove(custom_maps.at(i));
97 98
98 // remove it from the list too 99 // remove it from the list too
99 config.writeEntry("maps", custom_maps.join("|")); 100 config.writeEntry("maps", custom_maps.join("|"));
100 101
101 102
102 } else { 103 } else {
103 104
104 QFile map (custom_maps[i]); 105 QFile map (custom_maps[i]);
105 if (map.open(IO_ReadOnly)) { 106 if (map.open(IO_ReadOnly)) {
106 107
107 QString line; bool found = 0; 108 QString line; bool found = 0;
108 109
109 map.readLine(line, 1024); 110 map.readLine(line, 1024);
110 while (!map.atEnd()) { 111 while (!map.atEnd()) {
111 112
112 if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { 113 if (line.find(QRegExp("^title\\s*=\\s*")) != -1) {
113 114
114 keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); 115 keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace());
115 found = 1; 116 found = 1;
116 break; 117 break;
117 } 118 }
118 map.readLine(line, 1024); 119 map.readLine(line, 1024);
119 } 120 }
120 if (!found) keymaps->insertItem(custom_maps[i]); 121 if (!found) keymaps->insertItem(custom_maps[i]);
121 122
122 map.close(); 123 map.close();
123 } 124 }
124 if (custom_maps[i] == current_map) { 125 if (custom_maps[i] == current_map) {
125 126
126 keymaps->setSelected(map_dir.count() + i + 1, true); 127 keymaps->setSelected(map_dir.count() + i + 1, true);
127 } 128 }
128 } 129 }
129 } 130 }
130 131
131 // have to "+1" because the "current language" listItem... remember? 132 // have to "+1" because the "current language" listItem... remember?
132 133
133 connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); 134 connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int)));
134 135
135 136
136 QGrid *add_remove_grid = new QGrid(2, map_group); 137 QGrid *add_remove_grid = new QGrid(2, map_group);
137 add_remove_grid->setMargin(3); 138 add_remove_grid->setMargin(3);
138 add_remove_grid->setSpacing(3); 139 add_remove_grid->setSpacing(3);
139 140
140 add_button = new QPushButton(tr("Add"), add_remove_grid); 141 add_button = new QPushButton(tr("Add"), add_remove_grid);
141 add_button->setFlat((bool)1); 142 add_button->setFlat((bool)1);
142 connect(add_button, SIGNAL(clicked()), SLOT(addMap())); 143 connect(add_button, SIGNAL(clicked()), SLOT(addMap()));
143 144
144 remove_button = new QPushButton(tr("Remove"), add_remove_grid); 145 remove_button = new QPushButton(tr("Remove"), add_remove_grid);
145 remove_button->setFlat((bool)1); 146 remove_button->setFlat((bool)1);
146 if ((int)map_dir.count() >= keymaps->currentItem()) 147 if ((int)map_dir.count() >= keymaps->currentItem())
147 remove_button->setDisabled(true); 148 remove_button->setDisabled(true);
148 connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); 149 connect(remove_button, SIGNAL(clicked()), SLOT(removeMap()));
149 150
150 // make a box that will contain the buttons on the bottom 151 // make a box that will contain the buttons on the bottom
151 QGrid *other_grid = new QGrid(2, gen_box); 152 QGrid *other_grid = new QGrid(2, gen_box);
152 pick_button = new QCheckBox(tr("Pickboard"), other_grid); 153 pick_button = new QCheckBox(tr("Pickboard"), other_grid);
153 154
154 config.setGroup ("general"); 155 config.setGroup ("general");
155 bool pick_open = config.readBoolEntry ("usePickboard", (bool)0); // default closed 156 bool pick_open = config.readBoolEntry ("usePickboard", (bool)0); // default closed
156 if (pick_open) { 157 if (pick_open) {
157 158
158 pick_button->setChecked(true); 159 pick_button->setChecked(true);
159 } 160 }
160 161
161 // by connecting it after checking it, the signal isn't emmited 162 // by connecting it after checking it, the signal isn't emmited
162 connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); 163 connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog()));
163 164
164 repeat_button = new QCheckBox(tr("Key Repeat"), other_grid); 165 repeat_button = new QCheckBox(tr("Key Repeat"), other_grid);
165 bool repeat_on = config.readBoolEntry ("useRepeat", (bool)1); 166 bool repeat_on = config.readBoolEntry ("useRepeat", (bool)1);
166 167
167 if (repeat_on) { 168 if (repeat_on) {
168 169
169 repeat_button->setChecked(true); 170 repeat_button->setChecked(true);
170 } 171 }
171 connect (repeat_button, SIGNAL(clicked()), this, SLOT(repeatTog())); 172 connect (repeat_button, SIGNAL(clicked()), this, SLOT(repeatTog()));
172 173
173 174
174 /* 175 /*
175 * 'color' tab 176 * 'color' tab
176 */ 177 */
177 178
178 QGrid *color_box = new QGrid(2, this); 179 QGrid *color_box = new QGrid(2, this);
179 color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); 180 color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
180 color_box->setMargin(3); 181 color_box->setMargin(3);
181 color_box->setSpacing(3); 182 color_box->setSpacing(3);
182 addTab(color_box, tr("Colors")); 183 addTab(color_box, tr("Colors"));
183 184
184 QLabel *label; 185 QLabel *label;
185 QStringList color; 186 QStringList color;
186 config.setGroup("colors"); 187 config.setGroup("colors");
187 188
188 label = new QLabel(tr("Key Color"), color_box); 189 label = new QLabel(tr("Key Color"), color_box);
189 keycolor_button = new QPushButton(color_box); 190 keycolor_button = new QPushButton(color_box);
190 connect(keycolor_button, SIGNAL(clicked()), SLOT(keyColorClicked())); 191 connect(keycolor_button, SIGNAL(clicked()), SLOT(keyColorClicked()));
191 keycolor_button->setFlat((bool)1); 192 keycolor_button->setFlat((bool)1);
192 color = config.readListEntry("keycolor", QChar(',')); 193 color = config.readListEntry("keycolor", QChar(','));
193 /* 194 /*
194 * hopefully not required 195 * hopefully not required
195 196
196 if (color.isEmpty()) { 197 if (color.isEmpty()) {
197 color = QStringList::split(",", "240,240,240"); 198 color = QStringList::split(",", "240,240,240");
198 config.writeEntry("keycolor", color.join(",")); 199 config.writeEntry("keycolor", color.join(","));
199 200
200 } 201 }
201 */ 202 */
202 keycolor_button->setPalette(QPalette(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()))); 203 keycolor_button->setPalette(QPalette(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())));
203 204
204 205
205 label = new QLabel(tr("Key Pressed Color"), color_box); 206 label = new QLabel(tr("Key Pressed Color"), color_box);
206 keycolor_pressed_button = new QPushButton(color_box); 207 keycolor_pressed_button = new QPushButton(color_box);
207 connect(keycolor_pressed_button, SIGNAL(clicked()), SLOT(keyColorPressedClicked())); 208 connect(keycolor_pressed_button, SIGNAL(clicked()), SLOT(keyColorPressedClicked()));
208 keycolor_pressed_button->setFlat((bool)1); 209 keycolor_pressed_button->setFlat((bool)1);
209 color = config.readListEntry("keycolor_pressed", QChar(',')); 210 color = config.readListEntry("keycolor_pressed", QChar(','));
210 keycolor_pressed_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); 211 keycolor_pressed_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()))));
211 212
212 label = new QLabel(tr("Line Color"), color_box); 213 label = new QLabel(tr("Line Color"), color_box);
213 keycolor_lines_button = new QPushButton(color_box); 214 keycolor_lines_button = new QPushButton(color_box);
214 connect(keycolor_lines_button, SIGNAL(clicked()), SLOT(keyColorLinesClicked())); 215 connect(keycolor_lines_button, SIGNAL(clicked()), SLOT(keyColorLinesClicked()));
215 keycolor_lines_button->setFlat((bool)1); 216 keycolor_lines_button->setFlat((bool)1);
216 color = config.readListEntry("keycolor_lines", QChar(',')); 217 color = config.readListEntry("keycolor_lines", QChar(','));
217 keycolor_lines_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); 218 keycolor_lines_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()))));
218 219
219 220
220 label = new QLabel(tr("Text Color"), color_box); 221 label = new QLabel(tr("Text Color"), color_box);
221 textcolor_button = new QPushButton(color_box); 222 textcolor_button = new QPushButton(color_box);
222 connect(textcolor_button, SIGNAL(clicked()), SLOT(textColorClicked())); 223 connect(textcolor_button, SIGNAL(clicked()), SLOT(textColorClicked()));
223 textcolor_button->setFlat((bool)1); 224 textcolor_button->setFlat((bool)1);
224 color = config.readListEntry("textcolor", QChar(',')); 225 color = config.readListEntry("textcolor", QChar(','));
225 textcolor_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); 226 textcolor_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()))));
226 227
227 228
228 label = new QLabel("", color_box); // a spacer so the above buttons dont expand 229 label = new QLabel("", color_box); // a spacer so the above buttons dont expand
229 label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); 230 label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
230 231
231} 232}
232 233
233void ConfigDlg::pickTog() { 234void ConfigDlg::pickTog() {
234 235
235 Config config ("multikey"); 236 Config config ("multikey");
236 config.setGroup ("general"); 237 config.setGroup ("general");
237 config.writeEntry ("usePickboard", pick_button->isChecked()); // default closed 238 config.writeEntry ("usePickboard", pick_button->isChecked()); // default closed
238 239
239 emit pickboardToggled(pick_button->isChecked()); 240 emit pickboardToggled(pick_button->isChecked());
240} 241}
241 242
242void ConfigDlg::repeatTog() { 243void ConfigDlg::repeatTog() {
243 244
244 Config config ("multikey"); 245 Config config ("multikey");
245 config.setGroup ("general"); 246 config.setGroup ("general");
246 config.writeEntry ("useRepeat", repeat_button->isChecked()); // default closed 247 config.writeEntry ("useRepeat", repeat_button->isChecked()); // default closed
247 248
248 emit repeatToggled(repeat_button->isChecked()); 249 emit repeatToggled(repeat_button->isChecked());
249} 250}
250 251
252void ConfigDlg::closeEvent(QCloseEvent *) {
253
254 // tell the parent it was closed, so delete me
255 emit configDlgClosed();
256}
257
251// ConfigDlg::setMap {{{1 258// ConfigDlg::setMap {{{1
252 259
253/* 260/*
254 * the index is kinda screwy, because in the config file, index 0 is just the 261 * the index is kinda screwy, because in the config file, index 0 is just the
255 * first element in the QStringList, but here it's the "Current Language" 262 * first element in the QStringList, but here it's the "Current Language"
256 * listItem. therefor you have to minus one to the index before you access it. 263 * listItem. therefor you have to minus one to the index before you access it.
257 * 264 *
258 */ 265 */
259 266
260void ConfigDlg::setMap(int index) { 267void ConfigDlg::setMap(int index) {
261 268
262 if (index == 0) { 269 if (index == 0) {
263 270
264 remove_button->setDisabled(true); 271 remove_button->setDisabled(true);
265 emit setMapToDefault(); 272 emit setMapToDefault();
266 } 273 }
267 else if ((uint)index <= default_maps.count()) { 274 else if ((uint)index <= default_maps.count()) {
268 275
269 remove_button->setDisabled(true); 276 remove_button->setDisabled(true);
270 emit setMapToFile(QPEApplication::qpeDir() + "/share/multikey/" + default_maps[index - 1]); 277 emit setMapToFile(QPEApplication::qpeDir() + "share/multikey/" + default_maps[index - 1]);
271 278
272 } else { 279 } else {
273 280
274 remove_button->setEnabled(true); 281 remove_button->setEnabled(true);
275 emit setMapToFile(custom_maps[index - default_maps.count() - 1]); 282 emit setMapToFile(custom_maps[index - default_maps.count() - 1]);
276 } 283 }
277} 284}
278 285
279// ConfigDlg::addMap() {{{1 286// ConfigDlg::addMap() {{{1
280void ConfigDlg::addMap() { 287void ConfigDlg::addMap() {
281 288
282 QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath()); 289 QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath());
283 290
284 if (map.isNull()) return; 291 if (map.isNull()) return;
285 292
286 Config config ("multikey"); 293 Config config ("multikey");
287 config.setGroup("keymaps"); 294 config.setGroup("keymaps");
288 QStringList maps = config.readListEntry("maps", QChar('|')); 295 QStringList maps = config.readListEntry("maps", QChar('|'));
289 maps.append(map); 296 maps.append(map);
290 custom_maps.append(map); 297 custom_maps.append(map);
291 298
292 QFile map_file (map); 299 QFile map_file (map);
293 if (map_file.open(IO_ReadOnly)) { 300 if (map_file.open(IO_ReadOnly)) {
294 301
295 QString line; bool found = 0; 302 QString line; bool found = 0;
296 303
297 map_file.readLine(line, 1024); 304 map_file.readLine(line, 1024);
298 while (!map_file.atEnd()) { 305 while (!map_file.atEnd()) {
299 306
300 if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { 307 if (line.find(QRegExp("^title\\s*=\\s*")) != -1) {
301 308
302 keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); 309 keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace());
303 found = 1; 310 found = 1;
304 break; 311 break;
305 } 312 }
306 map_file.readLine(line, 1024); 313 map_file.readLine(line, 1024);
307 } 314 }
308 if (!found) keymaps->insertItem(map); 315 if (!found) keymaps->insertItem(map);
309 316
310 map_file.close(); 317 map_file.close();
311 } 318 }
312 319
313 keymaps->setSelected(keymaps->count() - 1, true); 320 keymaps->setSelected(keymaps->count() - 1, true);
314 321
315 322
316 config.writeEntry("maps", maps, QChar('|')); 323 config.writeEntry("maps", maps, QChar('|'));
317 config.writeEntry("current", map); 324 config.writeEntry("current", map);
318 325
319} 326}
320 327
321// ConfigDlg::removeMap() {{{1 328// ConfigDlg::removeMap() {{{1
322void ConfigDlg::removeMap() { 329void ConfigDlg::removeMap() {
323 330
324 // move selection up one 331 // move selection up one
325 keymaps->setSelected(keymaps->currentItem() - 1, true); 332 keymaps->setSelected(keymaps->currentItem() - 1, true);
326 // delete the next selected item cus you just moved it up 333 // delete the next selected item cus you just moved it up
327 keymaps->removeItem(keymaps->currentItem() + 1); 334 keymaps->removeItem(keymaps->currentItem() + 1);
328 335
329 custom_maps.remove(custom_maps.at(keymaps->currentItem() - default_maps.count())); 336 custom_maps.remove(custom_maps.at(keymaps->currentItem() - default_maps.count()));
330 337
331 // write the changes 338 // write the changes
332 Config config ("multikey"); 339 Config config ("multikey");
333 config.setGroup("keymaps"); 340 config.setGroup("keymaps");
334 config.writeEntry("maps", custom_maps, QChar('|')); 341 config.writeEntry("maps", custom_maps, QChar('|'));
335} 342}
336 343
337/* ConfigDlg::slots for the color buttons {{{1 344/* ConfigDlg::slots for the color buttons {{{1
338 * 345 *
339 * these four slots are almost the same, except for the names. i was thinking 346 * these four slots are almost the same, except for the names. i was thinking
340 * of making a map with pointers to the buttons and names of the configEntry 347 * of making a map with pointers to the buttons and names of the configEntry
341 * so it could be one slot, but then there would be no way of telling which 348 * so it could be one slot, but then there would be no way of telling which
342 * of the buttons was clicked if they all connect to the same slot. 349 * of the buttons was clicked if they all connect to the same slot.
343 * 350 *
344 */ 351 */
345 352
346void ConfigDlg::keyColorClicked() { 353void ConfigDlg::keyColorClicked() {
347 354
348 Config config ("multikey"); 355 Config config ("multikey");
349 config.setGroup ("colors"); 356 config.setGroup ("colors");
350 357
351 QStringList color = config.readListEntry("keycolor", QChar(',')); 358 QStringList color = config.readListEntry("keycolor", QChar(','));
352 359
353 QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); 360 QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()));
354 361
355 color[0].setNum(newcolor.red()); 362 color[0].setNum(newcolor.red());
356 color[1].setNum(newcolor.green()); 363 color[1].setNum(newcolor.green());
357 color[2].setNum(newcolor.blue()); 364 color[2].setNum(newcolor.blue());
358 365
359 config.writeEntry("keycolor", color, QChar(',')); 366 config.writeEntry("keycolor", color, QChar(','));
360 config.write(); 367 config.write();
361 368
362 keycolor_button->setPalette(QPalette(newcolor)); 369 keycolor_button->setPalette(QPalette(newcolor));
363 emit reloadKeyboard(); 370 emit reloadKeyboard();
364} 371}
365void ConfigDlg::keyColorPressedClicked() { 372void ConfigDlg::keyColorPressedClicked() {
366 373
367 Config config ("multikey"); 374 Config config ("multikey");
368 config.setGroup ("colors"); 375 config.setGroup ("colors");
369 376
370 QStringList color = config.readListEntry("keycolor_pressed", QChar(',')); 377 QStringList color = config.readListEntry("keycolor_pressed", QChar(','));
371 378
372 QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); 379 QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()));
373 380
374 color[0].setNum(newcolor.red()); 381 color[0].setNum(newcolor.red());
375 color[1].setNum(newcolor.green()); 382 color[1].setNum(newcolor.green());
376 color[2].setNum(newcolor.blue()); 383 color[2].setNum(newcolor.blue());
377 384
378 config.writeEntry("keycolor_pressed", color, QChar(',')); 385 config.writeEntry("keycolor_pressed", color, QChar(','));
379 config.write(); 386 config.write();
380 387
381 keycolor_pressed_button->setPalette(QPalette(newcolor)); 388 keycolor_pressed_button->setPalette(QPalette(newcolor));
382 emit reloadKeyboard(); 389 emit reloadKeyboard();
383} 390}
384void ConfigDlg::keyColorLinesClicked() { 391void ConfigDlg::keyColorLinesClicked() {
385 392
386 Config config ("multikey"); 393 Config config ("multikey");
387 config.setGroup ("colors"); 394 config.setGroup ("colors");
388 395
389 QStringList color = config.readListEntry("keycolor_lines", QChar(',')); 396 QStringList color = config.readListEntry("keycolor_lines", QChar(','));
390 397
391 QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); 398 QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()));
392 399
393 color[0].setNum(newcolor.red()); 400 color[0].setNum(newcolor.red());
394 color[1].setNum(newcolor.green()); 401 color[1].setNum(newcolor.green());
395 color[2].setNum(newcolor.blue()); 402 color[2].setNum(newcolor.blue());
396 403
397 config.writeEntry("keycolor_lines", color, QChar(',')); 404 config.writeEntry("keycolor_lines", color, QChar(','));
398 config.write(); 405 config.write();
399 406
400 keycolor_lines_button->setPalette(QPalette(newcolor)); 407 keycolor_lines_button->setPalette(QPalette(newcolor));
401 emit reloadKeyboard(); 408 emit reloadKeyboard();
402} 409}
403void ConfigDlg::textColorClicked() { 410void ConfigDlg::textColorClicked() {
404 411
405 Config config ("multikey"); 412 Config config ("multikey");
406 config.setGroup ("colors"); 413 config.setGroup ("colors");
407 414
408 QStringList color = config.readListEntry("textcolor", QChar(',')); 415 QStringList color = config.readListEntry("textcolor", QChar(','));
409 416
410 QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); 417 QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()));
411 418
412 color[0].setNum(newcolor.red()); 419 color[0].setNum(newcolor.red());
413 color[1].setNum(newcolor.green()); 420 color[1].setNum(newcolor.green());
414 color[2].setNum(newcolor.blue()); 421 color[2].setNum(newcolor.blue());
415 422
416 config.writeEntry("textcolor", color, QChar(',')); 423 config.writeEntry("textcolor", color, QChar(','));
417 config.write(); 424 config.write();
418 425
419 textcolor_button->setPalette(QPalette(newcolor)); 426 textcolor_button->setPalette(QPalette(newcolor));
420 emit reloadKeyboard(); 427 emit reloadKeyboard();
421} 428}
diff --git a/inputmethods/multikey/configdlg.h b/inputmethods/multikey/configdlg.h
index 5d6403f..336932b 100644
--- a/inputmethods/multikey/configdlg.h
+++ b/inputmethods/multikey/configdlg.h
@@ -1,56 +1,59 @@
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
10class ConfigDlg : public QTabWidget 10class ConfigDlg : public QTabWidget
11{ 11{
12 Q_OBJECT 12 Q_OBJECT
13 13
14public: 14public:
15 ConfigDlg (); 15 ConfigDlg ();
16 16
17signals: 17signals:
18 void pickboardToggled(bool on_off); 18 void pickboardToggled(bool on_off);
19 void repeatToggled(bool on_off); 19 void repeatToggled(bool on_off);
20 void setMapToDefault(); 20 void setMapToDefault();
21 void setMapToFile(QString map); 21 void setMapToFile(QString map);
22 void reloadKeyboard(); 22 void reloadKeyboard();
23 void configDlgClosed();
23 24
24private slots: 25private slots:
25 void pickTog(); 26 void pickTog();
26 void repeatTog(); 27 void repeatTog();
27 void setMap(int index); 28 void setMap(int index);
28 void addMap(); 29 void addMap();
29 void removeMap(); 30 void removeMap();
31 virtual void closeEvent ( QCloseEvent * );
32
30 33
31 // all those required slots for the color push buttons 34 // all those required slots for the color push buttons
32 void keyColorClicked(); 35 void keyColorClicked();
33 void keyColorPressedClicked(); 36 void keyColorPressedClicked();
34 void keyColorLinesClicked(); 37 void keyColorLinesClicked();
35 void textColorClicked(); 38 void textColorClicked();
36 39
37private: 40private:
38 QCheckBox *pick_button; 41 QCheckBox *pick_button;
39 QCheckBox *repeat_button; 42 QCheckBox *repeat_button;
40 QListBox *keymaps; 43 QListBox *keymaps;
41 QPushButton *add_button; 44 QPushButton *add_button;
42 QPushButton *remove_button; 45 QPushButton *remove_button;
43 46
44 47
45 QStringList default_maps; // the maps in your share/multikey/ dir 48 QStringList default_maps; // the maps in your share/multikey/ dir
46 QStringList custom_maps; // maps you added with the 'add' button 49 QStringList custom_maps; // maps you added with the 'add' button
47 50
48 /* color buttons */ 51 /* color buttons */
49 QPushButton *keycolor_button; 52 QPushButton *keycolor_button;
50 QPushButton *keycolor_pressed_button; 53 QPushButton *keycolor_pressed_button;
51 QPushButton *keycolor_lines_button; 54 QPushButton *keycolor_lines_button;
52 QPushButton *textcolor_button; 55 QPushButton *textcolor_button;
53 56
54}; 57};
55 58
56#endif 59#endif
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 4747f59..28d5cab 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -1,1264 +1,1495 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
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 37
38#include <sys/utsname.h> 38#include <sys/utsname.h>
39 39
40 40
41/* Keyboard::Keyboard {{{1 */ 41/* Keyboard::Keyboard {{{1 */
42Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : 42Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
43 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), meta(0), 43 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0),
44 useLargeKeys(TRUE), usePicks(0), useRepeat(0), pressedKeyRow(-1), pressedKeyCol(-1), 44 meta(0), circumflex(0), diaeresis(0),
45 useLargeKeys(TRUE), usePicks(0), useRepeat(0),
46 pressedKeyRow(-1), pressedKeyCol(-1),
45 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), 47 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0),
46 configdlg(0) 48 configdlg(0)
47 49
48{ 50{
49 51
50 // get the default font 52 // get the default font
51 Config *config = new Config( "qpe" ); 53 Config *config = new Config( "qpe" );
52 config->setGroup( "Appearance" ); 54 config->setGroup( "Appearance" );
53 QString familyStr = config->readEntry( "FontFamily", "fixed" ); 55 QString familyStr = config->readEntry( "FontFamily", "fixed" );
54 delete config; 56 delete config;
55 57
56 config = new Config("multikey"); 58 config = new Config("multikey");
57 config->setGroup ("general"); 59 config->setGroup ("general");
58 usePicks = config->readBoolEntry ("usePickboard", 0); // default closed 60 usePicks = config->readBoolEntry ("usePickboard", 0); // default closed
59 useRepeat = config->readBoolEntry ("useRepeat", 1); 61 useRepeat = config->readBoolEntry ("useRepeat", 1);
60 delete config; 62 delete config;
61 63
62 64
63 setFont( QFont( familyStr, 10 ) ); 65 setFont( QFont( familyStr, 10 ) );
64 66
65 picks = new KeyboardPicks( this ); 67 picks = new KeyboardPicks( this );
66 picks->setFont( QFont( familyStr, 10 ) ); 68 picks->setFont( QFont( familyStr, 10 ) );
67 picks->initialise(); 69 picks->initialise();
68 if (usePicks) { 70 if (usePicks) {
69 71
70 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 72 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
71 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 73 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
72 74
73 } else picks->hide(); 75 } else picks->hide();
74 76
75 loadKeyboardColors(); 77 loadKeyboardColors();
76 78
77 keys = new Keys(); 79 keys = new Keys();
78 80
79 repeatTimer = new QTimer( this ); 81 repeatTimer = new QTimer( this );
80 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); 82 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
81 83
82} 84}
83 85
84Keyboard::~Keyboard() { 86Keyboard::~Keyboard() {
85 87
86 if ( configdlg ) { 88 if ( configdlg ) {
87 delete (ConfigDlg *) configdlg; 89 delete (ConfigDlg *) configdlg;
88 configdlg = 0; 90 configdlg = 0;
89 } 91 }
90 92
91} 93}
92 94
93/* Keyboard::resizeEvent {{{1 */ 95/* Keyboard::resizeEvent {{{1 */
94void Keyboard::resizeEvent(QResizeEvent*) 96void Keyboard::resizeEvent(QResizeEvent*)
95{ 97{
96 int ph = picks->sizeHint().height(); 98 int ph = picks->sizeHint().height();
97 picks->setGeometry( 0, 0, width(), ph ); 99 picks->setGeometry( 0, 0, width(), ph );
98 keyHeight = (height()-(usePicks ? ph : 0))/5; 100 keyHeight = (height()-(usePicks ? ph : 0))/keys->rows();
99 101
100 int nk; // number of keys? 102 int nk; // number of keys?
101 if ( useLargeKeys ) { 103 if ( useLargeKeys ) {
102 nk = 15; 104 nk = 15;
103 } else { 105 } else {
104 nk = 19; 106 nk = 19;
105 } 107 }
106 defaultKeyWidth = (width()/nk)/2; 108 defaultKeyWidth = (width()/nk)/2;
107 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? 109 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces?
108 110
109} 111}
110 112
111/* KeyboardPicks::initialize {{{1 */ 113/* KeyboardPicks::initialize {{{1 */
112void KeyboardPicks::initialise() 114void KeyboardPicks::initialise()
113{ 115{
114 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 116 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
115 mode = 0; 117 mode = 0;
116 dc = new KeyboardConfig(this); 118 dc = new KeyboardConfig(this);
117 configs.append(dc); 119 configs.append(dc);
118} 120}
119 121
120/* KeyboardPicks::sizeHint {{{1 */ 122/* KeyboardPicks::sizeHint {{{1 */
121QSize KeyboardPicks::sizeHint() const 123QSize KeyboardPicks::sizeHint() const
122{ 124{
123 return QSize(240,fontMetrics().lineSpacing()); 125 return QSize(240,fontMetrics().lineSpacing());
124} 126}
125 127
126 128
127/* KeyboardConfig::generateText {{{1 */ 129/* KeyboardConfig::generateText {{{1 */
128void KeyboardConfig::generateText(const QString &s) 130void KeyboardConfig::generateText(const QString &s)
129{ 131{
130#if defined(Q_WS_QWS) || defined(_WS_QWS_) 132#if defined(Q_WS_QWS) || defined(_WS_QWS_)
131 for (int i=0; i<(int)backspaces; i++) { 133 for (int i=0; i<(int)backspaces; i++) {
132 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); 134 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false );
133 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); 135 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false );
134 } 136 }
135 for (int i=0; i<(int)s.length(); i++) { 137 for (int i=0; i<(int)s.length(); i++) {
136 parent->emitKey( s[i].unicode(), 0, 0, true, false ); 138 parent->emitKey( s[i].unicode(), 0, 0, true, false );
137 parent->emitKey( s[i].unicode(), 0, 0, false, false ); 139 parent->emitKey( s[i].unicode(), 0, 0, false, false );
138 } 140 }
139 parent->emitKey( 0, Qt::Key_Space, 0, true, false ); 141 parent->emitKey( 0, Qt::Key_Space, 0, true, false );
140 parent->emitKey( 0, Qt::Key_Space, 0, false, false ); 142 parent->emitKey( 0, Qt::Key_Space, 0, false, false );
141 backspaces = 0; 143 backspaces = 0;
142#endif 144#endif
143} 145}
144 146
145 147
146 148
147 149
148/* Keyboard::paintEvent {{{1 */ 150/* Keyboard::paintEvent {{{1 */
149void Keyboard::paintEvent(QPaintEvent* e) 151void Keyboard::paintEvent(QPaintEvent* e)
150{ 152{
151 QPainter painter(this); 153 QPainter painter(this);
152 painter.setClipRect(e->rect()); 154 painter.setClipRect(e->rect());
153 drawKeyboard( painter ); 155 drawKeyboard( painter );
154 picks->dc->draw( &painter ); 156 picks->dc->draw( &painter );
155} 157}
156 158
157 159
158/* Keyboard::drawKeyboard {{{1 */ 160/* Keyboard::drawKeyboard {{{1 */
159 161
160void Keyboard::drawKeyboard(QPainter &p, int row, int col) 162void Keyboard::drawKeyboard(QPainter &p, int row, int col)
161{ 163{
162 164
163 165
164 if (row != -1 && col != -1) { //just redraw one key 166 if (row != -1 && col != -1) { //just redraw one key
165 167
166 int x = 0; 168 int x = 0;
167 for (int i = 0; i < col; i++) { 169 for (int i = 0; i < col; i++) {
168 170
169 x += keys->width(row, i) * defaultKeyWidth; 171 x += keys->width(row, i) * defaultKeyWidth;
170 } 172 }
171 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 173 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
172 174
173 int keyWidth = keys->width(row, col); 175 int keyWidth = keys->width(row, col);
174 176
175 p.fillRect(x + 1, y + 1, 177 p.fillRect(x + 1, y + 1,
176 keyWidth * defaultKeyWidth - 1, keyHeight - 1, 178 keyWidth * defaultKeyWidth - 1, keyHeight - 1,
177 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); 179 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor);
178 180
179 QImage *pix = keys->pix(row,col); 181 QImage *pix = keys->pix(row,col);
180 182
181 ushort c = keys->uni(row, col); 183 ushort c = keys->uni(row, col);
182 184
183 p.setPen(textcolor); 185 p.setPen(textcolor);
184 if (!pix) { 186 if (!pix) {
185 if (shift || lock) 187 if ((shift || lock) && keys->shift(c))
186 c = keys->shift(c); 188
187 if (meta) { 189 if (circumflex && keys->circumflex(keys->shift(c)))
190 c = keys->circumflex(keys->shift(c));
191 else if (diaeresis && keys->diaeresis(keys->shift(c)))
192 c = keys->diaeresis(keys->shift(c));
193 else if (meta && keys->meta(keys->shift(c)))
194 c = keys->meta(keys->shift(c));
195 else
196 c = keys->shift(c);
188 197
198 else if (meta && keys->meta(c))
189 c = keys->meta(c); 199 c = keys->meta(c);
200 else if (circumflex && keys->circumflex(c))
201 c = keys->circumflex(c);
202 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) {
203
204 // the diaeresis key itself has to be in the diaeresisMap,
205 // or just do this to make it display the diaeresis char.
206
207 if (c == 0x2c6)
208 c = 0xa8;
209 else
210 c = keys->diaeresis(c);
190 } 211 }
212
191 p.drawText(x, y, 213 p.drawText(x, y,
192 defaultKeyWidth * keyWidth + 3, keyHeight, 214 defaultKeyWidth * keyWidth + 3, keyHeight,
193 AlignCenter, (QChar)c); 215 AlignCenter, (QChar)c);
194 } 216 }
195 else 217 else
196 // center the image in the middle of the key 218 // center the image in the middle of the key
197 p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, 219 p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1,
198 y + (keyHeight - pix->height())/2 + 1, 220 y + (keyHeight - pix->height())/2 + 1,
199 *pix ); 221 *pix );
200 222
201 // this fixes the problem that the very right end of the board's vertical line 223 // this fixes the problem that the very right end of the board's vertical line
202 // gets painted over, because it's one pixel shorter than all other keys 224 // gets painted over, because it's one pixel shorter than all other keys
203 p.setPen(keycolor_lines); 225 p.setPen(keycolor_lines);
204 p.drawLine(width() - 1, 0, width() - 1, height()); 226 p.drawLine(width() - 1, 0, width() - 1, height());
205 227
206 } else { 228 } else {
207 229
208 230
209 p.fillRect(0, 0, width(), height(), keycolor); 231 p.fillRect(0, 0, width(), height(), keycolor);
210 232
211 for (row = 1; row <= 5; row++) { 233 for (row = 1; row <= keys->rows(); row++) {
212 234
213 int x = 0; 235 int x = 0;
214 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 236 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
215 237
216 p.setPen(keycolor_lines); 238 p.setPen(keycolor_lines);
217 p.drawLine(x, y, x + width(), y); 239 p.drawLine(x, y, x + width(), y);
218 240
219 for (int col = 0; col < keys->numKeys(row); col++) { 241 for (int col = 0; col < keys->numKeys(row); col++) {
220 242
221 QImage *pix = keys->pix(row, col); 243 QImage *pix = keys->pix(row, col);
222 int keyWidth = keys->width(row, col); 244 int keyWidth = keys->width(row, col);
223 245
224 246
225 int keyWidthPix = defaultKeyWidth * keyWidth; 247 int keyWidthPix = defaultKeyWidth * keyWidth;
226 248
227 if (keys->pressed(row, col)) 249 if (keys->pressed(row, col))
228 p.fillRect(x+1, y+1, keyWidthPix - 1, 250 p.fillRect(x+1, y+1, keyWidthPix - 1,
229 keyHeight - 1, keycolor_pressed); 251 keyHeight - 1, keycolor_pressed);
230 252
231 ushort c = keys->uni(row, col); 253 ushort c = keys->uni(row, col);
232 254
233 p.setPen(textcolor); 255 p.setPen(textcolor);
234 if (!pix) { 256 if (!pix) {
235 if ((shift || lock) && keys->shift(c)) 257 if ((shift || lock) && keys->shift(c))
236 c = keys->shift(c); 258
259 if (circumflex && keys->circumflex(keys->shift(c)))
260 c = keys->circumflex(keys->shift(c));
261 else if (diaeresis && keys->diaeresis(keys->shift(c)))
262 c = keys->diaeresis(keys->shift(c));
263 else if (meta && keys->meta(keys->shift(c)))
264 c = keys->meta(keys->shift(c));
265 else
266 c = keys->shift(c);
267
237 else if (meta && keys->meta(c)) 268 else if (meta && keys->meta(c))
238 c = keys->meta(c); 269 c = keys->meta(c);
270 else if (circumflex && keys->circumflex(c))
271 c = keys->circumflex(c);
272 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) {
273
274 if (c == 0x2c6)
275 c = 0xa8;
276 else
277 c = keys->diaeresis(c);
278 }
239 279
240 p.drawText(x, y, 280 p.drawText(x, y,
241 keyWidthPix + 3, keyHeight, 281 keyWidthPix + 3, keyHeight,
242 AlignCenter, (QChar)c); 282 AlignCenter, (QChar)c);
243 } 283 }
244 else { 284 else {
245 // center the image in the middle of the key 285 // center the image in the middle of the key
246 pix->setColor(1, textcolor.rgb()); 286 pix->setColor(1, textcolor.rgb());
247 p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, 287 p.drawImage( x + (keyWidthPix - pix->width())/2 + 1,
248 y + (keyHeight - pix->height())/2 + 1, 288 y + (keyHeight - pix->height())/2 + 1,
249 QImage(*pix) ); 289 QImage(*pix) );
250 } 290 }
251 291
252 p.setPen(keycolor_lines); 292 p.setPen(keycolor_lines);
253 p.drawLine(x, y, x, y + keyHeight); 293 p.drawLine(x, y, x, y + keyHeight);
254 294
255 x += keyWidthPix; 295 x += keyWidthPix;
256 } 296 }
257 297
258 298
259 } 299 }
260 p.setPen(keycolor_lines); 300 p.setPen(keycolor_lines);
261 p.drawLine(0, height() - 1, width(), height() - 1); 301 p.drawLine(0, height() - 1, width(), height() - 1);
262 p.drawLine(width() - 1, 0, width() - 1, height()); 302 p.drawLine(width() - 1, 0, width() - 1, height());
263 } 303 }
264 304
265} 305}
266 306
267 307
268/* Keyboard::mousePressEvent {{{1 */ 308/* Keyboard::mousePressEvent {{{1 */
269void Keyboard::mousePressEvent(QMouseEvent *e) 309void Keyboard::mousePressEvent(QMouseEvent *e)
270{ 310{
271 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; 311 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1;
272 if (row > 5) row = 5; 312 if (row > 5) row = 5;
273 313
274 // figure out the column 314 // figure out the column
275 int col = 0; 315 int col = 0;
276 for (int w = 0; e->x() >= w; col++) 316 for (int w = 0; e->x() >= w; col++)
277 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys 317 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys
278 w += keys->width(row,col) * defaultKeyWidth; 318 w += keys->width(row,col) * defaultKeyWidth;
279 else break; 319 else break;
280 320
281 if (col <= 0) return; 321 if (col <= 0) return;
282 322
283 col --; // rewind one... 323 col --; // rewind one...
284 324
285 qkeycode = keys->qcode(row, col); 325 qkeycode = keys->qcode(row, col);
286 unicode = keys->uni(row, col); 326 unicode = keys->uni(row, col);
287 327
288 // might need to repaint if two or more of the same keys. 328 // might need to repaint if two or more of the same keys.
289 // should be faster if just paint one key even though multiple keys exist. 329 // should be faster if just paint one key even though multiple keys exist.
290 bool need_repaint = FALSE; 330 bool need_repaint = FALSE;
291 331
332 // circumflex and diaeresis support
333 // messy to have this here, but too hard to implement any other method
334 if (unicode == 0x2c6) {
335
336 unicode = 0;
337 if (shift || lock) {
338
339 // diaeresis
340 qkeycode = 0x2001;
341 }
342 else {
343
344 // circumflex
345 qkeycode = 0x2000;
346 }
347 }
348
292 if (unicode == 0) { // either Qt char, or nothing 349 if (unicode == 0) { // either Qt char, or nothing
293 350
294 if (qkeycode == Qt::Key_F1) { // toggle the pickboard 351 if (qkeycode == Qt::Key_F1) { // toggle the pickboard
295 352
296 if ( configdlg ) { 353 if ( configdlg ) {
354
297 delete (ConfigDlg *) configdlg; 355 delete (ConfigDlg *) configdlg;
298 configdlg = 0; 356 configdlg = 0;
299 } 357 }
300 else { 358 else {
301 configdlg = new ConfigDlg (); 359 configdlg = new ConfigDlg ();
302 connect(configdlg, SIGNAL(setMapToDefault()), 360 connect(configdlg, SIGNAL(setMapToDefault()),
303 this, SLOT(setMapToDefault())); 361 this, SLOT(setMapToDefault()));
304 connect(configdlg, SIGNAL(setMapToFile(QString)), 362 connect(configdlg, SIGNAL(setMapToFile(QString)),
305 this, SLOT(setMapToFile(QString))); 363 this, SLOT(setMapToFile(QString)));
306 connect(configdlg, SIGNAL(pickboardToggled(bool)), 364 connect(configdlg, SIGNAL(pickboardToggled(bool)),
307 this, SLOT(togglePickboard(bool))); 365 this, SLOT(togglePickboard(bool)));
308 connect(configdlg, SIGNAL(repeatToggled(bool)), 366 connect(configdlg, SIGNAL(repeatToggled(bool)),
309 this, SLOT(toggleRepeat(bool))); 367 this, SLOT(toggleRepeat(bool)));
310 connect(configdlg, SIGNAL(reloadKeyboard()), 368 connect(configdlg, SIGNAL(reloadKeyboard()),
311 this, SLOT(reloadKeyboard())); 369 this, SLOT(reloadKeyboard()));
370 connect(configdlg, SIGNAL(configDlgClosed()),
371 this, SLOT(cleanupConfigDlg()));
312 configdlg->showMaximized(); 372 configdlg->showMaximized();
313 configdlg->show(); 373 configdlg->show();
314 configdlg->raise(); 374 configdlg->raise();
315 } 375 }
316 376
317 } else if (qkeycode == Qt::Key_Control) { 377 } else if (qkeycode == Qt::Key_Control) {
318 need_repaint = TRUE; 378 need_repaint = TRUE;
319 379
320 if (ctrl) { 380 if (ctrl) {
321 381
322 *ctrl = 0; 382 *ctrl = 0;
323 ctrl = 0; 383 ctrl = 0;
324 384
325 } else { 385 } else {
326 386
327 ctrl = keys->pressedPtr(row, col); 387 ctrl = keys->pressedPtr(row, col);
328 need_repaint = TRUE; 388 need_repaint = TRUE;
329 *ctrl = !keys->pressed(row, col); 389 *ctrl = !keys->pressed(row, col);
330 390
331 } 391 }
332 392
333 } else if (qkeycode == Qt::Key_Alt) { 393 } else if (qkeycode == Qt::Key_Alt) {
334 need_repaint = TRUE; 394 need_repaint = TRUE;
335 395
336 if (alt) { 396 if (alt) {
337 *alt = 0; 397 *alt = 0;
338 alt = 0; 398 alt = 0;
339 399
340 } else { 400 } else {
341 401
342 alt = keys->pressedPtr(row, col); 402 alt = keys->pressedPtr(row, col);
343 need_repaint = TRUE; 403 need_repaint = TRUE;
344 *alt = !keys->pressed(row, col); 404 *alt = !keys->pressed(row, col);
345 } 405 }
346 406
347 } else if (qkeycode == Qt::Key_Shift) { 407 } else if (qkeycode == Qt::Key_Shift) {
348 need_repaint = TRUE; 408 need_repaint = TRUE;
349 409
350 if (shift) { 410 if (shift) {
351 *shift = 0; 411 *shift = 0;
352 shift = 0; 412 shift = 0;
353 } 413 }
354 else { 414 else {
355 shift = keys->pressedPtr(row, col); 415 shift = keys->pressedPtr(row, col);
356 *shift = 1; 416 *shift = 1;
357 if (lock) { 417 if (lock) {
358 *lock = 0; 418 *lock = 0;
359 lock = 0; 419 lock = 0;
360 } 420 }
361 } 421 }
362 if (meta) {
363 422
364 *meta = 0; 423
365 meta = 0; 424 /*
366 } 425 * want to be able to hit circumflex/diaeresis -> shift
426 * to type in shifted circumflex/diaeresis chars.
427 * same thing with meta
428
429 if (meta) { *meta = 0; meta = 0; }
430 if (circumflex) { *circumflex = 0; circumflex = 0; }
431 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
432
433 */
367 434
368 } else if (qkeycode == Qt::Key_CapsLock) { 435 } else if (qkeycode == Qt::Key_CapsLock) {
369 need_repaint = TRUE; 436 need_repaint = TRUE;
370 437
371 if (lock) { 438 if (lock) {
372 *lock = 0; 439 *lock = 0;
373 lock = 0; 440 lock = 0;
374 } 441 }
375 else { 442 else {
376 lock = keys->pressedPtr(row, col);; 443 lock = keys->pressedPtr(row, col);;
377 *lock = 1; 444 *lock = true;;
378 if (shift) { 445 if (shift) {
379 *shift = 0; 446 *shift = 0;
380 shift = 0; 447 shift = 0;
381 } 448 }
382 } 449 }
383 if (meta) {
384 450
385 *meta = 0; 451 /*
386 meta = 0; 452 if (meta) { *meta = 0; meta = 0; }
387 } 453 if (circumflex) { *circumflex = 0; circumflex = 0; }
454 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
455 */
388 456
389 } else if (qkeycode == Qt::Key_Meta) { 457 } else if (qkeycode == Qt::Key_Meta) {
390 need_repaint = TRUE; 458 need_repaint = TRUE;
391 459
392 if (meta) { 460 if (meta) {
393 *meta = 0; 461 *meta = 0;
394 meta = 0; 462 meta = 0;
395 463
396 } else { 464 } else {
397 465
398 meta = keys->pressedPtr(row, col); 466 meta = keys->pressedPtr(row, col);
399 need_repaint = TRUE; 467 *meta = true;
400 *meta = !keys->pressed(row, col);
401 } 468 }
402 469
403 if (shift) { 470 // reset all the other keys
471 if (shift) { *shift = 0; shift = 0; }
472 if (lock) { *lock = 0; lock = 0; }
473 if (circumflex) { *circumflex = 0; circumflex = 0; }
474 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
404 475
405 *shift = 0; 476 // dont need to emit this key... acts same as alt
406 shift = 0; 477 qkeycode = 0;
478
479 // circumflex
480 } else if (qkeycode == 0x2000) {
481 need_repaint = TRUE;
482
483 if (circumflex) {
484
485 *circumflex = 0;
486 circumflex = 0;
487
488 } else {
407 489
490 circumflex = keys->pressedPtr(row, col);
491 *circumflex = true;
408 } 492 }
409 if (lock) {
410 493
411 *lock = 0; 494 /* no need to turn off shift or lock if circumflex
412 lock = 0; 495 * keys are pressed
496
497 if (shift) { *shift = 0; shift = 0; }
498 if (lock) { *lock = 0; lock = 0; }
499
500 */
501
502 // have to reset all the other keys
503 if (meta) { *meta = 0; meta = 0; }
504 if (diaeresis) {
505
506 // *diaeresis and *circumflex point to the same thing
507 // when diaeresis is enabled and you hit the circumflex
508 // since they are the same key, it should turn off the
509 // key
510
511 *diaeresis = 0;
512 diaeresis = 0;
513 circumflex = 0;
514 }
515
516 qkeycode = 0;
413 517
518 // diaeresis
519 } else if (qkeycode == 0x2001) {
520 need_repaint = TRUE;
521
522 if (diaeresis) {
523
524 *diaeresis = 0;
525 diaeresis = 0;
526
527 } else {
528
529 diaeresis = keys->pressedPtr(row, col);
530 *diaeresis = true;
414 } 531 }
415 532
416 // dont need to emit this key... acts same as alt 533
534 if (shift) { *shift = 0; shift = 0; }
535
536 /*
537 *
538 if (lock) { *lock = 0; lock = 0; }
539 *
540 */
541
542 if (meta) { *meta = 0; meta = 0; }
543 if (circumflex) {
544
545 // *circumflex = 0;
546 //
547 // same thing the diaeresis pointer points too
548
549 circumflex = 0;
550 }
551
552
417 qkeycode = 0; 553 qkeycode = 0;
418 } 554 }
419 555
420 } 556 }
421 else { // normal char 557 else { // normal char
422 if ((shift || lock) && keys->shift(unicode)) { 558 if ((shift || lock) && keys->shift(unicode)) {
423 unicode = keys->shift(unicode); 559
560 // make diaeresis/circumflex -> shift input shifted
561 // diaeresis/circumflex chars
562
563 if (circumflex && keys->circumflex(keys->shift(unicode)))
564 unicode = keys->circumflex(keys->shift(unicode));
565 else if (diaeresis && keys->diaeresis(keys->shift(unicode)))
566 unicode = keys->diaeresis(keys->shift(unicode));
567 else if (meta && keys->meta(keys->shift(unicode)))
568 unicode = keys->meta(keys->shift(unicode));
569 else
570 unicode = keys->shift(unicode);
424 } 571 }
425 if (meta && keys->meta(unicode)) { 572 else if (meta && keys->meta(unicode)) {
426 unicode = keys->meta(unicode); 573 unicode = keys->meta(unicode);
427 } 574 }
575 else if (circumflex && keys->circumflex(unicode)) {
576 unicode = keys->circumflex(unicode);
577 }
578 else if (diaeresis && keys->diaeresis(unicode)) {
579
580 unicode = keys->diaeresis(unicode);
581 }
428 } 582 }
429 583
430 // korean parsing 584 // korean parsing
431 if (keys->lang == "ko") { 585 if (keys->lang == "ko") {
432 586
433 unicode = parseKoreanInput(unicode); 587 unicode = parseKoreanInput(unicode);
434 } 588 }
435 589
436 modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); 590 modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0);
437 591
438 if ('A' <= unicode && unicode <= 'z' && modifiers) { 592 if ('A' <= unicode && unicode <= 'z' && modifiers) {
439 593
440 qkeycode = QChar(unicode).upper(); 594 qkeycode = QChar(unicode).upper();
441 unicode = qkeycode - '@'; 595 unicode = qkeycode - '@';
442 } 596 }
443 597
444 QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); 598 QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false);
445 599
446 // pickboard stuff 600 // pickboard stuff
447 if (usePicks) { 601 if (usePicks) {
448 602
449 KeyboardConfig *dc = picks->dc; 603 KeyboardConfig *dc = picks->dc;
450 604
451 if (dc) { 605 if (dc) {
452 if (qkeycode == Qt::Key_Backspace) { 606 if (qkeycode == Qt::Key_Backspace) {
453 dc->input.remove(dc->input.last()); // remove last input 607 dc->input.remove(dc->input.last()); // remove last input
454 dc->decBackspaces(); 608 dc->decBackspaces();
455 } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { 609 } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) {
456 dc->input.clear(); 610 dc->input.clear();
457 dc->resetBackspaces(); 611 dc->resetBackspaces();
458 } else { 612 } else {
459 dc->add(QString(QChar(unicode))); 613 dc->add(QString(QChar(unicode)));
460 dc->incBackspaces(); 614 dc->incBackspaces();
461 } 615 }
462 } 616 }
463 picks->repaint(); 617 picks->repaint();
464 } 618 }
465 619
466 620
467 // painting 621 // painting
468 pressed = TRUE; 622 pressed = TRUE;
469 623
470 pressedKeyRow = row; 624 pressedKeyRow = row;
471 pressedKeyCol = col; 625 pressedKeyCol = col;
472 626
473 if (need_repaint) repaint(FALSE); 627 if (need_repaint) repaint(FALSE);
474 else { // just paint the one key pressed 628 else { // just paint the one key pressed
475 629
476 630
477 631
478 QPainter p(this); 632 QPainter p(this);
479 drawKeyboard(p, row, col); 633 drawKeyboard(p, row, col);
480 634
481 } 635 }
482 636
483 if (useRepeat) repeatTimer->start( 800 ); 637 if (useRepeat) repeatTimer->start( 800 );
484 //pressTid = startTimer(80); 638 //pressTid = startTimer(80);
485 639
486} 640}
487 641
488 642
489/* Keyboard::mouseReleaseEvent {{{1 */ 643/* Keyboard::mouseReleaseEvent {{{1 */
490void Keyboard::mouseReleaseEvent(QMouseEvent*) 644void Keyboard::mouseReleaseEvent(QMouseEvent*)
491{ 645{
492 pressed = FALSE; 646 pressed = FALSE;
493 //if ( pressTid == 0 ) 647 //if ( pressTid == 0 )
494#if defined(Q_WS_QWS) || defined(_WS_QWS_) 648#if defined(Q_WS_QWS) || defined(_WS_QWS_)
495 if ( unicode != -1 ) { 649 if ( unicode != -1 ) {
496 emit key( unicode, qkeycode, modifiers, false, false ); 650 emit key( unicode, qkeycode, modifiers, false, false );
497 repeatTimer->stop(); 651 repeatTimer->stop();
498 } 652 }
499#endif 653#endif
500 if (shift && unicode != 0) { 654 if (shift && unicode != 0) {
501 655
502 656
503 *shift = 0; // unpress shift key 657 *shift = 0; // unpress shift key
504 shift = 0; // reset the shift pointer 658 shift = 0; // reset the shift pointer
505 repaint(FALSE); 659 repaint(FALSE);
506 660
507 } else if (meta && unicode != 0) { 661 }
662
663 /*
664 * do not make the meta key release after being pressed
665 *
666
667 else if (meta && unicode != 0) {
508 668
509 *meta = 0; 669 *meta = 0;
510 meta = 0; 670 meta = 0;
511 repaint(FALSE); 671 repaint(FALSE);
512 } 672 }
513 else
514 673
515 clearHighlight(); 674 */
675
676 else clearHighlight();
516} 677}
517 678
518/* Keyboard::timerEvent {{{1 */ 679/* Keyboard::timerEvent {{{1 */
519 680
520/* dont know what this does, but i think it is here so that if your screen 681/* dont know what this does, but i think it is here so that if your screen
521 * sticks (like on an ipaq) then it will stop repeating if you click another 682 * sticks (like on an ipaq) then it will stop repeating if you click another
522 * key... but who knows what anything does in this thing anyway? 683 * key... but who knows what anything does in this thing anyway?
523 684
524 void Keyboard::timerEvent(QTimerEvent* e) 685 void Keyboard::timerEvent(QTimerEvent* e)
525{ 686{
526 if ( e->timerId() == pressTid ) { 687 if ( e->timerId() == pressTid ) {
527 killTimer(pressTid); 688 killTimer(pressTid);
528 pressTid = 0; 689 pressTid = 0;
529 if ( !pressed ) 690 if ( !pressed )
530 cout << "calling clearHighlight from timerEvent\n"; 691 cout << "calling clearHighlight from timerEvent\n";
531 //clearHighlight(); 692 //clearHighlight();
532 } 693 }
533} 694}
534*/ 695*/
535 696
536void Keyboard::repeat() 697void Keyboard::repeat()
537{ 698{
538 699
539 repeatTimer->start( 200 ); 700 repeatTimer->start( 200 );
540 emit key( unicode, qkeycode, modifiers, true, true ); 701 emit key( unicode, qkeycode, modifiers, true, true );
541} 702}
542 703
543void Keyboard::clearHighlight() 704void Keyboard::clearHighlight()
544{ 705{
545 if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { 706 if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) {
546 int tmpRow = pressedKeyRow; 707 int tmpRow = pressedKeyRow;
547 int tmpCol = pressedKeyCol; 708 int tmpCol = pressedKeyCol;
548 709
549 pressedKeyRow = -1; 710 pressedKeyRow = -1;
550 pressedKeyCol = -1; 711 pressedKeyCol = -1;
551 712
552 QPainter p(this); 713 QPainter p(this);
553 drawKeyboard(p, tmpRow, tmpCol); 714 drawKeyboard(p, tmpRow, tmpCol);
554 } 715 }
555} 716}
556 717
557 718
558/* Keyboard::sizeHint {{{1 */ 719/* Keyboard::sizeHint {{{1 */
559QSize Keyboard::sizeHint() const 720QSize Keyboard::sizeHint() const
560{ 721{
561 QFontMetrics fm=fontMetrics(); 722 QFontMetrics fm=fontMetrics();
562 int keyHeight = fm.lineSpacing() + 2; 723 int keyHeight = fm.lineSpacing() + 2;
563 724
564 return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); 725 return QSize( 240, keyHeight * keys->rows() + (usePicks ? picks->sizeHint().height() : 0) + 1);
565} 726}
566 727
567 728
568void Keyboard::resetState() 729void Keyboard::resetState()
569{ 730{
731 if (shift) { *shift = 0; shift = 0; }
732 if (lock) {*lock = 0; lock = 0; }
733 if (meta) { *meta = 0; meta = 0; }
734 if (circumflex) { *circumflex = 0; circumflex = 0; }
735 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
736
570 schar = mchar = echar = 0; 737 schar = mchar = echar = 0;
571 picks->resetState(); 738 picks->resetState();
572} 739}
573 740
574/* Keyboard::togglePickboard {{{1 */ 741/* Keyboard::togglePickboard {{{1 */
575void Keyboard::togglePickboard(bool on_off) 742void Keyboard::togglePickboard(bool on_off)
576{ 743{
577 usePicks = on_off; 744 usePicks = on_off;
578 if (usePicks) { 745 if (usePicks) {
579 picks->show(); 746 picks->show();
580 //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send 747 //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send
581 //adjustSize(); 748 //adjustSize();
582 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 749 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
583 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 750 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
584 } else { 751 } else {
585 752
586 picks->hide(); 753 picks->hide();
587 picks->resetState(); 754 picks->resetState();
588 //move(x(), y() + picks->height()); 755 //move(x(), y() + picks->height());
589 //adjustSize(); 756 //adjustSize();
590 QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 757 QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
591 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 758 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
592 759
593 } 760 }
594 /* 761 /*
595 * this closes && opens the input method 762 * this closes && opens the input method
596 */ 763 */
597 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); 764 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
598 QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); 765 QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
599} 766}
600 767
601void Keyboard::toggleRepeat(bool on) { 768void Keyboard::toggleRepeat(bool on) {
602 769
603 useRepeat = on; 770 useRepeat = on;
604 //cout << "setting useRepeat to: " << useRepeat << "\n"; 771 //cout << "setting useRepeat to: " << useRepeat << "\n";
605} 772}
606 773
774void Keyboard::cleanupConfigDlg() {
775
776 if ( configdlg ) {
777 delete (ConfigDlg *) configdlg;
778 configdlg = 0;
779 }
780}
781
607/* Keyboard::setMapTo ... {{{1 */ 782/* Keyboard::setMapTo ... {{{1 */
608void Keyboard::setMapToDefault() { 783void Keyboard::setMapToDefault() {
609 784
610 785
611 /* load current locale language map */ 786 /* load current locale language map */
612 Config *config = new Config("locale"); 787 Config *config = new Config("locale");
613 config->setGroup( "Language" ); 788 config->setGroup( "Language" );
614 QString l = config->readEntry( "Language" , "en" ); 789 QString l = config->readEntry( "Language" , "en" );
615 delete config; 790 delete config;
616 791
617 QString key_map = QPEApplication::qpeDir() + "/share/multikey/" 792 QString key_map = QPEApplication::qpeDir() + "share/multikey/"
618 + l + ".keymap"; 793 + l + ".keymap";
619 794
620 /* save change to multikey config file */ 795 /* save change to multikey config file */
621 config = new Config("multikey"); 796 config = new Config("multikey");
622 config->setGroup ("keymaps"); 797 config->setGroup ("keymaps");
623 config->writeEntry ("current", key_map); // default closed 798 config->writeEntry ("current", key_map); // default closed
624 delete config; 799 delete config;
625 800
801 int prevRows = keys->rows();
802
626 delete keys; 803 delete keys;
627 keys = new Keys(key_map); 804 keys = new Keys(key_map);
628 805
629 // have to repaint the keyboard 806 // have to repaint the keyboard
630 repaint(FALSE); 807 if (prevRows != keys->rows()) {
808
809 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
810 QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
811
812 } else repaint(FALSE);
813
814 resetState();
631} 815}
632 816
633void Keyboard::setMapToFile(QString map) { 817void Keyboard::setMapToFile(QString map) {
634 818
635 /* save change to multikey config file */ 819 /* save change to multikey config file */
636 Config *config = new Config("multikey"); 820 Config *config = new Config("multikey");
637 config->setGroup ("keymaps"); 821 config->setGroup ("keymaps");
638 config->writeEntry ("current", map); // default closed 822 config->writeEntry ("current", map); // default closed
639 823
640 delete config; 824 delete config;
641 825
826 int prevRows = keys->rows();
827
642 delete keys; 828 delete keys;
643 if (QFile(map).exists()) 829 if (QFile(map).exists())
644 keys = new Keys(map); 830 keys = new Keys(map);
645 else 831 else
646 keys = new Keys(); 832 keys = new Keys();
647 833
648 repaint(FALSE); 834 if (keys->rows() != prevRows) {
835
836 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
837 QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
838 }
839 else repaint(FALSE);
649 840
841 resetState();
650} 842}
651 843
652/* Keybaord::reloadKeyboard {{{1 */ 844/* Keybaord::reloadKeyboard {{{1 */
653void Keyboard::reloadKeyboard() { 845void Keyboard::reloadKeyboard() {
654 846
655 // reload colors and redraw 847 // reload colors and redraw
656 loadKeyboardColors(); 848 loadKeyboardColors();
657 repaint(); 849 repaint();
658 850
659} 851}
660 852
661void Keyboard::loadKeyboardColors() { 853void Keyboard::loadKeyboardColors() {
662 854
663 Config config ("multikey"); 855 Config config ("multikey");
664 config.setGroup("colors"); 856 config.setGroup("colors");
665 857
666 QStringList color; 858 QStringList color;
667 color = config.readListEntry("keycolor", QChar(',')); 859 color = config.readListEntry("keycolor", QChar(','));
668 if (color.isEmpty()) { 860 if (color.isEmpty()) {
669 color = QStringList::split(",", "240,240,240"); 861 color = QStringList::split(",", "240,240,240");
670 config.writeEntry("keycolor", color.join(",")); 862 config.writeEntry("keycolor", color.join(","));
671 863
672 } 864 }
673 keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 865 keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
674 866
675 color = config.readListEntry("keycolor_pressed", QChar(',')); 867 color = config.readListEntry("keycolor_pressed", QChar(','));
676 if (color.isEmpty()) { 868 if (color.isEmpty()) {
677 color = QStringList::split(",", "171,183,198"); 869 color = QStringList::split(",", "171,183,198");
678 config.writeEntry("keycolor_pressed", color.join(",")); 870 config.writeEntry("keycolor_pressed", color.join(","));
679 871
680 } 872 }
681 keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 873 keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
682 874
683 color = config.readListEntry("keycolor_lines", QChar(',')); 875 color = config.readListEntry("keycolor_lines", QChar(','));
684 if (color.isEmpty()) { 876 if (color.isEmpty()) {
685 color = QStringList::split(",", "138,148,160"); 877 color = QStringList::split(",", "138,148,160");
686 config.writeEntry("keycolor_lines", color.join(",")); 878 config.writeEntry("keycolor_lines", color.join(","));
687 879
688 } 880 }
689 keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 881 keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
690 882
691 color = config.readListEntry("textcolor", QChar(',')); 883 color = config.readListEntry("textcolor", QChar(','));
692 if (color.isEmpty()) { 884 if (color.isEmpty()) {
693 color = QStringList::split(",", "43,54,68"); 885 color = QStringList::split(",", "43,54,68");
694 config.writeEntry("textcolor", color.join(",")); 886 config.writeEntry("textcolor", color.join(","));
695 887
696 } 888 }
697 textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 889 textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
698 890
699} 891}
700 892
701/* korean input functions {{{1 893/* korean input functions {{{1
702 * 894 *
703 * TODO 895 * TODO
704 * one major problem with this implementation is that you can't move the 896 * one major problem with this implementation is that you can't move the
705 * cursor after inputing korean chars, otherwise it will eat up and replace 897 * cursor after inputing korean chars, otherwise it will eat up and replace
706 * the char before the cursor you move to. fix that 898 * the char before the cursor you move to. fix that
707 * 899 *
708 * make backspace delete one single char, not the whole thing if still 900 * make backspace delete one single char, not the whole thing if still
709 * editing. 901 * editing.
710 * 902 *
711 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 903 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
712 * 904 *
713 * how korean input works 905 * how korean input works
714 * 906 *
715 * all following chars means unicode char value and are in hex 907 * all following chars means unicode char value and are in hex
716 * 908 *
717 * ÃÊÀ½ = schar (start char) 909 * ÃÊÀ½ = schar (start char)
718 * ÁßÀ½ = mchar (middle char) 910 * ÁßÀ½ = mchar (middle char)
719 * ³¡À½ = echar (end char) 911 * ³¡À½ = echar (end char)
720 * 912 *
721 * there are 19 schars. unicode position is at 1100 - 1112 913 * there are 19 schars. unicode position is at 1100 - 1112
722 * there are 21 mchars. unicode position is at 1161 - 1175 914 * there are 21 mchars. unicode position is at 1161 - 1175
723 * there are 27 echars. unicode position is at 11a8 - 11c2 915 * there are 27 echars. unicode position is at 11a8 - 11c2
724 * 916 *
725 * the map with everything combined is at ac00 - d7a3 917 * the map with everything combined is at ac00 - d7a3
726 * 918 *
727 */ 919 */
728 920
729ushort Keyboard::parseKoreanInput (ushort c) { 921ushort Keyboard::parseKoreanInput (ushort c) {
730 922
731 if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) 923 if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c))
732 || 924 ||
733 (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode 925 (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode
734 && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { 926 && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) {
735 927
736 schar = 0, mchar = 0, echar = 0; 928 schar = 0, mchar = 0, echar = 0;
737 return c; 929 return c;
738 } 930 }
739 931
740 if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input 932 if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input
741 933
742 if (schar == 0 || (schar != 0 && mchar == 0)) { 934 if (schar == 0 || (schar != 0 && mchar == 0)) {
743 schar = c; mchar = 0; echar = 0; 935 schar = c; mchar = 0; echar = 0;
744 return c; 936 return c;
745 } 937 }
746 else if (mchar != 0) { 938 else if (mchar != 0) {
747 939
748 if (echar == 0) { 940 if (echar == 0) {
749 941
750 if (!(echar = constoe(c))) { 942 if (!(echar = constoe(c))) {
751 943
752 schar = c; mchar = 0; echar = 0; 944 schar = c; mchar = 0; echar = 0;
753 return c; 945 return c;
754 } 946 }
755 947
756 } 948 }
757 else { // must figure out what the echar is 949 else { // must figure out what the echar is
758 950
759 if (echar == 0x11a8) { // ¤¡ 951 if (echar == 0x11a8) { // ¤¡
760 952
761 if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡ 953 if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡
762 else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ 954 else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ
763 else { 955 else {
764 schar = c; mchar = 0; echar = 0; 956 schar = c; mchar = 0; echar = 0;
765 return c; 957 return c;
766 } 958 }
767 959
768 } else if (echar == 0x11ab) { // ¤¤ 960 } else if (echar == 0x11ab) { // ¤¤
769 961
770 if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸ 962 if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸
771 else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾ 963 else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾
772 else { 964 else {
773 schar = c; mchar = 0; echar = 0; 965 schar = c; mchar = 0; echar = 0;
774 return c; 966 return c;
775 } 967 }
776 968
777 } else if (echar == 0x11af) { // ¤© 969 } else if (echar == 0x11af) { // ¤©
778 970
779 if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡ 971 if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡
780 else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤± 972 else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤±
781 else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤² 973 else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤²
782 else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ 974 else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ
783 else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼ 975 else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼
784 else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½ 976 else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½
785 else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾ 977 else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾
786 else { 978 else {
787 schar = c; mchar = 0; echar = 0; 979 schar = c; mchar = 0; echar = 0;
788 return c; 980 return c;
789 } 981 }
790 982
791 } else if (echar == 0x11b8) { // ¤² 983 } else if (echar == 0x11b8) { // ¤²
792 984
793 if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ 985 if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ
794 else { 986 else {
795 schar = c; mchar = 0; echar = 0; 987 schar = c; mchar = 0; echar = 0;
796 return c; 988 return c;
797 } 989 }
798 990
799 } else if (echar == 0x11ba) { // ¤µ 991 } else if (echar == 0x11ba) { // ¤µ
800 992
801 if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ 993 if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ
802 else { 994 else {
803 schar = c; mchar = 0; echar = 0; 995 schar = c; mchar = 0; echar = 0;
804 return c; 996 return c;
805 } 997 }
806 998
807 } else { // if any other char, cannot combine chars 999 } else { // if any other char, cannot combine chars
808 1000
809 schar = c; mchar = 0; echar = 0; 1001 schar = c; mchar = 0; echar = 0;
810 return c; 1002 return c;
811 } 1003 }
812 1004
813 unicode = echar; 1005 unicode = echar;
814 } 1006 }
815 } 1007 }
816 1008
817 } 1009 }
818 else if (0x1161 <= c && c <= 0x1175) { // mchar was input 1010 else if (0x1161 <= c && c <= 0x1175) { // mchar was input
819 1011
820 if (schar != 0 && mchar == 0) { mchar = c; } 1012 if (schar != 0 && mchar == 0) { mchar = c; }
821 1013
822 else if (schar != 0 && mchar != 0 && echar == 0) { 1014 else if (schar != 0 && mchar != 0 && echar == 0) {
823 1015
824 switch (mchar) { 1016 switch (mchar) {
825 case 0x1169: 1017 case 0x1169:
826 if (c == 0x1161) mchar = 0x116a; 1018 if (c == 0x1161) mchar = 0x116a;
827 else if (c == 0x1162) mchar = 0x116b; 1019 else if (c == 0x1162) mchar = 0x116b;
828 else if (c == 0x1175) mchar = 0x116c; 1020 else if (c == 0x1175) mchar = 0x116c;
829 else { 1021 else {
830 schar = 0; mchar = 0; echar = 0; 1022 schar = 0; mchar = 0; echar = 0;
831 return c; 1023 return c;
832 } 1024 }
833 break; 1025 break;
834 case 0x116e: 1026 case 0x116e:
835 if (c == 0x1165) mchar = 0x116f; 1027 if (c == 0x1165) mchar = 0x116f;
836 else if (c == 0x1166) mchar = 0x1170; 1028 else if (c == 0x1166) mchar = 0x1170;
837 else if (c == 0x1175) mchar = 0x1171; 1029 else if (c == 0x1175) mchar = 0x1171;
838 else { 1030 else {
839 schar = 0; mchar = 0; echar = 0; 1031 schar = 0; mchar = 0; echar = 0;
840 return c; 1032 return c;
841 } 1033 }
842 break; 1034 break;
843 case 0x1173: 1035 case 0x1173:
844 if (c == 0x1175) mchar = 0x1174; 1036 if (c == 0x1175) mchar = 0x1174;
845 else { 1037 else {
846 schar = 0; mchar = 0; echar = 0; 1038 schar = 0; mchar = 0; echar = 0;
847 return c; 1039 return c;
848 } 1040 }
849 break; 1041 break;
850 default: 1042 default:
851 schar = 0; mchar = 0; echar = 0; 1043 schar = 0; mchar = 0; echar = 0;
852 return c; 1044 return c;
853 } 1045 }
854 } 1046 }
855 else if (schar != 0 && mchar != 0 && echar != 0) { 1047 else if (schar != 0 && mchar != 0 && echar != 0) {
856 1048
857 emit key( 8, Qt::Key_Backspace, 0, true, false ); 1049 emit key( 8, Qt::Key_Backspace, 0, true, false );
858 1050
859 ushort prev = 0; 1051 ushort prev = 0;
860 switch (echar) { 1052 switch (echar) {
861 /* 1053 /*
862 case 0x11a9: 1054 case 0x11a9:
863 prev = combineKoreanChars(schar, mchar, 0x11a8); 1055 prev = combineKoreanChars(schar, mchar, 0x11a8);
864 schar = 0x1100; 1056 schar = 0x1100;
865 break; 1057 break;
866 */ 1058 */
867 case 0x11aa: 1059 case 0x11aa:
868 prev = combineKoreanChars(schar, mchar, 0x11a8); 1060 prev = combineKoreanChars(schar, mchar, 0x11a8);
869 schar = 0x1109; 1061 schar = 0x1109;
870 break; 1062 break;
871 case 0x11ac: 1063 case 0x11ac:
872 prev = combineKoreanChars(schar, mchar, 0x11ab); 1064 prev = combineKoreanChars(schar, mchar, 0x11ab);
873 schar = 0x110c; 1065 schar = 0x110c;
874 break; 1066 break;
875 case 0x11ad: 1067 case 0x11ad:
876 prev = combineKoreanChars(schar, mchar, 0x11ab); 1068 prev = combineKoreanChars(schar, mchar, 0x11ab);
877 schar = 0x1112; 1069 schar = 0x1112;
878 break; 1070 break;
879 case 0x11b0: 1071 case 0x11b0:
880 prev = combineKoreanChars(schar, mchar, 0x11af); 1072 prev = combineKoreanChars(schar, mchar, 0x11af);
881 schar = 0x1100; 1073 schar = 0x1100;
882 break; 1074 break;
883 case 0x11b1: 1075 case 0x11b1:
884 prev = combineKoreanChars(schar, mchar, 0x11af); 1076 prev = combineKoreanChars(schar, mchar, 0x11af);
885 schar = 0x1106; 1077 schar = 0x1106;
886 break; 1078 break;
887 case 0x11b2: 1079 case 0x11b2:
888 prev = combineKoreanChars(schar, mchar, 0x11af); 1080 prev = combineKoreanChars(schar, mchar, 0x11af);
889 schar = 0x1107; 1081 schar = 0x1107;
890 break; 1082 break;
891 case 0x11b3: 1083 case 0x11b3:
892 prev = combineKoreanChars(schar, mchar, 0x11af); 1084 prev = combineKoreanChars(schar, mchar, 0x11af);
893 schar = 0x1109; 1085 schar = 0x1109;
894 break; 1086 break;
895 case 0x11b4: 1087 case 0x11b4:
896 prev = combineKoreanChars(schar, mchar, 0x11af); 1088 prev = combineKoreanChars(schar, mchar, 0x11af);
897 schar = 0x1110; 1089 schar = 0x1110;
898 break; 1090 break;
899 case 0x11b9: 1091 case 0x11b9:
900 prev = combineKoreanChars(schar, mchar, 0x11b8); 1092 prev = combineKoreanChars(schar, mchar, 0x11b8);
901 schar = 0x1109; 1093 schar = 0x1109;
902 break; 1094 break;
903 /* 1095 /*
904 case 0x11bb: 1096 case 0x11bb:
905 prev = combineKoreanChars(schar, mchar, 0x11ba); 1097 prev = combineKoreanChars(schar, mchar, 0x11ba);
906 schar = 0x1109; 1098 schar = 0x1109;
907 break; 1099 break;
908 */ 1100 */
909 default: 1101 default:
910 1102
911 if (constoe(echar)) { 1103 if (constoe(echar)) {
912 1104
913 prev = combineKoreanChars(schar, mchar, 0); 1105 prev = combineKoreanChars(schar, mchar, 0);
914 schar = constoe(echar); 1106 schar = constoe(echar);
915 } 1107 }
916 break; 1108 break;
917 } 1109 }
918 1110
919 emit key( prev, prev, 0, true, false ); 1111 emit key( prev, prev, 0, true, false );
920 1112
921 mchar = c; echar = 0; 1113 mchar = c; echar = 0;
922 1114
923 return combineKoreanChars(schar, mchar, 0); 1115 return combineKoreanChars(schar, mchar, 0);
924 1116
925 } 1117 }
926 else { 1118 else {
927 schar = 0; mchar = 0; echar = 0; 1119 schar = 0; mchar = 0; echar = 0;
928 return c; 1120 return c;
929 } 1121 }
930 1122
931 } 1123 }
932 else /*if (c == ' ')*/ return c; 1124 else /*if (c == ' ')*/ return c;
933 1125
934 1126
935 // and now... finally delete previous char, and return new char 1127 // and now... finally delete previous char, and return new char
936 emit key( 8, Qt::Key_Backspace, 0, true, false ); 1128 emit key( 8, Qt::Key_Backspace, 0, true, false );
937 1129
938 1130
939 return combineKoreanChars( schar, mchar, echar); 1131 return combineKoreanChars( schar, mchar, echar);
940 1132
941} 1133}
942 1134
943ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { 1135ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) {
944 1136
945 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; 1137 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00;
946 1138
947} 1139}
948 1140
949ushort Keyboard::constoe(const ushort c) { 1141ushort Keyboard::constoe(const ushort c) {
950 1142
951 // converts schars to echars if possible 1143 // converts schars to echars if possible
952 1144
953 if (0x1100 <= c && c <= 0x1112) { // schar to echar 1145 if (0x1100 <= c && c <= 0x1112) { // schar to echar
954 1146
955 switch (c) { 1147 switch (c) {
956 case 0x1100: return 0x11a8; 1148 case 0x1100: return 0x11a8;
957 case 0x1101: return 0x11a9; 1149 case 0x1101: return 0x11a9;
958 case 0x1102: return 0x11ab; 1150 case 0x1102: return 0x11ab;
959 case 0x1103: return 0x11ae; 1151 case 0x1103: return 0x11ae;
960 case 0x1105: return 0x11af; 1152 case 0x1105: return 0x11af;
961 case 0x1106: return 0x11b7; 1153 case 0x1106: return 0x11b7;
962 case 0x1107: return 0x11b8; 1154 case 0x1107: return 0x11b8;
963 case 0x1109: return 0x11ba; 1155 case 0x1109: return 0x11ba;
964 case 0x110a: return 0x11bb; 1156 case 0x110a: return 0x11bb;
965 case 0x110b: return 0x11bc; 1157 case 0x110b: return 0x11bc;
966 case 0x110c: return 0x11bd; 1158 case 0x110c: return 0x11bd;
967 case 0x110e: return 0x11be; 1159 case 0x110e: return 0x11be;
968 case 0x110f: return 0x11bf; 1160 case 0x110f: return 0x11bf;
969 case 0x1110: return 0x11c0; 1161 case 0x1110: return 0x11c0;
970 case 0x1111: return 0x11c1; 1162 case 0x1111: return 0x11c1;
971 case 0x1112: return 0x11c2; 1163 case 0x1112: return 0x11c2;
972 default: return 0; 1164 default: return 0;
973 1165
974 } 1166 }
975 1167
976 } else { //echar to schar 1168 } else { //echar to schar
977 1169
978 switch (c) { 1170 switch (c) {
979 case 0x11a8: return 0x1100; 1171 case 0x11a8: return 0x1100;
980 case 0x11a9: return 0x1101; 1172 case 0x11a9: return 0x1101;
981 case 0x11ab: return 0x1102; 1173 case 0x11ab: return 0x1102;
982 case 0x11ae: return 0x1103; 1174 case 0x11ae: return 0x1103;
983 case 0x11af: return 0x1105; 1175 case 0x11af: return 0x1105;
984 case 0x11b7: return 0x1106; 1176 case 0x11b7: return 0x1106;
985 case 0x11b8: return 0x1107; 1177 case 0x11b8: return 0x1107;
986 case 0x11ba: return 0x1109; 1178 case 0x11ba: return 0x1109;
987 case 0x11bb: return 0x110a; 1179 case 0x11bb: return 0x110a;
988 case 0x11bc: return 0x110b; 1180 case 0x11bc: return 0x110b;
989 case 0x11bd: return 0x110c; 1181 case 0x11bd: return 0x110c;
990 case 0x11be: return 0x110e; 1182 case 0x11be: return 0x110e;
991 case 0x11bf: return 0x110f; 1183 case 0x11bf: return 0x110f;
992 case 0x11c0: return 0x1110; 1184 case 0x11c0: return 0x1110;
993 case 0x11c1: return 0x1111; 1185 case 0x11c1: return 0x1111;
994 case 0x11c2: return 0x1112; 1186 case 0x11c2: return 0x1112;
995 default: return 0; 1187 default: return 0;
996 1188
997 } 1189 }
998 1190
999 } 1191 }
1000} 1192}
1001 1193
1002 1194
1003// Keys::Keys {{{1 1195// Keys::Keys {{{1
1004 1196
1005Keys::Keys() { 1197Keys::Keys() {
1006 1198
1007 Config *config = new Config ("multikey"); 1199 Config *config = new Config ("multikey");
1008 config->setGroup( "keymaps" ); 1200 config->setGroup( "keymaps" );
1009 QString map = config->readEntry( "current" ); 1201 QString map = config->readEntry( "current" );
1010 delete config; 1202 delete config;
1011 1203
1012 if (map.isNull() || !(QFile(map).exists())) { 1204 if (map.isNull() || !(QFile(map).exists())) {
1013 1205
1014 Config *config = new Config("locale"); 1206 Config *config = new Config("locale");
1015 config->setGroup( "Language" ); 1207 config->setGroup( "Language" );
1016 QString l = config->readEntry( "Language" , "en" ); 1208 QString l = config->readEntry( "Language" , "en" );
1017 delete config; 1209 delete config;
1018 1210
1019 map = QPEApplication::qpeDir() + "/share/multikey/" 1211 map = QPEApplication::qpeDir() + "/share/multikey/"
1020 + l + ".keymap"; 1212 + l + ".keymap";
1021 1213
1022 } 1214 }
1023 1215
1024 setKeysFromFile(map); 1216 setKeysFromFile(map);
1025} 1217}
1026 1218
1027Keys::Keys(const char * filename) { 1219Keys::Keys(const char * filename) {
1028 1220
1029 setKeysFromFile(filename); 1221 setKeysFromFile(filename);
1030} 1222}
1031 1223
1032// Keys::setKeysFromFile {{{2 1224// Keys::setKeysFromFile {{{2
1033void Keys::setKeysFromFile(const char * filename) { 1225void Keys::setKeysFromFile(const char * filename) {
1034 1226
1035 QFile f(filename); 1227 QFile f(filename);
1036 1228
1037 if (f.open(IO_ReadOnly)) { 1229 if (f.open(IO_ReadOnly)) {
1038 1230
1039 QTextStream t(&f); 1231 QTextStream t(&f);
1040 int row; 1232 int row;
1041 int qcode; 1233 int qcode;
1042 ushort unicode; 1234 ushort unicode;
1043 int width; 1235 int width;
1044 QString buf; 1236 QString buf;
1045 QString comment; 1237 QString comment;
1046 char * xpm[256]; //couldnt be larger than that... could it? 1238 char * xpm[256]; //couldnt be larger than that... could it?
1047 QImage *xpm2pix = 0; 1239 QImage *xpm2pix = 0;
1048 1240
1049 buf = t.readLine(); 1241 buf = t.readLine();
1050 while (buf) { 1242 while (buf) {
1051 1243
1052 // get rid of comments 1244 // get rid of comments
1053 buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); 1245 buf.replace(QRegExp("#.*$", FALSE, FALSE), "");
1054 1246
1055 // key definition 1247 // key definition
1056 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { 1248 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) {
1057 // no $1 type referencing!!! this implementation of regexp sucks 1249 // no $1 type referencing!!! this implementation of regexp sucks
1058 1250
1059 // dont know of any sscanf() type funcs in Qt lib 1251 // dont know of any sscanf() type funcs in Qt lib
1060 QTextStream tmp (buf, IO_ReadOnly); 1252 QTextStream tmp (buf, IO_ReadOnly);
1061 tmp >> row >> qcode >> unicode >> width >> comment; 1253 tmp >> row >> qcode >> unicode >> width >> comment;
1062 1254
1063 buf = t.readLine(); 1255 buf = t.readLine();
1064 int xpmLineCount = 0; 1256 int xpmLineCount = 0;
1065 xpm2pix = 0; 1257 xpm2pix = 0;
1066 1258
1067 // erase blank space 1259 // erase blank space
1068 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); 1260 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine();
1069 1261
1070 while (buf.contains(QRegExp("^\\s*\".*\""))) { 1262 while (buf.contains(QRegExp("^\\s*\".*\""))) {
1071 1263
1072 QString xpmBuf = buf.stripWhiteSpace(); 1264 QString xpmBuf = buf.stripWhiteSpace();
1073 1265
1074 xpm[xpmLineCount] = new char [xpmBuf.length()]; 1266 xpm[xpmLineCount] = new char [xpmBuf.length()];
1075 1267
1076 int j = 0; 1268 int j = 0;
1077 for (ushort i = 0; i < xpmBuf.length(); i++) { 1269 for (ushort i = 0; i < xpmBuf.length(); i++) {
1078 if (xpmBuf[i].latin1() != '"') { 1270 if (xpmBuf[i].latin1() != '"') {
1079 1271
1080 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); 1272 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1();
1081 j++; 1273 j++;
1082 } 1274 }
1083 1275
1084 } 1276 }
1085 // have to close that facker up 1277 // have to close that facker up
1086 ((char *)xpm[xpmLineCount])[j] = '\0'; 1278 ((char *)xpm[xpmLineCount])[j] = '\0';
1087 1279
1088 xpmLineCount++; 1280 xpmLineCount++;
1089 buf = t.readLine(); 1281 buf = t.readLine();
1090 } 1282 }
1091 if (xpmLineCount) { 1283 if (xpmLineCount) {
1092 1284
1093 xpm2pix = new QImage((const char **)xpm); 1285 xpm2pix = new QImage((const char **)xpm);
1094 for (int i = 0; i < xpmLineCount; i++) 1286 for (int i = 0; i < xpmLineCount; i++)
1095 1287
1096 delete [] (xpm[i]); 1288 delete [] (xpm[i]);
1097 1289
1098 } 1290 }
1099 setKey(row, qcode, unicode, width, xpm2pix); 1291 setKey(row, qcode, unicode, width, xpm2pix);
1100 } 1292 }
1101 1293
1102 // shift map 1294 // shift map
1103 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1295 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1104 1296
1105 QTextStream tmp (buf, IO_ReadOnly); 1297 QTextStream tmp (buf, IO_ReadOnly);
1106 ushort lower, shift; 1298 ushort lower, shift;
1107 tmp >> lower >> shift; 1299 tmp >> lower >> shift;
1108 1300
1109 shiftMap.insert(lower, shift); 1301 shiftMap.insert(lower, shift);
1110 1302
1111 buf = t.readLine(); 1303 buf = t.readLine();
1112 } 1304 }
1113 1305
1114 // meta key map 1306 // meta key map
1115 else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1307 else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1116 1308
1117 QTextStream tmp (buf, IO_ReadOnly); 1309 QTextStream tmp (buf, IO_ReadOnly);
1118 ushort lower, shift; 1310 ushort lower, shift;
1119 QChar m; 1311 QChar m;
1120 tmp >> m >> lower >> shift; 1312 tmp >> m >> lower >> shift;
1121 1313
1122 metaMap.insert(lower, shift); 1314 metaMap.insert(lower, shift);
1123 1315
1124 buf = t.readLine(); 1316 buf = t.readLine();
1125 } 1317 }
1126 1318
1319 // circumflex
1320 else if (buf.contains(QRegExp("^\\s*c\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1321
1322 QTextStream tmp (buf, IO_ReadOnly);
1323 ushort lower, shift;
1324 QChar c;
1325 tmp >> c >> lower >> shift;
1326
1327 circumflexMap.insert(lower, shift);
1328
1329 buf = t.readLine();
1330 }
1331 // diaeresis
1332 else if (buf.contains(QRegExp("^\\s*d\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1333
1334 QTextStream tmp (buf, IO_ReadOnly);
1335 ushort lower, shift;
1336 QChar d;
1337 tmp >> d >> lower >> shift;
1338
1339 diaeresisMap.insert(lower, shift);
1340
1341 buf = t.readLine();
1342 }
1343
1127 // other variables like lang & title 1344 // other variables like lang & title
1128 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { 1345 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) {
1129 1346
1130 QTextStream tmp (buf, IO_ReadOnly); 1347 QTextStream tmp (buf, IO_ReadOnly);
1131 QString name, equals, value; 1348 QString name, equals, value;
1132 1349
1133 tmp >> name >> equals >> value; 1350 tmp >> name >> equals >> value;
1134 1351
1135 if (name == "lang") { 1352 if (name == "lang") {
1136 1353
1137 lang = value; 1354 lang = value;
1138 1355
1139 } 1356 }
1140 1357
1141 buf = t.readLine(); 1358 buf = t.readLine();
1142 } 1359 }
1143 // comments 1360 // comments
1144 else if (buf.contains(QRegExp("^\\s*#"))) { 1361 else if (buf.contains(QRegExp("^\\s*#"))) {
1145 1362
1146 buf = t.readLine(); 1363 buf = t.readLine();
1147 1364
1148 } else { // blank line, or garbage 1365 } else { // blank line, or garbage
1149 1366
1150 buf = t.readLine(); 1367 buf = t.readLine();
1151 1368
1152 } 1369 }
1153 1370
1154 } 1371 }
1155 f.close(); 1372 f.close();
1156 } 1373 }
1157 1374
1158} 1375}
1159 1376
1160// Keys::setKey {{{2 1377// Keys::setKey {{{2
1161void Keys::setKey(const int row, const int qcode, const ushort unicode, 1378void Keys::setKey(const int row, const int qcode, const ushort unicode,
1162 const int width, QImage *pix) { 1379 const int width, QImage *pix) {
1163 1380
1164 Key * key; 1381 Key * key;
1165 key = new Key; 1382 key = new Key;
1166 key->qcode = qcode; 1383 key->qcode = qcode;
1167 key->unicode = unicode; 1384 key->unicode = unicode;
1168 key->width = width; 1385 key->width = width;
1169 1386
1170 // share key->pressed between same keys 1387 // share key->pressed between same keys
1171 bool found = 0; 1388 bool found = 0;
1172 for (int i = 1; i <= 5; i++) { 1389 for (int i = 1; i <= 5; i++) {
1173 for (unsigned int j = 0; j < keys[i].count(); j++) 1390 for (unsigned int j = 0; j < keys[i].count(); j++)
1174 if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { 1391 if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) {
1175 1392
1176 key->pressed = keys[i].at(j)->pressed; 1393 key->pressed = keys[i].at(j)->pressed;
1177 found = 1; 1394 found = 1;
1178 } 1395 }
1179 1396
1180 } 1397 }
1181 if (!found) { 1398 if (!found) {
1182 1399
1183 key->pressed = new bool; 1400 key->pressed = new bool;
1184 *(key->pressed) = 0; 1401 *(key->pressed) = 0;
1185 } 1402 }
1186 1403
1187 key->pix = pix; 1404 key->pix = pix;
1188 1405
1189 1406
1190 keys[row].append(key); 1407 keys[row].append(key);
1191} 1408}
1192 1409
1193// Keys::~Keys {{{2 1410// Keys::~Keys {{{2
1194Keys::~Keys() { 1411Keys::~Keys() {
1195 1412
1196 for (int i = 1; i <= 5; i++) 1413 for (int i = 1; i <= 5; i++)
1197 for (unsigned int j = 0; j < keys[i].count(); j++) 1414 for (unsigned int j = 0; j < keys[i].count(); j++)
1198 delete keys[i].at(j); 1415 delete keys[i].at(j);
1199 1416
1200} 1417}
1201 1418
1202// Keys:: other functions {{{2 1419// Keys:: other functions {{{2
1203int Keys::width(const int row, const int col) { 1420int Keys::width(const int row, const int col) {
1204 1421
1205 return keys[row].at(col)->width; 1422 return keys[row].at(col)->width;
1206 1423
1207} 1424}
1425
1426int Keys::rows() {
1427
1428 for (int i = 1; i <= 5; i++) {
1429
1430 if (keys[i].count() == 0)
1431 return i - 1;
1432
1433 }
1434 return 5;
1435}
1436
1208ushort Keys::uni(const int row, const int col) { 1437ushort Keys::uni(const int row, const int col) {
1209 1438
1210 return keys[row].at(col)->unicode; 1439 return keys[row].at(col)->unicode;
1211 1440
1212} 1441}
1213 1442
1214int Keys::qcode(const int row, const int col) { 1443int Keys::qcode(const int row, const int col) {
1215 1444
1216 return keys[row].at(col)->qcode; 1445 return keys[row].at(col)->qcode;
1217} 1446}
1218 1447
1219QImage *Keys::pix(const int row, const int col) { 1448QImage *Keys::pix(const int row, const int col) {
1220 1449
1221 return keys[row].at(col)->pix; 1450 return keys[row].at(col)->pix;
1222 1451
1223} 1452}
1224bool Keys::pressed(const int row, const int col) { 1453bool Keys::pressed(const int row, const int col) {
1225 1454
1226 return *(keys[row].at(col)->pressed); 1455 return *(keys[row].at(col)->pressed);
1227} 1456}
1228 1457
1229int Keys::numKeys(const int row) { 1458int Keys::numKeys(const int row) {
1230 1459
1231 return keys[row].count(); 1460 return keys[row].count();
1232} 1461}
1233 1462
1234void Keys::setPressed(const int row, const int col, const bool pressed) { 1463void Keys::setPressed(const int row, const int col, const bool pressed) {
1235 1464
1236 *(keys[row].at(col)->pressed) = pressed; 1465 *(keys[row].at(col)->pressed) = pressed;
1237} 1466}
1238 1467
1239ushort Keys::shift(const ushort uni) { 1468ushort Keys::shift(const ushort uni) {
1240 1469
1241 if (shiftMap[uni]) { 1470 if (shiftMap[uni]) return shiftMap[uni];
1471 else return 0;
1472}
1242 1473
1243 return shiftMap[uni]; 1474ushort Keys::meta(const ushort uni) {
1244 }
1245 else
1246 return 0;
1247 1475
1476 if (metaMap[uni]) return metaMap[uni];
1477 else return 0;
1248} 1478}
1249 1479
1250ushort Keys::meta(const ushort uni) { 1480ushort Keys::circumflex(const ushort uni) {
1251 1481
1252 if (metaMap[uni]) { 1482 if (circumflexMap[uni]) return circumflexMap[uni];
1483 else return 0;
1484}
1253 1485
1254 return metaMap[uni]; 1486ushort Keys::diaeresis(const ushort uni) {
1255 }
1256 else
1257 return 0;
1258 1487
1488 if(diaeresisMap[uni]) return diaeresisMap[uni];
1489 else return 0;
1259} 1490}
1260 1491
1261bool *Keys::pressedPtr(const int row, const int col) { 1492bool *Keys::pressedPtr(const int row, const int col) {
1262 1493
1263 return keys[row].at(col)->pressed; 1494 return keys[row].at(col)->pressed;
1264} 1495}
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h
index 1aa7a35..8af80d0 100644
--- a/inputmethods/multikey/keyboard.h
+++ b/inputmethods/multikey/keyboard.h
@@ -1,173 +1,182 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qframe.h> 20#include <qframe.h>
21#include <qmap.h> 21#include <qmap.h>
22#include "../pickboard/pickboardcfg.h" 22#include "../pickboard/pickboardcfg.h"
23#include "../pickboard/pickboardpicks.h" 23#include "../pickboard/pickboardpicks.h"
24#include "configdlg.h" 24#include "configdlg.h"
25 25
26class QTimer; 26class QTimer;
27 27
28class KeyboardConfig : public DictFilterConfig 28class KeyboardConfig : public DictFilterConfig
29{ 29{
30public: 30public:
31 KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; } 31 KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; }
32 virtual void generateText(const QString &s); 32 virtual void generateText(const QString &s);
33 void decBackspaces() { if (backspaces) backspaces--; } 33 void decBackspaces() { if (backspaces) backspaces--; }
34 void incBackspaces() { backspaces++; } 34 void incBackspaces() { backspaces++; }
35 void resetBackspaces() { backspaces = 0; } 35 void resetBackspaces() { backspaces = 0; }
36private: 36private:
37 int backspaces; 37 int backspaces;
38}; 38};
39 39
40 40
41class KeyboardPicks : public PickboardPicks 41class KeyboardPicks : public PickboardPicks
42{ 42{
43 Q_OBJECT 43 Q_OBJECT
44public: 44public:
45 KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0) 45 KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0)
46 : PickboardPicks(parent, name, f) { } 46 : PickboardPicks(parent, name, f) { }
47 void initialise(); 47 void initialise();
48 virtual QSize sizeHint() const; 48 virtual QSize sizeHint() const;
49 KeyboardConfig *dc; 49 KeyboardConfig *dc;
50}; 50};
51 51
52 52
53class Keys { 53class Keys {
54public: 54public:
55 55
56 Keys(); 56 Keys();
57 Keys(const char * filename); 57 Keys(const char * filename);
58 ~Keys(); 58 ~Keys();
59 int width(const int row, const int col);
60 int rows();
59 ushort uni(const int row, const int col); 61 ushort uni(const int row, const int col);
60 int qcode(const int row, const int col); 62 int qcode(const int row, const int col);
61 int width(const int row, const int col);
62 bool pressed(const int row, const int col); 63 bool pressed(const int row, const int col);
63 bool *pressedPtr(const int row, const int col); 64 bool *pressedPtr(const int row, const int col);
64 ushort shift(const ushort); 65 ushort shift(const ushort);
65 ushort meta(const ushort); 66 ushort meta(const ushort);
67 ushort circumflex(const ushort);
68 ushort diaeresis(const ushort);
66 QImage *pix(const int row, const int col); 69 QImage *pix(const int row, const int col);
67 int numKeys(const int row); 70 int numKeys(const int row);
68 void setKeysFromFile(const char *filename); 71 void setKeysFromFile(const char *filename);
69 void setKey(const int row, const int qcode, const ushort unicode, 72 void setKey(const int row, const int qcode, const ushort unicode,
70 const int width, QImage *pix); 73 const int width, QImage *pix);
71 void setPressed(const int row, const int col, const bool pressed); 74 void setPressed(const int row, const int col, const bool pressed);
72 QString lang; 75 QString lang;
73 QString label; 76 QString label;
74 77
75private: 78private:
76 79
77 typedef struct Key { 80 typedef struct Key {
78 int qcode; // are qt key codes just unicode values? 81 int qcode; // are qt key codes just unicode values?
79 ushort unicode; 82 ushort unicode;
80 int width; // not pixels but relative key width. normal key is 2 83 int width; // not pixels but relative key width. normal key is 2
81 84
82 // only needed for keys like ctrl that can have multiple keys pressed at once 85 // only needed for keys like ctrl that can have multiple keys pressed at once
83 bool *pressed; 86 bool *pressed;
84 QImage *pix; 87 QImage *pix;
85 }; 88 };
86 89
87 QList<Key> keys[6]; 90 QList<Key> keys[6];
88 QMap<ushort,ushort> shiftMap; 91 QMap<ushort,ushort> shiftMap;
89 QMap<ushort,ushort> metaMap; 92 QMap<ushort,ushort> metaMap;
93 QMap<ushort,ushort> circumflexMap;
94 QMap<ushort,ushort> diaeresisMap;
90 95
91}; 96};
92 97
93class Keyboard : public QFrame 98class Keyboard : public QFrame
94{ 99{
95 Q_OBJECT 100 Q_OBJECT
96public: 101public:
97 Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); 102 Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 );
98 ~Keyboard(); 103 ~Keyboard();
99 104
100 void resetState(); 105 void resetState();
101 106
102 void mousePressEvent(QMouseEvent*); 107 void mousePressEvent(QMouseEvent*);
103 void mouseReleaseEvent(QMouseEvent*); 108 void mouseReleaseEvent(QMouseEvent*);
104 void resizeEvent(QResizeEvent*); 109 void resizeEvent(QResizeEvent*);
105 void paintEvent(QPaintEvent* e); 110 void paintEvent(QPaintEvent* e);
106 //void timerEvent(QTimerEvent* e); 111 //void timerEvent(QTimerEvent* e);
107 void drawKeyboard( QPainter &p, int row = -1, int col = -1); 112 void drawKeyboard( QPainter &p, int row = -1, int col = -1);
108 113
109 QSize sizeHint() const; 114 QSize sizeHint() const;
110 115
111signals: 116signals:
112 void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); 117 void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool );
113 118
114private slots: 119private slots:
115 void repeat(); 120 void repeat();
116 void togglePickboard(bool on_off); 121 void togglePickboard(bool on_off);
117 void toggleRepeat(bool on_off); 122 void toggleRepeat(bool on_off);
118 void setMapToDefault(); 123 void setMapToDefault();
119 void setMapToFile(QString map); 124 void setMapToFile(QString map);
125 void cleanupConfigDlg();
120 126
121 // used to redraw keyboard after edited colors 127 // used to redraw keyboard after edited colors
122 void reloadKeyboard(); 128 void reloadKeyboard();
123 129
124private: 130private:
125 int getKey( int &w, int j = -1 ); 131 int getKey( int &w, int j = -1 );
126 void clearHighlight(); 132 void clearHighlight();
127 133
128 bool *shift; 134 bool *shift;
129 bool *lock; 135 bool *lock;
130 bool *ctrl; 136 bool *ctrl;
131 bool *alt; 137 bool *alt;
132 bool *meta; 138 bool *meta;
139 bool *circumflex;
140 bool *diaeresis;
141
133 uint useLargeKeys:1; 142 uint useLargeKeys:1;
134 uint usePicks:1; 143 uint usePicks:1;
135 uint useRepeat:1; 144 uint useRepeat:1;
136 145
137 int pressedKeyRow; 146 int pressedKeyRow;
138 int pressedKeyCol; 147 int pressedKeyCol;
139 148
140 KeyboardPicks *picks; 149 KeyboardPicks *picks;
141 150
142 int keyHeight; 151 int keyHeight;
143 int defaultKeyWidth; 152 int defaultKeyWidth;
144 int xoffs; 153 int xoffs;
145 154
146 int unicode; 155 int unicode;
147 int qkeycode; 156 int qkeycode;
148 int modifiers; 157 int modifiers;
149 158
150 int pressTid; 159 int pressTid;
151 bool pressed; 160 bool pressed;
152 161
153 Keys *keys; 162 Keys *keys;
154 163
155 /* for korean input */ 164 /* for korean input */
156 ushort schar, mchar, echar; 165 ushort schar, mchar, echar;
157 ushort parseKoreanInput(ushort c); 166 ushort parseKoreanInput(ushort c);
158 ushort combineKoreanChars(const ushort s, const ushort m, const ushort e); 167 ushort combineKoreanChars(const ushort s, const ushort m, const ushort e);
159 ushort constoe(const ushort c); 168 ushort constoe(const ushort c);
160 169
161 QTimer *repeatTimer; 170 QTimer *repeatTimer;
162 171
163 /* colors */ 172 /* colors */
164 void loadKeyboardColors(); 173 void loadKeyboardColors();
165 QColor keycolor; 174 QColor keycolor;
166 QColor keycolor_pressed; 175 QColor keycolor_pressed;
167 QColor keycolor_lines; 176 QColor keycolor_lines;
168 QColor textcolor; 177 QColor textcolor;
169 178
170 ConfigDlg *configdlg; 179 ConfigDlg *configdlg;
171}; 180};
172 181
173 182