Skip to content

Commit 828ccd1

Browse files
author
Qt Continuous Integration System
committed
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-s60-public into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-s60-public: symbian - handle path being passed as part of filename in QTranslator Symbian - fix compile error when default configured
2 parents d5cf162 + 865ad50 commit 828ccd1

File tree

5 files changed

+57
-8
lines changed

5 files changed

+57
-8
lines changed

src/corelib/kernel/qtranslator.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,26 @@ bool QTranslator::load(const QString & filename, const QString & directory,
405405
Q_D(QTranslator);
406406
d->clear();
407407

408+
QString fname = filename;
408409
QString prefix;
409410
if (QFileInfo(filename).isRelative()) {
410411
#ifdef Q_OS_SYMBIAN
411-
if (directory.isEmpty())
412+
//TFindFile doesn't like path in the filename
413+
QString dir(directory);
414+
int slash = filename.lastIndexOf(QLatin1Char('/'));
415+
slash = qMax(slash, filename.lastIndexOf(QLatin1Char('\\')));
416+
if (slash >=0) {
417+
//so move the path component into the directory prefix
418+
if (dir.isEmpty())
419+
dir = filename.left(slash + 1);
420+
else
421+
dir = dir + QLatin1Char('/') + filename.left(slash + 1);
422+
fname = fname.mid(slash + 1);
423+
}
424+
if (dir.isEmpty())
412425
prefix = QCoreApplication::applicationDirPath();
413426
else
414-
prefix = QFileInfo(directory).absoluteFilePath(); //TFindFile doesn't like dirty paths
427+
prefix = QFileInfo(dir).absoluteFilePath(); //TFindFile doesn't like dirty paths
415428
if (prefix.length() > 2 && prefix.at(1) == QLatin1Char(':') && prefix.at(0).isLetter())
416429
prefix[0] = QLatin1Char('Y');
417430
#else
@@ -425,7 +438,6 @@ bool QTranslator::load(const QString & filename, const QString & directory,
425438
QString nativePrefix = QDir::toNativeSeparators(prefix);
426439
#endif
427440

428-
QString fname = filename;
429441
QString realname;
430442
QString delims;
431443
delims = search_delimiters.isNull() ? QString::fromLatin1("_.") : search_delimiters;

src/gui/painting/qgraphicssystemex_symbian.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
#include <e32property.h>
4848

49-
#ifdef Q_SYMBIAN_SUPPORTS_SURFACES
49+
#if defined(Q_SYMBIAN_SUPPORTS_SURFACES) && !defined (QT_NO_EGL)
5050
#include "private/qegl_p.h"
5151
#endif
5252

@@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE
5555
static bool bcm2727Initialized = false;
5656
static bool bcm2727 = false;
5757

58-
#ifdef Q_SYMBIAN_SUPPORTS_SURFACES
58+
#if defined(Q_SYMBIAN_SUPPORTS_SURFACES) && !defined (QT_NO_EGL)
5959
typedef EGLBoolean (*NOK_resource_profiling)(EGLDisplay, EGLint, EGLint*, EGLint, EGLint*);
6060
#define EGL_PROF_TOTAL_MEMORY_NOK 0x3070
6161
#endif
@@ -69,7 +69,7 @@ bool QSymbianGraphicsSystemEx::hasBCM2727()
6969
if (bcm2727Initialized)
7070
return bcm2727;
7171

72-
#ifdef Q_SYMBIAN_SUPPORTS_SURFACES
72+
#if defined(Q_SYMBIAN_SUPPORTS_SURFACES) && !defined (QT_NO_EGL)
7373
EGLDisplay display = QEgl::display();
7474
#if 1
7575
// Hacky but fast ~0ms.
230 Bytes
Binary file not shown.

tests/auto/qtranslator/qtranslator.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ RESOURCES += qtranslator.qrc
44

55
wince*|symbian: {
66
addFiles.sources = hellotr_la.qm msgfmt_from_po.qm
7+
addFiles.sources += i18n
78
addFiles.path = .
89
DEPLOYMENT += addFiles
910
}

tests/auto/qtranslator/tst_qtranslator.cpp

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public slots:
6666
private slots:
6767
void load();
6868
void load2();
69+
void loadSubdir();
70+
void loadSubdir2();
71+
void loadSubdir3();
72+
void loadSubdir4();
6973
void threadLoad();
7074
void testLanguageChange();
7175
void plural();
@@ -124,6 +128,38 @@ void tst_QTranslator::load2()
124128
QCOMPARE(tor.translate("QPushButton", "Hello world!"), QString::fromLatin1("Hallo Welt!"));
125129
}
126130

131+
void tst_QTranslator::loadSubdir()
132+
{
133+
QTranslator tor( 0 );
134+
tor.load("hellotr_en_GB", "i18n");
135+
QVERIFY(!tor.isEmpty());
136+
QCOMPARE(tor.translate("QPushButton", "Hello world!"), QString::fromLatin1("Hallo Welt!"));
137+
}
138+
139+
void tst_QTranslator::loadSubdir2()
140+
{
141+
QTranslator tor( 0 );
142+
tor.load("i18n/hellotr_en_GB");
143+
QVERIFY(!tor.isEmpty());
144+
QCOMPARE(tor.translate("QPushButton", "Hello world!"), QString::fromLatin1("Hallo Welt!"));
145+
}
146+
147+
void tst_QTranslator::loadSubdir3()
148+
{
149+
QTranslator tor( 0 );
150+
tor.load(QString(QLatin1String("i18n%1hellotr_en_GB")).arg(QDir::separator()));
151+
QVERIFY(!tor.isEmpty());
152+
QCOMPARE(tor.translate("QPushButton", "Hello world!"), QString::fromLatin1("Hallo Welt!"));
153+
}
154+
155+
void tst_QTranslator::loadSubdir4()
156+
{
157+
QTranslator tor( 0 );
158+
tor.load("./hellotr_en_GB", "i18n");
159+
QVERIFY(!tor.isEmpty());
160+
QCOMPARE(tor.translate("QPushButton", "Hello world!"), QString::fromLatin1("Hallo Welt!"));
161+
}
162+
127163
class TranslatorThread : public QThread
128164
{
129165
void run() {
@@ -249,10 +285,10 @@ void tst_QTranslator::loadFromResource()
249285

250286
void tst_QTranslator::loadDirectory()
251287
{
252-
QVERIFY(QFileInfo("../qtranslator").isDir());
288+
QVERIFY(QFileInfo("i18n").isDir());
253289

254290
QTranslator tor;
255-
tor.load("qtranslator", "..");
291+
tor.load("qtranslator", "i18n");
256292
QVERIFY(tor.isEmpty());
257293
}
258294

0 commit comments

Comments
 (0)