| 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2002-2003 Andi Peredri * |
| 3 | * [email protected] * |
| 4 | * Copyright (C) 2004-2007 Artur Wiebe * |
| 5 | * [email protected] * |
| 6 | * * |
| 7 | * This program is free software; you can redistribute it and/or modify * |
| 8 | * it under the terms of the GNU General Public License as published by * |
| 9 | * the Free Software Foundation; either version 2 of the License, or * |
| 10 | * (at your option) any later version. * |
| 11 | * * |
| 12 | * This program is distributed in the hope that it will be useful, * |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 15 | * GNU General Public License for more details. * |
| 16 | * * |
| 17 | * You should have received a copy of the GNU General Public License * |
| 18 | * along with this program; if not, write to the * |
| 19 | * Free Software Foundation, Inc., * |
| 20 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
| 21 | ***************************************************************************/ |
| 22 | |
| 23 | #include <QApplication> |
| 24 | #include <QTranslator> |
| 25 | #include <QLocale> |
| 26 | #include <QDebug> |
| 27 | #include <QLibraryInfo> |
| 28 | //#include <QPlastiqueStyle> |
| 29 | |
| 30 | |
| 31 | #include "toplevel.h" |
| 32 | #include "common.h" |
| 33 | |
| 34 | |
| 35 | int main(int argc, char *argv[]) |
| 36 | { |
| 37 | QApplication app(argc,argv); |
| 38 | QString current_lang = QLocale::system().name().split("_").front(); |
| 39 | QString qt_lang_path = QLibraryInfo::location(QLibraryInfo::TranslationsPath); |
| 40 | QString qcheckers_share_path = PREFIX"/share/qcheckers/lang"; |
| 41 | |
| 42 | qDebug() |
| 43 | << "Your Locale:" << current_lang << endl |
| 44 | << "QCheckers Prefix path:" << PREFIX << endl |
| 45 | << "QT Translations path:" << qt_lang_path << endl; |
| 46 | |
| 47 | // Qt translations |
| 48 | QTranslator qt_tr; |
| 49 | if(qt_tr.load("qt_" + current_lang, qt_lang_path)) { |
| 50 | app.installTranslator(&qt_tr); |
| 51 | } else { |
| 52 | qDebug() << "Loading Qt translations failed."; |
| 53 | } |
| 54 | |
| 55 | // App translations |
| 56 | QTranslator app_tr; |
| 57 | if(app_tr.load("qcheckers_" + current_lang, |
| 58 | qcheckers_share_path)) { |
| 59 | app.installTranslator(&app_tr); |
| 60 | } else { |
| 61 | qDebug() << "Loading QCheckers translations failed."; |
| 62 | } |
| 63 | |
| 64 | myTopLevel* top = new myTopLevel(); |
| 65 | top->show(); |
| 66 | |
| 67 | // command line |
| 68 | if(app.arguments().length()==2) { |
| 69 | top->open(app.arguments()[1]); |
| 70 | } |
| 71 | |
| 72 | int exit = app.exec(); |
| 73 | |
| 74 | delete top; |
| 75 | return exit; |
| 76 | } |