1 /** @file qtguiapp.h  Application based on Qt GUI widgets.
2  *
3  * @authors Copyright © 2013-2017 Jaakko Keränen <jaakko.keranen@iki.fi>
4  *
5  * @par License
6  * GPL: http://www.gnu.org/licenses/gpl.html
7  *
8  * <small>This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by the
10  * Free Software Foundation; either version 2 of the License, or (at your
11  * option) any later version. This program is distributed in the hope that it
12  * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14  * Public License for more details. You should have received a copy of the GNU
15  * General Public License along with this program; if not, see:
16  * http://www.gnu.org/licenses</small>
17  */
18 
19 #include "qtguiapp.h"
20 #include <QMessageBox>
21 #include <de/LogBuffer>
22 #include <de/Error>
23 #include <de/Clock>
24 #include <de/Animation>
25 
26 using namespace de;
27 
DENG2_PIMPL(QtGuiApp)28 DENG2_PIMPL(QtGuiApp)
29 {
30     LogBuffer logBuffer;
31     Clock clock;
32 
33     Impl(Public *i) : Base(i)
34     {
35         LogBuffer::setAppBuffer(logBuffer);
36         Clock::setAppClock(&clock);
37         Animation::setClock(&clock);
38 
39         logBuffer.setAutoFlushInterval(0.1);
40     }
41 
42     ~Impl()
43     {
44         Clock::setAppClock(0);
45         Animation::setClock(0);
46     }
47 };
48 
QtGuiApp(int & argc,char ** argv)49 QtGuiApp::QtGuiApp(int &argc, char **argv)
50     : QApplication(argc, argv), d(new Impl(this))
51 {}
52 
notify(QObject * receiver,QEvent * event)53 bool QtGuiApp::notify(QObject *receiver, QEvent *event)
54 {
55     try
56     {
57         return QApplication::notify(receiver, event);
58     }
59     catch (Error const &er)
60     {
61         QMessageBox::critical(NULL, "Uncaught Exception", er.asText());
62     }
63     return false;
64 }
65