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