New version. Update home page link in About box.
[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     int ret;
32
33     // Set up application
34     QApplication a(argc, argv);
35     a.setApplicationName("Dorian");
36     a.setApplicationVersion(DORIAN_VERSION);
37     a.setOrganizationDomain("pipacs.com");
38     a.setOrganizationName("Pipacs");
39
40     // Initialize tracing
41     Settings *settings = Settings::instance();
42     Trace::level = (QtMsgType)settings->
43         value("tracelevel", (int)DORIAN_DEFAULT_TRACE_LEVEL).toInt();
44     Trace::setFileName(settings->value("tracefilename").toString());
45     qInstallMsgHandler(Trace::messageHandler);
46
47 #if 0 // def Q_OS_SYMBIAN
48     // Show splash screen
49     Splash *splash = new Splash();
50     splash->showFullScreen();
51     // splash->showMaximized();
52     splash->raise();
53     a.processEvents();
54 #endif
55
56     // Create and initialize main window, then run event loop
57     MainWindow *mainWindow = new MainWindow();
58     settings->apply();
59     mainWindow->initialize();
60 #if 0 // def Q_OS_SYMBIAN
61     splash->close();
62     delete splash;
63     mainWindow->showNormal();
64 #endif
65     ret = a.exec();
66     delete mainWindow;
67
68     // Re-start application if event loop exit code was 1000
69     if (ret == 1000) {
70         Platform::instance()->restart(argv);
71     }
72
73     // Release singletons
74     Library::close();
75     BookDb::close();
76     Settings::close();
77     Search::close();
78     Platform::close();
79 #ifdef Q_OS_SYMBIAN
80     MediaKeysObserver::close();
81 #endif
82
83     return ret;
84 }