Update splash screen.
[dorian] / main.cpp
1 #include <QtGui/QApplication>
2
3 #include "mainwindow.h"
4 #include "trace.h"
5 #include "settings.h"
6 #include "library.h"
7 #include "settings.h"
8 #include "bookdb.h"
9 #include "search.h"
10 #include "platform.h"
11 #include "splash.h"
12
13 #ifdef Q_OS_SYMBIAN
14 #   include "mediakeysobserver.h"
15 #endif
16
17 static const char *DORIAN_VERSION =
18 #include "pkg/version.txt"
19 ;
20
21 static const QtMsgType DORIAN_DEFAULT_TRACE_LEVEL =
22 #ifdef Q_OS_SYMBIAN
23         QtDebugMsg
24 #else
25         QtWarningMsg
26 #endif
27         ;
28
29 int main(int argc, char *argv[])
30 {
31     QApplication a(argc, argv);
32     int ret;
33
34     a.setApplicationName("Dorian");
35     a.setApplicationVersion(DORIAN_VERSION);
36     a.setOrganizationDomain("pipacs.com");
37     a.setOrganizationName("Pipacs");
38
39     Trace::level = (QtMsgType)Settings::instance()->
40         value("tracelevel", (int)DORIAN_DEFAULT_TRACE_LEVEL).toInt();
41     qInstallMsgHandler(Trace::messageHandler);
42
43 #ifdef Q_OS_SYMBIAN
44     Splash *splash = new Splash();
45     splash->showFullScreen();
46     a.processEvents();
47 #endif
48
49     {
50         MainWindow w;
51 #ifdef Q_OS_SYMBIAN
52         splash->close();
53         splash->deleteLater();
54 #endif
55         ret = a.exec();
56     }
57
58     // Release singletons
59     Library::close();
60     BookDb::close();
61     Settings::close();
62     Search::close();
63 #ifdef Q_OS_SYMBIAN
64     MediaKeysObserver::close();
65 #endif
66
67     // Re-start application if event loop exit code was 1000
68     if (ret == 1000) {
69         Platform::restart(argv);
70     }
71     return ret;
72 }