|
@@ -20,62 +20,45 @@
|
|
|
#include "src/classes/arunguard.h"
|
|
|
#include "src/database/adatabase.h"
|
|
|
#include "src/classes/asettings.h"
|
|
|
+#include "src/astandardpaths.h"
|
|
|
+#include "src/classes/asettings.h"
|
|
|
#include <QApplication>
|
|
|
#include <QProcess>
|
|
|
#include <QSettings>
|
|
|
#include <QFileInfo>
|
|
|
+#include <QStandardPaths>
|
|
|
|
|
|
-
|
|
|
-const auto DATA_DIR = QLatin1String("data");
|
|
|
-/*!
|
|
|
- * \brief setup checks if data folder and settings files exists.
|
|
|
- * \return
|
|
|
- */
|
|
|
-bool setup()
|
|
|
-{
|
|
|
- if (!QDir(DATA_DIR).exists())
|
|
|
- QDir().mkdir(DATA_DIR);
|
|
|
-
|
|
|
- QDir settingspath(DATA_DIR + QLatin1Char('/') + QCoreApplication::organizationName());
|
|
|
- QString settingsfile = QCoreApplication::applicationName() + QLatin1String(".ini");
|
|
|
- QFileInfo check_file(settingspath,settingsfile);
|
|
|
-
|
|
|
- QSettings settings;
|
|
|
- settings.setValue("setup/touch", true);
|
|
|
- settings.sync();
|
|
|
-
|
|
|
- return check_file.exists() && check_file.isFile();
|
|
|
-};
|
|
|
+#define APPNAME "openPilotLog"
|
|
|
+#define ORGNAME APPNAME
|
|
|
+#define ORGDOMAIN "https://github.com/fiffty-50/openpilotlog"
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
{
|
|
|
- QCoreApplication::setOrganizationName("openPilotLog");
|
|
|
- QCoreApplication::setOrganizationDomain("https://github.com/fiffty-50/openpilotlog");
|
|
|
- QCoreApplication::setApplicationName("openPilotLog");
|
|
|
-
|
|
|
- QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, DATA_DIR);
|
|
|
- QSettings::setDefaultFormat(QSettings::IniFormat);
|
|
|
- QSettings settings;
|
|
|
-
|
|
|
- aDB()->connect();
|
|
|
-
|
|
|
QApplication openPilotLog(argc, argv);
|
|
|
- if(!setup()){
|
|
|
- DEB "error creating required directories";
|
|
|
- return 0;
|
|
|
+ QCoreApplication::setOrganizationName(ORGNAME);
|
|
|
+ QCoreApplication::setOrganizationDomain(ORGDOMAIN);
|
|
|
+ QCoreApplication::setApplicationName(APPNAME);
|
|
|
+
|
|
|
+ AStandardPaths::setup();
|
|
|
+ AStandardPaths::scan_paths();
|
|
|
+ if(!AStandardPaths::validate_paths()){
|
|
|
+ DEB("Standard paths not valid.");
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
- if (!ASettings::read("setup/setup_complete").toBool()) {
|
|
|
- FirstRunDialog dialog;
|
|
|
- dialog.exec();
|
|
|
- }
|
|
|
+ ASettings::setup();
|
|
|
|
|
|
+ aDB()->connect();
|
|
|
|
|
|
+// if (!ASettings::read("setup/setup_complete").toBool()) {
|
|
|
+// FirstRunDialog dialog;
|
|
|
+// dialog.exec();
|
|
|
+// }
|
|
|
|
|
|
//Theming
|
|
|
- int selectedtheme = settings.value("main/theme").toInt();
|
|
|
+ int selectedtheme = ASettings::getSettings().value("main/theme").toInt();
|
|
|
QDir::setCurrent("/themes");
|
|
|
- switch (selectedtheme) {
|
|
|
+ switch (2) {
|
|
|
case 1:{
|
|
|
DEB "main :: Loading light theme";
|
|
|
QFile file(":light.qss");
|
|
@@ -96,7 +79,6 @@ int main(int argc, char *argv[])
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//sqlite does not deal well with multiple connections, ensure only one instance is running
|
|
|
ARunGuard guard("opl_single_key");
|
|
|
if ( !guard.tryToRun() ){
|