summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp80
1 files changed, 53 insertions, 27 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 0eab2ca..f265ad7 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -7,38 +7,31 @@
*
**********/
-//own includes
-#include "bibletimeapp.h"
+#include <cstdlib>
+#include <cstdio>
+#include <csignal>
+#ifndef NO_DBUS
+#include <QDBusConnection>
+#endif
+#include <QDebug>
+#include <QLocale>
+#include <QTextCodec>
+#include <QTranslator>
+#include <QVariant>
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
+#include "backend/config/cbtconfig.h"
#include "bibletime.h"
#include "bibletime_dbus_adaptor.h"
-
+#include "bibletimeapp.h"
#include "util/cresmgr.h"
-#include "util/directoryutil.h"
+#include "util/directory.h"
#include "util/migrationutil.h"
-#include "backend/bookshelfmodel/btbookshelftreemodel.h"
-#include "backend/config/cbtconfig.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <signal.h>
-
-#include <boost/scoped_ptr.hpp>
-
-#include <QLocale>
-#include <QTranslator>
-#include <QDebug>
-#include <QTextCodec>
-#ifndef NO_DBUS
-#include <QDBusConnection>
-#endif
-
#ifdef BT_ENABLE_TESTING
#include <QtTest/QtTest>
#include "tests/bibletime_test.h"
#endif
-using namespace util::filesystem;
bool showDebugMessages;
@@ -65,8 +58,12 @@ void registerMetaTypes() {
qRegisterMetaTypeStreamOperators<BtBookshelfTreeModel::Grouping>("BtBookshelfTreeModel::Grouping");
}
+/// \todo Reimplement signal handler which handles consecutive crashes.
+
int main(int argc, char* argv[]) {
- qInstallMsgHandler( myMessageOutput );
+ namespace DU = util::directory;
+
+// qInstallMsgHandler( myMessageOutput );
#ifdef BT_ENABLE_TESTING
if (QString(argv[1]) == QString("--run-tests")) {
@@ -75,13 +72,42 @@ int main(int argc, char* argv[]) {
}
#endif
+ /**
+ \todo Reimplement "--ignore-session" and "--open-default-bible <key>"
+ command line argument handling.
+ */
+
BibleTimeApp app(argc, argv); //for QApplication
app.setApplicationName("bibletime");
app.setApplicationVersion(BT_VERSION);
+#ifdef Q_WS_WIN
+
+ // On Windows, add a path for Qt plugins to be loaded from
+ app.addLibraryPath(app.applicationDirPath() + "/plugins");
+
+ // Must set HOME var on Windows
+ QString homeDir(getenv("APPDATA"));
+ _putenv_s("HOME", qPrintable(homeDir));
+
+#endif
+
registerMetaTypes();
- // This is needed for languagemgr language names to work, they use \uxxxx escape sequences in string literals
+ if (!DU::initDirectoryCache()) {
+ qFatal("Error initializing directory cache!");
+ return EXIT_FAILURE;
+ }
+
+#ifdef Q_WS_WIN
+ // change directory to the Sword or .sword directory in the $HOME dir so that
+ // the sword.conf is found. It points to the sword/locales.d directory
+ QString homeSwordDir = util::directory::getUserHomeDir().absolutePath();
+ QDir dir;
+ dir.setCurrent(homeSwordDir);
+#endif
+
+ // This is needed for languagemgr language names to work, they use \uxxxx escape sequences in string literals
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
//first install QT's own translations
QTranslator qtTranslator;
@@ -89,16 +115,16 @@ int main(int argc, char* argv[]) {
app.installTranslator(&qtTranslator);
//then our own
QTranslator BibleTimeTranslator;
- BibleTimeTranslator.load( QString("bibletime_ui_").append(QLocale::system().name()), DirectoryUtil::getLocaleDir().canonicalPath());
+ BibleTimeTranslator.load( QString("bibletime_ui_").append(QLocale::system().name()), DU::getLocaleDir().canonicalPath());
app.installTranslator(&BibleTimeTranslator);
// This is the QT4 version, will only work if main App is QApplication
// A binary option (on / off)
showDebugMessages = QCoreApplication::arguments().contains("--debug");
- app.setProperty("--debug", showDebugMessages);
+ app.setProperty("--debug", QVariant(showDebugMessages));
//Migrate configuration data, if neccessary
- util::MigrationUtil::checkMigration();
+ util::migration::checkMigration();
// setSignalHandler(signalHandler);