projects
/
dorian
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add tool bar on Symbian. Fix some orientation change bugs.
[dorian]
/
main.cpp
diff --git
a/main.cpp
b/main.cpp
index
647822e
..
b655866
100644
(file)
--- a/
main.cpp
+++ b/
main.cpp
@@
-1,38
+1,84
@@
-#ifdef Q_OS_UNIX
-#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 QtMsgType DORIAN_DEFAULT_TRACE_LEVEL =
+#ifdef Q_OS_SYMBIAN
+ QtDebugMsg
+#else
+ QtWarningMsg
+#endif
+ ;
int main(int argc, char *argv[])
{
int main(int argc, char *argv[])
{
+ int ret;
+
+ // Set up application
QApplication a(argc, argv);
a.setApplicationName("Dorian");
QApplication a(argc, argv);
a.setApplicationName("Dorian");
- a.setApplicationVersion("0.0.1");
+ a.setApplicationVersion(DORIAN_VERSION);
a.setOrganizationDomain("pipacs.com");
a.setOrganizationName("Pipacs");
a.setOrganizationDomain("pipacs.com");
a.setOrganizationName("Pipacs");
- Trace::level = (QtMsgType)Settings::instance()->
- value("tracelevel", (int)QtWarningMsg).toInt();
+ // Initialize tracing
+ Settings *settings = Settings::instance();
+ Trace::level = (QtMsgType)settings->
+ value("tracelevel", (int)DORIAN_DEFAULT_TRACE_LEVEL).toInt();
+ Trace::setFileName(settings->value("tracefilename").toString());
qInstallMsgHandler(Trace::messageHandler);
qInstallMsgHandler(Trace::messageHandler);
- MainWindow w;
-#ifdef Q_WS_S60
- w.showMaximized();
-#else
- w.show();
+#if 0 // def Q_OS_SYMBIAN
+ // Show splash screen
+ Splash *splash = new Splash();
+ splash->showFullScreen();
+ // splash->showMaximized();
+ splash->raise();
+ a.processEvents();
#endif
#endif
- int ret = a.exec();
- if (ret == 1000) {
-#ifdef Q_OS_UNIX
- extern char **environ;
- execve(argv[0], argv, environ);
+ // Create and initialize main window, then run event loop
+ MainWindow *mainWindow = new MainWindow();
+ settings->apply();
+ mainWindow->initialize();
+#if 0 // def Q_OS_SYMBIAN
+ splash->close();
+ delete splash;
+ mainWindow->showNormal();
#endif
#endif
+ ret = a.exec();
+ delete mainWindow;
+
+ // Re-start application if event loop exit code was 1000
+ if (ret == 1000) {
+ Platform::instance()->restart(argv);
}
}
+
+ // Release singletons
+ Library::close();
+ BookDb::close();
+ Settings::close();
+ Search::close();
+ Platform::close();
+#ifdef Q_OS_SYMBIAN
+ MediaKeysObserver::close();
+#endif
+
return ret;
}
return ret;
}