summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index c3ee8f3..92ea896 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -101,243 +101,243 @@ void Keyboard::resizeEvent(QResizeEvent*)
101 if ( useLargeKeys ) { 101 if ( useLargeKeys ) {
102 nk = 15; 102 nk = 15;
103 } else { 103 } else {
104 nk = 19; 104 nk = 19;
105 } 105 }
106 defaultKeyWidth = (width()/nk)/2; 106 defaultKeyWidth = (width()/nk)/2;
107 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? 107 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces?
108 108
109} 109}
110 110
111/* KeyboardPicks::initialize {{{1 */ 111/* KeyboardPicks::initialize {{{1 */
112void KeyboardPicks::initialise() 112void KeyboardPicks::initialise()
113{ 113{
114 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 114 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
115 mode = 0; 115 mode = 0;
116 dc = new KeyboardConfig(this); 116 dc = new KeyboardConfig(this);
117 configs.append(dc); 117 configs.append(dc);
118} 118}
119 119
120/* KeyboardPicks::sizeHint {{{1 */ 120/* KeyboardPicks::sizeHint {{{1 */
121QSize KeyboardPicks::sizeHint() const 121QSize KeyboardPicks::sizeHint() const
122{ 122{
123 return QSize(240,fontMetrics().lineSpacing()); 123 return QSize(240,fontMetrics().lineSpacing());
124} 124}
125 125
126 126
127/* KeyboardConfig::generateText {{{1 */ 127/* KeyboardConfig::generateText {{{1 */
128void KeyboardConfig::generateText(const QString &s) 128void KeyboardConfig::generateText(const QString &s)
129{ 129{
130#if defined(Q_WS_QWS) || defined(_WS_QWS_) 130#if defined(Q_WS_QWS) || defined(_WS_QWS_)
131 for (int i=0; i<(int)backspaces; i++) { 131 for (int i=0; i<(int)backspaces; i++) {
132 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); 132 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false );
133 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); 133 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false );
134 } 134 }
135 for (int i=0; i<(int)s.length(); i++) { 135 for (int i=0; i<(int)s.length(); i++) {
136 parent->emitKey( s[i].unicode(), 0, 0, true, false ); 136 parent->emitKey( s[i].unicode(), 0, 0, true, false );
137 parent->emitKey( s[i].unicode(), 0, 0, false, false ); 137 parent->emitKey( s[i].unicode(), 0, 0, false, false );
138 } 138 }
139 parent->emitKey( 0, Qt::Key_Space, 0, true, false ); 139 parent->emitKey( 0, Qt::Key_Space, 0, true, false );
140 parent->emitKey( 0, Qt::Key_Space, 0, false, false ); 140 parent->emitKey( 0, Qt::Key_Space, 0, false, false );
141 backspaces = 0; 141 backspaces = 0;
142#endif 142#endif
143} 143}
144 144
145 145
146 146
147 147
148/* Keyboard::paintEvent {{{1 */ 148/* Keyboard::paintEvent {{{1 */
149void Keyboard::paintEvent(QPaintEvent* e) 149void Keyboard::paintEvent(QPaintEvent* e)
150{ 150{
151 QPainter painter(this); 151 QPainter painter(this);
152 painter.setClipRect(e->rect()); 152 painter.setClipRect(e->rect());
153 drawKeyboard( painter ); 153 drawKeyboard( painter );
154 picks->dc->draw( &painter ); 154 picks->dc->draw( &painter );
155} 155}
156 156
157 157
158/* Keyboard::drawKeyboard {{{1 */ 158/* Keyboard::drawKeyboard {{{1 */
159 159
160void Keyboard::drawKeyboard(QPainter &p, int row, int col) 160void Keyboard::drawKeyboard(QPainter &p, int row, int col)
161{ 161{
162 162
163 163
164 if (row != -1 && col != -1) { //just redraw one key 164 if (row != -1 && col != -1) { //just redraw one key
165 165
166 int x = 0; 166 int x = 0;
167 for (int i = 0; i < col; i++) { 167 for (int i = 0; i < col; i++) {
168 168
169 x += keys->width(row, i) * defaultKeyWidth; 169 x += keys->width(row, i) * defaultKeyWidth;
170 } 170 }
171 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 171 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
172 172
173 int keyWidth = keys->width(row, col); 173 int keyWidth = keys->width(row, col);
174 174
175 p.fillRect(x + 1, y + 1, 175 p.fillRect(x + 1, y + 1,
176 keyWidth * defaultKeyWidth - 1, keyHeight - 1, 176 keyWidth * defaultKeyWidth - 1, keyHeight - 1,
177 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); 177 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor);
178 178
179 QImage *pix = keys->pix(row,col); 179 QImage *pix = keys->pix(row,col);
180 180
181 ushort c = keys->uni(row, col); 181 ushort c = keys->uni(row, col);
182 182
183 p.setPen(textcolor); 183 p.setPen(textcolor);
184 if (!pix) { 184 if (!pix) {
185 if (shift || lock) 185 if (shift || lock)
186 c = keys->shift(c); 186 c = keys->shift(c);
187 if (meta) { 187 if (meta) {
188 188
189 c = keys->meta(c); 189 c = keys->meta(c);
190 } 190 }
191 p.drawText(x, y, 191 p.drawText(x, y,
192 defaultKeyWidth * keyWidth + 3, keyHeight, 192 defaultKeyWidth * keyWidth + 3, keyHeight,
193 AlignCenter, (QChar)c); 193 AlignCenter, (QChar)c);
194 } 194 }
195 else 195 else
196 // center the image in the middle of the key 196 // center the image in the middle of the key
197 p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2, 197 p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1,
198 y + (keyHeight - pix->height())/2 + 1, 198 y + (keyHeight - pix->height())/2 + 1,
199 *pix ); 199 *pix );
200 200
201 // this fixes the problem that the very right end of the board's vertical line 201 // this fixes the problem that the very right end of the board's vertical line
202 // gets painted over, because it's one pixel shorter than all other keys 202 // gets painted over, because it's one pixel shorter than all other keys
203 p.setPen(keycolor_lines); 203 p.setPen(keycolor_lines);
204 p.drawLine(width() - 1, 0, width() - 1, height()); 204 p.drawLine(width() - 1, 0, width() - 1, height());
205 205
206 } else { 206 } else {
207 207
208 208
209 p.fillRect(0, 0, width(), height(), keycolor); 209 p.fillRect(0, 0, width(), height(), keycolor);
210 210
211 for (row = 1; row <= 5; row++) { 211 for (row = 1; row <= 5; row++) {
212 212
213 int x = 0; 213 int x = 0;
214 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 214 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
215 215
216 p.setPen(keycolor_lines); 216 p.setPen(keycolor_lines);
217 p.drawLine(x, y, x + width(), y); 217 p.drawLine(x, y, x + width(), y);
218 218
219 for (int col = 0; col < keys->numKeys(row); col++) { 219 for (int col = 0; col < keys->numKeys(row); col++) {
220 220
221 QImage *pix = keys->pix(row, col); 221 QImage *pix = keys->pix(row, col);
222 int keyWidth = keys->width(row, col); 222 int keyWidth = keys->width(row, col);
223 223
224 224
225 int keyWidthPix = defaultKeyWidth * keyWidth; 225 int keyWidthPix = defaultKeyWidth * keyWidth;
226 226
227 if (keys->pressed(row, col)) 227 if (keys->pressed(row, col))
228 p.fillRect(x+1, y+1, keyWidthPix - 1, 228 p.fillRect(x+1, y+1, keyWidthPix - 1,
229 keyHeight - 1, keycolor_pressed); 229 keyHeight - 1, keycolor_pressed);
230 230
231 ushort c = keys->uni(row, col); 231 ushort c = keys->uni(row, col);
232 232
233 p.setPen(textcolor); 233 p.setPen(textcolor);
234 if (!pix) { 234 if (!pix) {
235 if ((shift || lock) && keys->shift(c)) 235 if ((shift || lock) && keys->shift(c))
236 c = keys->shift(c); 236 c = keys->shift(c);
237 else if (meta && keys->meta(c)) 237 else if (meta && keys->meta(c))
238 c = keys->meta(c); 238 c = keys->meta(c);
239 239
240 p.drawText(x, y, 240 p.drawText(x, y,
241 keyWidthPix + 3, keyHeight, 241 keyWidthPix + 3, keyHeight,
242 AlignCenter, (QChar)c); 242 AlignCenter, (QChar)c);
243 } 243 }
244 else { 244 else {
245 // center the image in the middle of the key 245 // center the image in the middle of the key
246 pix->setColor(1, textcolor.rgb()); 246 pix->setColor(1, textcolor.rgb());
247 p.drawImage( x + (keyWidthPix - pix->width())/2, 247 p.drawImage( x + (keyWidthPix - pix->width())/2 + 1,
248 y + (keyHeight - pix->height())/2 + 1, 248 y + (keyHeight - pix->height())/2 + 1,
249 QImage(*pix) ); 249 QImage(*pix) );
250 } 250 }
251 251
252 p.setPen(keycolor_lines); 252 p.setPen(keycolor_lines);
253 p.drawLine(x, y, x, y + keyHeight); 253 p.drawLine(x, y, x, y + keyHeight);
254 254
255 x += keyWidthPix; 255 x += keyWidthPix;
256 } 256 }
257 257
258 258
259 } 259 }
260 p.setPen(keycolor_lines); 260 p.setPen(keycolor_lines);
261 p.drawLine(0, height() - 1, width(), height() - 1); 261 p.drawLine(0, height() - 1, width(), height() - 1);
262 p.drawLine(width() - 1, 0, width() - 1, height()); 262 p.drawLine(width() - 1, 0, width() - 1, height());
263 } 263 }
264 264
265} 265}
266 266
267 267
268/* Keyboard::mousePressEvent {{{1 */ 268/* Keyboard::mousePressEvent {{{1 */
269void Keyboard::mousePressEvent(QMouseEvent *e) 269void Keyboard::mousePressEvent(QMouseEvent *e)
270{ 270{
271 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; 271 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1;
272 if (row > 5) row = 5; 272 if (row > 5) row = 5;
273 273
274 // figure out the column 274 // figure out the column
275 int col = 0; 275 int col = 0;
276 for (int w = 0; e->x() >= w; col++) 276 for (int w = 0; e->x() >= w; col++)
277 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
278 w += keys->width(row,col) * defaultKeyWidth; 278 w += keys->width(row,col) * defaultKeyWidth;
279 else break; 279 else break;
280 280
281 if (col <= 0) return; 281 if (col <= 0) return;
282 282
283 col --; // rewind one... 283 col --; // rewind one...
284 284
285 qkeycode = keys->qcode(row, col); 285 qkeycode = keys->qcode(row, col);
286 unicode = keys->uni(row, col); 286 unicode = keys->uni(row, col);
287 287
288 // 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.
289 // 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.
290 bool need_repaint = FALSE; 290 bool need_repaint = FALSE;
291 291
292 if (unicode == 0) { // either Qt char, or nothing 292 if (unicode == 0) { // either Qt char, or nothing
293 293
294 if (qkeycode == Qt::Key_F1) { // toggle the pickboard 294 if (qkeycode == Qt::Key_F1) { // toggle the pickboard
295 295
296 if ( configdlg ) { 296 if ( configdlg ) {
297 delete (ConfigDlg *) configdlg; 297 delete (ConfigDlg *) configdlg;
298 configdlg = 0; 298 configdlg = 0;
299 } 299 }
300 else { 300 else {
301 configdlg = new ConfigDlg (); 301 configdlg = new ConfigDlg ();
302 connect(configdlg, SIGNAL(setMapToDefault()), 302 connect(configdlg, SIGNAL(setMapToDefault()),
303 this, SLOT(setMapToDefault())); 303 this, SLOT(setMapToDefault()));
304 connect(configdlg, SIGNAL(setMapToFile(QString)), 304 connect(configdlg, SIGNAL(setMapToFile(QString)),
305 this, SLOT(setMapToFile(QString))); 305 this, SLOT(setMapToFile(QString)));
306 connect(configdlg, SIGNAL(pickboardToggled(bool)), 306 connect(configdlg, SIGNAL(pickboardToggled(bool)),
307 this, SLOT(togglePickboard(bool))); 307 this, SLOT(togglePickboard(bool)));
308 connect(configdlg, SIGNAL(repeatToggled(bool)), 308 connect(configdlg, SIGNAL(repeatToggled(bool)),
309 this, SLOT(toggleRepeat(bool))); 309 this, SLOT(toggleRepeat(bool)));
310 connect(configdlg, SIGNAL(reloadKeyboard()), 310 connect(configdlg, SIGNAL(reloadKeyboard()),
311 this, SLOT(reloadKeyboard())); 311 this, SLOT(reloadKeyboard()));
312 configdlg->showMaximized(); 312 configdlg->showMaximized();
313 configdlg->show(); 313 configdlg->show();
314 configdlg->raise(); 314 configdlg->raise();
315 } 315 }
316 316
317 } else if (qkeycode == Qt::Key_Control) { 317 } else if (qkeycode == Qt::Key_Control) {
318 need_repaint = TRUE; 318 need_repaint = TRUE;
319 319
320 if (ctrl) { 320 if (ctrl) {
321 321
322 *ctrl = 0; 322 *ctrl = 0;
323 ctrl = 0; 323 ctrl = 0;
324 324
325 } else { 325 } else {
326 326
327 ctrl = keys->pressedPtr(row, col); 327 ctrl = keys->pressedPtr(row, col);
328 need_repaint = TRUE; 328 need_repaint = TRUE;
329 *ctrl = !keys->pressed(row, col); 329 *ctrl = !keys->pressed(row, col);
330 330
331 } 331 }
332 332
333 } else if (qkeycode == Qt::Key_Alt) { 333 } else if (qkeycode == Qt::Key_Alt) {
334 need_repaint = TRUE; 334 need_repaint = TRUE;
335 335
336 if (alt) { 336 if (alt) {
337 *alt = 0; 337 *alt = 0;
338 alt = 0; 338 alt = 0;
339 339
340 } else { 340 } else {
341 341
342 alt = keys->pressedPtr(row, col); 342 alt = keys->pressedPtr(row, col);
343 need_repaint = TRUE; 343 need_repaint = TRUE;