| 1 |
// Copyright 2004 "Gilles Degottex" |
| 2 |
|
| 3 |
// This file is part of "fmit" |
| 4 |
|
| 5 |
// "fmit" is free software; you can redistribute it and/or modify |
| 6 |
// it under the terms of the GNU General Public License as published by |
| 7 |
// the Free Software Foundation; either version 2 of the License, or |
| 8 |
// (at your option) any later version. |
| 9 |
// |
| 10 |
// "fmit" is distributed in the hope that it will be useful, |
| 11 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
// GNU General Public License for more details. |
| 14 |
// |
| 15 |
// You should have received a copy of the GNU General Public License |
| 16 |
// along with this program; if not, write to the Free Software |
| 17 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 |
|
| 19 |
|
| 20 |
#include <stdlib.h> |
| 21 |
#include <iostream> |
| 22 |
#include <cstdlib> |
| 23 |
using namespace std; |
| 24 |
#include <signal.h> |
| 25 |
#include <qapplication.h> |
| 26 |
// #include <qtextcodec.h> |
| 27 |
#include <qtranslator.h> |
| 28 |
#include <QLibraryInfo> |
| 29 |
|
| 30 |
#include "CppAddons/CAMath.h" |
| 31 |
|
| 32 |
#include "qthelper.h" |
| 33 |
|
| 34 |
#include "CustomInstrumentTunerForm.h" |
| 35 |
CustomInstrumentTunerForm* g_main_form = NULL; |
| 36 |
|
| 37 |
|
| 38 |
QString g_version; |
| 39 |
QString FMITVersion(){ |
| 40 |
if(!g_version.isEmpty()) |
| 41 |
return g_version; |
| 42 |
|
| 43 |
QString fmitbranchgit(STR(FMITBRANCHGIT)); |
| 44 |
|
| 45 |
QString fmitversion(STR(FMITVERSION)); |
| 46 |
if(!fmitbranchgit.isEmpty() && fmitbranchgit!="master") { |
| 47 |
fmitversion += "-" + fmitbranchgit; |
| 48 |
} |
| 49 |
g_version = fmitversion; |
| 50 |
|
| 51 |
return g_version; |
| 52 |
} |
| 53 |
|
| 54 |
int main(int argc, char** argv) |
| 55 |
{ |
| 56 |
std::cout << "Free Music Instrument Tuner (Version " << FMITVersion().toLatin1().constData() << ")" << std::endl; |
| 57 |
|
| 58 |
QString fmitprefix(STR(PREFIX)); |
| 59 |
|
| 60 |
QApplication a(argc, argv, true); |
| 61 |
QApplication::setQuitOnLastWindowClosed(true); |
| 62 |
QCoreApplication::setOrganizationName("FMIT"); |
| 63 |
QCoreApplication::setOrganizationDomain("gillesdegottex.eu"); |
| 64 |
QCoreApplication::setApplicationName("FMIT"); |
| 65 |
QCoreApplication::setApplicationVersion(FMITVersion()); |
| 66 |
a.setWindowIcon(QIcon(":/fmit/ui/images/fmit.svg")); |
| 67 |
|
| 68 |
// Load translation |
| 69 |
QTranslator qtTranslator; |
| 70 |
std::cout << "INFO: QLocale::system()=" << QLocale::system().name() << std::endl; |
| 71 |
std::cout << "INFO: QLibraryInfo::path(QLibraryInfo::TranslationsPath)=" << QLibraryInfo::path(QLibraryInfo::TranslationsPath).toLatin1().constData() << std::endl; |
| 72 |
QString trFile = "qt_" + QLocale::system().name(); |
| 73 |
if (!qtTranslator.load(trFile, QLibraryInfo::path(QLibraryInfo::TranslationsPath))) { |
| 74 |
cout << "ERROR: Failed to load Qt translation file: " << trFile.toLatin1().constData() << " in " << QLibraryInfo::path(QLibraryInfo::TranslationsPath).toLatin1().constData() << endl; |
| 75 |
} |
| 76 |
a.installTranslator(&qtTranslator); |
| 77 |
QTranslator fmitTranslator; |
| 78 |
trFile = QString("fmit_")+QLocale::system().name(); |
| 79 |
|
| 80 |
#ifdef Q_OS_WIN32 |
| 81 |
QString trPath = QCoreApplication::applicationDirPath()+"/"; |
| 82 |
#else |
| 83 |
QString trPath = fmitprefix + QString("/share/fmit/translations"); |
| 84 |
#endif |
| 85 |
cout << "INFO: Loading FMIT translation directory: " << trFile.toLatin1().constData() << " in " << trPath.toLatin1().constData() << endl; |
| 86 |
if (!fmitTranslator.load(trFile, trPath)) { |
| 87 |
cout << "ERROR: Failed to load FMIT translation file: " << trFile.toLatin1().constData() << " in " << trPath.toLatin1().constData() << endl; |
| 88 |
} |
| 89 |
a.installTranslator(&fmitTranslator); |
| 90 |
|
| 91 |
g_main_form = new CustomInstrumentTunerForm(); |
| 92 |
g_main_form->show(); |
| 93 |
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); |
| 94 |
a.exec(); |
| 95 |
|
| 96 |
delete g_main_form; |
| 97 |
|
| 98 |
return 0; |
| 99 |
} |
| 100 |
|