Handle nested TOC items.
[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
12 static const char *DORIAN_VERSION =
13 #include "pkg/version.txt"
14 ;
15
16 static const QtMsgType DORIAN_DEFAULT_TRACE_LEVEL =
17 #ifdef Q_OS_SYMBIAN
18         QtDebugMsg
19 #else
20         QtWarningMsg
21 #endif
22         ;
23
24 int main(int argc, char *argv[])
25 {
26     QApplication a(argc, argv);
27     int ret;
28
29     a.setApplicationName("Dorian");
30     a.setApplicationVersion(DORIAN_VERSION);
31     a.setOrganizationDomain("pipacs.com");
32     a.setOrganizationName("Pipacs");
33
34     Trace::level = (QtMsgType)Settings::instance()->
35         value("tracelevel", (int)DORIAN_DEFAULT_TRACE_LEVEL).toInt();
36     qInstallMsgHandler(Trace::messageHandler);
37
38     {
39         MainWindow w;
40         w.show();
41         ret = a.exec();
42     }
43
44     // Release singletons
45     Library::close();
46     BookDb::close();
47     Settings::close();
48     Search::close();
49
50     // Re-start application if event loop exit code was 1000
51     if (ret == 1000) {
52         Platform::restart(argv);
53     }
54     return ret;
55 }