- Timestamp:
- Sep 12, 2009, 2:10:36 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gui/kernel/qkeymapper_pm.cpp
r169 r179 197 197 }; 198 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 199 229 // Key translation ---------------------------------------------------[ end ]--- 200 230 … … 241 271 } 242 272 243 static inline int asciiToKeycode(char a, int state) 244 { 245 if (a >= 'a' && a <= 'z') 246 a = toupper(a); 247 if ((state & Qt::ControlModifier) != 0) { 248 if (a >= 0 && a <= 31) // [email protected]+A..CTRL+Z..Ctrl+_ 249 a += '@'; // to @..A..Z.._ 250 } 251 return a & 0xff; 273 static inline int charToKeycode(const QChar &ch, int state) 274 { 275 if (!ch.row()) { 276 if ((state & Qt::ControlModifier) != 0) { 277 int ascii = ch.cell(); 278 if (ascii >= 0 && ascii <= 31) // [email protected]+A..CTRL+Z..Ctrl+_ 279 return ascii + '@'; // to @..A..Z.._ 280 } 281 } 282 283 return ch.toUpper().unicode(); 252 284 } 253 285 … … 383 415 QString text; 384 416 if (chm.chr) { 385 // Note: We ignore the KC_CHAR flag when generating text for the386 // key in order to get correct (non-null) text even for Alt+Letter387 // combinations (that don't have KC_CHAR set) because processing388 // Alt+Letter shortcuts for non-ASCII letters in widgets (e.g.389 // QPushButton) depends on that.417 // Note: We ignore the KC_CHAR flag when 418 // 419 // 420 // 421 // QPushButton) depends on that. 390 422 if ((chm.fs & (KC_VIRTUALKEY | KC_CHAR)) == KC_CHAR && (chm.chr & 0xFF00)) { 391 // We ass ime we get a DBCS char if the above condition is met.423 // We assme we get a DBCS char if the above condition is met. 392 424 // DBCS chars seem to have KC_CHAR set but not KC_VIRTUALKEY; we 393 425 // use this to prevent keys like ESC (chm=0x011B) with the … … 396 428 } else if (chm.chr & 0xFF) { 397 429 text = QString::fromLocal8Bit((char*)&chm.chr, 1); 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 398 445 } 399 446 400 447 Q_ASSERT(code || !text.isEmpty()); // we must provide the key code 401 448 if (!code && !text.isEmpty()) { 402 if (!text[0].row()) 403 code = asciiToKeycode(text[0].cell(), state); 404 else 405 code = text[0].toUpper().unicode(); 449 code = charToKeycode(text[0], state); 406 450 } 407 451 }
Note:
See TracChangeset
for help on using the changeset viewer.