X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;ds=sidebyside;f=main.cpp;h=b6558660fa3488f9f1c8ae0b15f2913df66364f9;hb=b28659ebcbbcd4c42d90e0439fc09e03fc5a47cc;hp=fa8bbb0b0d36da74c93842188c03e6fd26afce36;hpb=f0f805b5e6cd0fda0dafe6254debe6845ae2738b;p=dorian diff --git a/main.cpp b/main.cpp index fa8bbb0..b655866 100644 --- a/main.cpp +++ b/main.cpp @@ -1,12 +1,18 @@ -#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) -#include -#endif - #include #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" @@ -22,33 +28,57 @@ static const QtMsgType DORIAN_DEFAULT_TRACE_LEVEL = int main(int argc, char *argv[]) { - QApplication a(argc, argv); - - Trace::level = (QtMsgType)Settings::instance()-> - value("tracelevel", (int)DORIAN_DEFAULT_TRACE_LEVEL).toInt(); - qInstallMsgHandler(Trace::messageHandler); + int ret; + // Set up application + QApplication a(argc, argv); a.setApplicationName("Dorian"); a.setApplicationVersion(DORIAN_VERSION); a.setOrganizationDomain("pipacs.com"); a.setOrganizationName("Pipacs"); - MainWindow w; - w.show(); + // 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); -#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 +#if 0 // def Q_OS_SYMBIAN + // Show splash screen + Splash *splash = new Splash(); + splash->showFullScreen(); + // splash->showMaximized(); + splash->raise(); + a.processEvents(); +#endif - int ret = a.exec(); - if (ret == 1000) { -#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) - 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 + 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; }