summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2010-06-05 21:15:16 (GMT)
committerLars Knoll <lars.knoll@nokia.com>2010-06-09 22:08:28 (GMT)
commitda603c7c80ea14df18790ae77f5de82880307650 (patch)
tree9e1703c20595ecab1c0efe8f77b32f25996c60aa /src
parent424735f91dbf5847640aca4011a309dbef7b1e31 (diff)
downloadQt-da603c7c80ea14df18790ae77f5de82880307650.zip
Qt-da603c7c80ea14df18790ae77f5de82880307650.tar.gz
Qt-da603c7c80ea14df18790ae77f5de82880307650.tar.bz2
Fixed some bugs in detection of keyboard directionality
The mapping table on X11 had a few bugs. Implemented rudimentary support on QWS and fixed a tiny issue on Mac. Reviewed-by: Simon Hausmann
Diffstat (limited to 'src')
-rw-r--r--src/gui/inputmethod/qximinputcontext_x11.cpp14
-rw-r--r--src/gui/kernel/qkeymapper_mac.cpp18
-rw-r--r--src/gui/kernel/qkeymapper_qws.cpp2
-rw-r--r--src/gui/kernel/qkeymapper_x11.cpp21
-rw-r--r--src/gui/kernel/qkeymapper_x11_p.cpp14
5 files changed, 18 insertions, 51 deletions
diff --git a/src/gui/inputmethod/qximinputcontext_x11.cpp b/src/gui/inputmethod/qximinputcontext_x11.cpp
index d048b36..88f8daf 100644
--- a/src/gui/inputmethod/qximinputcontext_x11.cpp
+++ b/src/gui/inputmethod/qximinputcontext_x11.cpp
@@ -346,10 +346,7 @@ static XFontSet getFontSet(const QFont &f)
extern bool qt_use_rtl_extensions; // from qapplication_x11.cpp
#ifndef QT_NO_XKB
-extern void q_getLocaleAndDirection(QLocale *locale,
- Qt::LayoutDirection *direction,
- const QByteArray &layoutName,
- const QByteArray &variantName);
+extern QLocale q_getKeyboardLocale(const QByteArray &layoutName, const QByteArray &variantName);
#endif
QXIMInputContext::QXIMInputContext()
@@ -407,17 +404,12 @@ QXIMInputContext::QXIMInputContext()
QList<QByteArray> layoutNames = QByteArray::fromRawData(names[2], qstrlen(names[2])).split(',');
QList<QByteArray> variantNames = QByteArray::fromRawData(names[3], qstrlen(names[3])).split(',');
for (int i = 0; i < qMin(layoutNames.count(), variantNames.count()); ++i ) {
- QLocale keyboardInputLocale;
- Qt::LayoutDirection keyboardInputDirection;
QByteArray variantName = variantNames.at(i);
const int dashPos = variantName.indexOf("-");
if (dashPos >= 0)
variantName.truncate(dashPos);
- q_getLocaleAndDirection(&keyboardInputLocale,
- &keyboardInputDirection,
- layoutNames.at(i),
- variantName);
- if (keyboardInputDirection == Qt::RightToLeft)
+ QLocale keyboardInputLocale = q_getKeyboardLocale(layoutNames.at(i), variantName);
+ if (keyboardInputLocale.isWrittenRightToLeft())
qt_use_rtl_extensions = true;
}
}
diff --git a/src/gui/kernel/qkeymapper_mac.cpp b/src/gui/kernel/qkeymapper_mac.cpp
index a7145d4..885f5ba 100644
--- a/src/gui/kernel/qkeymapper_mac.cpp
+++ b/src/gui/kernel/qkeymapper_mac.cpp
@@ -672,23 +672,7 @@ QKeyMapperPrivate::updateKeyboard()
#endif
if (iso639Code) {
keyboardInputLocale = QLocale(QCFString::toQString(iso639Code));
- QString monday = keyboardInputLocale.dayName(1);
- bool rtl = false;
- for (int i = 0; i < monday.length(); ++i) {
- switch (monday.at(i).direction()) {
- default:
- break;
- case QChar::DirR:
- case QChar::DirAL:
- case QChar::DirRLE:
- case QChar::DirRLO:
- rtl = true;
- break;
- }
- if (rtl)
- break;
- }
- keyboardInputDirection = rtl ? Qt::RightToLeft : Qt::LeftToRight;
+ keyboardInputDirection = keyboardInputLocale.isWrittenRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight;
} else {
keyboardInputLocale = QLocale::c();
keyboardInputDirection = Qt::LeftToRight;
diff --git a/src/gui/kernel/qkeymapper_qws.cpp b/src/gui/kernel/qkeymapper_qws.cpp
index 5b6b1c4..0e9f35a 100644
--- a/src/gui/kernel/qkeymapper_qws.cpp
+++ b/src/gui/kernel/qkeymapper_qws.cpp
@@ -52,7 +52,7 @@ QT_USE_NAMESPACE
QKeyMapperPrivate::QKeyMapperPrivate()
{
keyboardInputLocale = QLocale::system();
- keyboardInputDirection = Qt::RightToLeft;
+ keyboardInputDirection = keyboardInputLocale.isWrittenRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight;
}
QKeyMapperPrivate::~QKeyMapperPrivate()
diff --git a/src/gui/kernel/qkeymapper_x11.cpp b/src/gui/kernel/qkeymapper_x11.cpp
index 807959c..f0d548c 100644
--- a/src/gui/kernel/qkeymapper_x11.cpp
+++ b/src/gui/kernel/qkeymapper_x11.cpp
@@ -80,22 +80,15 @@ QT_BEGIN_NAMESPACE
(((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF))
#endif
-void q_getLocaleAndDirection(QLocale *locale,
- Qt::LayoutDirection *direction,
- const QByteArray &layoutName,
- const QByteArray &variantName)
+QLocale q_getKeyboardLocale(const QByteArray &layoutName, const QByteArray &variantName)
{
int i = 0;
while (xkbLayoutData[i].layout != 0) {
- if (layoutName == xkbLayoutData[i].layout && variantName == xkbLayoutData[i].variant) {
- *locale = QLocale(xkbLayoutData[i].language, xkbLayoutData[i].country);
- *direction = xkbLayoutData[i].direction;
- return;
- }
+ if (layoutName == xkbLayoutData[i].layout && variantName == xkbLayoutData[i].variant)
+ return QLocale(xkbLayoutData[i].language, xkbLayoutData[i].country);
++i;
}
- *locale = QLocale::c();
- *direction = Qt::LeftToRight;
+ return QLocale::c();
}
#endif // QT_NO_XKB
@@ -523,10 +516,8 @@ void QKeyMapperPrivate::clearMappings()
// if (keyboardLayoutName.isEmpty())
// qWarning("Qt: unable to determine keyboard layout, please talk to qt-bugs@trolltech.com"); ?
- q_getLocaleAndDirection(&keyboardInputLocale,
- &keyboardInputDirection,
- layoutName,
- variantName);
+ keyboardInputLocale = q_getKeyboardLocale(layoutName, variantName);
+ keyboardInputDirection = keyboardInputLocale.isWrittenRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight;
#if 0
qDebug() << "keyboard input locale ="
diff --git a/src/gui/kernel/qkeymapper_x11_p.cpp b/src/gui/kernel/qkeymapper_x11_p.cpp
index 20fcc86..6308973 100644
--- a/src/gui/kernel/qkeymapper_x11_p.cpp
+++ b/src/gui/kernel/qkeymapper_x11_p.cpp
@@ -271,13 +271,13 @@ static struct {
// name = is:nodeadkeys, description = Iceland
{ "is", "nodeadkeys", Qt::LeftToRight, QLocale::Icelandic, QLocale::Iceland },
// name = il, description = Israel
- { "il", "", Qt::LeftToRight, QLocale::Hebrew, QLocale::Israel },
+ { "il", "", Qt::RightToLeft, QLocale::Hebrew, QLocale::Israel },
// name = il:lyx, description = Israel
- { "il", "lyx", Qt::LeftToRight, QLocale::Hebrew, QLocale::Israel },
+ { "il", "lyx", Qt::RightToLeft, QLocale::Hebrew, QLocale::Israel },
// name = il:si1452, description = Israel
- { "il", "si1452", Qt::LeftToRight, QLocale::Hebrew, QLocale::Israel },
+ { "il", "si1452", Qt::RightToLeft, QLocale::Hebrew, QLocale::Israel },
// name = il:phonetic, description = Israel
- { "il", "phonetic", Qt::LeftToRight, QLocale::Hebrew, QLocale::Israel },
+ { "il", "phonetic", Qt::RightToLeft, QLocale::Hebrew, QLocale::Israel },
// name = it, description = Italy
{ "it", "", Qt::LeftToRight, QLocale::Italian, QLocale::Italy },
// name = it:nodeadkeys, description = Italy
@@ -419,11 +419,11 @@ static struct {
// name = ch:fr_sundeadkeys, description = Switzerland
{ "ch", "fr_sundeadkeys", Qt::LeftToRight, QLocale::French, QLocale::Switzerland },
// name = sy, description = Syria
- { "sy", "", Qt::RightToLeft, QLocale::Arabic, QLocale::SyrianArabRepublic },
+ { "sy", "", Qt::RightToLeft, QLocale::Syriac, QLocale::SyrianArabRepublic },
// name = sy:syc, description = Syria
- { "sy", "syc", Qt::RightToLeft, QLocale::Arabic, QLocale::SyrianArabRepublic },
+ { "sy", "syc", Qt::RightToLeft, QLocale::Syriac, QLocale::SyrianArabRepublic },
// name = sy:syc_phonetic, description = Syria
- { "sy", "syc_phonetic", Qt::RightToLeft, QLocale::Arabic, QLocale::SyrianArabRepublic },
+ { "sy", "syc_phonetic", Qt::RightToLeft, QLocale::Syriac, QLocale::SyrianArabRepublic },
// name = tj, description = Tajikistan
{ "tj", "", Qt::LeftToRight, QLocale::Tajik, QLocale::Tajikistan },
// name = lk, description = Sri Lanka