MNE-CPP  beta 1.0
main.cpp
1 //=============================================================================================================
38 //*************************************************************************************************************
39 //=============================================================================================================
40 // INCLUDES
41 //=============================================================================================================
42 
43 #include <stdio.h>
44 #include "Windows/mainwindow.h"
45 #include "Utils/info.h"
46 
47 
48 //*************************************************************************************************************
49 //=============================================================================================================
50 // Qt INCLUDES
51 //=============================================================================================================
52 
53 #include <QtGui>
54 #include <QApplication>
55 #include <QDateTime>
56 #include <QSplashScreen>
57 #include <QThread>
58 
59 
60 //*************************************************************************************************************
61 //=============================================================================================================
62 // USED NAMESPACES
63 //=============================================================================================================
64 
65 using namespace MNEBrowseRawQt;
66 
67 
68 //*************************************************************************************************************
69 //=============================================================================================================
70 // FORWARD DECLARATIONS
71 //=============================================================================================================
72 
73 MainWindow* mainWindow = NULL;
74 
75 
76 //*************************************************************************************************************
77 
78 void customMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
79 {
80  Q_UNUSED(context);
81 
82  QString dt = QDateTime::currentDateTime().toString("dd/MM/yyyy hh:mm:ss");
83  QString txt = QString("[%1] ").arg(dt);
84 
85  if(mainWindow) {
86  switch (type) {
87  case QtDebugMsg:
88  txt += QString("{Debug} \t\t %1").arg(msg);
89  mainWindow->writeToLog(txt,_LogKndMessage, _LogLvMax);
90  break;
91  case QtWarningMsg:
92  txt += QString("{Warning} \t %1").arg(msg);
93  mainWindow->writeToLog(txt,_LogKndWarning, _LogLvNormal);
94  break;
95  case QtCriticalMsg:
96  txt += QString("{Critical} \t %1").arg(msg);
97  mainWindow->writeToLog(txt,_LogKndError, _LogLvMin);
98  break;
99  case QtFatalMsg:
100  txt += QString("{Fatal} \t\t %1").arg(msg);
101  mainWindow->writeToLog(txt,_LogKndError, _LogLvMin);
102  abort();
103  break;
104  }
105  }
106 }
107 
108 
109 //=============================================================================================================
110 // MAIN
111 int main(int argc, char *argv[])
112 {
113  qInstallMessageHandler(customMessageHandler);
114  QApplication a(argc, argv);
115 
116  //set application settings
117  QCoreApplication::setOrganizationName(CInfo::OrganizationName());
118  QCoreApplication::setApplicationName(CInfo::AppNameShort());
119 
120  //show splash screen for 1 second
121  QPixmap pixmap(":/Resources/Images/splashscreen_mne_browse_raw_qt.png");
122  QSplashScreen splash(pixmap);
123  splash.show();
124  QThread::sleep(1);
125 
126  mainWindow = new MainWindow();
127  mainWindow->show();
128 
129  splash.finish(mainWindow);
130 
131  return a.exec();
132 }
static const QString AppNameShort()
Definition: info.h:97
void writeToLog(const QString &logMsg, LogKind lgknd, LogLevel lglvl)
Definition: mainwindow.cpp:444