Changeset 846 for trunk/src/gui/inputmethod
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/inputmethod/qcoefepinputcontext_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 67 67 QT_BEGIN_NAMESPACE 68 68 69 class Q CoeFepInputContext : public QInputContext,70 public MCoeFepAwareTextEditor,71 public MCoeFepAwareTextEditor_Extension1,72 public MObjectProvider69 class Q_AUTOTEST_EXPORT QCoeFepInputContext : public QInputContext, 70 public MCoeFepAwareTextEditor, 71 public MCoeFepAwareTextEditor_Extension1, 72 public MObjectProvider 73 73 { 74 74 Q_OBJECT … … 85 85 86 86 bool filterEvent(const QEvent *event); 87 bool symbianFilterEvent(QWidget *keyWidget, const QSymbianEvent *event); 87 88 void mouseHandler( int x, QMouseEvent *event); 88 89 bool isComposing() const { return !m_preeditString.isEmpty(); } … … 152 153 MFepInlineTextFormatRetriever *m_formatRetriever; 153 154 MFepPointerEventHandlerDuringInlineEdit *m_pointerHandler; 154 int m_cursorPos;155 155 QBasicTimer m_tempPreeditStringTimeout; 156 156 bool m_hasTempPreeditString; 157 158 friend class tst_QInputContext; 157 159 }; 158 160 -
trunk/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 45 45 #include <qapplication.h> 46 46 #include <qtextformat.h> 47 #include <qgraphicsview.h> 48 #include <qgraphicsscene.h> 49 #include <qgraphicswidget.h> 50 #include <qsymbianevent.h> 47 51 #include <private/qcore_symbian_p.h> 48 52 … … 77 81 m_formatRetriever(0), 78 82 m_pointerHandler(0), 79 m_cursorPos(0),80 83 m_hasTempPreeditString(false) 81 84 { … … 87 90 m_fepState->SetDefaultInputMode( EAknEditorTextInputMode ); 88 91 m_fepState->SetPermittedInputModes( EAknEditorAllInputModes ); 89 m_fepState->SetDefaultCase( EAknEditor LowerCase );92 m_fepState->SetDefaultCase( EAknEditorTextCase ); 90 93 m_fepState->SetPermittedCases( EAknEditorAllCaseModes ); 91 94 m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG); … … 235 238 } 236 239 240 QString widgetText = focusWidget()->inputMethodQuery(Qt::ImSurroundingText).toString(); 241 bool validLength; 242 int maxLength = focusWidget()->inputMethodQuery(Qt::ImMaximumTextLength).toInt(&validLength); 243 if (!keyEvent->text().isEmpty() && validLength 244 && widgetText.size() + m_preeditString.size() >= maxLength) { 245 // Don't send key events with string content if the widget is "full". 246 return true; 247 } 248 237 249 if (keyEvent->type() == QEvent::KeyPress 238 250 && focusWidget()->inputMethodHints() & Qt::ImhHiddenText 239 251 && !keyEvent->text().isEmpty()) { 240 252 // Send some temporary preedit text in order to make text visible for a moment. 241 m_cursorPos = focusWidget()->inputMethodQuery(Qt::ImCursorPosition).toInt();242 253 m_preeditString = keyEvent->text(); 243 254 QList<QInputMethodEvent::Attribute> attributes; … … 280 291 } 281 292 293 bool QCoeFepInputContext::symbianFilterEvent(QWidget *keyWidget, const QSymbianEvent *event) 294 { 295 Q_UNUSED(keyWidget); 296 if (event->type() == QSymbianEvent::CommandEvent) 297 // A command basically means the same as a button being pushed. With Qt buttons 298 // that would normally result in a reset of the input method due to the focus change. 299 // This should also happen for commands. 300 reset(); 301 302 return false; 303 } 304 282 305 void QCoeFepInputContext::timerEvent(QTimerEvent *timerEvent) 283 306 { … … 321 344 } 322 345 323 static QTextCharFormat qt_TCharFormat2QTextCharFormat(const TCharFormat &cFormat )346 static QTextCharFormat qt_TCharFormat2QTextCharFormat(const TCharFormat &cFormat, bool validStyleColor) 324 347 { 325 348 QTextCharFormat qFormat; 326 349 327 QBrush foreground(QColor(cFormat.iFontPresentation.iTextColor.Internal())); 328 qFormat.setForeground(foreground); 350 if (validStyleColor) { 351 QBrush foreground(QColor(cFormat.iFontPresentation.iTextColor.Internal())); 352 qFormat.setForeground(foreground); 353 } 329 354 330 355 qFormat.setFontStrikeOut(cFormat.iFontPresentation.iStrikethrough == EStrikethroughOn); … … 356 381 commitTemporaryPreeditString(); 357 382 358 bool numbersOnly = hints & ImhDigitsOnly || hints & ImhFormattedNumbersOnly 359 || hints & ImhDialableCharactersOnly; 360 bool noOnlys = !(numbersOnly || hints & ImhUppercaseOnly 361 || hints & ImhLowercaseOnly); 383 const bool anynumbermodes = hints & (ImhDigitsOnly | ImhFormattedNumbersOnly | ImhDialableCharactersOnly); 384 const bool anytextmodes = hints & (ImhUppercaseOnly | ImhLowercaseOnly | ImhEmailCharactersOnly | ImhUrlCharactersOnly); 385 const bool numbersOnly = anynumbermodes && !anytextmodes; 386 const bool noOnlys = !(hints & ImhExclusiveInputMask); 387 // if alphanumeric input, or if multiple incompatible number modes are selected; 388 // then make all symbols available in numeric mode too. 389 const bool needsCharMap= !numbersOnly || ((hints & ImhFormattedNumbersOnly) && (hints & ImhDialableCharactersOnly)); 362 390 TInt flags; 363 391 Qt::InputMethodHints oldHints = hints; … … 371 399 if (!noOnlys) { 372 400 // Make sure that the preference is within the permitted set. 373 if (hints & ImhPreferNumbers && !(hints & ImhDigitsOnly || hints & ImhFormattedNumbersOnly 374 || hints & ImhDialableCharactersOnly)) { 401 if (hints & ImhPreferNumbers && !anynumbermodes) { 375 402 hints &= ~ImhPreferNumbers; 376 403 } else if (hints & ImhPreferUppercase && !(hints & ImhUppercaseOnly)) { … … 385 412 } else if (hints & ImhUppercaseOnly) { 386 413 hints |= ImhPreferUppercase; 387 } else if (hints & ImhDigitsOnly || hints & ImhFormattedNumbersOnly 388 || hints & ImhDialableCharactersOnly) { 414 } else if (numbersOnly) { 389 415 hints |= ImhPreferNumbers; 390 416 } … … 400 426 } 401 427 flags = 0; 402 if (numbersOnly) { 428 if (noOnlys || (anynumbermodes && anytextmodes)) { 429 flags = EAknEditorAllInputModes; 430 } 431 else if (anynumbermodes) { 403 432 flags |= EAknEditorNumericInputMode; 404 } 405 if (hints & ImhUppercaseOnly || hints & ImhLowercaseOnly) { 433 if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0 434 && ((hints & ImhFormattedNumbersOnly) || (hints & ImhDialableCharactersOnly))) { 435 //workaround - the * key does not launch the symbols menu, making it impossible to use these modes unless text mode is enabled. 436 flags |= EAknEditorTextInputMode; 437 } 438 } 439 else if (anytextmodes) { 406 440 flags |= EAknEditorTextInputMode; 407 441 } 408 if (flags == 0){442 else { 409 443 flags = EAknEditorAllInputModes; 410 444 } … … 453 487 flags |= EAknEditorFlagNoT9; 454 488 } 489 if (needsCharMap) 490 flags |= EAknEditorFlagUseSCTNumericCharmap; 455 491 m_fepState->SetFlags(flags); 456 492 ReportAknEdStateEvent(MAknEdStateObserver::EAknEdwinStateFlagsUpdate); 457 493 458 if (hints & ImhFormattedNumbersOnly) { 494 if (hints & ImhDialableCharactersOnly) { 495 // This is first, because if (ImhDialableCharactersOnly | ImhFormattedNumbersOnly) 496 // is specified, this one is more natural (# key enters a #) 497 flags = EAknEditorStandardNumberModeKeymap; 498 } else if (hints & ImhFormattedNumbersOnly) { 499 // # key enters decimal point 459 500 flags = EAknEditorCalculatorNumberModeKeymap; 460 501 } else if (hints & ImhDigitsOnly) { 502 // This is last, because it is most restrictive (# key is inactive) 461 503 flags = EAknEditorPlainNumberModeKeymap; 462 504 } else { 463 // ImhDialableCharactersOnly is the fallback as well, so we don't need to check for464 // that flag.465 505 flags = EAknEditorStandardNumberModeKeymap; 466 506 } 467 507 m_fepState->SetNumericKeymap(static_cast<TAknEditorNumericKeymap>(flags)); 468 508 469 if (hints & ImhEmailCharactersOnly) { 509 if (hints & ImhUrlCharactersOnly) { 510 // URL characters is everything except space, so a superset of the other restrictions 511 m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_URL_SPECIAL_CHARACTER_TABLE_DIALOG); 512 } else if (hints & ImhEmailCharactersOnly) { 470 513 m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_EMAIL_ADDR_SPECIAL_CHARACTER_TABLE_DIALOG); 471 } else if ( hints & ImhUrlCharactersOnly) {472 m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_ URL_SPECIAL_CHARACTER_TABLE_DIALOG);514 } else if (needsCharMap) { 515 m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG); 473 516 } else { 474 m_fepState->SetSpecialCharacterTableResourceId( R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG);517 m_fepState->SetSpecialCharacterTableResourceId(0); 475 518 } 476 519 … … 485 528 { 486 529 TCharFormat cFormat; 487 const QColor styleTextColor = focusWidget() ? focusWidget()->palette().text().color() : 488 QApplication::palette("QLineEdit").text().color(); 489 const TLogicalRgb fontColor(TRgb(styleTextColor.red(), styleTextColor.green(), styleTextColor.blue(), styleTextColor.alpha())); 490 cFormat.iFontPresentation.iTextColor = fontColor; 530 QColor styleTextColor; 531 if (QWidget *focused = focusWidget()) { 532 QGraphicsView *gv = qobject_cast<QGraphicsView*>(focused); 533 if (!gv) // could be either the QGV or its viewport that has focus 534 gv = qobject_cast<QGraphicsView*>(focused->parentWidget()); 535 if (gv) { 536 if (QGraphicsScene *scene = gv->scene()) { 537 if (QGraphicsItem *focusItem = scene->focusItem()) { 538 if (focusItem->isWidget()) { 539 styleTextColor = static_cast<QGraphicsWidget*>(focusItem)->palette().text().color(); 540 } 541 } 542 } 543 } else { 544 styleTextColor = focused->palette().text().color(); 545 } 546 } else { 547 styleTextColor = QApplication::palette("QLineEdit").text().color(); 548 } 549 550 if (styleTextColor.isValid()) { 551 const TLogicalRgb fontColor(TRgb(styleTextColor.red(), styleTextColor.green(), styleTextColor.blue(), styleTextColor.alpha())); 552 cFormat.iFontPresentation.iTextColor = fontColor; 553 } 491 554 492 555 TInt numChars = 0; … … 502 565 charPos, 503 566 numChars, 504 QVariant(qt_TCharFormat2QTextCharFormat(cFormat ))));567 QVariant(qt_TCharFormat2QTextCharFormat(cFormat, styleTextColor.isValid())))); 505 568 charPos += numChars; 506 569 if (charPos >= m_preeditString.size()) { … … 553 616 commitTemporaryPreeditString(); 554 617 555 m_cursorPos = w->inputMethodQuery(Qt::ImCursorPosition).toInt();556 557 618 QList<QInputMethodEvent::Attribute> attributes; 558 619 … … 569 630 if (m_preeditString.isEmpty()) { 570 631 int anchor = w->inputMethodQuery(Qt::ImAnchorPosition).toInt(); 571 int replacementLength = qAbs(m_cursorPos-anchor); 632 int cursorPos = w->inputMethodQuery(Qt::ImCursorPosition).toInt(); 633 int replacementLength = qAbs(cursorPos-anchor); 572 634 if (replacementLength > 0) { 573 int replacementStart = m_cursorPos < anchor ? 0 : -replacementLength;635 int replacementStart = cursorPos < anchor ? 0 : -replacementLength; 574 636 QList<QInputMethodEvent::Attribute> clearSelectionAttributes; 575 637 QInputMethodEvent clearSelectionEvent(QLatin1String(""), clearSelectionAttributes); … … 596 658 return; 597 659 660 commitTemporaryPreeditString(); 661 598 662 m_inlinePosition = aPositionOfInsertionPointInInlineText; 599 663 … … 604 668 m_cursorVisibility, 605 669 QVariant())); 606 m_preeditString = qt_TDesC2QString(aNewInlineText); 607 QInputMethodEvent event(m_preeditString, attributes); 670 QString newPreeditString = qt_TDesC2QString(aNewInlineText); 671 QInputMethodEvent event(newPreeditString, attributes); 672 if (newPreeditString.isEmpty() && m_preeditString.isEmpty()) { 673 // In Symbian world this means "erase last character". 674 event.setCommitString(QLatin1String(""), -1, 1); 675 } 676 m_preeditString = newPreeditString; 608 677 sendEvent(event); 609 678 } … … 628 697 void QCoeFepInputContext::CancelFepInlineEdit() 629 698 { 699 // We are not supposed to ever have a tempPreeditString and a real preedit string 700 // from S60 at the same time, so it should be safe to rely on this test to determine 701 // whether we should honor S60's request to clear the text or not. 702 if (m_hasTempPreeditString) 703 return; 704 630 705 QList<QInputMethodEvent::Attribute> attributes; 631 706 QInputMethodEvent event(QLatin1String(""), attributes); 632 707 event.setCommitString(QLatin1String(""), 0, 0); 633 708 m_preeditString.clear(); 709 m_inlinePosition = 0; 634 710 sendEvent(event); 635 711 } … … 775 851 void QCoeFepInputContext::commitCurrentString(bool cancelFepTransaction) 776 852 { 777 int longPress = 0;778 779 if (m_preeditString.size() == 0) {780 QWidget *w = focusWidget();781 if (!cancelFepTransaction && w) {782 // We must replace the last character only if the input box has already accepted one783 if (w->inputMethodQuery(Qt::ImCursorPosition).toInt() != m_cursorPos)784 longPress = 1;785 }786 }787 788 853 QList<QInputMethodEvent::Attribute> attributes; 789 854 QInputMethodEvent event(QLatin1String(""), attributes); 790 event.setCommitString(m_preeditString, 0 -longPress, longPress);855 event.setCommitString(m_preeditString, 0, 0); 791 856 m_preeditString.clear(); 857 m_inlinePosition = 0; 792 858 sendEvent(event); 793 859 794 860 m_hasTempPreeditString = false; 795 longPress = 0;796 861 797 862 if (cancelFepTransaction) { -
trunk/src/gui/inputmethod/qinputcontext.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/inputmethod/qinputcontext.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/inputmethod/qinputcontext_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/inputmethod/qinputcontextfactory.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 74 74 #ifdef Q_WS_S60 75 75 #include "qcoefepinputcontext_p.h" 76 #include " akninputlanguageinfo.h"76 #include "AknInputLanguageInfo.h" 77 77 #endif 78 78 … … 82 82 QT_BEGIN_NAMESPACE 83 83 84 #if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)84 #ifndef QT_NO_LIBRARY 85 85 Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, 86 86 (QInputContextFactoryInterface_iid, QLatin1String("/inputmethods"))) … … 154 154 } 155 155 #endif 156 #if defined(QT_NO_LIBRARY) || defined(QT_NO_SETTINGS)156 #ifdef QT_NO_LIBRARY 157 157 Q_UNUSED(key); 158 158 #else … … 194 194 result << QLatin1String("coefep"); 195 195 #endif 196 #if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)196 #ifndef QT_NO_LIBRARY 197 197 result += loader()->keys(); 198 198 #endif // QT_NO_LIBRARY … … 206 206 This function contains pure Symbian exception handling code for 207 207 getting S60 language list. 208 Returned object ownership is transfer ed to caller.208 Returned object ownership is transferred to caller. 209 209 */ 210 210 static CAknInputLanguageList* s60LangListL() … … 225 225 226 226 This function utility function return S60 language list. 227 Returned object ownership is transfer ed to caller.227 Returned object ownership is transferred to caller. 228 228 */ 229 229 static CAknInputLanguageList* s60LangList() -
trunk/src/gui/inputmethod/qinputcontextfactory.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/inputmethod/qinputcontextplugin.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/inputmethod/qinputcontextplugin.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/inputmethod/qmacinputcontext_mac.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/inputmethod/qmacinputcontext_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/inputmethod/qwininputcontext_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 57 57 #include "QtCore/qt_windows.h" 58 58 59 #if defined(Q_CC_MINGW) &&!defined(IMR_RECONVERTSTRING)59 #if !defined(IMR_RECONVERTSTRING) 60 60 typedef struct tagRECONVERTSTRING { 61 61 DWORD dwSize; -
trunk/src/gui/inputmethod/qwininputcontext_win.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/inputmethod/qwsinputcontext_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/inputmethod/qwsinputcontext_qws.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/inputmethod/qximinputcontext_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/inputmethod/qximinputcontext_x11.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 345 345 } 346 346 347 347 extern bool qt_use_rtl_extensions; // from qapplication_x11.cpp 348 #ifndef QT_NO_XKB 349 extern QLocale q_getKeyboardLocale(const QByteArray &layoutName, const QByteArray &variantName); 350 #endif 348 351 349 352 QXIMInputContext::QXIMInputContext() … … 376 379 QXIMInputContext::create_xim(); 377 380 #endif // USE_X11R6_XIM 381 382 #ifndef QT_NO_XKB 383 if (X11->use_xkb) { 384 QByteArray layoutName; 385 QByteArray variantName; 386 387 Atom type = XNone; 388 int format = 0; 389 ulong nitems = 0; 390 ulong bytesAfter = 0; 391 uchar *data = 0; 392 if (XGetWindowProperty(X11->display, RootWindow(X11->display, 0), ATOM(_XKB_RULES_NAMES), 0, 1024, 393 false, XA_STRING, &type, &format, &nitems, &bytesAfter, &data) == Success 394 && type == XA_STRING && format == 8 && nitems > 2) { 395 396 char *names[5] = { 0, 0, 0, 0, 0 }; 397 char *p = reinterpret_cast<char *>(data), *end = p + nitems; 398 int i = 0; 399 do { 400 names[i++] = p; 401 p += qstrlen(p) + 1; 402 } while (p < end); 403 404 QList<QByteArray> layoutNames = QByteArray::fromRawData(names[2], qstrlen(names[2])).split(','); 405 QList<QByteArray> variantNames = QByteArray::fromRawData(names[3], qstrlen(names[3])).split(','); 406 for (int i = 0; i < qMin(layoutNames.count(), variantNames.count()); ++i ) { 407 QByteArray variantName = variantNames.at(i); 408 const int dashPos = variantName.indexOf("-"); 409 if (dashPos >= 0) 410 variantName.truncate(dashPos); 411 QLocale keyboardInputLocale = q_getKeyboardLocale(layoutNames.at(i), variantName); 412 if (keyboardInputLocale.textDirection() == Qt::RightToLeft) 413 qt_use_rtl_extensions = true; 414 } 415 } 416 417 if (data) 418 XFree(data); 419 } 420 #endif // QT_NO_XKB 421 378 422 } 379 423
Note:
See TracChangeset
for help on using the changeset viewer.