diff --git a/cli/main.cpp b/cli/main.cpp index 0a4e723..bae01f6 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include "encodingdetector.h" @@ -23,6 +24,8 @@ #include "commandsearch.h" #include "databasefactory.h" #include "logger.h" +#include "../shared/common.h" + void printUsage(QString argv0) { qInfo() << "Usage: " << argv0 << "command"; @@ -52,8 +55,9 @@ Command *commandFromName(QString name, SqliteDbService &dbService) int main(int argc, char *argv[]) { - QCoreApplication app(argc, argv); + Common::setupAppInfo(); + QCoreApplication app(argc, argv); QStringList args = app.arguments(); QString argv0 = args.takeFirst(); if(args.length() < 1) @@ -63,7 +67,8 @@ int main(int argc, char *argv[]) } QString commandName = args.first(); - QString connectionString = QProcessEnvironment::systemEnvironment().value("QSS_PATH"); + QSettings settings; + QString connectionString = settings.value("dbpath").toString(); DatabaseFactory dbFactory(connectionString); SqliteDbService dbService(dbFactory); Command *cmd = commandFromName(commandName, dbService); diff --git a/gui/main.cpp b/gui/main.cpp index bca1d4a..c093291 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -1,13 +1,13 @@ -#include "mainwindow.h" #include #include +#include "mainwindow.h" #include "searchresult.h" #include "pdfpreview.h" +#include "../shared/common.h" + int main(int argc, char *argv[]) { - QCoreApplication::setOrganizationName("quitesimple.org"); - QCoreApplication::setOrganizationDomain("quitesimple.org"); - QCoreApplication::setApplicationName("qss"); + Common::setupAppInfo(); QApplication a(argc, argv); qRegisterMetaType>("QVector"); qRegisterMetaType>("QVector"); diff --git a/shared/common.cpp b/shared/common.cpp new file mode 100644 index 0000000..43be177 --- /dev/null +++ b/shared/common.cpp @@ -0,0 +1,8 @@ +#include "common.h" + +void Common::setupAppInfo() +{ + QCoreApplication::setOrganizationName("quitesimple.org"); + QCoreApplication::setOrganizationDomain("quitesimple.org"); + QCoreApplication::setApplicationName("qss"); +} diff --git a/shared/common.h b/shared/common.h new file mode 100644 index 0000000..410ef96 --- /dev/null +++ b/shared/common.h @@ -0,0 +1,9 @@ +#ifndef COMMON_H +#define COMMON_H +#include + +namespace Common +{ +void setupAppInfo(); +} +#endif diff --git a/shared/shared.pro b/shared/shared.pro index 3b53026..40cc3ff 100644 --- a/shared/shared.pro +++ b/shared/shared.pro @@ -26,14 +26,16 @@ DEFINES += QT_DEPRECATED_WARNINGS SOURCES += sqlitesearch.cpp \ qssgeneralexception.cpp \ - qssquery.cpp + qssquery.cpp \ + common.cpp HEADERS += sqlitesearch.h \ filedata.h \ searchresult.h \ qssgeneralexception.h \ token.h \ - qssquery.h + qssquery.h \ + common.h unix { target.path = /usr/lib INSTALLS += target