File: main.cpp

package info (click to toggle)
fmit 1.2.6-0.2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 2,828 kB
  • sloc: cpp: 9,490; sh: 62; makefile: 15
file content (95 lines) | stat: -rw-r--r-- 3,133 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Copyright 2004 "Gilles Degottex"

// This file is part of "fmit"

// "fmit" is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// "fmit" is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


#include <stdlib.h>
#include <iostream>
#include <cstdlib>
using namespace std;
#include <signal.h>
#include <qapplication.h>
#include <qtextcodec.h>
#include <qtranslator.h>
#include <QLibraryInfo>

#include "CppAddons/CAMath.h"

#include "qthelper.h"

#include "CustomInstrumentTunerForm.h"
CustomInstrumentTunerForm* g_main_form = NULL;


QString g_version;
QString FMITVersion(){
    if(!g_version.isEmpty())
        return g_version;

    QString fmitbranchgit(STR(FMITBRANCHGIT));

    QString	fmitversion(STR(FMITVERSION));
    if(!fmitbranchgit.isEmpty() && fmitbranchgit!="master") {
        fmitversion += "-" + fmitbranchgit;
    }
    g_version = fmitversion;

    return g_version;
}

int main(int argc, char** argv)
{
    std::cout << "Free Music Instrument Tuner (Version " << FMITVersion().toLatin1().constData() << ")" << std::endl;

    QString fmitprefix(STR(PREFIX));

    QApplication a(argc, argv, true);
    QApplication::setQuitOnLastWindowClosed(true);
    QCoreApplication::setOrganizationName("FMIT");
    QCoreApplication::setOrganizationDomain("gillesdegottex.eu");
    QCoreApplication::setApplicationName("FMIT");
    QCoreApplication::setApplicationVersion(FMITVersion());
    a.setWindowIcon(QIcon(":/fmit/ui/images/fmit.svg"));

    // Load translation
    QTranslator qtTranslator;
    QString trFile = "qt_" + QLocale::system().name();
    cout << "INFO: Loading Qt translation file: " << trFile.toLatin1().constData() << " in " << QLibraryInfo::location(QLibraryInfo::TranslationsPath).toLatin1().constData() << endl;
    qtTranslator.load(trFile, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
    a.installTranslator(&qtTranslator);
    QTranslator fmitTranslator;
    trFile = QString("fmit_")+QLocale::system().name();

    #ifdef Q_OS_WIN32
        QString trPath = QCoreApplication::applicationDirPath()+"/";
    #else
        QString trPath = fmitprefix + QString("/share/fmit/translations");
    #endif
    cout << "INFO: Loading FMIT translation file: " << trFile.toLatin1().constData() << " in " << trPath.toLatin1().constData() << endl;
    fmitTranslator.load(trFile, trPath);
    a.installTranslator(&fmitTranslator);

    g_main_form = new CustomInstrumentTunerForm();
	g_main_form->show();
	a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
	a.exec();

	delete g_main_form;

	return 0;
}