PageRenderTime 19ms CodeModel.GetById 2ms app.highlight 11ms RepoModel.GetById 2ms app.codeStats 0ms

/main.cpp

http://ewitool.googlecode.com/
C++ | 81 lines | 47 code | 10 blank | 24 comment | 7 complexity | bbee55af5ecaf22a80371f9e186a6bce MD5 | raw file
 1/***************************************************************************
 2 *   Copyright (C) 2008 by Steve Merrony   *
 3 *   ewitool At merrony dot flyer dot co dot uk   *
 4 *                                                                         *
 5 *   This program 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 3 of the License, or     *
 8 *   (at your option) any later version.                                   *
 9 *                                                                         *
10 *   This program 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                         *
17 *   Free Software Foundation, Inc.,                                       *
18 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19 ***************************************************************************/
20#include <QApplication>
21
22#include <iostream>
23using namespace std;
24
25#include "mainwindow.h"
26
27#ifdef Q_WS_WIN
28#include <windows.h>
29#endif
30				 
31//#ifndef Q_WS_WIN
32#include "midilistener.h"
33//#endif
34				 
35#include "midi_data.h"
36				 
37int main(int argc, char *argv[])
38{
39	//Q_INIT_RESOURCE(application);
40
41	midi_data *main_midi_data = new midi_data();
42	QString argStr;
43	QApplication app(argc, argv);
44	
45	// handle any arguments passed in
46	if ( app.argc() > 1 ) {
47		for (int arg = 1; arg<app.argc(); arg++) {
48			argStr = app.argv()[arg];
49			if (argStr.compare( "--help" ) == 0) {
50				cout << "\nUsage: EWItool [options]\n\
51Options:\n\
52--help       This help\n\
53--verbose    Be a lot more verbose in the console while EWItool is running\n\
54\n\
55For more information please visit http://code.google.com/p/ewitool/ \n";
56				exit(0);
57			}
58			if (argStr.compare( "--verbose" ) == 0) { main_midi_data->verboseMode = TRUE; continue; }
59		}
60	}
61#ifdef Q_WS_WIN
62	// if we're in win32 and user specifed verbose, then open a console for the messages
63	if (main_midi_data->verboseMode) {
64		AllocConsole();
65		freopen("conin$", "r", stdin);
66		freopen("conout$", "w", stdout);
67		freopen("conout$", "w", stderr);
68	}
69#endif
70	app.setQuitOnLastWindowClosed( true );
71	MainWindow mw( main_midi_data );
72	mw.show();
73
74	MidiListener *mlThread = new MidiListener( (QObject *) main_midi_data );
75	mlThread->start();
76	
77    const int retval = app.exec();
78    mlThread->terminate();
79    delete main_midi_data;
80    return retval;
81}