Release version 0.99.2-1
[fmit.git] / src / main.cpp
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 "config.h"
21
22 #include <stdlib.h>
23 #include <iostream>
24 using namespace std;
25 #include <signal.h>
26 #include <qapplication.h>
27 #include <qtextcodec.h>
28 #include <qtranslator.h>
29 #include <GL/glut.h>
30
31 #include <CppAddons/CAMath.h>
32
33 #include "CustomInstrumentTunerForm.h"
34 CustomInstrumentTunerForm* g_main_form = NULL;
35
36 void signal_interrupt(int sig)
37 {
38         cerr << "Interrupt" << endl;
39
40         delete g_main_form;
41
42         exit(sig);
43 }
44 void signal_term(int sig)
45 {
46         cerr << "No No ! Pleeeeeease ... *argl*" << endl;
47         cerr << endl;
48         cerr << PACKAGE_NAME << " nastily killed with signal " << sig << endl;
49
50         exit(sig);
51 }
52
53 int main(int argc, char** argv)
54 {
55         cerr << "Free Music Instrument Tuner version " << PACKAGE_VERSION << " built at " << __DATE__ << " " << __TIME__ << endl;
56         cerr << "Install directory '" << PREFIX << "'" << endl;
57
58         signal(SIGINT, signal_interrupt);
59         signal(SIGTERM, signal_term);
60
61         QApplication a(argc, argv, true);
62
63         glutInit(&argc, argv);
64
65 //      if(a.argc()>1)
66 //      {
67 //              if(a.argc()>2 && (QString(a.argv()[1])=="-d" || QString(a.argv()[1])=="--device"))
68 //              {
69 //                      cerr << "used device: " << a.argv()[2] << endl;
70 //              }
71 //      }
72
73 //      cerr << "LANG=" << QTextCodec::locale() << endl;
74
75         QTranslator tr_fmit;
76         QString trFile = QString("fmit_") + QLocale::system().name();
77         QString trPath = QString(PREFIX) + QString("/share/fmit/tr");
78         cerr << "Looking up translation '" << trFile.toStdString() << "' in '" << trPath.toStdString() << "'" << endl;
79         tr_fmit.load(trFile, trPath);
80         a.installTranslator(&tr_fmit);
81
82         g_main_form = new CustomInstrumentTunerForm();
83
84         g_main_form->show();
85
86         a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
87         a.exec();
88
89         delete g_main_form;
90
91         return 0;
92 }
93