summaryrefslogtreecommitdiff
path: root/inputmethods/multikey
authormickeyl <mickeyl>2004-04-24 15:51:18 (UTC)
committer mickeyl <mickeyl>2004-04-24 15:51:18 (UTC)
commit629ced22fc26892442be433403a9cfa9f662f08a (patch) (unidiff)
tree830973cb7ba701b0a897220e1307ad3f1243384b /inputmethods/multikey
parentf7b5905d990f374dd6cb177b7a03628cc593b7cf (diff)
downloadopie-629ced22fc26892442be433403a9cfa9f662f08a.zip
opie-629ced22fc26892442be433403a9cfa9f662f08a.tar.gz
opie-629ced22fc26892442be433403a9cfa9f662f08a.tar.bz2
gcc 3.4 fixes
Diffstat (limited to 'inputmethods/multikey') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 4f4f25f..7ddfd3e 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -1,542 +1,542 @@
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 <qdir.h> 34#include <qdir.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
40using namespace MultiKey; 40using namespace MultiKey;
41 41
42static const char * const kb_config_xpm[] = { 42static const char * const kb_config_xpm[] = {
43"13 7 2 1", 43"13 7 2 1",
44" c None", 44" c None",
45". c #000000", 45". c #000000",
46" ", 46" ",
47" . ", 47" . ",
48" ... ", 48" ... ",
49" ..... ", 49" ..... ",
50" . ", 50" . ",
51" . ", 51" . ",
52" "}; 52" "};
53 53
54/* Keyboard::Keyboard {{{1 */ 54/* Keyboard::Keyboard {{{1 */
55Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : 55Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
56 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), 56 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0),
57 meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0), 57 meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0),
58 useLargeKeys(TRUE), usePicks(0), useRepeat(0), 58 useLargeKeys(TRUE), usePicks(0), useRepeat(0),
59 pressedKeyRow(-1), pressedKeyCol(-1), 59 pressedKeyRow(-1), pressedKeyCol(-1),
60 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), 60 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0),
61 configdlg(0) 61 configdlg(0)
62 62
63{ 63{
64 64
65 // get the default font 65 // get the default font
66 Config *config = new Config( "qpe" ); 66 Config *config = new Config( "qpe" );
67 config->setGroup( "Appearance" ); 67 config->setGroup( "Appearance" );
68 QString familyStr = config->readEntry( "FontFamily", "smallsmooth" ); 68 QString familyStr = config->readEntry( "FontFamily", "smallsmooth" );
69 delete config; 69 delete config;
70 70
71 config = new Config("multikey"); 71 config = new Config("multikey");
72 config->setGroup ("general"); 72 config->setGroup ("general");
73 usePicks = config->readBoolEntry ("usePickboard", 0); // default closed 73 usePicks = config->readBoolEntry ("usePickboard", 0); // default closed
74 useRepeat = config->readBoolEntry ("useRepeat", 1); 74 useRepeat = config->readBoolEntry ("useRepeat", 1);
75 delete config; 75 delete config;
76 76
77 77
78 setFont( QFont( familyStr, 10 ) ); 78 setFont( QFont( familyStr, 10 ) );
79 79
80 picks = new KeyboardPicks( this ); 80 picks = new KeyboardPicks( this );
81 picks->setFont( QFont( familyStr, 10 ) ); 81 picks->setFont( QFont( familyStr, 10 ) );
82 picks->initialise(); 82 picks->initialise();
83 if (usePicks) { 83 if (usePicks) {
84 84
85 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 85 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
86 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 86 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
87 87
88 } else picks->hide(); 88 } else picks->hide();
89 89
90 loadKeyboardColors(); 90 loadKeyboardColors();
91 91
92 keys = new Keys(); 92 keys = new Keys();
93 93
94 repeatTimer = new QTimer( this ); 94 repeatTimer = new QTimer( this );
95 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); 95 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
96 96
97 QCopChannel* kbdChannel = new QCopChannel("MultiKey/Keyboard", this); 97 QCopChannel* kbdChannel = new QCopChannel("MultiKey/Keyboard", this);
98 connect(kbdChannel, SIGNAL(received(const QCString&,const QByteArray&)), 98 connect(kbdChannel, SIGNAL(received(const QCString&,const QByteArray&)),
99 this, SLOT(receive(const QCString&,const QByteArray&))); 99 this, SLOT(receive(const QCString&,const QByteArray&)));
100} 100}
101 101
102Keyboard::~Keyboard() { 102Keyboard::~Keyboard() {
103 103
104 if ( configdlg ) { 104 if ( configdlg ) {
105 delete configdlg; 105 delete configdlg;
106 configdlg = 0; 106 configdlg = 0;
107 } 107 }
108 108
109} 109}
110 110
111/* Keyboard::resizeEvent {{{1 */ 111/* Keyboard::resizeEvent {{{1 */
112void Keyboard::resizeEvent(QResizeEvent*) 112void Keyboard::resizeEvent(QResizeEvent*)
113{ 113{
114 int ph = picks->sizeHint().height(); 114 int ph = picks->sizeHint().height();
115 picks->setGeometry( 0, 0, width(), ph ); 115 picks->setGeometry( 0, 0, width(), ph );
116 keyHeight = (height()-(usePicks ? ph : 0))/(keys->rows()?keys->rows():1); 116 keyHeight = (height()-(usePicks ? ph : 0))/(keys->rows()?keys->rows():1);
117 117
118 int nk; // number of keys? 118 int nk; // number of keys?
119 if ( useLargeKeys ) { 119 if ( useLargeKeys ) {
120 nk = 15; 120 nk = 15;
121 } else { 121 } else {
122 nk = 19; 122 nk = 19;
123 } 123 }
124 defaultKeyWidth = (width()/nk)/2; 124 defaultKeyWidth = (width()/nk)/2;
125 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? 125 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces?
126 126
127} 127}
128 128
129/* KeyboardPicks::initialize {{{1 */ 129/* KeyboardPicks::initialize {{{1 */
130void KeyboardPicks::initialise() 130void KeyboardPicks::initialise()
131{ 131{
132 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 132 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
133 mode = 0; 133 mode = 0;
134 dc = new KeyboardConfig(this); 134 dc = new KeyboardConfig(this);
135 configs.append(dc); 135 configs.append(dc);
136} 136}
137 137
138/* KeyboardPicks::sizeHint {{{1 */ 138/* KeyboardPicks::sizeHint {{{1 */
139QSize KeyboardPicks::sizeHint() const 139QSize KeyboardPicks::sizeHint() const
140{ 140{
141 return QSize(240,fontMetrics().lineSpacing()); 141 return QSize(240,fontMetrics().lineSpacing());
142} 142}
143 143
144 144
145/* KeyboardConfig::generateText {{{1 */ 145/* KeyboardConfig::generateText {{{1 */
146void KeyboardConfig::generateText(const QString &s) 146void KeyboardConfig::generateText(const QString &s)
147{ 147{
148#if defined(Q_WS_QWS) || defined(_WS_QWS_) 148#if defined(Q_WS_QWS) || defined(_WS_QWS_)
149 for (int i=0; i<(int)backspaces; i++) { 149 for (int i=0; i<(int)backspaces; i++) {
150 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); 150 parent->emitKey( 0, ::Qt::Key_Backspace, 0, true, false );
151 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); 151 parent->emitKey( 0, ::Qt::Key_Backspace, 0, false, false );
152 } 152 }
153 for (int i=0; i<(int)s.length(); i++) { 153 for (int i=0; i<(int)s.length(); i++) {
154 parent->emitKey( s[i].unicode(), 0, 0, true, false ); 154 parent->emitKey( s[i].unicode(), 0, 0, true, false );
155 parent->emitKey( s[i].unicode(), 0, 0, false, false ); 155 parent->emitKey( s[i].unicode(), 0, 0, false, false );
156 } 156 }
157 parent->emitKey( 0, Qt::Key_Space, 0, true, false ); 157 parent->emitKey( 0, ::Qt::Key_Space, 0, true, false );
158 parent->emitKey( 0, Qt::Key_Space, 0, false, false ); 158 parent->emitKey( 0, ::Qt::Key_Space, 0, false, false );
159 backspaces = 0; 159 backspaces = 0;
160#endif 160#endif
161} 161}
162 162
163 163
164 164
165 165
166/* Keyboard::paintEvent {{{1 */ 166/* Keyboard::paintEvent {{{1 */
167void Keyboard::paintEvent(QPaintEvent* e) 167void Keyboard::paintEvent(QPaintEvent* e)
168{ 168{
169 QPainter painter(this); 169 QPainter painter(this);
170 painter.setClipRect(e->rect()); 170 painter.setClipRect(e->rect());
171 drawKeyboard( painter ); 171 drawKeyboard( painter );
172 picks->dc->draw( &painter ); 172 picks->dc->draw( &painter );
173} 173}
174 174
175 175
176/* Keyboard::drawKeyboard {{{1 */ 176/* Keyboard::drawKeyboard {{{1 */
177 177
178void Keyboard::drawKeyboard(QPainter &p, int row, int col) 178void Keyboard::drawKeyboard(QPainter &p, int row, int col)
179{ 179{
180 180
181 181
182 if (row != -1 && col != -1) { //just redraw one key 182 if (row != -1 && col != -1) { //just redraw one key
183 183
184 int x = 0; 184 int x = 0;
185 for (int i = 0; i < col; i++) { 185 for (int i = 0; i < col; i++) {
186 186
187 x += keys->width(row, i) * defaultKeyWidth; 187 x += keys->width(row, i) * defaultKeyWidth;
188 } 188 }
189 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 189 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
190 190
191 int keyWidth = keys->width(row, col); 191 int keyWidth = keys->width(row, col);
192 192
193 p.fillRect(x + 1, y + 1, 193 p.fillRect(x + 1, y + 1,
194 keyWidth * defaultKeyWidth - 1, keyHeight - 1, 194 keyWidth * defaultKeyWidth - 1, keyHeight - 1,
195 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); 195 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor);
196 196
197 QImage *pix = keys->pix(row,col); 197 QImage *pix = keys->pix(row,col);
198 198
199 ushort c = keys->uni(row, col); 199 ushort c = keys->uni(row, col);
200 200
201 p.setPen(textcolor); 201 p.setPen(textcolor);
202 if (!pix) { 202 if (!pix) {
203 if ((shift || lock) && keys->shift(c)) 203 if ((shift || lock) && keys->shift(c))
204 204
205 if (circumflex && keys->circumflex(keys->shift(c))) 205 if (circumflex && keys->circumflex(keys->shift(c)))
206 c = keys->circumflex(keys->shift(c)); 206 c = keys->circumflex(keys->shift(c));
207 else if (diaeresis && keys->diaeresis(keys->shift(c))) 207 else if (diaeresis && keys->diaeresis(keys->shift(c)))
208 c = keys->diaeresis(keys->shift(c)); 208 c = keys->diaeresis(keys->shift(c));
209 else if (baccent && keys->baccent(keys->shift(c))) 209 else if (baccent && keys->baccent(keys->shift(c)))
210 c = keys->baccent(keys->shift(c)); 210 c = keys->baccent(keys->shift(c));
211 else if (accent && keys->accent(keys->shift(c))) 211 else if (accent && keys->accent(keys->shift(c)))
212 c = keys->accent(keys->shift(c)); 212 c = keys->accent(keys->shift(c));
213 else if (meta && keys->meta(keys->shift(c))) 213 else if (meta && keys->meta(keys->shift(c)))
214 c = keys->meta(keys->shift(c)); 214 c = keys->meta(keys->shift(c));
215 else 215 else
216 c = keys->shift(c); 216 c = keys->shift(c);
217 217
218 else if (meta && keys->meta(c)) 218 else if (meta && keys->meta(c))
219 c = keys->meta(c); 219 c = keys->meta(c);
220 else if (circumflex && keys->circumflex(c)) 220 else if (circumflex && keys->circumflex(c))
221 c = keys->circumflex(c); 221 c = keys->circumflex(c);
222 else if (baccent && keys->baccent(c)) 222 else if (baccent && keys->baccent(c))
223 c = keys->baccent(c); 223 c = keys->baccent(c);
224 else if (accent && keys->accent(c)) 224 else if (accent && keys->accent(c))
225 c = keys->accent(c); 225 c = keys->accent(c);
226 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { 226 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) {
227 227
228 // the diaeresis key itself has to be in the diaeresisMap, 228 // the diaeresis key itself has to be in the diaeresisMap,
229 // or just do this to make it display the diaeresis char. 229 // or just do this to make it display the diaeresis char.
230 230
231 if (c == 0x2c6) 231 if (c == 0x2c6)
232 c = 0xa8; 232 c = 0xa8;
233 else 233 else
234 c = keys->diaeresis(c); 234 c = keys->diaeresis(c);
235 } 235 }
236 236
237 p.drawText(x, y, 237 p.drawText(x, y,
238 defaultKeyWidth * keyWidth + 3, keyHeight, 238 defaultKeyWidth * keyWidth + 3, keyHeight,
239 AlignCenter, (QChar)c); 239 AlignCenter, (QChar)c);
240 } 240 }
241 else 241 else
242 // center the image in the middle of the key 242 // center the image in the middle of the key
243 p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, 243 p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1,
244 y + (keyHeight - pix->height())/2 + 1, 244 y + (keyHeight - pix->height())/2 + 1,
245 *pix ); 245 *pix );
246 246
247 // this fixes the problem that the very right end of the board's vertical line 247 // this fixes the problem that the very right end of the board's vertical line
248 // gets painted over, because it's one pixel shorter than all other keys 248 // gets painted over, because it's one pixel shorter than all other keys
249 p.setPen(keycolor_lines); 249 p.setPen(keycolor_lines);
250 p.drawLine(width() - 1, 0, width() - 1, height()); 250 p.drawLine(width() - 1, 0, width() - 1, height());
251 251
252 } else { 252 } else {
253 253
254 254
255 p.fillRect(0, 0, width(), height(), keycolor); 255 p.fillRect(0, 0, width(), height(), keycolor);
256 256
257 for (row = 1; row <= keys->rows(); row++) { 257 for (row = 1; row <= keys->rows(); row++) {
258 258
259 int x = 0; 259 int x = 0;
260 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 260 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
261 261
262 p.setPen(keycolor_lines); 262 p.setPen(keycolor_lines);
263 p.drawLine(x, y, x + width(), y); 263 p.drawLine(x, y, x + width(), y);
264 264
265 for (int col = 0; col < keys->numKeys(row); col++) { 265 for (int col = 0; col < keys->numKeys(row); col++) {
266 266
267 QImage *pix = keys->pix(row, col); 267 QImage *pix = keys->pix(row, col);
268 int keyWidth = keys->width(row, col); 268 int keyWidth = keys->width(row, col);
269 269
270 270
271 int keyWidthPix = defaultKeyWidth * keyWidth; 271 int keyWidthPix = defaultKeyWidth * keyWidth;
272 272
273 if (keys->pressed(row, col)) 273 if (keys->pressed(row, col))
274 p.fillRect(x+1, y+1, keyWidthPix - 1, 274 p.fillRect(x+1, y+1, keyWidthPix - 1,
275 keyHeight - 1, keycolor_pressed); 275 keyHeight - 1, keycolor_pressed);
276 276
277 ushort c = keys->uni(row, col); 277 ushort c = keys->uni(row, col);
278 278
279 p.setPen(textcolor); 279 p.setPen(textcolor);
280 if (!pix) { 280 if (!pix) {
281 if ((shift || lock) && keys->shift(c)) 281 if ((shift || lock) && keys->shift(c))
282 282
283 if (circumflex && keys->circumflex(keys->shift(c))) 283 if (circumflex && keys->circumflex(keys->shift(c)))
284 c = keys->circumflex(keys->shift(c)); 284 c = keys->circumflex(keys->shift(c));
285 else if (diaeresis && keys->diaeresis(keys->shift(c))) 285 else if (diaeresis && keys->diaeresis(keys->shift(c)))
286 c = keys->diaeresis(keys->shift(c)); 286 c = keys->diaeresis(keys->shift(c));
287 else if (baccent && keys->baccent(keys->shift(c))) 287 else if (baccent && keys->baccent(keys->shift(c)))
288 c = keys->baccent(keys->shift(c)); 288 c = keys->baccent(keys->shift(c));
289 else if (accent && keys->accent(keys->shift(c))) 289 else if (accent && keys->accent(keys->shift(c)))
290 c = keys->accent(keys->shift(c)); 290 c = keys->accent(keys->shift(c));
291 else if (meta && keys->meta(keys->shift(c))) 291 else if (meta && keys->meta(keys->shift(c)))
292 c = keys->meta(keys->shift(c)); 292 c = keys->meta(keys->shift(c));
293 else 293 else
294 c = keys->shift(c); 294 c = keys->shift(c);
295 295
296 else if (meta && keys->meta(c)) 296 else if (meta && keys->meta(c))
297 c = keys->meta(c); 297 c = keys->meta(c);
298 else if (circumflex && keys->circumflex(c)) 298 else if (circumflex && keys->circumflex(c))
299 c = keys->circumflex(c); 299 c = keys->circumflex(c);
300 else if (baccent && keys->baccent(c)) 300 else if (baccent && keys->baccent(c))
301 c = keys->baccent(c); 301 c = keys->baccent(c);
302 else if (accent && keys->accent(c)) 302 else if (accent && keys->accent(c))
303 c = keys->accent(c); 303 c = keys->accent(c);
304 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { 304 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) {
305 305
306 if (c == 0x2c6) 306 if (c == 0x2c6)
307 c = 0xa8; 307 c = 0xa8;
308 else 308 else
309 c = keys->diaeresis(c); 309 c = keys->diaeresis(c);
310 } 310 }
311 311
312 p.drawText(x, y, 312 p.drawText(x, y,
313 keyWidthPix + 3, keyHeight, 313 keyWidthPix + 3, keyHeight,
314 AlignCenter, (QChar)c); 314 AlignCenter, (QChar)c);
315 } 315 }
316 else { 316 else {
317 // center the image in the middle of the key 317 // center the image in the middle of the key
318 pix->setColor(1, textcolor.rgb()); 318 pix->setColor(1, textcolor.rgb());
319 p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, 319 p.drawImage( x + (keyWidthPix - pix->width())/2 + 1,
320 y + (keyHeight - pix->height())/2 + 1, 320 y + (keyHeight - pix->height())/2 + 1,
321 QImage(*pix) ); 321 QImage(*pix) );
322 } 322 }
323 323
324 p.setPen(keycolor_lines); 324 p.setPen(keycolor_lines);
325 p.drawLine(x, y, x, y + keyHeight); 325 p.drawLine(x, y, x, y + keyHeight);
326 326
327 x += keyWidthPix; 327 x += keyWidthPix;
328 } 328 }
329 329
330 330
331 } 331 }
332 p.setPen(keycolor_lines); 332 p.setPen(keycolor_lines);
333 p.drawLine(0, height() - 1, width(), height() - 1); 333 p.drawLine(0, height() - 1, width(), height() - 1);
334 p.drawLine(width() - 1, 0, width() - 1, height()); 334 p.drawLine(width() - 1, 0, width() - 1, height());
335 } 335 }
336 336
337} 337}
338 338
339 339
340/* Keyboard::mousePressEvent {{{1 */ 340/* Keyboard::mousePressEvent {{{1 */
341void Keyboard::mousePressEvent(QMouseEvent *e) 341void Keyboard::mousePressEvent(QMouseEvent *e)
342{ 342{
343 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; 343 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1;
344 if (row > 5) row = 5; 344 if (row > 5) row = 5;
345 345
346 // figure out the column 346 // figure out the column
347 int col = 0; 347 int col = 0;
348 for (int w = 0; e->x() >= w; col++) 348 for (int w = 0; e->x() >= w; col++)
349 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys 349 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys
350 w += keys->width(row,col) * defaultKeyWidth; 350 w += keys->width(row,col) * defaultKeyWidth;
351 else break; 351 else break;
352 352
353 if (col <= 0) return; 353 if (col <= 0) return;
354 354
355 col --; // rewind one... 355 col --; // rewind one...
356 356
357 qkeycode = keys->qcode(row, col); 357 qkeycode = keys->qcode(row, col);
358 unicode = keys->uni(row, col); 358 unicode = keys->uni(row, col);
359 359
360 // might need to repaint if two or more of the same keys. 360 // might need to repaint if two or more of the same keys.
361 // should be faster if just paint one key even though multiple keys exist. 361 // should be faster if just paint one key even though multiple keys exist.
362 bool need_repaint = FALSE; 362 bool need_repaint = FALSE;
363 363
364 // circumflex and diaeresis support 364 // circumflex and diaeresis support
365 // messy to have this here, but too hard to implement any other method 365 // messy to have this here, but too hard to implement any other method
366 if (unicode == 0x2c6) { 366 if (unicode == 0x2c6) {
367 367
368 unicode = 0; 368 unicode = 0;
369 if (shift || lock) { 369 if (shift || lock) {
370 370
371 // diaeresis 371 // diaeresis
372 qkeycode = 0x2001; 372 qkeycode = 0x2001;
373 } 373 }
374 else { 374 else {
375 375
376 // circumflex 376 // circumflex
377 qkeycode = 0x2000; 377 qkeycode = 0x2000;
378 } 378 }
379 } 379 }
380 380
381 // Back accent character support 381 // Back accent character support
382 382
383 // the keys from 2c6 ~ 2cf should be used instead of the ascii one 383 // the keys from 2c6 ~ 2cf should be used instead of the ascii one
384 if (unicode == 0x2cb) { 384 if (unicode == 0x2cb) {
385 385
386 unicode = 0; 386 unicode = 0;
387 if (shift || lock) { 387 if (shift || lock) {
388 388
389 // circumblex 389 // circumblex
390 qkeycode = 0x2000; 390 qkeycode = 0x2000;
391 } 391 }
392 else { 392 else {
393 393
394 // back accent 394 // back accent
395 qkeycode = 0x2002; 395 qkeycode = 0x2002;
396 } 396 }
397 } 397 }
398 398
399 // Accent character support 399 // Accent character support
400 400
401 if (unicode == 0x2ca) { 401 if (unicode == 0x2ca) {
402 402
403 unicode = 0; 403 unicode = 0;
404 if (shift || lock) { 404 if (shift || lock) {
405 405
406 // diaeresis 406 // diaeresis
407 qkeycode = 0x2001; 407 qkeycode = 0x2001;
408 } 408 }
409 else { 409 else {
410 410
411 // accent 411 // accent
412 qkeycode = 0x2003; 412 qkeycode = 0x2003;
413 } 413 }
414 } 414 }
415 415
416 416
417 if (unicode == 0) { // either Qt char, or nothing 417 if (unicode == 0) { // either Qt char, or nothing
418 418
419 if (qkeycode == Qt::Key_F1) { // toggle the pickboard 419 if (qkeycode == Qt::Key_F1) { // toggle the pickboard
420 420
421 if ( configdlg ) { 421 if ( configdlg ) {
422 422
423 delete configdlg; 423 delete configdlg;
424 configdlg = 0; 424 configdlg = 0;
425 } 425 }
426 else { 426 else {
427 configdlg = new ConfigDlg (); 427 configdlg = new ConfigDlg ();
428 connect(configdlg, SIGNAL(setMapToDefault()), 428 connect(configdlg, SIGNAL(setMapToDefault()),
429 this, SLOT(setMapToDefault())); 429 this, SLOT(setMapToDefault()));
430 connect(configdlg, SIGNAL(setMapToFile(QString)), 430 connect(configdlg, SIGNAL(setMapToFile(QString)),
431 this, SLOT(setMapToFile(QString))); 431 this, SLOT(setMapToFile(QString)));
432 connect(configdlg, SIGNAL(pickboardToggled(bool)), 432 connect(configdlg, SIGNAL(pickboardToggled(bool)),
433 this, SLOT(togglePickboard(bool))); 433 this, SLOT(togglePickboard(bool)));
434 connect(configdlg, SIGNAL(repeatToggled(bool)), 434 connect(configdlg, SIGNAL(repeatToggled(bool)),
435 this, SLOT(toggleRepeat(bool))); 435 this, SLOT(toggleRepeat(bool)));
436 connect(configdlg, SIGNAL(reloadKeyboard()), 436 connect(configdlg, SIGNAL(reloadKeyboard()),
437 this, SLOT(reloadKeyboard())); 437 this, SLOT(reloadKeyboard()));
438 connect(configdlg, SIGNAL(configDlgClosed()), 438 connect(configdlg, SIGNAL(configDlgClosed()),
439 this, SLOT(cleanupConfigDlg())); 439 this, SLOT(cleanupConfigDlg()));
440 connect(configdlg, SIGNAL(reloadSw()), 440 connect(configdlg, SIGNAL(reloadSw()),
441 this, SLOT(reloadSw())); 441 this, SLOT(reloadSw()));
442 configdlg->showMaximized(); 442 configdlg->showMaximized();
443 configdlg->show(); 443 configdlg->show();
444 configdlg->raise(); 444 configdlg->raise();
445 } 445 }
446 446
447 } else if (qkeycode == Qt::Key_Control) { 447 } else if (qkeycode == Qt::Key_Control) {
448 need_repaint = TRUE; 448 need_repaint = TRUE;
449 449
450 if (ctrl) { 450 if (ctrl) {
451 451
452 *ctrl = 0; 452 *ctrl = 0;
453 ctrl = 0; 453 ctrl = 0;
454 454
455 } else { 455 } else {
456 456
457 ctrl = keys->pressedPtr(row, col); 457 ctrl = keys->pressedPtr(row, col);
458 need_repaint = TRUE; 458 need_repaint = TRUE;
459 *ctrl = !keys->pressed(row, col); 459 *ctrl = !keys->pressed(row, col);
460 460
461 } 461 }
462 462
463 } else if (qkeycode == Qt::Key_Alt) { 463 } else if (qkeycode == Qt::Key_Alt) {
464 need_repaint = TRUE; 464 need_repaint = TRUE;
465 465
466 if (alt) { 466 if (alt) {
467 *alt = 0; 467 *alt = 0;
468 alt = 0; 468 alt = 0;
469 469
470 } else { 470 } else {
471 471
472 alt = keys->pressedPtr(row, col); 472 alt = keys->pressedPtr(row, col);
473 need_repaint = TRUE; 473 need_repaint = TRUE;
474 *alt = !keys->pressed(row, col); 474 *alt = !keys->pressed(row, col);
475 } 475 }
476 476
477 } else if (qkeycode == Qt::Key_Shift) { 477 } else if (qkeycode == Qt::Key_Shift) {
478 need_repaint = TRUE; 478 need_repaint = TRUE;
479 479
480 if (shift) { 480 if (shift) {
481 *shift = 0; 481 *shift = 0;
482 shift = 0; 482 shift = 0;
483 } 483 }
484 else { 484 else {
485 shift = keys->pressedPtr(row, col); 485 shift = keys->pressedPtr(row, col);
486 *shift = 1; 486 *shift = 1;
487 if (lock) { 487 if (lock) {
488 *lock = 0; 488 *lock = 0;
489 lock = 0; 489 lock = 0;
490 } 490 }
491 } 491 }
492 492
493 493
494 /* 494 /*
495 * want to be able to hit circumflex/diaeresis -> shift 495 * want to be able to hit circumflex/diaeresis -> shift
496 * to type in shifted circumflex/diaeresis chars. 496 * to type in shifted circumflex/diaeresis chars.
497 * same thing with meta 497 * same thing with meta
498 498
499 if (meta) { *meta = 0; meta = 0; } 499 if (meta) { *meta = 0; meta = 0; }
500 if (circumflex) { *circumflex = 0; circumflex = 0; } 500 if (circumflex) { *circumflex = 0; circumflex = 0; }
501 if (diaeresis) { *diaeresis = 0; diaeresis = 0; } 501 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
502 502
503 */ 503 */
504 504
505 } else if (qkeycode == Qt::Key_CapsLock) { 505 } else if (qkeycode == Qt::Key_CapsLock) {
506 need_repaint = TRUE; 506 need_repaint = TRUE;
507 507
508 if (lock) { 508 if (lock) {
509 *lock = 0; 509 *lock = 0;
510 lock = 0; 510 lock = 0;
511 } 511 }
512 else { 512 else {
513 lock = keys->pressedPtr(row, col);; 513 lock = keys->pressedPtr(row, col);;
514 *lock = true;; 514 *lock = true;;
515 if (shift) { 515 if (shift) {
516 *shift = 0; 516 *shift = 0;
517 shift = 0; 517 shift = 0;
518 } 518 }
519 } 519 }
520 520
521 /* 521 /*
522 if (meta) { *meta = 0; meta = 0; } 522 if (meta) { *meta = 0; meta = 0; }
523 if (circumflex) { *circumflex = 0; circumflex = 0; } 523 if (circumflex) { *circumflex = 0; circumflex = 0; }
524 if (diaeresis) { *diaeresis = 0; diaeresis = 0; } 524 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
525 */ 525 */
526 526
527 } else if (qkeycode == Qt::Key_Meta) { 527 } else if (qkeycode == Qt::Key_Meta) {
528 need_repaint = TRUE; 528 need_repaint = TRUE;
529 529
530 if (meta) { 530 if (meta) {
531 *meta = 0; 531 *meta = 0;
532 meta = 0; 532 meta = 0;
533 533
534 } else { 534 } else {
535 535
536 meta = keys->pressedPtr(row, col); 536 meta = keys->pressedPtr(row, col);
537 *meta = true; 537 *meta = true;
538 } 538 }
539 539
540 // reset all the other keys 540 // reset all the other keys
541 if (shift) { *shift = 0; shift = 0; } 541 if (shift) { *shift = 0; shift = 0; }
542 if (lock) { *lock = 0; lock = 0; } 542 if (lock) { *lock = 0; lock = 0; }