2017-04-27 18:27:59 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2013-09-09 08:59:03 +00:00
|
|
|
/* main.c */
|
|
|
|
#include <locale.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
2016-04-05 05:02:03 +00:00
|
|
|
#include "core/qt-gui.h"
|
|
|
|
#include "core/subsurfacestartup.h"
|
|
|
|
#include "core/color.h"
|
|
|
|
#include "core/qthelper.h"
|
2017-04-27 18:24:14 +00:00
|
|
|
#include "core/downloadfromdcthread.h"
|
2013-09-09 08:59:03 +00:00
|
|
|
|
|
|
|
#include <QStringList>
|
2015-06-16 13:52:06 +00:00
|
|
|
#include <QApplication>
|
2015-07-06 14:11:02 +00:00
|
|
|
#include <QLoggingCategory>
|
2017-12-03 13:04:45 +00:00
|
|
|
#include <QLocale>
|
2014-03-31 20:37:41 +00:00
|
|
|
#include <git2.h>
|
2013-09-09 08:59:03 +00:00
|
|
|
|
2018-05-28 14:25:39 +00:00
|
|
|
// Implementation of STP logging
|
|
|
|
#include "core/ssrf.h"
|
|
|
|
#ifdef ENABLE_STARTUP_TIMING
|
|
|
|
#include <QElapsedTimer>
|
|
|
|
#include <QMutex>
|
|
|
|
#include <QMutexLocker>
|
|
|
|
void log_stp(const char *ident, QString *buf)
|
|
|
|
{
|
|
|
|
static bool firstCall = true;
|
|
|
|
static QElapsedTimer stpDuration;
|
|
|
|
static QString stpText;
|
|
|
|
static QMutex logMutex;
|
|
|
|
|
|
|
|
QMutexLocker l(&logMutex);
|
|
|
|
|
|
|
|
if (firstCall) {
|
|
|
|
firstCall = false;
|
|
|
|
stpDuration.start();
|
|
|
|
}
|
|
|
|
if (ident)
|
|
|
|
stpText += QString("STP ") \
|
|
|
|
.append(QString::number(stpDuration.elapsed())) \
|
|
|
|
.append(" ms, ") \
|
|
|
|
.append(ident) \
|
|
|
|
.append("\n");
|
|
|
|
if (buf) {
|
|
|
|
*buf += "---------- startup timer ----------\n";
|
|
|
|
*buf += stpText;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // ENABLE_STARTUP_TIMING
|
|
|
|
|
|
|
|
|
2013-09-09 08:59:03 +00:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2018-05-28 14:25:39 +00:00
|
|
|
LOG_STP("main starting");
|
|
|
|
|
2013-09-09 08:59:03 +00:00
|
|
|
int i;
|
2017-03-31 14:15:14 +00:00
|
|
|
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
2015-07-06 14:11:02 +00:00
|
|
|
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
|
2018-05-21 18:57:10 +00:00
|
|
|
|
|
|
|
// Start application
|
|
|
|
new QApplication(argc, argv);
|
2018-05-28 14:25:39 +00:00
|
|
|
LOG_STP("main Qt started");
|
2018-05-21 18:57:10 +00:00
|
|
|
|
|
|
|
// and get comand line arguments
|
2013-10-08 09:48:46 +00:00
|
|
|
QStringList arguments = QCoreApplication::arguments();
|
2014-03-25 14:55:56 +00:00
|
|
|
|
2017-11-02 23:51:33 +00:00
|
|
|
subsurface_console_init();
|
2014-03-25 14:55:56 +00:00
|
|
|
|
2013-10-08 09:48:46 +00:00
|
|
|
for (i = 1; i < arguments.length(); i++) {
|
|
|
|
QString a = arguments.at(i);
|
2016-06-17 11:10:34 +00:00
|
|
|
if (!a.isEmpty() && a.at(0) == '-') {
|
2018-02-25 12:51:41 +00:00
|
|
|
parse_argument(qPrintable(a));
|
2013-09-09 08:59:03 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2014-12-06 13:49:57 +00:00
|
|
|
git_libgit2_init();
|
2018-05-28 14:25:39 +00:00
|
|
|
LOG_STP("main git loaded");
|
2014-03-19 16:23:43 +00:00
|
|
|
setup_system_prefs();
|
2017-12-03 13:04:45 +00:00
|
|
|
if (QLocale().measurementSystem() == QLocale::MetricSystem)
|
|
|
|
default_prefs.units = SI_units;
|
|
|
|
else
|
2016-01-06 07:43:05 +00:00
|
|
|
default_prefs.units = IMPERIAL_units;
|
2017-11-25 08:22:19 +00:00
|
|
|
copy_prefs(&default_prefs, &prefs);
|
2014-03-19 16:23:43 +00:00
|
|
|
fill_profile_color();
|
2017-04-27 18:24:14 +00:00
|
|
|
fill_computer_list();
|
|
|
|
|
2014-03-19 16:23:43 +00:00
|
|
|
parse_xml_init();
|
2018-05-28 14:25:39 +00:00
|
|
|
LOG_STP("main xml parsed");
|
2014-03-19 16:23:43 +00:00
|
|
|
taglist_init_global();
|
2018-05-28 14:25:39 +00:00
|
|
|
LOG_STP("main taglist done");
|
2014-03-19 16:23:43 +00:00
|
|
|
init_ui();
|
2018-05-28 14:25:39 +00:00
|
|
|
LOG_STP("main init_ui done");
|
2016-04-22 13:57:08 +00:00
|
|
|
if (prefs.default_file_behavior == LOCAL_DEFAULT_FILE)
|
2017-12-10 21:22:13 +00:00
|
|
|
set_filename(prefs.default_filename);
|
2016-04-27 13:01:07 +00:00
|
|
|
else
|
2017-12-10 21:22:13 +00:00
|
|
|
set_filename(NULL);
|
2016-04-22 13:57:08 +00:00
|
|
|
|
2016-03-28 00:18:48 +00:00
|
|
|
// some hard coded settings
|
2016-03-30 02:19:12 +00:00
|
|
|
prefs.animation_speed = 0; // we render the profile to pixmap, no animations
|
2016-02-06 07:36:42 +00:00
|
|
|
|
2016-03-28 00:18:48 +00:00
|
|
|
// always show the divecomputer reported ceiling in red
|
2016-02-06 07:36:42 +00:00
|
|
|
prefs.redceiling = 1;
|
|
|
|
|
2015-11-14 17:38:18 +00:00
|
|
|
init_proxy();
|
2015-10-05 22:52:39 +00:00
|
|
|
|
2018-05-28 14:25:39 +00:00
|
|
|
LOG_STP("main call run_ui (continue in qmlmanager)");
|
2013-11-02 19:00:16 +00:00
|
|
|
if (!quit)
|
|
|
|
run_ui();
|
2013-09-09 08:59:03 +00:00
|
|
|
exit_ui();
|
2014-12-18 07:47:55 +00:00
|
|
|
taglist_free(g_tag_list);
|
2014-03-19 16:23:43 +00:00
|
|
|
parse_xml_exit();
|
2014-03-25 14:55:56 +00:00
|
|
|
subsurface_console_exit();
|
2014-12-18 07:47:42 +00:00
|
|
|
free_prefs();
|
2013-09-09 08:59:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|