summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforminputcontexts
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-11-26 22:30:27 +0100
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2013-11-26 22:35:48 +0100
commit4a8273a6fc2e741e811cf5dabc9a3c240306cf7f (patch)
tree2148abc88f8543eecdc0b97b2dd92594836af9b2 /src/plugins/platforminputcontexts
parent036c5db468164297d213764c59a4b59daa76d90a (diff)
parent1c2be58fecaff1de5f2849192eb712984ebd59bd (diff)
Merge remote-tracking branch 'origin/stable' into dev
For the conflicts in msvc_nmake.cpp the ifdefs are extended since we need to support windows phone in the target branch while it is not there in the current stable branch (as of Qt 5.2). Conflicts: configure qmake/generators/win32/msvc_nmake.cpp src/3rdparty/angle/src/libEGL/Surface.cpp src/angle/src/common/common.pri src/corelib/global/qglobal.h src/corelib/io/qstandardpaths.cpp src/plugins/platforms/qnx/qqnxintegration.cpp src/plugins/platforms/qnx/qqnxscreeneventhandler.h src/plugins/platforms/xcb/qglxintegration.h src/widgets/kernel/win.pri tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp tools/configure/configureapp.cpp Change-Id: I00b579eefebaf61d26ab9b00046d2b5bd5958812
Diffstat (limited to 'src/plugins/platforminputcontexts')
-rw-r--r--src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp64
-rw-r--r--src/plugins/platforminputcontexts/compose/generator/qtablegenerator.h1
2 files changed, 55 insertions, 10 deletions
diff --git a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
index 459a450222..3d1b281620 100644
--- a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
+++ b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
@@ -101,7 +101,6 @@ void TableGenerator::findComposeFile()
qDebug() << "Using Compose file from: " << composeFile;
#endif
}
-
// check if user’s home directory has a file named .XCompose
if (!found && cleanState()) {
QString composeFile = qgetenv("HOME") + QStringLiteral("/.XCompose");
@@ -112,10 +111,12 @@ void TableGenerator::findComposeFile()
qDebug() << "Using Compose file from: " << composeFile;
#endif
}
-
// check for the system provided compose files
if (!found && cleanState()) {
- QString table = readLocaleMappings(locale().toUpper().toUtf8());
+ QByteArray loc = locale().toUpper().toUtf8();
+ QString table = readLocaleMappings(loc);
+ if (table.isEmpty())
+ table = readLocaleMappings(readLocaleAliases(loc));
if (cleanState()) {
if (table.isEmpty())
@@ -178,8 +179,11 @@ QString TableGenerator::locale() const
QString TableGenerator::readLocaleMappings(const QByteArray &locale)
{
- QFile mappings(systemComposeDir() + QLatin1String("/compose.dir"));
QString file;
+ if (locale.isEmpty())
+ return file;
+
+ QFile mappings(systemComposeDir() + QLatin1String("/compose.dir"));
if (mappings.open(QIODevice::ReadOnly)) {
const int localeNameLength = locale.size();
const char * const localeData = locale.constData();
@@ -209,9 +213,8 @@ QString TableGenerator::readLocaleMappings(const QByteArray &locale)
while (*line && *line != ' ' && *line != '\t' && *line != '\n')
++line;
*line = '\0';
-
if (localeNameLength == (line - lc) && !strncasecmp(lc, localeData, line - lc)) {
- file = QString::fromUtf8(l, composeFileNameEnd - l);
+ file = QString::fromLocal8Bit(l, composeFileNameEnd - l);
break;
}
}
@@ -221,6 +224,47 @@ QString TableGenerator::readLocaleMappings(const QByteArray &locale)
return file;
}
+QByteArray TableGenerator::readLocaleAliases(const QByteArray &locale)
+{
+ QFile aliases(systemComposeDir() + QLatin1String("/locale.alias"));
+ QByteArray fullLocaleName;
+ if (aliases.exists()) {
+ aliases.open(QIODevice::ReadOnly);
+ while (!aliases.atEnd()) {
+ char l[1024];
+ int read = aliases.readLine(l, sizeof(l));
+ char *line = l;
+ if (read && ((*line >= 'a' && *line <= 'z') ||
+ (*line >= 'A' && *line <= 'Z'))) {
+ const char *alias = line;
+ while (*line && *line != ':' && *line != ' ' && *line != '\t')
+ ++line;
+ if (!*line)
+ continue;
+ *line = 0;
+ if (locale.size() == (line - alias)
+ && !strncasecmp(alias, locale.constData(), line - alias)) {
+ // found a match for alias, read the real locale name
+ ++line;
+ while (*line && (*line == ' ' || *line == '\t'))
+ ++line;
+ const char *fullName = line;
+ while (*line && *line != ' ' && *line != '\t' && *line != '\n')
+ ++line;
+ *line = 0;
+ fullLocaleName = fullName;
+#ifdef DEBUG_GENERATOR
+ qDebug() << "Alias for: " << alias << "is: " << fullLocaleName;
+ break;
+#endif
+ }
+ }
+ }
+ aliases.close();
+ }
+ return fullLocaleName;
+}
+
bool TableGenerator::processFile(QString composeFileName)
{
QFile composeFile(composeFileName);
@@ -255,7 +299,7 @@ void TableGenerator::parseComposeFile(QFile *composeFile)
if (*line == '<')
parseKeySequence(line);
else if (!strncmp(line, "include", 7))
- parseIncludeInstruction(QString::fromUtf8(line));
+ parseIncludeInstruction(QString::fromLocal8Bit(line));
}
composeFile->close();
@@ -309,7 +353,7 @@ ushort TableGenerator::keysymToUtf8(quint32 sym)
qDebug() << QString("keysym - 0x%1 : utf8 - %2").arg(QString::number(sym, 16))
.arg(codec->toUnicode(chars));
#endif
- return QString::fromUtf8(chars).at(0).unicode();
+ return QString::fromLocal8Bit(chars).at(0).unicode();
}
static inline int fromBase8(const char *s, const char *end)
@@ -378,13 +422,13 @@ void TableGenerator::parseKeySequence(char *line)
// handle direct text encoded in the locale
if (*composeValue == '\\')
++composeValue;
- elem.value = QString::fromUtf8(composeValue).at(0).unicode();
+ elem.value = QString::fromLocal8Bit(composeValue).at(0).unicode();
++composeValue;
}
#ifdef DEBUG_GENERATOR
// find the comment
- elem.comment = QString::fromUtf8(composeValueEnd + 1).trimmed();
+ elem.comment = QString::fromLocal8Bit(composeValueEnd + 1).trimmed();
#endif
// find the key sequence and convert to X11 keysym
diff --git a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.h b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.h
index aa65b7b895..248c09f3ea 100644
--- a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.h
+++ b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.h
@@ -122,6 +122,7 @@ protected:
ushort keysymToUtf8(quint32 sym);
QString readLocaleMappings(const QByteArray &locale);
+ QByteArray readLocaleAliases(const QByteArray &locale);
void initPossibleLocations();
bool cleanState() const { return ((m_state & NoErrors) == NoErrors); }
QString locale() const;