summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 89937cf..e3d3928 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -186,121 +186,123 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
186 if (shift || lock) 186 if (shift || lock)
187 c = keys->shift(c); 187 c = keys->shift(c);
188 if (meta) { 188 if (meta) {
189 189
190 c = keys->meta(c); 190 c = keys->meta(c);
191 } 191 }
192 p.drawText(x, y, 192 p.drawText(x, y,
193 defaultKeyWidth * keyWidth + 3, keyHeight, 193 defaultKeyWidth * keyWidth + 3, keyHeight,
194 AlignCenter, (QChar)c); 194 AlignCenter, (QChar)c);
195 } 195 }
196 else 196 else
197 // center the image in the middle of the key 197 // center the image in the middle of the key
198 p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2, 198 p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2,
199 y + (keyHeight - pix->height())/2 + 1, 199 y + (keyHeight - pix->height())/2 + 1,
200 *pix ); 200 *pix );
201 201
202 // this fixes the problem that the very right end of the board's vertical line 202 // this fixes the problem that the very right end of the board's vertical line
203 // gets painted over, because it's one pixel shorter than all other keys 203 // gets painted over, because it's one pixel shorter than all other keys
204 p.setPen(keycolor_lines); 204 p.setPen(keycolor_lines);
205 p.drawLine(width() - 1, 0, width() - 1, height()); 205 p.drawLine(width() - 1, 0, width() - 1, height());
206 206
207 } else { 207 } else {
208 208
209 209
210 p.fillRect(0, 0, width(), height(), keycolor); 210 p.fillRect(0, 0, width(), height(), keycolor);
211 211
212 for (row = 1; row <= 5; row++) { 212 for (row = 1; row <= 5; row++) {
213 213
214 int x = 0; 214 int x = 0;
215 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 215 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
216 216
217 p.setPen(keycolor_lines); 217 p.setPen(keycolor_lines);
218 p.drawLine(x, y, x + width(), y); 218 p.drawLine(x, y, x + width(), y);
219 219
220 for (int col = 0; col < keys->numKeys(row); col++) { 220 for (int col = 0; col < keys->numKeys(row); col++) {
221 221
222 QPixmap *pix = keys->pix(row, col); 222 QPixmap *pix = keys->pix(row, col);
223 int keyWidth = keys->width(row, col); 223 int keyWidth = keys->width(row, col);
224 224
225 225
226 int keyWidthPix = defaultKeyWidth * keyWidth; 226 int keyWidthPix = defaultKeyWidth * keyWidth;
227 227
228 if (keys->pressed(row, col)) 228 if (keys->pressed(row, col))
229 p.fillRect(x+1, y+1, keyWidthPix - 1, 229 p.fillRect(x+1, y+1, keyWidthPix - 1,
230 keyHeight - 1, keycolor_pressed); 230 keyHeight - 1, keycolor_pressed);
231 231
232 ushort c = keys->uni(row, col); 232 ushort c = keys->uni(row, col);
233 233
234 p.setPen(textcolor);
234 if (!pix) { 235 if (!pix) {
235 if ((shift || lock) && keys->shift(c)) 236 if ((shift || lock) && keys->shift(c))
236 c = keys->shift(c); 237 c = keys->shift(c);
237 else if (meta && keys->meta(c)) 238 else if (meta && keys->meta(c))
238 c = keys->meta(c); 239 c = keys->meta(c);
239 240
240 p.drawText(x, y, 241 p.drawText(x, y,
241 defaultKeyWidth * keyWidth + 3, keyHeight, 242 keyWidthPix + 3, keyHeight,
242 AlignCenter, (QChar)c); 243 AlignCenter, (QChar)c);
243 } 244 }
244 else { 245 else {
245 // center the image in the middle of the key 246 // center the image in the middle of the key
246 p.drawPixmap( x + (keyWidthPix - pix->width())/2, 247 p.drawPixmap( x + (keyWidthPix - pix->width())/2,
247 y + (keyHeight - pix->height())/2 + 1, 248 y + (keyHeight - pix->height())/2 + 1,
248 QPixmap(*pix) ); 249 QPixmap(*pix) );
249 } 250 }
250 251
251 p.setPen(keycolor_lines); 252 p.setPen(keycolor_lines);
252 p.drawLine(x, y, x, y + keyHeight); 253 p.drawLine(x, y, x, y + keyHeight);
253 254
254 x += keyWidthPix; 255 x += keyWidthPix;
255 } 256 }
256 257
257 258
258 } 259 }
260 p.setPen(keycolor_lines);
259 p.drawLine(0, height() - 1, width(), height() - 1); 261 p.drawLine(0, height() - 1, width(), height() - 1);
260 p.drawLine(width() - 1, 0, width() - 1, height()); 262 p.drawLine(width() - 1, 0, width() - 1, height());
261 } 263 }
262 264
263} 265}
264 266
265 267
266/* Keyboard::mousePressEvent {{{1 */ 268/* Keyboard::mousePressEvent {{{1 */
267void Keyboard::mousePressEvent(QMouseEvent *e) 269void Keyboard::mousePressEvent(QMouseEvent *e)
268{ 270{
269 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; 271 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1;
270 if (row > 5) row = 5; 272 if (row > 5) row = 5;
271 273
272 // figure out the column 274 // figure out the column
273 int col = 0; 275 int col = 0;
274 for (int w = 0; e->x() >= w; col++) 276 for (int w = 0; e->x() >= w; col++)
275 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys 277 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys
276 w += keys->width(row,col) * defaultKeyWidth; 278 w += keys->width(row,col) * defaultKeyWidth;
277 else break; 279 else break;
278 280
279 if (col <= 0) return; 281 if (col <= 0) return;
280 282
281 col --; // rewind one... 283 col --; // rewind one...
282 284
283 qkeycode = keys->qcode(row, col); 285 qkeycode = keys->qcode(row, col);
284 unicode = keys->uni(row, col); 286 unicode = keys->uni(row, col);
285 287
286 // might need to repaint if two or more of the same keys. 288 // might need to repaint if two or more of the same keys.
287 // should be faster if just paint one key even though multiple keys exist. 289 // should be faster if just paint one key even though multiple keys exist.
288 bool need_repaint = FALSE; 290 bool need_repaint = FALSE;
289 291
290 if (unicode == 0) { // either Qt char, or nothing 292 if (unicode == 0) { // either Qt char, or nothing
291 293
292 if (qkeycode == Qt::Key_F1) { // toggle the pickboard 294 if (qkeycode == Qt::Key_F1) { // toggle the pickboard
293 295
294 if ( configdlg ) { 296 if ( configdlg ) {
295 delete (ConfigDlg *) configdlg; 297 delete (ConfigDlg *) configdlg;
296 configdlg = 0; 298 configdlg = 0;
297 } 299 }
298 else { 300 else {
299 configdlg = new ConfigDlg (); 301 configdlg = new ConfigDlg ();
300 connect(configdlg, SIGNAL(setMapToDefault()), 302 connect(configdlg, SIGNAL(setMapToDefault()),
301 this, SLOT(setMapToDefault())); 303 this, SLOT(setMapToDefault()));
302 connect(configdlg, SIGNAL(setMapToFile(QString)), 304 connect(configdlg, SIGNAL(setMapToFile(QString)),
303 this, SLOT(setMapToFile(QString))); 305 this, SLOT(setMapToFile(QString)));
304 connect(configdlg, SIGNAL(pickboardToggled(bool)), 306 connect(configdlg, SIGNAL(pickboardToggled(bool)),
305 this, SLOT(togglePickboard(bool))); 307 this, SLOT(togglePickboard(bool)));
306 connect(configdlg, SIGNAL(repeatToggled(bool)), 308 connect(configdlg, SIGNAL(repeatToggled(bool)),