Prepare new maemo release
[maemo-rb.git] / rbutil / rbutilqt / main.cpp
blob7d57f422900550cd410199ae8ae40c59cccca5bc
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2007 by Dominik Riebeling
11 * All files in this archive are subject to the GNU General Public License.
12 * See the file COPYING in the source tree root for full license agreement.
14 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
15 * KIND, either express or implied.
17 ****************************************************************************/
20 #include <QCoreApplication>
21 #include <QSettings>
22 #include "rbutilqt.h"
23 #include "systrace.h"
25 #ifdef STATIC
26 #include <QtPlugin>
27 Q_IMPORT_PLUGIN(qtaccessiblewidgets)
28 #endif
32 int main( int argc, char ** argv ) {
33 #if QT_VERSION < 0x050000
34 qInstallMsgHandler(SysTrace::debug);
35 #else
36 qInstallMessageHandler(SysTrace::debug);
37 #endif
38 QApplication app( argc, argv );
39 #if defined(Q_OS_MAC)
40 QDir dir(QApplication::applicationDirPath());
41 dir.cdUp();
42 dir.cd("plugins");
43 QApplication::addLibraryPath(dir.absolutePath());
44 #endif
45 QString absolutePath = QCoreApplication::instance()->applicationDirPath();
46 // portable installation:
47 // check for a configuration file in the program folder.
48 QSettings *user;
49 if(QFileInfo(absolutePath + "/RockboxUtility.ini").isFile())
50 user = new QSettings(absolutePath + "/RockboxUtility.ini", QSettings::IniFormat, 0);
51 else user = new QSettings(QSettings::IniFormat, QSettings::UserScope, "rockbox.org", "RockboxUtility");
53 QString applang = QLocale::system().name();
54 QTranslator translator;
55 QTranslator qttrans;
56 // install translator
57 if(!user->value("lang", "").toString().isEmpty()) {
58 applang = user->value("lang", "").toString();
60 if(!applang.isEmpty()) {
61 if(!translator.load("rbutil_" + applang, absolutePath))
62 translator.load("rbutil_" + applang, ":/lang");
63 if(!qttrans.load("qt_" + applang,
64 QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
65 qttrans.load("qt_" + applang, ":/lang");
67 QLocale::setDefault(applang);
69 delete user;
70 app.installTranslator(&translator);
71 app.installTranslator(&qttrans);
72 //: This string is used to indicate the writing direction. Translate it
73 //: to "RTL" (without quotes) for RTL languages. Anything else will get
74 //: treated as LTR language.
75 if(QObject::tr("LTR") == "RTL")
76 app.setLayoutDirection(Qt::RightToLeft);
78 // keep a list of installed translators. Needed to be able uninstalling them
79 // later again (in case of translation changes)
80 QList<QTranslator*> translators;
81 translators.append(&translator);
82 translators.append(&qttrans);
83 RbUtilQt window(0);
84 RbUtilQt::translators = translators;
85 window.show();
87 // app.connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );
88 return app.exec();