projects
/
dorian
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make orientation switch explicit on Symbian, too.
[dorian]
/
main.cpp
diff --git
a/main.cpp
b/main.cpp
index
fa8bbb0
..
69bf13c
100644
(file)
--- a/
main.cpp
+++ b/
main.cpp
@@
-1,12
+1,18
@@
-#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
-#include <unistd.h>
-#endif
-
#include <QtGui/QApplication>
#include "mainwindow.h"
#include "trace.h"
#include "settings.h"
#include <QtGui/QApplication>
#include "mainwindow.h"
#include "trace.h"
#include "settings.h"
+#include "library.h"
+#include "settings.h"
+#include "bookdb.h"
+#include "search.h"
+#include "platform.h"
+#include "splash.h"
+
+#ifdef Q_OS_SYMBIAN
+# include "mediakeysobserver.h"
+#endif
static const char *DORIAN_VERSION =
#include "pkg/version.txt"
static const char *DORIAN_VERSION =
#include "pkg/version.txt"
@@
-22,33
+28,55
@@
static const QtMsgType DORIAN_DEFAULT_TRACE_LEVEL =
int main(int argc, char *argv[])
{
int main(int argc, char *argv[])
{
- QApplication a(argc, argv);
+ int ret;
+
+ // Set up application
+ QApplication app(argc, argv);
+ app.setApplicationName("Dorian");
+ app.setApplicationVersion(DORIAN_VERSION);
+ app.setOrganizationDomain("pipacs.com");
+ app.setOrganizationName("Pipacs");
- Trace::level = (QtMsgType)Settings::instance()->
+ // Initialize tracing
+ Settings *settings = Settings::instance();
+ Trace::level = (QtMsgType)settings->
value("tracelevel", (int)DORIAN_DEFAULT_TRACE_LEVEL).toInt();
value("tracelevel", (int)DORIAN_DEFAULT_TRACE_LEVEL).toInt();
+ Trace::setFileName(settings->value("tracefilename").toString());
qInstallMsgHandler(Trace::messageHandler);
qInstallMsgHandler(Trace::messageHandler);
- a.setApplicationName("Dorian");
- a.setApplicationVersion(DORIAN_VERSION);
- a.setOrganizationDomain("pipacs.com");
- a.setOrganizationName("Pipacs");
+#ifdef Q_OS_SYMBIAN
+ // Show splash screen
+ Splash splash;
+ splash.show();
+ app.processEvents();
+#endif
- MainWindow w;
- w.show();
+ // Initialize main window
+ MainWindow *mainWindow = new MainWindow();
+ settings->apply();
+ mainWindow->initialize();
-#if 0 // FIXME #ifdef Q_OS_SYMBIAN
- // Remove context menu from all widgets
- foreach (QWidget *w, QApplication::allWidgets()) {
- w->setContextMenuPolicy(Qt::NoContextMenu);
- }
-#endif // Q_OS_SYMBIAN
+#ifdef Q_OS_SYMBIAN
+ // Hide splash screen
+ splash.finish(mainWindow);
+#endif
- int ret = a.exec();
+ // Run event loop, Re-start application if event loop exit code was 1000
+ ret = app.exec();
if (ret == 1000) {
if (ret == 1000) {
-#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
- extern char **environ;
- execve(argv[0], argv, environ);
-#endif
+ Platform::instance()->restart(argv);
}
}
+
+ // Release singletons
+ delete mainWindow;
+ Library::close();
+ BookDb::close();
+ Settings::close();
+ Search::close();
+ Platform::close();
+#ifdef Q_OS_SYMBIAN
+ MediaKeysObserver::close();
+#endif
+
return ret;
}
return ret;
}