diff options
author | Shane Kearns <shane.kearns@accenture.com> | 2011-10-13 14:45:47 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@accenture.com> | 2011-10-13 16:37:33 (GMT) |
commit | 5dec90ff13cd96ca4f341cf5e8360037edf5eeb3 (patch) | |
tree | 22b9feab2e7a3307034a49f44e562a1b64f70606 /src/corelib/kernel | |
parent | c47cd8f01ea5d3f2a6d0ea73572d9735947919a0 (diff) | |
download | Qt-5dec90ff13cd96ca4f341cf5e8360037edf5eeb3.zip Qt-5dec90ff13cd96ca4f341cf5e8360037edf5eeb3.tar.gz Qt-5dec90ff13cd96ca4f341cf5e8360037edf5eeb3.tar.bz2 |
symbian - search drives for translation files
Qt may be installed on a different drive from the application,
particularly the case when Qt is included in ROM (Z:) and the
application is on C:
With this change, if QTranslator::load() specifies an absolute
directory in the filesystem (e.g. "/resource/qt/translations") without
a drive letter, then the symbian search paths are used.
Note that this example path is the one returned by QLibraryInfo so
applications using the example code from
http://doc.qt.nokia.com/latest/internationalization.html#produce-translations
will work as expected.
Task-number: QT-5246
Reviewed-by: mread
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qtranslator.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index 3672846..8c08760 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -50,6 +50,7 @@ #include "qcoreapplication.h" #include "qcoreapplication_p.h" #include "qdatastream.h" +#include "qdir.h" #include "qfile.h" #include "qmap.h" #include "qalgorithms.h" @@ -61,6 +62,10 @@ #include "private/qcore_unix_p.h" #endif +#ifdef Q_OS_SYMBIAN +#include "private/qcore_symbian_p.h" +#endif + // most of the headers below are already included in qplatformdefs.h // also this lacks Large File support but that's probably irrelevant #if defined(QT_USE_MMAP) @@ -402,11 +407,24 @@ bool QTranslator::load(const QString & filename, const QString & directory, QString prefix; if (QFileInfo(filename).isRelative()) { +#ifdef Q_OS_SYMBIAN + if (directory.isEmpty()) + prefix = QCoreApplication::applicationDirPath(); + else + prefix = QFileInfo(directory).absoluteFilePath(); //TFindFile doesn't like dirty paths + if (prefix.length() > 2 && prefix.at(1) == QLatin1Char(':') && prefix.at(0).isLetter()) + prefix[0] = QLatin1Char('Y'); +#else prefix = directory; - if (prefix.length() && !prefix.endsWith(QLatin1Char('/'))) - prefix += QLatin1Char('/'); +#endif + if (prefix.length() && !prefix.endsWith(QLatin1Char('/'))) + prefix += QLatin1Char('/'); } +#ifdef Q_OS_SYMBIAN + QString nativePrefix = QDir::toNativeSeparators(prefix); +#endif + QString fname = filename; QString realname; QString delims; @@ -415,6 +433,24 @@ bool QTranslator::load(const QString & filename, const QString & directory, for (;;) { QFileInfo fi; +#ifdef Q_OS_SYMBIAN + //search for translations on other drives, e.g. Qt may be in Z, while app is in C + //note this uses symbian search rules, i.e. y:->a:, followed by z: + TFindFile finder(qt_s60GetRFs()); + QString fname2 = fname + (suffix.isNull() ? QString::fromLatin1(".qm") : suffix); + TInt err = finder.FindByDir( + qt_QString2TPtrC(fname2), + qt_QString2TPtrC(nativePrefix)); + if (err != KErrNone) + err = finder.FindByDir(qt_QString2TPtrC(fname), qt_QString2TPtrC(nativePrefix)); + if (err == KErrNone) { + fi.setFile(qt_TDesC2QString(finder.File())); + realname = fi.canonicalFilePath(); + if (fi.isReadable() && fi.isFile()) + break; + } +#endif + realname = prefix + fname + (suffix.isNull() ? QString::fromLatin1(".qm") : suffix); fi.setFile(realname); if (fi.isReadable() && fi.isFile()) |