123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- #include "mainwindow.h"
- #include "src/opl.h"
- #include "src/functions/log.h"
- #include "src/gui/dialogues/firstrundialog.h"
- #include "src/classes/runguard.h"
- #include "src/classes/settings.h"
- #include "src/classes/settings.h"
- #include "src/classes/style.h"
- #include "src/functions/log.h"
- #include "src/classes/paths.h"
- #include <QApplication>
- #include <QProcess>
- #include <QSettings>
- #include <QFileInfo>
- #include <QStandardPaths>
- #include <QDebug>
- #include <QTranslator>
- namespace Main {
- void init()
- {
- LOG << "Setting up / verifying Application Directories...";
- if(OPL::Paths::setup()) {
- LOG << "Application Directories... verified";
- } else {
- LOG << "Unable to create directories.";
- }
- LOG << "Setting up logging facilities...";
- if(OPL::Log::init(true)) {
- LOG << "Logging enabled.";
- } else {
- LOG << "Unable to initalise logging.";
- }
- LOG << "Reading Settings...";
- Settings::setup();
- LOG << "Setting up application style...";
- OPL::Style::setup();
-
-
-
- }
- bool firstRun()
- {
- if(FirstRunDialog().exec() == QDialog::Rejected){
- LOG << "Initial setup incomplete or unsuccessfull.";
- return false;
- }
- Settings::write(Settings::Main::SetupComplete, true);
- LOG << "Initial Setup Completed successfully";
- return true;
- }
- }
- int main(int argc, char *argv[])
- {
- QApplication openPilotLog(argc, argv);
- QCoreApplication::setOrganizationName(ORGNAME);
- QCoreApplication::setOrganizationDomain(ORGDOMAIN);
- QCoreApplication::setApplicationName(APPNAME);
-
- RunGuard guard(QStringLiteral("opl_single_key"));
- if ( !guard.tryToRun() ){
- LOG << "Another Instance of openPilotLog is already running. Exiting.";
- return 0;
- }
-
- Main::init();
-
- if (!Settings::read(Settings::Main::SetupComplete).toBool())
- if(!Main::firstRun())
- return 0;
-
- MainWindow w;
- #ifdef __linux__
- w.setWindowIcon(QIcon(OPL::Assets::ICON_APPICON_LINUX));
- #elif defined(_WIN32) || defined(_WIN64)
- w.setWindowIcon(QIcon(OPL::Assets::ICON_APPICON_WIN));
- #elif __APPLE__
- #include <TargetConditionals.h>
- #if TARGET_IPHONE_SIMULATOR
-
- #elif TARGET_OS_IPHONE
-
- #elif TARGET_OS_MAC
- w.setWindowIcon(QIcon(OPL::Assets::ICON_APPICON_IOS));
- #else
- # error "Unknown Apple platform"
- #endif
- #endif
-
- w.show();
- return openPilotLog.exec();
- }
|