2020-01-04 08:26:09 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include "qmlinterface.h"
|
|
|
|
#include <QQmlEngine>
|
|
|
|
|
2020-01-31 08:37:08 +00:00
|
|
|
QMLInterface::QMLInterface()
|
2020-01-04 08:26:09 +00:00
|
|
|
{
|
|
|
|
// relink signals to QML
|
2020-01-18 13:02:00 +00:00
|
|
|
connect(qPrefCloudStorage::instance(), &qPrefCloudStorage::cloud_verification_statusChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
[this] (int value) { emit cloud_verification_statusChanged(CLOUD_STATUS(value)); });
|
2020-01-18 22:12:32 +00:00
|
|
|
connect(qPrefUnits::instance(), &qPrefUnits::duration_unitsChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
[this] (int value) { emit duration_unitsChanged(DURATION(value)); });
|
2020-01-18 22:12:32 +00:00
|
|
|
connect(qPrefUnits::instance(), &qPrefUnits::lengthChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
[this] (int value) { emit lengthChanged(LENGTH(value)); });
|
2020-01-18 22:12:32 +00:00
|
|
|
connect(qPrefUnits::instance(), &qPrefUnits::pressureChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
[this] (int value) { emit pressureChanged(PRESSURE(value)); });
|
2020-01-18 22:12:32 +00:00
|
|
|
connect(qPrefUnits::instance(), &qPrefUnits::temperatureChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
[this] (int value) { emit temperatureChanged(TEMPERATURE(value)); });
|
2020-01-18 22:12:32 +00:00
|
|
|
connect(qPrefUnits::instance(), &qPrefUnits::unit_systemChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
[this] (int value) { emit unit_systemChanged(UNIT_SYSTEM(value)); });
|
2020-01-18 22:12:32 +00:00
|
|
|
connect(qPrefUnits::instance(), &qPrefUnits::vertical_speed_timeChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
[this] (int value) { emit vertical_speed_timeChanged(TIME(value)); });
|
2020-01-18 22:12:32 +00:00
|
|
|
connect(qPrefUnits::instance(), &qPrefUnits::volumeChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
[this] (int value) { emit volumeChanged(VOLUME(value)); });
|
2020-01-18 22:12:32 +00:00
|
|
|
connect(qPrefUnits::instance(), &qPrefUnits::weightChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
[this] (int value) { emit weightChanged(WEIGHT(value)); });
|
2020-01-19 17:44:16 +00:00
|
|
|
|
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::ascratelast6mChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::ascratelast6mChanged);
|
2020-01-19 17:44:16 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::ascratestopsChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::ascratestopsChanged);
|
2020-01-19 17:44:16 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::ascrate50Changed,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::ascrate50Changed);
|
2020-01-19 17:44:16 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::ascrate75Changed,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::ascrate75Changed);
|
2020-01-19 17:44:16 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::descrateChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::descrateChanged);
|
2020-01-20 19:10:35 +00:00
|
|
|
|
2020-01-20 20:19:12 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::safetystopChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::safetystopChanged);
|
2020-01-20 20:19:12 +00:00
|
|
|
connect(qPrefTechnicalDetails::instance(), &qPrefTechnicalDetails::gflowChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::gflowChanged);
|
2020-01-20 20:19:12 +00:00
|
|
|
connect(qPrefTechnicalDetails::instance(), &qPrefTechnicalDetails::gfhighChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::gfhighChanged);
|
2020-01-20 20:19:12 +00:00
|
|
|
connect(qPrefTechnicalDetails::instance(), &qPrefTechnicalDetails::vpmb_conservatismChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::vpmb_conservatismChanged);
|
2020-01-20 20:19:12 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::drop_stone_modeChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::drop_stone_modeChanged);
|
2020-01-20 20:19:12 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::last_stopChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::last_stop6mChanged);
|
2020-01-20 20:19:12 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::switch_at_req_stopChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::switch_at_req_stopChanged);
|
2020-01-20 20:19:12 +00:00
|
|
|
|
2020-01-21 11:24:40 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::problemsolvingtimeChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::problemsolvingtimeChanged);
|
2020-01-08 11:06:23 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::bottomsacChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::bottomsacChanged);
|
2020-01-08 11:06:23 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::decosacChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::decosacChanged);
|
2020-01-21 15:16:10 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::sacfactorChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::sacfactorChanged);
|
2020-01-21 16:43:18 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::problemsolvingtimeChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::problemsolvingtimeChanged);
|
2020-01-21 16:43:18 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::o2narcoticChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::o2narcoticChanged);
|
2020-01-21 16:43:18 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::bottompo2Changed,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::bottompo2Changed);
|
2020-01-21 16:43:18 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::decopo2Changed,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::decopo2Changed);
|
2020-01-21 16:43:18 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::bestmixendChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::bestmixendChanged);
|
2020-01-21 15:16:10 +00:00
|
|
|
|
2020-01-20 19:10:35 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::display_runtimeChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::display_runtimeChanged);
|
2020-01-20 19:10:35 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::display_durationChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::display_durationChanged);
|
2020-01-20 19:10:35 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::display_transitionsChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::display_transitionsChanged);
|
2020-01-20 19:10:35 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::verbatim_planChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::verbatim_planChanged);
|
2020-01-20 19:10:35 +00:00
|
|
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::display_variationsChanged,
|
2020-01-31 08:37:08 +00:00
|
|
|
this, &QMLInterface::display_variationsChanged);
|
|
|
|
}
|
|
|
|
|
|
|
|
QMLInterface *QMLInterface::instance()
|
|
|
|
{
|
|
|
|
static QMLInterface *self = new QMLInterface;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QMLInterface::setup(QQmlContext *ct)
|
|
|
|
{
|
|
|
|
// Register interface class
|
|
|
|
ct->setContextProperty("Backend", QMLInterface::instance());
|
|
|
|
|
|
|
|
// Make enums available as types
|
|
|
|
qmlRegisterUncreatableType<QMLInterface>("org.subsurfacedivelog.mobile",1,0,"Enums","Enum is not a type");
|
2020-01-24 12:31:51 +00:00
|
|
|
|
|
|
|
// calculate divesummary first time.
|
|
|
|
// this is needed in order to load the divesummary page
|
|
|
|
diveSummary::summaryCalculation(0, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QMLInterface::summaryCalculation(int primaryPeriod, int secondaryPeriod)
|
|
|
|
{
|
|
|
|
diveSummary::summaryCalculation(primaryPeriod, secondaryPeriod);
|
|
|
|
emit diveSummaryTextChanged(diveSummary::diveSummaryText);
|
2020-01-04 08:26:09 +00:00
|
|
|
}
|