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