Created a class MainApplication to handle notify()

This commit is contained in:
Tats
2014-01-23 23:24:20 -05:00
parent 18f6160507
commit a539023a30
4 changed files with 87 additions and 2 deletions
+46
View File
@@ -0,0 +1,46 @@
/*
* MainApplication.cpp
*
* (c) 2014 Sofian Audry -- info(@)sofianaudry(.)com
* (c) 2014 Alexandre Quessy -- alexandre(@)quessy(.)net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "MainApplication.h"
MainApplication::MainApplication(int &argc, char *argv[])
: QApplication(argc, argv)
{
}
MainApplication::~MainApplication()
{
}
bool MainApplication::notify(QObject *receiver, QEvent *event)
{
try
{
return QApplication::notify(receiver, event);
}
catch (std::exception &ex)
{
qDebug() << "std::exception was caught: " << ex.what() << endl;
qDebug() << "event type: " << event->type() << endl;
}
return false;
}
+36
View File
@@ -0,0 +1,36 @@
/*
* MainApplication.h
*
* (c) 2014 Sofian Audry -- info(@)sofianaudry(.)com
* (c) 2014 Alexandre Quessy -- alexandre(@)quessy(.)net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MAINAPPLICATION_H_
#define MAINAPPLICATION_H_
#include <QApplication>
#include <QDebug>
class MainApplication : public QApplication
{
public:
MainApplication(int &argc, char *argv[]);
virtual ~MainApplication();
bool notify(QObject *receiver, QEvent *event);
};
#endif /* MAINAPPLICATION_H_ */
+2
View File
@@ -3,6 +3,7 @@ TEMPLATE = app
HEADERS = \
DestinationGLCanvas.h \
# Facade.h \
MainApplication.h \
MainWindow.h \
Mapper.h \
MapperGLCanvas.h \
@@ -22,6 +23,7 @@ SOURCES = \
DestinationGLCanvas.cpp \
# Facade.cpp \
MainWindow.cpp \
MainApplication.cpp \
Mapper.cpp \
MapperGLCanvas.cpp \
Mapping.cpp \
+3 -2
View File
@@ -1,18 +1,19 @@
// NOTE: To run, it is recommended not to be in Compiz or Beryl, they have shown some instability.
#include <iostream>
#include <QApplication>
#include <QTranslator>
#include <QtGui>
#include "Common.h"
#include "MainWindow.h"
#include "MainApplication.h"
#include <iostream>
int main(int argc, char *argv[])
{
// TODO: avoid segfaults when OSC port is busy
QApplication app(argc, argv);
MainApplication app(argc, argv);
if (! QGLFormat::hasOpenGL())
{