The threading model should be set from configure, not config.h.
[maemo-rb.git] / rbutil / rbutilqt / main.cpp
blobbb70ec1ba1638c4731012529c14c9e7227504402
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 <QtGui>
21 #include "rbutilqt.h"
22 #include "systrace.h"
24 #ifdef STATIC
25 #include <QtPlugin>
26 Q_IMPORT_PLUGIN(qtaccessiblewidgets)
27 #endif
31 int main( int argc, char ** argv ) {
32 qInstallMsgHandler(SysTrace::debug);
33 QApplication app( argc, argv );
34 #if defined(Q_OS_MAC)
35 QDir dir(QApplication::applicationDirPath());
36 dir.cdUp();
37 dir.cd("plugins");
38 QApplication::addLibraryPath(dir.absolutePath());
39 #endif
40 QString absolutePath = QCoreApplication::instance()->applicationDirPath();
41 // portable installation:
42 // check for a configuration file in the program folder.
43 QSettings *user;
44 if(QFileInfo(absolutePath + "/RockboxUtility.ini").isFile())
45 user = new QSettings(absolutePath + "/RockboxUtility.ini", QSettings::IniFormat, 0);
46 else user = new QSettings(QSettings::IniFormat, QSettings::UserScope, "rockbox.org", "RockboxUtility");
48 QString applang = QLocale::system().name();
49 QTranslator translator;
50 QTranslator qttrans;
51 // install translator
52 if(!user->value("lang", "").toString().isEmpty()) {
53 applang = user->value("lang", "").toString();
55 if(!applang.isEmpty()) {
56 if(!translator.load("rbutil_" + applang, absolutePath))
57 translator.load("rbutil_" + applang, ":/lang");
58 if(!qttrans.load("qt_" + applang,
59 QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
60 qttrans.load("qt_" + applang, ":/lang");
62 QLocale::setDefault(applang);
64 delete user;
65 app.installTranslator(&translator);
66 app.installTranslator(&qttrans);
67 //: This string is used to indicate the writing direction. Translate it
68 //: to "RTL" (without quotes) for RTL languages. Anything else will get
69 //: treated as LTR language.
70 if(QObject::tr("LTR") == "RTL")
71 app.setLayoutDirection(Qt::RightToLeft);
73 // keep a list of installed translators. Needed to be able uninstalling them
74 // later again (in case of translation changes)
75 QList<QTranslator*> translators;
76 translators.append(&translator);
77 translators.append(&qttrans);
78 RbUtilQt window(0);
79 RbUtilQt::translators = translators;
80 window.show();
82 // app.connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );
83 return app.exec();