-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 949164a..d5a7afd 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -204,128 +204,130 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col) | |||
204 | 204 | ||
205 | for (row = 1; row <= 5; row++) { | 205 | for (row = 1; row <= 5; row++) { |
206 | 206 | ||
207 | int x = 0; | 207 | int x = 0; |
208 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 208 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
209 | 209 | ||
210 | p.setPen(keycolor_lines); | 210 | p.setPen(keycolor_lines); |
211 | p.drawLine(x, y, x + width(), y); | 211 | p.drawLine(x, y, x + width(), y); |
212 | 212 | ||
213 | for (int col = 0; col < keys->numKeys(row); col++) { | 213 | for (int col = 0; col < keys->numKeys(row); col++) { |
214 | 214 | ||
215 | QPixmap *pix = keys->pix(row, col); | 215 | QPixmap *pix = keys->pix(row, col); |
216 | int keyWidth = keys->width(row, col); | 216 | int keyWidth = keys->width(row, col); |
217 | 217 | ||
218 | 218 | ||
219 | int keyWidthPix = defaultKeyWidth * keyWidth; | 219 | int keyWidthPix = defaultKeyWidth * keyWidth; |
220 | 220 | ||
221 | if (keys->pressed(row, col)) | 221 | if (keys->pressed(row, col)) |
222 | p.fillRect(x+1, y+1, keyWidthPix - 1, | 222 | p.fillRect(x+1, y+1, keyWidthPix - 1, |
223 | keyHeight - 1, keycolor_pressed); | 223 | keyHeight - 1, keycolor_pressed); |
224 | 224 | ||
225 | ushort c = keys->uni(row, col); | 225 | ushort c = keys->uni(row, col); |
226 | 226 | ||
227 | if (!pix) { | 227 | if (!pix) { |
228 | p.setPen(textcolor); | 228 | p.setPen(textcolor); |
229 | p.drawText(x, y, | 229 | p.drawText(x, y, |
230 | keyWidthPix, keyHeight, | 230 | keyWidthPix, keyHeight, |
231 | AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c); | 231 | AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c); |
232 | } | 232 | } |
233 | else { | 233 | else { |
234 | // center the image in the middle of the key | 234 | // center the image in the middle of the key |
235 | p.drawPixmap( x + (keyWidthPix - pix->width())/2, | 235 | p.drawPixmap( x + (keyWidthPix - pix->width())/2, |
236 | y + (keyHeight - pix->height())/2 + 1, | 236 | y + (keyHeight - pix->height())/2 + 1, |
237 | QPixmap(*pix) ); | 237 | QPixmap(*pix) ); |
238 | } | 238 | } |
239 | 239 | ||
240 | p.setPen(keycolor_lines); | 240 | p.setPen(keycolor_lines); |
241 | p.drawLine(x, y, x, y + keyHeight); | 241 | p.drawLine(x, y, x, y + keyHeight); |
242 | 242 | ||
243 | x += keyWidthPix; | 243 | x += keyWidthPix; |
244 | } | 244 | } |
245 | 245 | ||
246 | 246 | ||
247 | } | 247 | } |
248 | p.drawLine(0, height() - 1, width(), height() - 1); | 248 | p.drawLine(0, height() - 1, width(), height() - 1); |
249 | p.drawLine(width() - 1, 0, width() - 1, height()); | 249 | p.drawLine(width() - 1, 0, width() - 1, height()); |
250 | } | 250 | } |
251 | 251 | ||
252 | } | 252 | } |
253 | 253 | ||
254 | 254 | ||
255 | /* Keyboard::mousePressEvent {{{1 */ | 255 | /* Keyboard::mousePressEvent {{{1 */ |
256 | void Keyboard::mousePressEvent(QMouseEvent *e) | 256 | void Keyboard::mousePressEvent(QMouseEvent *e) |
257 | { | 257 | { |
258 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; | 258 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; |
259 | if (row > 5) row = 5; | 259 | if (row > 5) row = 5; |
260 | 260 | ||
261 | // figure out the column | 261 | // figure out the column |
262 | int col = 0; | 262 | int col = 0; |
263 | for (int w = 0; e->x() >= w; col++) | 263 | for (int w = 0; e->x() >= w; col++) |
264 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys | 264 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys |
265 | w += keys->width(row,col) * defaultKeyWidth; | 265 | w += keys->width(row,col) * defaultKeyWidth; |
266 | else break; | 266 | else break; |
267 | 267 | ||
268 | if (col <= 0) return; | ||
269 | |||
268 | col --; // rewind one... | 270 | col --; // rewind one... |
269 | 271 | ||
270 | qkeycode = keys->qcode(row, col); | 272 | qkeycode = keys->qcode(row, col); |
271 | unicode = keys->uni(row, col); | 273 | unicode = keys->uni(row, col); |
272 | 274 | ||
273 | // might need to repaint if two or more of the same keys. | 275 | // might need to repaint if two or more of the same keys. |
274 | // should be faster if just paint one key even though multiple keys exist. | 276 | // should be faster if just paint one key even though multiple keys exist. |
275 | bool need_repaint = FALSE; | 277 | bool need_repaint = FALSE; |
276 | 278 | ||
277 | if (unicode == 0) { // either Qt char, or nothing | 279 | if (unicode == 0) { // either Qt char, or nothing |
278 | 280 | ||
279 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard | 281 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard |
280 | 282 | ||
281 | if ( configdlg ) { | 283 | if ( configdlg ) { |
282 | delete (ConfigDlg *) configdlg; | 284 | delete (ConfigDlg *) configdlg; |
283 | configdlg = 0; | 285 | configdlg = 0; |
284 | } | 286 | } |
285 | else { | 287 | else { |
286 | configdlg = new ConfigDlg (); | 288 | configdlg = new ConfigDlg (); |
287 | connect(configdlg, SIGNAL(setMapToDefault()), | 289 | connect(configdlg, SIGNAL(setMapToDefault()), |
288 | this, SLOT(setMapToDefault())); | 290 | this, SLOT(setMapToDefault())); |
289 | connect(configdlg, SIGNAL(setMapToFile(QString)), | 291 | connect(configdlg, SIGNAL(setMapToFile(QString)), |
290 | this, SLOT(setMapToFile(QString))); | 292 | this, SLOT(setMapToFile(QString))); |
291 | connect(configdlg, SIGNAL(pickboardToggled(bool)), | 293 | connect(configdlg, SIGNAL(pickboardToggled(bool)), |
292 | this, SLOT(togglePickboard(bool))); | 294 | this, SLOT(togglePickboard(bool))); |
293 | connect(configdlg, SIGNAL(repeatToggled(bool)), | 295 | connect(configdlg, SIGNAL(repeatToggled(bool)), |
294 | this, SLOT(toggleRepeat(bool))); | 296 | this, SLOT(toggleRepeat(bool))); |
295 | connect(configdlg, SIGNAL(reloadKeyboard()), | 297 | connect(configdlg, SIGNAL(reloadKeyboard()), |
296 | this, SLOT(reloadKeyboard())); | 298 | this, SLOT(reloadKeyboard())); |
297 | configdlg->showMaximized(); | 299 | configdlg->showMaximized(); |
298 | configdlg->show(); | 300 | configdlg->show(); |
299 | configdlg->raise(); | 301 | configdlg->raise(); |
300 | } | 302 | } |
301 | 303 | ||
302 | } else if (qkeycode == Qt::Key_Control) { | 304 | } else if (qkeycode == Qt::Key_Control) { |
303 | ctrl = keys->pressedPtr(row, col); | 305 | ctrl = keys->pressedPtr(row, col); |
304 | need_repaint = TRUE; | 306 | need_repaint = TRUE; |
305 | *ctrl = !keys->pressed(row, col); | 307 | *ctrl = !keys->pressed(row, col); |
306 | 308 | ||
307 | } else if (qkeycode == Qt::Key_Alt) { | 309 | } else if (qkeycode == Qt::Key_Alt) { |
308 | alt = keys->pressedPtr(row, col); | 310 | alt = keys->pressedPtr(row, col); |
309 | need_repaint = TRUE; | 311 | need_repaint = TRUE; |
310 | *alt = !keys->pressed(row, col); | 312 | *alt = !keys->pressed(row, col); |
311 | 313 | ||
312 | } else if (qkeycode == Qt::Key_Shift) { | 314 | } else if (qkeycode == Qt::Key_Shift) { |
313 | need_repaint = TRUE; | 315 | need_repaint = TRUE; |
314 | 316 | ||
315 | if (shift) { | 317 | if (shift) { |
316 | *shift = 0; | 318 | *shift = 0; |
317 | shift = 0; | 319 | shift = 0; |
318 | } | 320 | } |
319 | else { | 321 | else { |
320 | shift = keys->pressedPtr(row, col); | 322 | shift = keys->pressedPtr(row, col); |
321 | *shift = 1; | 323 | *shift = 1; |
322 | if (lock) { | 324 | if (lock) { |
323 | *lock = 0; | 325 | *lock = 0; |
324 | lock = 0; | 326 | lock = 0; |
325 | } | 327 | } |
326 | } | 328 | } |
327 | 329 | ||
328 | } else if (qkeycode == Qt::Key_CapsLock) { | 330 | } else if (qkeycode == Qt::Key_CapsLock) { |
329 | need_repaint = TRUE; | 331 | need_repaint = TRUE; |
330 | 332 | ||
331 | if (lock) { | 333 | if (lock) { |