-
Notifications
You must be signed in to change notification settings - Fork 1
/
mainapplication.cpp
52 lines (46 loc) · 1.47 KB
/
mainapplication.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "mainapplication.h"
#include "topfactory.h"
MainApplication::MainApplication(int &argc, char **argv) : QApplication(argc, argv)
{
errorCaught = false;
srand (static_cast <unsigned> (time(0))); // Seed the random number generator
try
{
window = new MainWindow(&(this->handler));
connect(window, SIGNAL(destroyed()), this, SLOT(quit()));
window->setAttribute(Qt::WA_DeleteOnClose, true);
handler.setWindow(window);
handler.setContainer(&(this->mathsContainer));
factory = std::unique_ptr<TopFactory>(new TopFactory(&(this->mathsContainer), &(this->handler)));
handler.setFactory(factory.get());
handler.resetDelegatePointers();
window->show();
window->setEnabled(true);
window->setFocus();
}
catch(QString errorMessage)
{
qDebug() << "Error caught (by MainApplication::MainApplication): " << errorMessage;
throw(QString("Error thrown in MainApplication::MainApplication"));
}
}
bool MainApplication::notify(QObject * receiver, QEvent * event)
{
try
{
return QApplication::notify(receiver, event);
}
catch(QString errorMessage)
{
if (errorCaught)
{
return QApplication::notify(receiver, event);
}
else
{
qDebug() << "In MainApplication::notify: errorMessage = " << errorMessage;
// Do Something (see CirclePackings code)
}
}
return false;
}