/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. #include <iostream>
  22. using namespace std;
  23. #include "mainwindow.h"
  24. #ifdef Q_WS_WIN
  25. #include <windows.h>
  26. #endif
  27. //#ifndef Q_WS_WIN
  28. #include "midilistener.h"
  29. //#endif
  30. #include "midi_data.h"
  31. int main(int argc, char *argv[])
  32. {
  33. //Q_INIT_RESOURCE(application);
  34. midi_data *main_midi_data = new midi_data();
  35. QString argStr;
  36. QApplication app(argc, argv);
  37. // handle any arguments passed in
  38. if ( app.argc() > 1 ) {
  39. for (int arg = 1; arg<app.argc(); arg++) {
  40. argStr = app.argv()[arg];
  41. if (argStr.compare( "--help" ) == 0) {
  42. cout << "\nUsage: EWItool [options]\n\
  43. Options:\n\
  44. --help This help\n\
  45. --verbose Be a lot more verbose in the console while EWItool is running\n\
  46. \n\
  47. For more information please visit http://code.google.com/p/ewitool/ \n";
  48. exit(0);
  49. }
  50. if (argStr.compare( "--verbose" ) == 0) { main_midi_data->verboseMode = TRUE; continue; }
  51. }
  52. }
  53. #ifdef Q_WS_WIN
  54. // if we're in win32 and user specifed verbose, then open a console for the messages
  55. if (main_midi_data->verboseMode) {
  56. AllocConsole();
  57. freopen("conin$", "r", stdin);
  58. freopen("conout$", "w", stdout);
  59. freopen("conout$", "w", stderr);
  60. }
  61. #endif
  62. app.setQuitOnLastWindowClosed( true );
  63. MainWindow mw( main_midi_data );
  64. mw.show();
  65. MidiListener *mlThread = new MidiListener( (QObject *) main_midi_data );
  66. mlThread->start();
  67. const int retval = app.exec();
  68. mlThread->terminate();
  69. delete main_midi_data;
  70. return retval;
  71. }