summaryrefslogtreecommitdiff
path: root/inputmethods
Unidiff
Diffstat (limited to 'inputmethods') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp7
-rw-r--r--inputmethods/multikey/keyboardimpl.cpp1
2 files changed, 5 insertions, 3 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 1dd8ca1..de3aa52 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -1,356 +1,356 @@
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), 43 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0),
44 meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0), 44 meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0),
45 useLargeKeys(TRUE), usePicks(0), useRepeat(0), 45 useLargeKeys(TRUE), usePicks(0), useRepeat(0),
46 pressedKeyRow(-1), pressedKeyCol(-1), 46 pressedKeyRow(-1), pressedKeyCol(-1),
47 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),
48 configdlg(0) 48 configdlg(0)
49 49
50{ 50{
51 51
52 // get the default font 52 // get the default font
53 Config *config = new Config( "qpe" ); 53 Config *config = new Config( "qpe" );
54 config->setGroup( "Appearance" ); 54 config->setGroup( "Appearance" );
55 QString familyStr = config->readEntry( "FontFamily", "fixed" ); 55 QString familyStr = config->readEntry( "FontFamily", "fixed" );
56 delete config; 56 delete config;
57 57
58 config = new Config("multikey"); 58 config = new Config("multikey");
59 config->setGroup ("general"); 59 config->setGroup ("general");
60 usePicks = config->readBoolEntry ("usePickboard", 0); // default closed 60 usePicks = config->readBoolEntry ("usePickboard", 0); // default closed
61 useRepeat = config->readBoolEntry ("useRepeat", 1); 61 useRepeat = config->readBoolEntry ("useRepeat", 1);
62 delete config; 62 delete config;
63 63
64 64
65 setFont( QFont( familyStr, 10 ) ); 65 setFont( QFont( familyStr, 10 ) );
66 66
67 picks = new KeyboardPicks( this ); 67 picks = new KeyboardPicks( this );
68 picks->setFont( QFont( familyStr, 10 ) ); 68 picks->setFont( QFont( familyStr, 10 ) );
69 picks->initialise(); 69 picks->initialise();
70 if (usePicks) { 70 if (usePicks) {
71 71
72 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 72 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
73 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 73 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
74 74
75 } else picks->hide(); 75 } else picks->hide();
76 76
77 loadKeyboardColors(); 77 loadKeyboardColors();
78 78
79 keys = new Keys(); 79 keys = new Keys();
80 80
81 repeatTimer = new QTimer( this ); 81 repeatTimer = new QTimer( this );
82 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); 82 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
83 83
84} 84}
85 85
86Keyboard::~Keyboard() { 86Keyboard::~Keyboard() {
87 87
88 if ( configdlg ) { 88 if ( configdlg ) {
89 delete (ConfigDlg *) configdlg; 89 delete (ConfigDlg *) configdlg;
90 configdlg = 0; 90 configdlg = 0;
91 } 91 }
92 92
93} 93}
94 94
95/* Keyboard::resizeEvent {{{1 */ 95/* Keyboard::resizeEvent {{{1 */
96void Keyboard::resizeEvent(QResizeEvent*) 96void Keyboard::resizeEvent(QResizeEvent*)
97{ 97{
98 int ph = picks->sizeHint().height(); 98 int ph = picks->sizeHint().height();
99 picks->setGeometry( 0, 0, width(), ph ); 99 picks->setGeometry( 0, 0, width(), ph );
100 keyHeight = (height()-(usePicks ? ph : 0))/keys->rows(); 100 keyHeight = (height()-(usePicks ? ph : 0))/(keys->rows()?keys->rows():1);
101 101
102 int nk; // number of keys? 102 int nk; // number of keys?
103 if ( useLargeKeys ) { 103 if ( useLargeKeys ) {
104 nk = 15; 104 nk = 15;
105 } else { 105 } else {
106 nk = 19; 106 nk = 19;
107 } 107 }
108 defaultKeyWidth = (width()/nk)/2; 108 defaultKeyWidth = (width()/nk)/2;
109 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? 109 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces?
110 110
111} 111}
112 112
113/* KeyboardPicks::initialize {{{1 */ 113/* KeyboardPicks::initialize {{{1 */
114void KeyboardPicks::initialise() 114void KeyboardPicks::initialise()
115{ 115{
116 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 116 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
117 mode = 0; 117 mode = 0;
118 dc = new KeyboardConfig(this); 118 dc = new KeyboardConfig(this);
119 configs.append(dc); 119 configs.append(dc);
120} 120}
121 121
122/* KeyboardPicks::sizeHint {{{1 */ 122/* KeyboardPicks::sizeHint {{{1 */
123QSize KeyboardPicks::sizeHint() const 123QSize KeyboardPicks::sizeHint() const
124{ 124{
125 return QSize(240,fontMetrics().lineSpacing()); 125 return QSize(240,fontMetrics().lineSpacing());
126} 126}
127 127
128 128
129/* KeyboardConfig::generateText {{{1 */ 129/* KeyboardConfig::generateText {{{1 */
130void KeyboardConfig::generateText(const QString &s) 130void KeyboardConfig::generateText(const QString &s)
131{ 131{
132#if defined(Q_WS_QWS) || defined(_WS_QWS_) 132#if defined(Q_WS_QWS) || defined(_WS_QWS_)
133 for (int i=0; i<(int)backspaces; i++) { 133 for (int i=0; i<(int)backspaces; i++) {
134 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); 134 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false );
135 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); 135 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false );
136 } 136 }
137 for (int i=0; i<(int)s.length(); i++) { 137 for (int i=0; i<(int)s.length(); i++) {
138 parent->emitKey( s[i].unicode(), 0, 0, true, false ); 138 parent->emitKey( s[i].unicode(), 0, 0, true, false );
139 parent->emitKey( s[i].unicode(), 0, 0, false, false ); 139 parent->emitKey( s[i].unicode(), 0, 0, false, false );
140 } 140 }
141 parent->emitKey( 0, Qt::Key_Space, 0, true, false ); 141 parent->emitKey( 0, Qt::Key_Space, 0, true, false );
142 parent->emitKey( 0, Qt::Key_Space, 0, false, false ); 142 parent->emitKey( 0, Qt::Key_Space, 0, false, false );
143 backspaces = 0; 143 backspaces = 0;
144#endif 144#endif
145} 145}
146 146
147 147
148 148
149 149
150/* Keyboard::paintEvent {{{1 */ 150/* Keyboard::paintEvent {{{1 */
151void Keyboard::paintEvent(QPaintEvent* e) 151void Keyboard::paintEvent(QPaintEvent* e)
152{ 152{
153 QPainter painter(this); 153 QPainter painter(this);
154 painter.setClipRect(e->rect()); 154 painter.setClipRect(e->rect());
155 drawKeyboard( painter ); 155 drawKeyboard( painter );
156 picks->dc->draw( &painter ); 156 picks->dc->draw( &painter );
157} 157}
158 158
159 159
160/* Keyboard::drawKeyboard {{{1 */ 160/* Keyboard::drawKeyboard {{{1 */
161 161
162void Keyboard::drawKeyboard(QPainter &p, int row, int col) 162void Keyboard::drawKeyboard(QPainter &p, int row, int col)
163{ 163{
164 164
165 165
166 if (row != -1 && col != -1) { //just redraw one key 166 if (row != -1 && col != -1) { //just redraw one key
167 167
168 int x = 0; 168 int x = 0;
169 for (int i = 0; i < col; i++) { 169 for (int i = 0; i < col; i++) {
170 170
171 x += keys->width(row, i) * defaultKeyWidth; 171 x += keys->width(row, i) * defaultKeyWidth;
172 } 172 }
173 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 173 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
174 174
175 int keyWidth = keys->width(row, col); 175 int keyWidth = keys->width(row, col);
176 176
177 p.fillRect(x + 1, y + 1, 177 p.fillRect(x + 1, y + 1,
178 keyWidth * defaultKeyWidth - 1, keyHeight - 1, 178 keyWidth * defaultKeyWidth - 1, keyHeight - 1,
179 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); 179 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor);
180 180
181 QImage *pix = keys->pix(row,col); 181 QImage *pix = keys->pix(row,col);
182 182
183 ushort c = keys->uni(row, col); 183 ushort c = keys->uni(row, col);
184 184
185 p.setPen(textcolor); 185 p.setPen(textcolor);
186 if (!pix) { 186 if (!pix) {
187 if ((shift || lock) && keys->shift(c)) 187 if ((shift || lock) && keys->shift(c))
188 188
189 if (circumflex && keys->circumflex(keys->shift(c))) 189 if (circumflex && keys->circumflex(keys->shift(c)))
190 c = keys->circumflex(keys->shift(c)); 190 c = keys->circumflex(keys->shift(c));
191 else if (diaeresis && keys->diaeresis(keys->shift(c))) 191 else if (diaeresis && keys->diaeresis(keys->shift(c)))
192 c = keys->diaeresis(keys->shift(c)); 192 c = keys->diaeresis(keys->shift(c));
193 else if (baccent && keys->baccent(keys->shift(c))) 193 else if (baccent && keys->baccent(keys->shift(c)))
194 c = keys->baccent(keys->shift(c)); 194 c = keys->baccent(keys->shift(c));
195 else if (accent && keys->accent(keys->shift(c))) 195 else if (accent && keys->accent(keys->shift(c)))
196 c = keys->accent(keys->shift(c)); 196 c = keys->accent(keys->shift(c));
197 else if (meta && keys->meta(keys->shift(c))) 197 else if (meta && keys->meta(keys->shift(c)))
198 c = keys->meta(keys->shift(c)); 198 c = keys->meta(keys->shift(c));
199 else 199 else
200 c = keys->shift(c); 200 c = keys->shift(c);
201 201
202 else if (meta && keys->meta(c)) 202 else if (meta && keys->meta(c))
203 c = keys->meta(c); 203 c = keys->meta(c);
204 else if (circumflex && keys->circumflex(c)) 204 else if (circumflex && keys->circumflex(c))
205 c = keys->circumflex(c); 205 c = keys->circumflex(c);
206 else if (baccent && keys->baccent(c)) 206 else if (baccent && keys->baccent(c))
207 c = keys->baccent(c); 207 c = keys->baccent(c);
208 else if (accent && keys->accent(c)) 208 else if (accent && keys->accent(c))
209 c = keys->accent(c); 209 c = keys->accent(c);
210 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { 210 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) {
211 211
212 // the diaeresis key itself has to be in the diaeresisMap, 212 // the diaeresis key itself has to be in the diaeresisMap,
213 // or just do this to make it display the diaeresis char. 213 // or just do this to make it display the diaeresis char.
214 214
215 if (c == 0x2c6) 215 if (c == 0x2c6)
216 c = 0xa8; 216 c = 0xa8;
217 else 217 else
218 c = keys->diaeresis(c); 218 c = keys->diaeresis(c);
219 } 219 }
220 220
221 p.drawText(x, y, 221 p.drawText(x, y,
222 defaultKeyWidth * keyWidth + 3, keyHeight, 222 defaultKeyWidth * keyWidth + 3, keyHeight,
223 AlignCenter, (QChar)c); 223 AlignCenter, (QChar)c);
224 } 224 }
225 else 225 else
226 // center the image in the middle of the key 226 // center the image in the middle of the key
227 p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, 227 p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1,
228 y + (keyHeight - pix->height())/2 + 1, 228 y + (keyHeight - pix->height())/2 + 1,
229 *pix ); 229 *pix );
230 230
231 // this fixes the problem that the very right end of the board's vertical line 231 // this fixes the problem that the very right end of the board's vertical line
232 // gets painted over, because it's one pixel shorter than all other keys 232 // gets painted over, because it's one pixel shorter than all other keys
233 p.setPen(keycolor_lines); 233 p.setPen(keycolor_lines);
234 p.drawLine(width() - 1, 0, width() - 1, height()); 234 p.drawLine(width() - 1, 0, width() - 1, height());
235 235
236 } else { 236 } else {
237 237
238 238
239 p.fillRect(0, 0, width(), height(), keycolor); 239 p.fillRect(0, 0, width(), height(), keycolor);
240 240
241 for (row = 1; row <= keys->rows(); row++) { 241 for (row = 1; row <= keys->rows(); row++) {
242 242
243 int x = 0; 243 int x = 0;
244 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 244 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
245 245
246 p.setPen(keycolor_lines); 246 p.setPen(keycolor_lines);
247 p.drawLine(x, y, x + width(), y); 247 p.drawLine(x, y, x + width(), y);
248 248
249 for (int col = 0; col < keys->numKeys(row); col++) { 249 for (int col = 0; col < keys->numKeys(row); col++) {
250 250
251 QImage *pix = keys->pix(row, col); 251 QImage *pix = keys->pix(row, col);
252 int keyWidth = keys->width(row, col); 252 int keyWidth = keys->width(row, col);
253 253
254 254
255 int keyWidthPix = defaultKeyWidth * keyWidth; 255 int keyWidthPix = defaultKeyWidth * keyWidth;
256 256
257 if (keys->pressed(row, col)) 257 if (keys->pressed(row, col))
258 p.fillRect(x+1, y+1, keyWidthPix - 1, 258 p.fillRect(x+1, y+1, keyWidthPix - 1,
259 keyHeight - 1, keycolor_pressed); 259 keyHeight - 1, keycolor_pressed);
260 260
261 ushort c = keys->uni(row, col); 261 ushort c = keys->uni(row, col);
262 262
263 p.setPen(textcolor); 263 p.setPen(textcolor);
264 if (!pix) { 264 if (!pix) {
265 if ((shift || lock) && keys->shift(c)) 265 if ((shift || lock) && keys->shift(c))
266 266
267 if (circumflex && keys->circumflex(keys->shift(c))) 267 if (circumflex && keys->circumflex(keys->shift(c)))
268 c = keys->circumflex(keys->shift(c)); 268 c = keys->circumflex(keys->shift(c));
269 else if (diaeresis && keys->diaeresis(keys->shift(c))) 269 else if (diaeresis && keys->diaeresis(keys->shift(c)))
270 c = keys->diaeresis(keys->shift(c)); 270 c = keys->diaeresis(keys->shift(c));
271 else if (baccent && keys->baccent(keys->shift(c))) 271 else if (baccent && keys->baccent(keys->shift(c)))
272 c = keys->baccent(keys->shift(c)); 272 c = keys->baccent(keys->shift(c));
273 else if (accent && keys->accent(keys->shift(c))) 273 else if (accent && keys->accent(keys->shift(c)))
274 c = keys->accent(keys->shift(c)); 274 c = keys->accent(keys->shift(c));
275 else if (meta && keys->meta(keys->shift(c))) 275 else if (meta && keys->meta(keys->shift(c)))
276 c = keys->meta(keys->shift(c)); 276 c = keys->meta(keys->shift(c));
277 else 277 else
278 c = keys->shift(c); 278 c = keys->shift(c);
279 279
280 else if (meta && keys->meta(c)) 280 else if (meta && keys->meta(c))
281 c = keys->meta(c); 281 c = keys->meta(c);
282 else if (circumflex && keys->circumflex(c)) 282 else if (circumflex && keys->circumflex(c))
283 c = keys->circumflex(c); 283 c = keys->circumflex(c);
284 else if (baccent && keys->baccent(c)) 284 else if (baccent && keys->baccent(c))
285 c = keys->baccent(c); 285 c = keys->baccent(c);
286 else if (accent && keys->accent(c)) 286 else if (accent && keys->accent(c))
287 c = keys->accent(c); 287 c = keys->accent(c);
288 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { 288 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) {
289 289
290 if (c == 0x2c6) 290 if (c == 0x2c6)
291 c = 0xa8; 291 c = 0xa8;
292 else 292 else
293 c = keys->diaeresis(c); 293 c = keys->diaeresis(c);
294 } 294 }
295 295
296 p.drawText(x, y, 296 p.drawText(x, y,
297 keyWidthPix + 3, keyHeight, 297 keyWidthPix + 3, keyHeight,
298 AlignCenter, (QChar)c); 298 AlignCenter, (QChar)c);
299 } 299 }
300 else { 300 else {
301 // center the image in the middle of the key 301 // center the image in the middle of the key
302 pix->setColor(1, textcolor.rgb()); 302 pix->setColor(1, textcolor.rgb());
303 p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, 303 p.drawImage( x + (keyWidthPix - pix->width())/2 + 1,
304 y + (keyHeight - pix->height())/2 + 1, 304 y + (keyHeight - pix->height())/2 + 1,
305 QImage(*pix) ); 305 QImage(*pix) );
306 } 306 }
307 307
308 p.setPen(keycolor_lines); 308 p.setPen(keycolor_lines);
309 p.drawLine(x, y, x, y + keyHeight); 309 p.drawLine(x, y, x, y + keyHeight);
310 310
311 x += keyWidthPix; 311 x += keyWidthPix;
312 } 312 }
313 313
314 314
315 } 315 }
316 p.setPen(keycolor_lines); 316 p.setPen(keycolor_lines);
317 p.drawLine(0, height() - 1, width(), height() - 1); 317 p.drawLine(0, height() - 1, width(), height() - 1);
318 p.drawLine(width() - 1, 0, width() - 1, height()); 318 p.drawLine(width() - 1, 0, width() - 1, height());
319 } 319 }
320 320
321} 321}
322 322
323 323
324/* Keyboard::mousePressEvent {{{1 */ 324/* Keyboard::mousePressEvent {{{1 */
325void Keyboard::mousePressEvent(QMouseEvent *e) 325void Keyboard::mousePressEvent(QMouseEvent *e)
326{ 326{
327 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; 327 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1;
328 if (row > 5) row = 5; 328 if (row > 5) row = 5;
329 329
330 // figure out the column 330 // figure out the column
331 int col = 0; 331 int col = 0;
332 for (int w = 0; e->x() >= w; col++) 332 for (int w = 0; e->x() >= w; col++)
333 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys 333 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys
334 w += keys->width(row,col) * defaultKeyWidth; 334 w += keys->width(row,col) * defaultKeyWidth;
335 else break; 335 else break;
336 336
337 if (col <= 0) return; 337 if (col <= 0) return;
338 338
339 col --; // rewind one... 339 col --; // rewind one...
340 340
341 qkeycode = keys->qcode(row, col); 341 qkeycode = keys->qcode(row, col);
342 unicode = keys->uni(row, col); 342 unicode = keys->uni(row, col);
343 343
344 // might need to repaint if two or more of the same keys. 344 // might need to repaint if two or more of the same keys.
345 // should be faster if just paint one key even though multiple keys exist. 345 // should be faster if just paint one key even though multiple keys exist.
346 bool need_repaint = FALSE; 346 bool need_repaint = FALSE;
347 347
348 // circumflex and diaeresis support 348 // circumflex and diaeresis support
349 // messy to have this here, but too hard to implement any other method 349 // messy to have this here, but too hard to implement any other method
350 if (unicode == 0x2c6) { 350 if (unicode == 0x2c6) {
351 351
352 unicode = 0; 352 unicode = 0;
353 if (shift || lock) { 353 if (shift || lock) {
354 354
355 // diaeresis 355 // diaeresis
356 qkeycode = 0x2001; 356 qkeycode = 0x2001;
@@ -1068,513 +1068,516 @@ ushort Keyboard::parseKoreanInput (ushort c) {
1068 1068
1069 } else if (echar == 0x11ab) { // ¤¤ 1069 } else if (echar == 0x11ab) { // ¤¤
1070 1070
1071 if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸ 1071 if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸
1072 else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾ 1072 else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾
1073 else { 1073 else {
1074 schar = c; mchar = 0; echar = 0; 1074 schar = c; mchar = 0; echar = 0;
1075 return c; 1075 return c;
1076 } 1076 }
1077 1077
1078 } else if (echar == 0x11af) { // ¤© 1078 } else if (echar == 0x11af) { // ¤©
1079 1079
1080 if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡ 1080 if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡
1081 else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤± 1081 else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤±
1082 else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤² 1082 else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤²
1083 else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ 1083 else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ
1084 else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼ 1084 else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼
1085 else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½ 1085 else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½
1086 else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾ 1086 else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾
1087 else { 1087 else {
1088 schar = c; mchar = 0; echar = 0; 1088 schar = c; mchar = 0; echar = 0;
1089 return c; 1089 return c;
1090 } 1090 }
1091 1091
1092 } else if (echar == 0x11b8) { // ¤² 1092 } else if (echar == 0x11b8) { // ¤²
1093 1093
1094 if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ 1094 if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ
1095 else { 1095 else {
1096 schar = c; mchar = 0; echar = 0; 1096 schar = c; mchar = 0; echar = 0;
1097 return c; 1097 return c;
1098 } 1098 }
1099 1099
1100 } else if (echar == 0x11ba) { // ¤µ 1100 } else if (echar == 0x11ba) { // ¤µ
1101 1101
1102 if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ 1102 if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ
1103 else { 1103 else {
1104 schar = c; mchar = 0; echar = 0; 1104 schar = c; mchar = 0; echar = 0;
1105 return c; 1105 return c;
1106 } 1106 }
1107 1107
1108 } else { // if any other char, cannot combine chars 1108 } else { // if any other char, cannot combine chars
1109 1109
1110 schar = c; mchar = 0; echar = 0; 1110 schar = c; mchar = 0; echar = 0;
1111 return c; 1111 return c;
1112 } 1112 }
1113 1113
1114 unicode = echar; 1114 unicode = echar;
1115 } 1115 }
1116 } 1116 }
1117 1117
1118 } 1118 }
1119 else if (0x1161 <= c && c <= 0x1175) { // mchar was input 1119 else if (0x1161 <= c && c <= 0x1175) { // mchar was input
1120 1120
1121 if (schar != 0 && mchar == 0) { mchar = c; } 1121 if (schar != 0 && mchar == 0) { mchar = c; }
1122 1122
1123 else if (schar != 0 && mchar != 0 && echar == 0) { 1123 else if (schar != 0 && mchar != 0 && echar == 0) {
1124 1124
1125 switch (mchar) { 1125 switch (mchar) {
1126 case 0x1169: 1126 case 0x1169:
1127 if (c == 0x1161) mchar = 0x116a; 1127 if (c == 0x1161) mchar = 0x116a;
1128 else if (c == 0x1162) mchar = 0x116b; 1128 else if (c == 0x1162) mchar = 0x116b;
1129 else if (c == 0x1175) mchar = 0x116c; 1129 else if (c == 0x1175) mchar = 0x116c;
1130 else { 1130 else {
1131 schar = 0; mchar = 0; echar = 0; 1131 schar = 0; mchar = 0; echar = 0;
1132 return c; 1132 return c;
1133 } 1133 }
1134 break; 1134 break;
1135 case 0x116e: 1135 case 0x116e:
1136 if (c == 0x1165) mchar = 0x116f; 1136 if (c == 0x1165) mchar = 0x116f;
1137 else if (c == 0x1166) mchar = 0x1170; 1137 else if (c == 0x1166) mchar = 0x1170;
1138 else if (c == 0x1175) mchar = 0x1171; 1138 else if (c == 0x1175) mchar = 0x1171;
1139 else { 1139 else {
1140 schar = 0; mchar = 0; echar = 0; 1140 schar = 0; mchar = 0; echar = 0;
1141 return c; 1141 return c;
1142 } 1142 }
1143 break; 1143 break;
1144 case 0x1173: 1144 case 0x1173:
1145 if (c == 0x1175) mchar = 0x1174; 1145 if (c == 0x1175) mchar = 0x1174;
1146 else { 1146 else {
1147 schar = 0; mchar = 0; echar = 0; 1147 schar = 0; mchar = 0; echar = 0;
1148 return c; 1148 return c;
1149 } 1149 }
1150 break; 1150 break;
1151 default: 1151 default:
1152 schar = 0; mchar = 0; echar = 0; 1152 schar = 0; mchar = 0; echar = 0;
1153 return c; 1153 return c;
1154 } 1154 }
1155 } 1155 }
1156 else if (schar != 0 && mchar != 0 && echar != 0) { 1156 else if (schar != 0 && mchar != 0 && echar != 0) {
1157 1157
1158 emit key( 8, Qt::Key_Backspace, 0, true, false ); 1158 emit key( 8, Qt::Key_Backspace, 0, true, false );
1159 1159
1160 ushort prev = 0; 1160 ushort prev = 0;
1161 switch (echar) { 1161 switch (echar) {
1162 /* 1162 /*
1163 case 0x11a9: 1163 case 0x11a9:
1164 prev = combineKoreanChars(schar, mchar, 0x11a8); 1164 prev = combineKoreanChars(schar, mchar, 0x11a8);
1165 schar = 0x1100; 1165 schar = 0x1100;
1166 break; 1166 break;
1167 */ 1167 */
1168 case 0x11aa: 1168 case 0x11aa:
1169 prev = combineKoreanChars(schar, mchar, 0x11a8); 1169 prev = combineKoreanChars(schar, mchar, 0x11a8);
1170 schar = 0x1109; 1170 schar = 0x1109;
1171 break; 1171 break;
1172 case 0x11ac: 1172 case 0x11ac:
1173 prev = combineKoreanChars(schar, mchar, 0x11ab); 1173 prev = combineKoreanChars(schar, mchar, 0x11ab);
1174 schar = 0x110c; 1174 schar = 0x110c;
1175 break; 1175 break;
1176 case 0x11ad: 1176 case 0x11ad:
1177 prev = combineKoreanChars(schar, mchar, 0x11ab); 1177 prev = combineKoreanChars(schar, mchar, 0x11ab);
1178 schar = 0x1112; 1178 schar = 0x1112;
1179 break; 1179 break;
1180 case 0x11b0: 1180 case 0x11b0:
1181 prev = combineKoreanChars(schar, mchar, 0x11af); 1181 prev = combineKoreanChars(schar, mchar, 0x11af);
1182 schar = 0x1100; 1182 schar = 0x1100;
1183 break; 1183 break;
1184 case 0x11b1: 1184 case 0x11b1:
1185 prev = combineKoreanChars(schar, mchar, 0x11af); 1185 prev = combineKoreanChars(schar, mchar, 0x11af);
1186 schar = 0x1106; 1186 schar = 0x1106;
1187 break; 1187 break;
1188 case 0x11b2: 1188 case 0x11b2:
1189 prev = combineKoreanChars(schar, mchar, 0x11af); 1189 prev = combineKoreanChars(schar, mchar, 0x11af);
1190 schar = 0x1107; 1190 schar = 0x1107;
1191 break; 1191 break;
1192 case 0x11b3: 1192 case 0x11b3:
1193 prev = combineKoreanChars(schar, mchar, 0x11af); 1193 prev = combineKoreanChars(schar, mchar, 0x11af);
1194 schar = 0x1109; 1194 schar = 0x1109;
1195 break; 1195 break;
1196 case 0x11b4: 1196 case 0x11b4:
1197 prev = combineKoreanChars(schar, mchar, 0x11af); 1197 prev = combineKoreanChars(schar, mchar, 0x11af);
1198 schar = 0x1110; 1198 schar = 0x1110;
1199 break; 1199 break;
1200 case 0x11b9: 1200 case 0x11b9:
1201 prev = combineKoreanChars(schar, mchar, 0x11b8); 1201 prev = combineKoreanChars(schar, mchar, 0x11b8);
1202 schar = 0x1109; 1202 schar = 0x1109;
1203 break; 1203 break;
1204 /* 1204 /*
1205 case 0x11bb: 1205 case 0x11bb:
1206 prev = combineKoreanChars(schar, mchar, 0x11ba); 1206 prev = combineKoreanChars(schar, mchar, 0x11ba);
1207 schar = 0x1109; 1207 schar = 0x1109;
1208 break; 1208 break;
1209 */ 1209 */
1210 default: 1210 default:
1211 1211
1212 if (constoe(echar)) { 1212 if (constoe(echar)) {
1213 1213
1214 prev = combineKoreanChars(schar, mchar, 0); 1214 prev = combineKoreanChars(schar, mchar, 0);
1215 schar = constoe(echar); 1215 schar = constoe(echar);
1216 } 1216 }
1217 break; 1217 break;
1218 } 1218 }
1219 1219
1220 emit key( prev, prev, 0, true, false ); 1220 emit key( prev, prev, 0, true, false );
1221 1221
1222 mchar = c; echar = 0; 1222 mchar = c; echar = 0;
1223 1223
1224 return combineKoreanChars(schar, mchar, 0); 1224 return combineKoreanChars(schar, mchar, 0);
1225 1225
1226 } 1226 }
1227 else { 1227 else {
1228 schar = 0; mchar = 0; echar = 0; 1228 schar = 0; mchar = 0; echar = 0;
1229 return c; 1229 return c;
1230 } 1230 }
1231 1231
1232 } 1232 }
1233 else /*if (c == ' ')*/ return c; 1233 else /*if (c == ' ')*/ return c;
1234 1234
1235 1235
1236 // and now... finally delete previous char, and return new char 1236 // and now... finally delete previous char, and return new char
1237 emit key( 8, Qt::Key_Backspace, 0, true, false ); 1237 emit key( 8, Qt::Key_Backspace, 0, true, false );
1238 1238
1239 1239
1240 return combineKoreanChars( schar, mchar, echar); 1240 return combineKoreanChars( schar, mchar, echar);
1241 1241
1242} 1242}
1243 1243
1244ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { 1244ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) {
1245 1245
1246 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; 1246 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00;
1247 1247
1248} 1248}
1249 1249
1250ushort Keyboard::constoe(const ushort c) { 1250ushort Keyboard::constoe(const ushort c) {
1251 1251
1252 // converts schars to echars if possible 1252 // converts schars to echars if possible
1253 1253
1254 if (0x1100 <= c && c <= 0x1112) { // schar to echar 1254 if (0x1100 <= c && c <= 0x1112) { // schar to echar
1255 1255
1256 switch (c) { 1256 switch (c) {
1257 case 0x1100: return 0x11a8; 1257 case 0x1100: return 0x11a8;
1258 case 0x1101: return 0x11a9; 1258 case 0x1101: return 0x11a9;
1259 case 0x1102: return 0x11ab; 1259 case 0x1102: return 0x11ab;
1260 case 0x1103: return 0x11ae; 1260 case 0x1103: return 0x11ae;
1261 case 0x1105: return 0x11af; 1261 case 0x1105: return 0x11af;
1262 case 0x1106: return 0x11b7; 1262 case 0x1106: return 0x11b7;
1263 case 0x1107: return 0x11b8; 1263 case 0x1107: return 0x11b8;
1264 case 0x1109: return 0x11ba; 1264 case 0x1109: return 0x11ba;
1265 case 0x110a: return 0x11bb; 1265 case 0x110a: return 0x11bb;
1266 case 0x110b: return 0x11bc; 1266 case 0x110b: return 0x11bc;
1267 case 0x110c: return 0x11bd; 1267 case 0x110c: return 0x11bd;
1268 case 0x110e: return 0x11be; 1268 case 0x110e: return 0x11be;
1269 case 0x110f: return 0x11bf; 1269 case 0x110f: return 0x11bf;
1270 case 0x1110: return 0x11c0; 1270 case 0x1110: return 0x11c0;
1271 case 0x1111: return 0x11c1; 1271 case 0x1111: return 0x11c1;
1272 case 0x1112: return 0x11c2; 1272 case 0x1112: return 0x11c2;
1273 default: return 0; 1273 default: return 0;
1274 1274
1275 } 1275 }
1276 1276
1277 } else { //echar to schar 1277 } else { //echar to schar
1278 1278
1279 switch (c) { 1279 switch (c) {
1280 case 0x11a8: return 0x1100; 1280 case 0x11a8: return 0x1100;
1281 case 0x11a9: return 0x1101; 1281 case 0x11a9: return 0x1101;
1282 case 0x11ab: return 0x1102; 1282 case 0x11ab: return 0x1102;
1283 case 0x11ae: return 0x1103; 1283 case 0x11ae: return 0x1103;
1284 case 0x11af: return 0x1105; 1284 case 0x11af: return 0x1105;
1285 case 0x11b7: return 0x1106; 1285 case 0x11b7: return 0x1106;
1286 case 0x11b8: return 0x1107; 1286 case 0x11b8: return 0x1107;
1287 case 0x11ba: return 0x1109; 1287 case 0x11ba: return 0x1109;
1288 case 0x11bb: return 0x110a; 1288 case 0x11bb: return 0x110a;
1289 case 0x11bc: return 0x110b; 1289 case 0x11bc: return 0x110b;
1290 case 0x11bd: return 0x110c; 1290 case 0x11bd: return 0x110c;
1291 case 0x11be: return 0x110e; 1291 case 0x11be: return 0x110e;
1292 case 0x11bf: return 0x110f; 1292 case 0x11bf: return 0x110f;
1293 case 0x11c0: return 0x1110; 1293 case 0x11c0: return 0x1110;
1294 case 0x11c1: return 0x1111; 1294 case 0x11c1: return 0x1111;
1295 case 0x11c2: return 0x1112; 1295 case 0x11c2: return 0x1112;
1296 default: return 0; 1296 default: return 0;
1297 1297
1298 } 1298 }
1299 1299
1300 } 1300 }
1301} 1301}
1302 1302
1303 1303
1304// Keys::Keys {{{1 1304// Keys::Keys {{{1
1305 1305
1306Keys::Keys() { 1306Keys::Keys() {
1307 1307
1308 Config *config = new Config ("multikey"); 1308 Config *config = new Config ("multikey");
1309 config->setGroup( "keymaps" ); 1309 config->setGroup( "keymaps" );
1310 QString map = config->readEntry( "current" ); 1310 QString map = config->readEntry( "current" );
1311 delete config; 1311 delete config;
1312 1312
1313 if (map.isNull() || !(QFile(map).exists())) { 1313 if (map.isNull() || !(QFile(map).exists())) {
1314 1314
1315 Config *config = new Config("locale"); 1315 Config *config = new Config("locale");
1316 config->setGroup( "Language" ); 1316 config->setGroup( "Language" );
1317 QString l = config->readEntry( "Language" , "en" ); 1317 QString l = config->readEntry( "Language" , "en" );
1318 delete config; 1318 delete config;
1319 1319
1320 map = QPEApplication::qpeDir() + "/share/multikey/" 1320 map = QPEApplication::qpeDir() + "/share/multikey/"
1321 + l + ".keymap"; 1321 + l + ".keymap";
1322 1322
1323 } 1323 }
1324 1324 if (map.isNull() || !(QFile(map).exists())) {
1325 map = QPEApplication::qpeDir() + "/share/multikey/en.keymap";
1326 }
1327
1325 setKeysFromFile(map); 1328 setKeysFromFile(map);
1326} 1329}
1327 1330
1328Keys::Keys(const char * filename) { 1331Keys::Keys(const char * filename) {
1329 1332
1330 setKeysFromFile(filename); 1333 setKeysFromFile(filename);
1331} 1334}
1332 1335
1333// Keys::setKeysFromFile {{{2 1336// Keys::setKeysFromFile {{{2
1334void Keys::setKeysFromFile(const char * filename) { 1337void Keys::setKeysFromFile(const char * filename) {
1335 1338
1336 QFile f(filename); 1339 QFile f(filename);
1337 1340
1338 if (f.open(IO_ReadOnly)) { 1341 if (f.open(IO_ReadOnly)) {
1339 1342
1340 QTextStream t(&f); 1343 QTextStream t(&f);
1341 int row; 1344 int row;
1342 int qcode; 1345 int qcode;
1343 ushort unicode; 1346 ushort unicode;
1344 int width; 1347 int width;
1345 QString buf; 1348 QString buf;
1346 QString comment; 1349 QString comment;
1347 char * xpm[256]; //couldnt be larger than that... could it? 1350 char * xpm[256]; //couldnt be larger than that... could it?
1348 QImage *xpm2pix = 0; 1351 QImage *xpm2pix = 0;
1349 1352
1350 buf = t.readLine(); 1353 buf = t.readLine();
1351 while (buf) { 1354 while (buf) {
1352 1355
1353 // get rid of comments 1356 // get rid of comments
1354 buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); 1357 buf.replace(QRegExp("#.*$", FALSE, FALSE), "");
1355 1358
1356 // key definition 1359 // key definition
1357 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { 1360 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) {
1358 // no $1 type referencing!!! this implementation of regexp sucks 1361 // no $1 type referencing!!! this implementation of regexp sucks
1359 1362
1360 // dont know of any sscanf() type funcs in Qt lib 1363 // dont know of any sscanf() type funcs in Qt lib
1361 QTextStream tmp (buf, IO_ReadOnly); 1364 QTextStream tmp (buf, IO_ReadOnly);
1362 tmp >> row >> qcode >> unicode >> width >> comment; 1365 tmp >> row >> qcode >> unicode >> width >> comment;
1363 1366
1364 buf = t.readLine(); 1367 buf = t.readLine();
1365 int xpmLineCount = 0; 1368 int xpmLineCount = 0;
1366 xpm2pix = 0; 1369 xpm2pix = 0;
1367 1370
1368 // erase blank space 1371 // erase blank space
1369 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); 1372 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine();
1370 1373
1371 while (buf.contains(QRegExp("^\\s*\".*\""))) { 1374 while (buf.contains(QRegExp("^\\s*\".*\""))) {
1372 1375
1373 QString xpmBuf = buf.stripWhiteSpace(); 1376 QString xpmBuf = buf.stripWhiteSpace();
1374 1377
1375 xpm[xpmLineCount] = new char [xpmBuf.length()]; 1378 xpm[xpmLineCount] = new char [xpmBuf.length()];
1376 1379
1377 int j = 0; 1380 int j = 0;
1378 for (ushort i = 0; i < xpmBuf.length(); i++) { 1381 for (ushort i = 0; i < xpmBuf.length(); i++) {
1379 if (xpmBuf[i].latin1() != '"') { 1382 if (xpmBuf[i].latin1() != '"') {
1380 1383
1381 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); 1384 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1();
1382 j++; 1385 j++;
1383 } 1386 }
1384 1387
1385 } 1388 }
1386 // have to close that facker up 1389 // have to close that facker up
1387 ((char *)xpm[xpmLineCount])[j] = '\0'; 1390 ((char *)xpm[xpmLineCount])[j] = '\0';
1388 1391
1389 xpmLineCount++; 1392 xpmLineCount++;
1390 buf = t.readLine(); 1393 buf = t.readLine();
1391 } 1394 }
1392 if (xpmLineCount) { 1395 if (xpmLineCount) {
1393 1396
1394 xpm2pix = new QImage((const char **)xpm); 1397 xpm2pix = new QImage((const char **)xpm);
1395 for (int i = 0; i < xpmLineCount; i++) 1398 for (int i = 0; i < xpmLineCount; i++)
1396 1399
1397 delete [] (xpm[i]); 1400 delete [] (xpm[i]);
1398 1401
1399 } 1402 }
1400 setKey(row, qcode, unicode, width, xpm2pix); 1403 setKey(row, qcode, unicode, width, xpm2pix);
1401 } 1404 }
1402 1405
1403 // shift map 1406 // shift map
1404 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1407 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1405 1408
1406 QTextStream tmp (buf, IO_ReadOnly); 1409 QTextStream tmp (buf, IO_ReadOnly);
1407 ushort lower, shift; 1410 ushort lower, shift;
1408 tmp >> lower >> shift; 1411 tmp >> lower >> shift;
1409 1412
1410 shiftMap.insert(lower, shift); 1413 shiftMap.insert(lower, shift);
1411 1414
1412 buf = t.readLine(); 1415 buf = t.readLine();
1413 } 1416 }
1414 1417
1415 // meta key map 1418 // meta key map
1416 else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1419 else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1417 1420
1418 QTextStream tmp (buf, IO_ReadOnly); 1421 QTextStream tmp (buf, IO_ReadOnly);
1419 ushort lower, shift; 1422 ushort lower, shift;
1420 QChar m; 1423 QChar m;
1421 tmp >> m >> lower >> shift; 1424 tmp >> m >> lower >> shift;
1422 1425
1423 metaMap.insert(lower, shift); 1426 metaMap.insert(lower, shift);
1424 1427
1425 buf = t.readLine(); 1428 buf = t.readLine();
1426 } 1429 }
1427 1430
1428 // circumflex 1431 // circumflex
1429 else if (buf.contains(QRegExp("^\\s*c\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1432 else if (buf.contains(QRegExp("^\\s*c\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1430 1433
1431 QTextStream tmp (buf, IO_ReadOnly); 1434 QTextStream tmp (buf, IO_ReadOnly);
1432 ushort lower, shift; 1435 ushort lower, shift;
1433 QChar c; 1436 QChar c;
1434 tmp >> c >> lower >> shift; 1437 tmp >> c >> lower >> shift;
1435 1438
1436 circumflexMap.insert(lower, shift); 1439 circumflexMap.insert(lower, shift);
1437 1440
1438 buf = t.readLine(); 1441 buf = t.readLine();
1439 } 1442 }
1440 // diaeresis 1443 // diaeresis
1441 else if (buf.contains(QRegExp("^\\s*d\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1444 else if (buf.contains(QRegExp("^\\s*d\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1442 1445
1443 QTextStream tmp (buf, IO_ReadOnly); 1446 QTextStream tmp (buf, IO_ReadOnly);
1444 ushort lower, shift; 1447 ushort lower, shift;
1445 QChar d; 1448 QChar d;
1446 tmp >> d >> lower >> shift; 1449 tmp >> d >> lower >> shift;
1447 1450
1448 diaeresisMap.insert(lower, shift); 1451 diaeresisMap.insert(lower, shift);
1449 1452
1450 buf = t.readLine(); 1453 buf = t.readLine();
1451 } 1454 }
1452 // back accent 1455 // back accent
1453 else if (buf.contains(QRegExp("^\\s*b\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1456 else if (buf.contains(QRegExp("^\\s*b\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1454 1457
1455 QTextStream tmp (buf, IO_ReadOnly); 1458 QTextStream tmp (buf, IO_ReadOnly);
1456 ushort lower, shift; 1459 ushort lower, shift;
1457 QChar d; 1460 QChar d;
1458 tmp >> d >> lower >> shift; 1461 tmp >> d >> lower >> shift;
1459 1462
1460 baccentMap.insert(lower, shift); 1463 baccentMap.insert(lower, shift);
1461 1464
1462 qDebug ("Estoy añadiendo %i con %i", lower, shift); 1465 qDebug ("Estoy añadiendo %i con %i", lower, shift);
1463 buf = t.readLine(); 1466 buf = t.readLine();
1464 } 1467 }
1465 // accent 1468 // accent
1466 else if (buf.contains(QRegExp("^\\s*a\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1469 else if (buf.contains(QRegExp("^\\s*a\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1467 1470
1468 QTextStream tmp (buf, IO_ReadOnly); 1471 QTextStream tmp (buf, IO_ReadOnly);
1469 ushort lower, shift; 1472 ushort lower, shift;
1470 QChar d; 1473 QChar d;
1471 tmp >> d >> lower >> shift; 1474 tmp >> d >> lower >> shift;
1472 1475
1473 accentMap.insert(lower, shift); 1476 accentMap.insert(lower, shift);
1474 1477
1475 buf = t.readLine(); 1478 buf = t.readLine();
1476 } 1479 }
1477 1480
1478 // other variables like lang & title 1481 // other variables like lang & title
1479 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { 1482 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) {
1480 1483
1481 QTextStream tmp (buf, IO_ReadOnly); 1484 QTextStream tmp (buf, IO_ReadOnly);
1482 QString name, equals, value; 1485 QString name, equals, value;
1483 1486
1484 tmp >> name >> equals >> value; 1487 tmp >> name >> equals >> value;
1485 1488
1486 if (name == "lang") { 1489 if (name == "lang") {
1487 1490
1488 lang = value; 1491 lang = value;
1489 1492
1490 } 1493 }
1491 1494
1492 buf = t.readLine(); 1495 buf = t.readLine();
1493 } 1496 }
1494 // comments 1497 // comments
1495 else if (buf.contains(QRegExp("^\\s*#"))) { 1498 else if (buf.contains(QRegExp("^\\s*#"))) {
1496 1499
1497 buf = t.readLine(); 1500 buf = t.readLine();
1498 1501
1499 } else { // blank line, or garbage 1502 } else { // blank line, or garbage
1500 1503
1501 buf = t.readLine(); 1504 buf = t.readLine();
1502 1505
1503 } 1506 }
1504 1507
1505 } 1508 }
1506 f.close(); 1509 f.close();
1507 } 1510 }
1508 1511
1509} 1512}
1510 1513
1511// Keys::setKey {{{2 1514// Keys::setKey {{{2
1512void Keys::setKey(const int row, const int qcode, const ushort unicode, 1515void Keys::setKey(const int row, const int qcode, const ushort unicode,
1513 const int width, QImage *pix) { 1516 const int width, QImage *pix) {
1514 1517
1515 Key * key; 1518 Key * key;
1516 key = new Key; 1519 key = new Key;
1517 key->qcode = qcode; 1520 key->qcode = qcode;
1518 key->unicode = unicode; 1521 key->unicode = unicode;
1519 key->width = width; 1522 key->width = width;
1520 1523
1521 // share key->pressed between same keys 1524 // share key->pressed between same keys
1522 bool found = 0; 1525 bool found = 0;
1523 for (int i = 1; i <= 5; i++) { 1526 for (int i = 1; i <= 5; i++) {
1524 for (unsigned int j = 0; j < keys[i].count(); j++) 1527 for (unsigned int j = 0; j < keys[i].count(); j++)
1525 if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { 1528 if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) {
1526 1529
1527 key->pressed = keys[i].at(j)->pressed; 1530 key->pressed = keys[i].at(j)->pressed;
1528 found = 1; 1531 found = 1;
1529 } 1532 }
1530 1533
1531 } 1534 }
1532 if (!found) { 1535 if (!found) {
1533 1536
1534 key->pressed = new bool; 1537 key->pressed = new bool;
1535 *(key->pressed) = 0; 1538 *(key->pressed) = 0;
1536 } 1539 }
1537 1540
1538 key->pix = pix; 1541 key->pix = pix;
1539 1542
1540 1543
1541 keys[row].append(key); 1544 keys[row].append(key);
1542} 1545}
1543 1546
1544// Keys::~Keys {{{2 1547// Keys::~Keys {{{2
1545Keys::~Keys() { 1548Keys::~Keys() {
1546 1549
1547 for (int i = 1; i <= 5; i++) 1550 for (int i = 1; i <= 5; i++)
1548 for (unsigned int j = 0; j < keys[i].count(); j++) 1551 for (unsigned int j = 0; j < keys[i].count(); j++)
1549 delete keys[i].at(j); 1552 delete keys[i].at(j);
1550 1553
1551} 1554}
1552 1555
1553// Keys:: other functions {{{2 1556// Keys:: other functions {{{2
1554int Keys::width(const int row, const int col) { 1557int Keys::width(const int row, const int col) {
1555 1558
1556 return keys[row].at(col)->width; 1559 return keys[row].at(col)->width;
1557 1560
1558} 1561}
1559 1562
1560int Keys::rows() { 1563int Keys::rows() {
1561 1564
1562 for (int i = 1; i <= 5; i++) { 1565 for (int i = 1; i <= 5; i++) {
1563 1566
1564 if (keys[i].count() == 0) 1567 if (keys[i].count() == 0)
1565 return i - 1; 1568 return i - 1;
1566 1569
1567 } 1570 }
1568 return 5; 1571 return 5;
1569} 1572}
1570 1573
1571ushort Keys::uni(const int row, const int col) { 1574ushort Keys::uni(const int row, const int col) {
1572 1575
1573 return keys[row].at(col)->unicode; 1576 return keys[row].at(col)->unicode;
1574 1577
1575} 1578}
1576 1579
1577int Keys::qcode(const int row, const int col) { 1580int Keys::qcode(const int row, const int col) {
1578 1581
1579 return keys[row].at(col)->qcode; 1582 return keys[row].at(col)->qcode;
1580} 1583}
diff --git a/inputmethods/multikey/keyboardimpl.cpp b/inputmethods/multikey/keyboardimpl.cpp
index 2bcb0fa..cebd43d 100644
--- a/inputmethods/multikey/keyboardimpl.cpp
+++ b/inputmethods/multikey/keyboardimpl.cpp
@@ -1,108 +1,107 @@
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 <qapplication.h> 20#include <qapplication.h>
21#include <qpixmap.h> 21#include <qpixmap.h>
22#include "keyboard.h" 22#include "keyboard.h"
23#include "keyboardimpl.h" 23#include "keyboardimpl.h"
24 24
25/* XPM */ 25/* XPM */
26static const char * kb_xpm[] = { 26static const char * kb_xpm[] = {
27"28 13 4 1", 27"28 13 4 1",
28" c None", 28" c None",
29". c #4C4C4C", 29". c #4C4C4C",
30"+ c #FFF7DD", 30"+ c #FFF7DD",
31"@ c #D6CFBA", 31"@ c #D6CFBA",
32" .......................... ", 32" .......................... ",
33" .+++.+++.+++.+++.+++.++++. ", 33" .+++.+++.+++.+++.+++.++++. ",
34" .+@@.+@@.+@@.+@@.+@@.+@@@. ", 34" .+@@.+@@.+@@.+@@.+@@.+@@@. ",
35" .......................... ", 35" .......................... ",
36" .+++++.+++.+++.+++.++++++. ", 36" .+++++.+++.+++.+++.++++++. ",
37" .+@@@@.+@@.+@@.+@@.+@@@@@. ", 37" .+@@@@.+@@.+@@.+@@.+@@@@@. ",
38" .......................... ", 38" .......................... ",
39" .++++++.+++.+++.+++.+++++. ", 39" .++++++.+++.+++.+++.+++++. ",
40" .+@@@@@.+@@.+@@.+@@.+@@@@. ", 40" .+@@@@@.+@@.+@@.+@@.+@@@@. ",
41" .......................... ", 41" .......................... ",
42" .++++.++++++++++++++.++++. ", 42" .++++.++++++++++++++.++++. ",
43" .+@@@.+@@@@@@@@@@@@@.+@@@. ", 43" .+@@@.+@@@@@@@@@@@@@.+@@@. ",
44" .......................... "}; 44" .......................... "};
45 45
46 46
47KeyboardImpl::KeyboardImpl() 47KeyboardImpl::KeyboardImpl()
48 : input(0), icn(0), ref(0) 48 : input(0), icn(0), ref(0)
49{ 49{
50} 50}
51 51
52KeyboardImpl::~KeyboardImpl() 52KeyboardImpl::~KeyboardImpl()
53{ 53{
54 delete input; 54 delete input;
55 delete icn; 55 delete icn;
56} 56}
57 57
58QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) 58QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f )
59{ 59{
60 if ( !input ) 60 if ( !input )
61 input = new Keyboard( parent, "Keyboard", f ); 61 input = new Keyboard( parent, "Keyboard", f );
62 return input; 62 return input;
63} 63}
64 64
65void KeyboardImpl::resetState() 65void KeyboardImpl::resetState()
66{ 66{
67 if ( input ) 67 if ( input )
68 input->resetState(); 68 input->resetState();
69} 69}
70 70
71QPixmap *KeyboardImpl::icon() 71QPixmap *KeyboardImpl::icon()
72{ 72{
73 if ( !icn ) 73 if ( !icn )
74 icn = new QPixmap( (const char **)kb_xpm ); 74 icn = new QPixmap( (const char **)kb_xpm );
75 return icn; 75 return icn;
76} 76}
77 77
78QString KeyboardImpl::name() 78QString KeyboardImpl::name()
79{ 79{
80 return qApp->translate( "InputMethods", "Multikey" ); 80 return qApp->translate( "InputMethods", "Multikey" );
81// return qApp->translate( "InputMethods", "Opti" );
82} 81}
83 82
84void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot ) 83void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot )
85{ 84{
86 if ( input ) 85 if ( input )
87 QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); 86 QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot );
88} 87}
89 88
90#ifndef QT_NO_COMPONENT 89#ifndef QT_NO_COMPONENT
91QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) 90QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
92{ 91{
93 *iface = 0; 92 *iface = 0;
94 if ( uuid == IID_QUnknown ) 93 if ( uuid == IID_QUnknown )
95 *iface = this; 94 *iface = this;
96 else if ( uuid == IID_InputMethod ) 95 else if ( uuid == IID_InputMethod )
97 *iface = this; 96 *iface = this;
98 97
99 if ( *iface ) 98 if ( *iface )
100 (*iface)->addRef(); 99 (*iface)->addRef();
101 return QS_OK; 100 return QS_OK;
102} 101}
103 102
104Q_EXPORT_INTERFACE() 103Q_EXPORT_INTERFACE()
105{ 104{
106 Q_CREATE_INSTANCE( KeyboardImpl ) 105 Q_CREATE_INSTANCE( KeyboardImpl )
107} 106}
108#endif 107#endif