mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	preferences: use std::string in struct preferences
This is a messy commit, because the "qPref" system relies heavily on QString, which means lots of conversions between the two worlds. Ultimately, I plan to base the preferences system on std::string and only convert to QString when pushing through Qt's property system or when writing into Qt's settings. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
		
							parent
							
								
									82fc9de40b
								
							
						
					
					
						commit
						ccdd92aeb7
					
				
					 78 changed files with 645 additions and 694 deletions
				
			
		| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
// SPDX-License-Identifier: GPL-2.0
 | 
					// SPDX-License-Identifier: GPL-2.0
 | 
				
			||||||
#include "qt-models/diveimportedmodel.h"
 | 
					#include "qt-models/diveimportedmodel.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void cliDownloader(const char *vendor, const char *product, const char *device)
 | 
					void cliDownloader(const std::string &vendor, const std::string &product, const std::string &device)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	DiveImportedModel diveImportedModel;
 | 
						DiveImportedModel diveImportedModel;
 | 
				
			||||||
	DiveImportedModel::connect(&diveImportedModel, &DiveImportedModel::downloadFinished, [] {
 | 
						DiveImportedModel::connect(&diveImportedModel, &DiveImportedModel::downloadFinished, [] {
 | 
				
			||||||
| 
						 | 
					@ -10,11 +10,11 @@ void cliDownloader(const char *vendor, const char *product, const char *device)
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto data = diveImportedModel.thread.data();
 | 
						auto data = diveImportedModel.thread.data();
 | 
				
			||||||
	data->setVendor(vendor);
 | 
						data->setVendor(QString::fromStdString(vendor));
 | 
				
			||||||
	data->setProduct(product);
 | 
						data->setProduct(QString::fromStdString(product));
 | 
				
			||||||
	data->setBluetoothMode(false);
 | 
						data->setBluetoothMode(false);
 | 
				
			||||||
	if (data->vendor() == "Uemis") {
 | 
						if (data->vendor() == "Uemis") {
 | 
				
			||||||
		QString devname(device);
 | 
							QString devname = QString::fromStdString(device);
 | 
				
			||||||
		int colon = devname.indexOf(QStringLiteral(":\\ (UEMISSDA)"));
 | 
							int colon = devname.indexOf(QStringLiteral(":\\ (UEMISSDA)"));
 | 
				
			||||||
		if (colon >= 0) {
 | 
							if (colon >= 0) {
 | 
				
			||||||
			devname.truncate(colon + 2);
 | 
								devname.truncate(colon + 2);
 | 
				
			||||||
| 
						 | 
					@ -22,7 +22,7 @@ void cliDownloader(const char *vendor, const char *product, const char *device)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		data->setDevName(devname);
 | 
							data->setDevName(devname);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		data->setDevName(device);
 | 
							data->setDevName(QString::fromStdString(device));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// some assumptions - should all be configurable
 | 
						// some assumptions - should all be configurable
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,31 +41,31 @@ static std::string make_default_filename()
 | 
				
			||||||
	return system_default_path() + "/subsurface.xml";
 | 
						return system_default_path() + "/subsurface.xml";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char android_system_divelist_default_font[] = "Roboto";
 | 
					using namespace std::string_literals;
 | 
				
			||||||
const char *system_divelist_default_font = android_system_divelist_default_font;
 | 
					std::string system_divelist_default_font = "Roboto"s;
 | 
				
			||||||
double system_divelist_default_font_size = -1;
 | 
					double system_divelist_default_font_size = -1.0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int get_usb_fd(uint16_t idVendor, uint16_t idProduct);
 | 
					int get_usb_fd(uint16_t idVendor, uint16_t idProduct);
 | 
				
			||||||
void subsurface_OS_pref_setup()
 | 
					void subsurface_OS_pref_setup()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool subsurface_ignore_font(const char *font)
 | 
					bool subsurface_ignore_font(const std::string &font)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// there are no old default fonts that we would want to ignore
 | 
						// there are no old default fonts that we would want to ignore
 | 
				
			||||||
	return false;
 | 
						return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char *system_default_directory()
 | 
					std::string system_default_directory()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	static const std::string path = system_default_path();
 | 
						static const std::string path = system_default_path();
 | 
				
			||||||
	return path.c_str();
 | 
						return path;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char *system_default_filename()
 | 
					std::string system_default_filename()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	static const std::string fn = make_default_filename();
 | 
						static const std::string fn = make_default_filename();
 | 
				
			||||||
	return fn.c_str();
 | 
						return fn;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,7 +21,6 @@ CheckCloudConnection::CheckCloudConnection(QObject *parent) :
 | 
				
			||||||
	QObject(parent),
 | 
						QObject(parent),
 | 
				
			||||||
	reply(0)
 | 
						reply(0)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// two free APIs to figure out where we are
 | 
					// two free APIs to figure out where we are
 | 
				
			||||||
| 
						 | 
					@ -43,7 +42,7 @@ bool CheckCloudConnection::checkServer()
 | 
				
			||||||
		QNetworkRequest request;
 | 
							QNetworkRequest request;
 | 
				
			||||||
		request.setRawHeader("Accept", "text/plain");
 | 
							request.setRawHeader("Accept", "text/plain");
 | 
				
			||||||
		request.setRawHeader("User-Agent", getUserAgent().toUtf8());
 | 
							request.setRawHeader("User-Agent", getUserAgent().toUtf8());
 | 
				
			||||||
		request.setUrl(QString(prefs.cloud_base_url) + TEAPOT);
 | 
							request.setUrl(QString::fromStdString(prefs.cloud_base_url) + TEAPOT);
 | 
				
			||||||
		reply = mgr->get(request);
 | 
							reply = mgr->get(request);
 | 
				
			||||||
		QTimer timer;
 | 
							QTimer timer;
 | 
				
			||||||
		timer.setSingleShot(true);
 | 
							timer.setSingleShot(true);
 | 
				
			||||||
| 
						 | 
					@ -73,7 +72,7 @@ bool CheckCloudConnection::checkServer()
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (verbose)
 | 
							if (verbose)
 | 
				
			||||||
			report_info("connection test to cloud server %s failed %d %s %d %s", prefs.cloud_base_url,
 | 
								report_info("connection test to cloud server %s failed %d %s %d %s", prefs.cloud_base_url.c_str(),
 | 
				
			||||||
				    static_cast<int>(reply->error()), qPrintable(reply->errorString()),
 | 
									    static_cast<int>(reply->error()), qPrintable(reply->errorString()),
 | 
				
			||||||
				    reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(),
 | 
									    reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(),
 | 
				
			||||||
				    qPrintable(reply->readAll()));
 | 
									    qPrintable(reply->readAll()));
 | 
				
			||||||
| 
						 | 
					@ -109,19 +108,16 @@ bool CheckCloudConnection::nextServer()
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
	const char *server = nullptr;
 | 
						const char *server = nullptr;
 | 
				
			||||||
	for (serverTried &item: cloudServers) {
 | 
						for (serverTried &item: cloudServers) {
 | 
				
			||||||
		if (strstr(prefs.cloud_base_url, item.server))
 | 
							if (contains(prefs.cloud_base_url, item.server))
 | 
				
			||||||
			item.tried = true;
 | 
								item.tried = true;
 | 
				
			||||||
		else if (item.tried == false)
 | 
							else if (item.tried == false)
 | 
				
			||||||
			server = item.server;
 | 
								server = item.server;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (server) {
 | 
						if (server) {
 | 
				
			||||||
		int s = strlen(server);
 | 
							using namespace std::string_literals;
 | 
				
			||||||
		char *baseurl = (char *)malloc(10 + s);
 | 
							std::string base_url = "https://"s + server + "/"s;
 | 
				
			||||||
		strcpy(baseurl, "https://");
 | 
							report_info("failed to connect to %s next server to try: %s", prefs.cloud_base_url.c_str(), base_url.c_str());
 | 
				
			||||||
		strncat(baseurl, server, s);
 | 
							prefs.cloud_base_url = std::move(base_url);
 | 
				
			||||||
		strcat(baseurl, "/");
 | 
					 | 
				
			||||||
		report_info("failed to connect to %s next server to try: %s", prefs.cloud_base_url, baseurl);
 | 
					 | 
				
			||||||
		prefs.cloud_base_url = baseurl;
 | 
					 | 
				
			||||||
		git_storage_update_progress(qPrintable(tr("Trying different cloud server...")));
 | 
							git_storage_update_progress(qPrintable(tr("Trying different cloud server...")));
 | 
				
			||||||
		return true;
 | 
							return true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -192,7 +188,7 @@ void CheckCloudConnection::gotContinent(QNetworkReply *reply)
 | 
				
			||||||
		base_url = "https://" CLOUD_HOST_US "/";
 | 
							base_url = "https://" CLOUD_HOST_US "/";
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		base_url = "https://" CLOUD_HOST_EU "/";
 | 
							base_url = "https://" CLOUD_HOST_EU "/";
 | 
				
			||||||
	if (!same_string(base_url, prefs.cloud_base_url)) {
 | 
						if (base_url != prefs.cloud_base_url) {
 | 
				
			||||||
		if (verbose)
 | 
							if (verbose)
 | 
				
			||||||
			report_info("remember cloud server %s based on IP location in %s", base_url, qPrintable(continentString));
 | 
								report_info("remember cloud server %s based on IP location in %s", base_url, qPrintable(continentString));
 | 
				
			||||||
		qPrefCloudStorage::instance()->store_cloud_base_url(base_url);
 | 
							qPrefCloudStorage::instance()->store_cloud_base_url(base_url);
 | 
				
			||||||
| 
						 | 
					@ -211,7 +207,7 @@ bool canReachCloudServer(struct git_info *info)
 | 
				
			||||||
		// the cloud_base_url ends with a '/', so we need the text starting at "git/..."
 | 
							// the cloud_base_url ends with a '/', so we need the text starting at "git/..."
 | 
				
			||||||
		size_t pos = info->url.find("org/git/");
 | 
							size_t pos = info->url.find("org/git/");
 | 
				
			||||||
		if (pos != std::string::npos) {
 | 
							if (pos != std::string::npos) {
 | 
				
			||||||
			info->url = format_string_std("%s%s", prefs.cloud_base_url, info->url.c_str() + pos + 4);
 | 
								info->url = format_string_std("%s%s", prefs.cloud_base_url.c_str(), info->url.c_str() + pos + 4);
 | 
				
			||||||
			if (verbose)
 | 
								if (verbose)
 | 
				
			||||||
				report_info("updating remote to: %s", info->url.c_str());
 | 
									report_info("updating remote to: %s", info->url.c_str());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,24 +13,43 @@ CloudStorageAuthenticate::CloudStorageAuthenticate(QObject *parent) :
 | 
				
			||||||
	userAgent = getUserAgent();
 | 
						userAgent = getUserAgent();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CLOUDURL QString(prefs.cloud_base_url)
 | 
					static QString cloudUrl()
 | 
				
			||||||
#define CLOUDBACKENDSTORAGE CLOUDURL + "/storage"
 | 
					{
 | 
				
			||||||
#define CLOUDBACKENDVERIFY CLOUDURL + "/verify"
 | 
						return QString::fromStdString(prefs.cloud_base_url);
 | 
				
			||||||
#define CLOUDBACKENDUPDATE CLOUDURL + "/update"
 | 
					}
 | 
				
			||||||
#define CLOUDBACKENDDELETE CLOUDURL + "/delete-account"
 | 
					
 | 
				
			||||||
 | 
					static QUrl cloudBackendStorage()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return QUrl(cloudUrl() + "/storage");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static QUrl cloudBackendVerify()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return QUrl(cloudUrl() + "/verify");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static QUrl cloudBackendUpdate()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return QUrl(cloudUrl() + "/update");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static QUrl cloudBackendDelete()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return QUrl(cloudUrl() + "/delete-account");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QNetworkReply* CloudStorageAuthenticate::backend(const QString& email,const QString& password,const QString& pin,const QString& newpasswd)
 | 
					QNetworkReply* CloudStorageAuthenticate::backend(const QString& email,const QString& password,const QString& pin,const QString& newpasswd)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QString payload(email + QChar(' ') + password);
 | 
						QString payload(email + QChar(' ') + password);
 | 
				
			||||||
	QUrl requestUrl;
 | 
						QUrl requestUrl;
 | 
				
			||||||
	if (pin.isEmpty() && newpasswd.isEmpty()) {
 | 
						if (pin.isEmpty() && newpasswd.isEmpty()) {
 | 
				
			||||||
		requestUrl = QUrl(CLOUDBACKENDSTORAGE);
 | 
							requestUrl = cloudBackendStorage();
 | 
				
			||||||
	} else if (!newpasswd.isEmpty()) {
 | 
						} else if (!newpasswd.isEmpty()) {
 | 
				
			||||||
		requestUrl = QUrl(CLOUDBACKENDUPDATE);
 | 
							requestUrl = cloudBackendUpdate();
 | 
				
			||||||
		payload += QChar(' ') + newpasswd;
 | 
							payload += QChar(' ') + newpasswd;
 | 
				
			||||||
		cloudNewPassword = newpasswd;
 | 
							cloudNewPassword = newpasswd;
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		requestUrl = QUrl(CLOUDBACKENDVERIFY);
 | 
							requestUrl = cloudBackendVerify();
 | 
				
			||||||
		payload += QChar(' ') + pin;
 | 
							payload += QChar(' ') + pin;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	QNetworkRequest *request = new QNetworkRequest(requestUrl);
 | 
						QNetworkRequest *request = new QNetworkRequest(requestUrl);
 | 
				
			||||||
| 
						 | 
					@ -54,7 +73,7 @@ QNetworkReply* CloudStorageAuthenticate::backend(const QString& email,const QStr
 | 
				
			||||||
QNetworkReply* CloudStorageAuthenticate::deleteAccount(const QString& email, const QString& password)
 | 
					QNetworkReply* CloudStorageAuthenticate::deleteAccount(const QString& email, const QString& password)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QString payload(email + QChar(' ') + password);
 | 
						QString payload(email + QChar(' ') + password);
 | 
				
			||||||
	QNetworkRequest *request = new QNetworkRequest(QUrl(CLOUDBACKENDDELETE));
 | 
						QNetworkRequest *request = new QNetworkRequest(cloudBackendDelete());
 | 
				
			||||||
	request->setRawHeader("Accept", "text/xml, text/plain");
 | 
						request->setRawHeader("Accept", "text/xml, text/plain");
 | 
				
			||||||
	request->setRawHeader("User-Agent", userAgent.toUtf8());
 | 
						request->setRawHeader("User-Agent", userAgent.toUtf8());
 | 
				
			||||||
	request->setHeader(QNetworkRequest::ContentTypeHeader, "text/plain");
 | 
						request->setHeader(QNetworkRequest::ContentTypeHeader, "text/plain");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2639,18 +2639,6 @@ void set_informational_units(const char *units)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void set_git_prefs(const char *prefs)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (strstr(prefs, "TANKBAR"))
 | 
					 | 
				
			||||||
		git_prefs.tankbar = 1;
 | 
					 | 
				
			||||||
	if (strstr(prefs, "SHOW_SETPOINT"))
 | 
					 | 
				
			||||||
		git_prefs.show_ccr_setpoint = 1;
 | 
					 | 
				
			||||||
	if (strstr(prefs, "SHOW_SENSORS"))
 | 
					 | 
				
			||||||
		git_prefs.show_ccr_sensors = 1;
 | 
					 | 
				
			||||||
	if (strstr(prefs, "PO2_GRAPH"))
 | 
					 | 
				
			||||||
		git_prefs.pp_graphs.po2 = 1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* clones a dive and moves given dive computer to front */
 | 
					/* clones a dive and moves given dive computer to front */
 | 
				
			||||||
std::unique_ptr<dive> clone_make_first_dc(const struct dive &d, int dc_number)
 | 
					std::unique_ptr<dive> clone_make_first_dc(const struct dive &d, int dc_number)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -146,8 +146,6 @@ extern unsigned int number_of_computers(const struct dive *dive);
 | 
				
			||||||
extern struct divecomputer *get_dive_dc(struct dive *dive, int nr);
 | 
					extern struct divecomputer *get_dive_dc(struct dive *dive, int nr);
 | 
				
			||||||
extern const struct divecomputer *get_dive_dc(const struct dive *dive, int nr);
 | 
					extern const struct divecomputer *get_dive_dc(const struct dive *dive, int nr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern void set_git_prefs(const char *prefs);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern std::unique_ptr<dive> clone_make_first_dc(const struct dive &d, int dc_number);
 | 
					extern std::unique_ptr<dive> clone_make_first_dc(const struct dive &d, int dc_number);
 | 
				
			||||||
extern std::unique_ptr<dive> clone_delete_divecomputer(const struct dive &d, int dc_number);
 | 
					extern std::unique_ptr<dive> clone_delete_divecomputer(const struct dive &d, int dc_number);
 | 
				
			||||||
extern std::array<std::unique_ptr<dive>, 2> split_divecomputer(const struct dive &src, int num);
 | 
					extern std::array<std::unique_ptr<dive>, 2> split_divecomputer(const struct dive &src, int num);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -402,10 +402,10 @@ cylinder_t *get_or_create_cylinder(struct dive *d, int idx)
 | 
				
			||||||
/* if a default cylinder is set, use that */
 | 
					/* if a default cylinder is set, use that */
 | 
				
			||||||
void fill_default_cylinder(const struct dive *dive, cylinder_t *cyl)
 | 
					void fill_default_cylinder(const struct dive *dive, cylinder_t *cyl)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const char *cyl_name = prefs.default_cylinder;
 | 
						const std::string &cyl_name = prefs.default_cylinder;
 | 
				
			||||||
	pressure_t pO2 = {.mbar = static_cast<int>(lrint(prefs.modpO2 * 1000.0))};
 | 
						pressure_t pO2 = {.mbar = static_cast<int>(lrint(prefs.modpO2 * 1000.0))};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!cyl_name)
 | 
						if (cyl_name.empty())
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	for (auto &ti: tank_info_table) {
 | 
						for (auto &ti: tank_info_table) {
 | 
				
			||||||
		if (ti.name == cyl_name) {
 | 
							if (ti.name == cyl_name) {
 | 
				
			||||||
| 
						 | 
					@ -454,7 +454,7 @@ void add_default_cylinder(struct dive *d)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cylinder_t cyl;
 | 
						cylinder_t cyl;
 | 
				
			||||||
	if (!empty_string(prefs.default_cylinder)) {
 | 
						if (!prefs.default_cylinder.empty()) {
 | 
				
			||||||
		cyl = create_new_cylinder(d);
 | 
							cyl = create_new_cylinder(d);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		// roughly an AL80
 | 
							// roughly an AL80
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -289,7 +289,7 @@ int parse_file(const char *filename, struct divelog *log)
 | 
				
			||||||
	auto [mem, err] = readfile(filename);
 | 
						auto [mem, err] = readfile(filename);
 | 
				
			||||||
	if (err < 0) {
 | 
						if (err < 0) {
 | 
				
			||||||
		/* we don't want to display an error if this was the default file  */
 | 
							/* we don't want to display an error if this was the default file  */
 | 
				
			||||||
		if (same_string(filename, prefs.default_filename))
 | 
							if (filename == prefs.default_filename)
 | 
				
			||||||
			return 0;
 | 
								return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return report_error(translate("gettextFromC", "Failed to read '%s'"), filename);
 | 
							return report_error(translate("gettextFromC", "Failed to read '%s'"), filename);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -150,7 +150,7 @@ std::string get_local_dir(const std::string &url, const std::string &branch)
 | 
				
			||||||
	sha.update(branch);
 | 
						sha.update(branch);
 | 
				
			||||||
	auto hash = sha.hash();
 | 
						auto hash = sha.hash();
 | 
				
			||||||
	return format_string_std("%s/cloudstorage/%02x%02x%02x%02x%02x%02x%02x%02x",
 | 
						return format_string_std("%s/cloudstorage/%02x%02x%02x%02x%02x%02x%02x%02x",
 | 
				
			||||||
			system_default_directory(),
 | 
								system_default_directory().c_str(),
 | 
				
			||||||
			hash[0], hash[1], hash[2], hash[3],
 | 
								hash[0], hash[1], hash[2], hash[3],
 | 
				
			||||||
			hash[4], hash[5], hash[6], hash[7]);
 | 
								hash[4], hash[5], hash[6], hash[7]);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -246,27 +246,27 @@ int credential_ssh_cb(git_cred **out,
 | 
				
			||||||
		  unsigned int allowed_types,
 | 
							  unsigned int allowed_types,
 | 
				
			||||||
		  void *)
 | 
							  void *)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const char *username = prefs.cloud_storage_email_encoded;
 | 
						const std::string &username = prefs.cloud_storage_email_encoded;
 | 
				
			||||||
	const char *passphrase = prefs.cloud_storage_password ? prefs.cloud_storage_password : "";
 | 
						const std::string &passphrase = prefs.cloud_storage_password;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// TODO: We need a way to differentiate between password and private key authentication
 | 
						// TODO: We need a way to differentiate between password and private key authentication
 | 
				
			||||||
	if (allowed_types & GIT_CREDTYPE_SSH_KEY) {
 | 
						if (allowed_types & GIT_CREDTYPE_SSH_KEY) {
 | 
				
			||||||
		std::string priv_key = std::string(system_default_directory()) + "/ssrf_remote.key";
 | 
							std::string priv_key = system_default_directory() + "/ssrf_remote.key";
 | 
				
			||||||
		if (!access(priv_key.c_str(), F_OK)) {
 | 
							if (!access(priv_key.c_str(), F_OK)) {
 | 
				
			||||||
			if (exceeded_auth_attempts())
 | 
								if (exceeded_auth_attempts())
 | 
				
			||||||
				return GIT_EUSER;
 | 
									return GIT_EUSER;
 | 
				
			||||||
			return git_cred_ssh_key_new(out, username, NULL, priv_key.c_str(), passphrase);
 | 
								return git_cred_ssh_key_new(out, username.c_str(), NULL, priv_key.c_str(), passphrase.c_str());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (allowed_types & GIT_CREDTYPE_USERPASS_PLAINTEXT) {
 | 
						if (allowed_types & GIT_CREDTYPE_USERPASS_PLAINTEXT) {
 | 
				
			||||||
		if (exceeded_auth_attempts())
 | 
							if (exceeded_auth_attempts())
 | 
				
			||||||
			return GIT_EUSER;
 | 
								return GIT_EUSER;
 | 
				
			||||||
		return git_cred_userpass_plaintext_new(out, username, passphrase);
 | 
							return git_cred_userpass_plaintext_new(out, username.c_str(), passphrase.c_str());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (allowed_types & GIT_CREDTYPE_USERNAME)
 | 
						if (allowed_types & GIT_CREDTYPE_USERNAME)
 | 
				
			||||||
		return git_cred_username_new(out, username);
 | 
							return git_cred_username_new(out, username.c_str());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	report_error("No supported ssh authentication.");
 | 
						report_error("No supported ssh authentication.");
 | 
				
			||||||
	return GIT_EUSER;
 | 
						return GIT_EUSER;
 | 
				
			||||||
| 
						 | 
					@ -281,10 +281,10 @@ int credential_https_cb(git_cred **out,
 | 
				
			||||||
	if (exceeded_auth_attempts())
 | 
						if (exceeded_auth_attempts())
 | 
				
			||||||
		return GIT_EUSER;
 | 
							return GIT_EUSER;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const char *username = prefs.cloud_storage_email_encoded;
 | 
						const std::string &username = prefs.cloud_storage_email_encoded;
 | 
				
			||||||
	const char *password = prefs.cloud_storage_password ? prefs.cloud_storage_password : "";
 | 
						const std::string &password = prefs.cloud_storage_password;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return git_cred_userpass_plaintext_new(out, username, password);
 | 
						return git_cred_userpass_plaintext_new(out, username.c_str(), password.c_str());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int certificate_check_cb(git_cert *cert, int valid, const char *host, void *)
 | 
					int certificate_check_cb(git_cert *cert, int valid, const char *host, void *)
 | 
				
			||||||
| 
						 | 
					@ -609,10 +609,10 @@ static std::string getProxyString()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (prefs.proxy_type == QNetworkProxy::HttpProxy) {
 | 
						if (prefs.proxy_type == QNetworkProxy::HttpProxy) {
 | 
				
			||||||
		if (prefs.proxy_auth)
 | 
							if (prefs.proxy_auth)
 | 
				
			||||||
			return format_string_std("http://%s:%s@%s:%d", prefs.proxy_user, prefs.proxy_pass,
 | 
								return format_string_std("http://%s:%s@%s:%d", prefs.proxy_user.c_str(), prefs.proxy_pass.c_str(),
 | 
				
			||||||
					prefs.proxy_host, prefs.proxy_port);
 | 
										prefs.proxy_host.c_str(), prefs.proxy_port);
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			return format_string_std("http://%s:%d", prefs.proxy_host, prefs.proxy_port);
 | 
								return format_string_std("http://%s:%d", prefs.proxy_host.c_str(), prefs.proxy_port);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return std::string();
 | 
						return std::string();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -990,7 +990,7 @@ std::string extract_username(struct git_info *info, const std::string &url)
 | 
				
			||||||
	 * Ugly, ugly. Parsing the remote repo user name also sets
 | 
						 * Ugly, ugly. Parsing the remote repo user name also sets
 | 
				
			||||||
	 * it in the preferences. We should do this somewhere else!
 | 
						 * it in the preferences. We should do this somewhere else!
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	prefs.cloud_storage_email_encoded = strdup(info->username.c_str());
 | 
						prefs.cloud_storage_email_encoded = info->username;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return url.substr(at + 1 - url.c_str());
 | 
						return url.substr(at + 1 - url.c_str());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1107,7 +1107,7 @@ bool is_git_repository(const char *filename, struct git_info *info)
 | 
				
			||||||
	 *
 | 
						 *
 | 
				
			||||||
	 * This is used to create more user friendly error message and warnings.
 | 
						 * This is used to create more user friendly error message and warnings.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	info->is_subsurface_cloud = (strstr(info->url.c_str(), prefs.cloud_base_url) != NULL);
 | 
						info->is_subsurface_cloud = contains(info->url, prefs.cloud_base_url);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return true;
 | 
						return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										14
									
								
								core/ios.cpp
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								core/ios.cpp
									
										
									
									
									
								
							| 
						 | 
					@ -32,8 +32,8 @@ static std::string make_default_filename()
 | 
				
			||||||
	return system_default_path() + "/subsurface.xml";
 | 
						return system_default_path() + "/subsurface.xml";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char mac_system_divelist_default_font[] = "Arial";
 | 
					using namespace std::string_literals;
 | 
				
			||||||
const char *system_divelist_default_font = mac_system_divelist_default_font;
 | 
					std::string system_divelist_default_font = "Arial"s;
 | 
				
			||||||
double system_divelist_default_font_size = -1.0;
 | 
					double system_divelist_default_font_size = -1.0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void subsurface_OS_pref_setup()
 | 
					void subsurface_OS_pref_setup()
 | 
				
			||||||
| 
						 | 
					@ -41,22 +41,22 @@ void subsurface_OS_pref_setup()
 | 
				
			||||||
	// nothing
 | 
						// nothing
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool subsurface_ignore_font(const char*)
 | 
					bool subsurface_ignore_font(const std::string &)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// there are no old default fonts that we would want to ignore
 | 
						// there are no old default fonts that we would want to ignore
 | 
				
			||||||
	return false;
 | 
						return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char *system_default_directory()
 | 
					std::string system_default_directory()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	static const std::string path = system_default_path();
 | 
						static const std::string path = system_default_path();
 | 
				
			||||||
	return path.c_str();
 | 
						return path;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char *system_default_filename()
 | 
					std::string system_default_filename()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	static const std::string fn = make_default_filename();
 | 
						static const std::string fn = make_default_filename();
 | 
				
			||||||
	return fn.c_str();
 | 
						return fn;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int enumerate_devices(device_callback_t, void *, unsigned int)
 | 
					int enumerate_devices(device_callback_t, void *, unsigned int)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -911,7 +911,7 @@ static std::string fingerprint_file(device_data_t *devdata)
 | 
				
			||||||
	serial = devdata->devinfo.serial;
 | 
						serial = devdata->devinfo.serial;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return format_string_std("%s/fingerprints/%04x.%u",
 | 
						return format_string_std("%s/fingerprints/%04x.%u",
 | 
				
			||||||
		system_default_directory(),
 | 
							system_default_directory().c_str(),
 | 
				
			||||||
		model, serial);
 | 
							model, serial);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -952,7 +952,7 @@ static void save_fingerprint(device_data_t *devdata)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Make sure the fingerprints directory exists
 | 
						// Make sure the fingerprints directory exists
 | 
				
			||||||
	std::string dir = format_string_std("%s/fingerprints", system_default_directory());
 | 
						std::string dir = system_default_directory() + "/fingerprints";
 | 
				
			||||||
	subsurface_mkdir(dir.c_str());
 | 
						subsurface_mkdir(dir.c_str());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	std::string final = fingerprint_file(devdata);
 | 
						std::string final = fingerprint_file(devdata);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,8 +47,8 @@ static std::string make_default_filename()
 | 
				
			||||||
	return system_default_path() + "/" + user + ".xml";
 | 
						return system_default_path() + "/" + user + ".xml";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char mac_system_divelist_default_font[] = "Arial";
 | 
					using namespace std::string_literals;
 | 
				
			||||||
const char *system_divelist_default_font = mac_system_divelist_default_font;
 | 
					std::string system_divelist_default_font = "Arial"s;
 | 
				
			||||||
double system_divelist_default_font_size = -1.0;
 | 
					double system_divelist_default_font_size = -1.0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void subsurface_OS_pref_setup()
 | 
					void subsurface_OS_pref_setup()
 | 
				
			||||||
| 
						 | 
					@ -56,22 +56,22 @@ void subsurface_OS_pref_setup()
 | 
				
			||||||
	// nothing
 | 
						// nothing
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool subsurface_ignore_font(const char *)
 | 
					bool subsurface_ignore_font(const std::string &)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// there are no old default fonts to ignore
 | 
						// there are no old default fonts to ignore
 | 
				
			||||||
	return false;
 | 
						return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char *system_default_directory()
 | 
					std::string system_default_directory()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	static const std::string path = system_default_path();
 | 
						static const std::string path = system_default_path();
 | 
				
			||||||
	return path.c_str();
 | 
						return path.c_str();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char *system_default_filename()
 | 
					std::string system_default_filename()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	static const std::string fn = make_default_filename();
 | 
						static const std::string fn = make_default_filename();
 | 
				
			||||||
	return fn.c_str();
 | 
						return fn;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int enumerate_devices(device_callback_t callback, void *userdata, unsigned int transport)
 | 
					int enumerate_devices(device_callback_t callback, void *userdata, unsigned int transport)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										243
									
								
								core/pref.cpp
									
										
									
									
									
								
							
							
						
						
									
										243
									
								
								core/pref.cpp
									
										
									
									
									
								
							| 
						 | 
					@ -3,153 +3,112 @@
 | 
				
			||||||
#include "subsurface-string.h"
 | 
					#include "subsurface-string.h"
 | 
				
			||||||
#include "git-access.h" // for CLOUD_HOST
 | 
					#include "git-access.h" // for CLOUD_HOST
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct preferences prefs, git_prefs;
 | 
					struct preferences prefs, git_prefs, default_prefs;
 | 
				
			||||||
struct preferences default_prefs = {
 | 
					
 | 
				
			||||||
	.animation_speed = 500,
 | 
					preferences::preferences() :
 | 
				
			||||||
	.cloud_base_url = "https://" CLOUD_HOST_EU "/", // if we don't know any better, use the European host
 | 
						animation_speed(500),
 | 
				
			||||||
 | 
						cloud_base_url("https://" CLOUD_HOST_EU "/"), // if we don't know any better, use the European host
 | 
				
			||||||
#if defined(SUBSURFACE_MOBILE)
 | 
					#if defined(SUBSURFACE_MOBILE)
 | 
				
			||||||
	.cloud_timeout = 10,
 | 
						cloud_timeout(10),
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
	.cloud_timeout = 5,
 | 
						cloud_timeout(5),
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	.sync_dc_time = false,
 | 
						sync_dc_time(false),
 | 
				
			||||||
	.display_invalid_dives = false,
 | 
						display_invalid_dives(false),
 | 
				
			||||||
	.divelist_font = NULL,
 | 
						font_size(-1),
 | 
				
			||||||
	.font_size = -1,
 | 
						mobile_scale(1.0),
 | 
				
			||||||
	.mobile_scale = 1.0,
 | 
						show_developer(true),
 | 
				
			||||||
	.show_developer = true,
 | 
						three_m_based_grid(false),
 | 
				
			||||||
	.three_m_based_grid = false,
 | 
						map_short_names(false),
 | 
				
			||||||
	.map_short_names = false,
 | 
						include_unused_tanks(false),
 | 
				
			||||||
	.default_cylinder = NULL,
 | 
						display_default_tank_infos(true),
 | 
				
			||||||
	.include_unused_tanks = false,
 | 
						auto_recalculate_thumbnails(true),
 | 
				
			||||||
	.display_default_tank_infos = true,
 | 
						extract_video_thumbnails(true),
 | 
				
			||||||
	.auto_recalculate_thumbnails = true,
 | 
						extract_video_thumbnails_position(20),		// The first fifth seems like a reasonable place
 | 
				
			||||||
	.extract_video_thumbnails = true,
 | 
						defaultsetpoint(1100),
 | 
				
			||||||
	.extract_video_thumbnails_position = 20,		// The first fifth seems like a reasonable place
 | 
						default_file_behavior(LOCAL_DEFAULT_FILE),
 | 
				
			||||||
	.ffmpeg_executable = NULL,
 | 
						o2consumption(720),
 | 
				
			||||||
	.defaultsetpoint = 1100,
 | 
						pscr_ratio(100),
 | 
				
			||||||
	.default_filename = NULL,
 | 
						use_default_file(true),
 | 
				
			||||||
	.default_file_behavior = LOCAL_DEFAULT_FILE,
 | 
						extraEnvironmentalDefault(false),
 | 
				
			||||||
	.o2consumption = 720,
 | 
						salinityEditDefault(false),
 | 
				
			||||||
	.pscr_ratio = 100,
 | 
						date_format_override(false),
 | 
				
			||||||
	.use_default_file = true,
 | 
						time_format_override(false),
 | 
				
			||||||
	.extraEnvironmentalDefault = false,
 | 
						proxy_auth(false),
 | 
				
			||||||
	.salinityEditDefault = false,
 | 
						proxy_port(0),
 | 
				
			||||||
	.geocoding = {
 | 
						proxy_type(0),
 | 
				
			||||||
		.category = { TC_NONE, TC_NONE, TC_NONE }
 | 
						ascratelast6m(9000 / 60),
 | 
				
			||||||
	},
 | 
						ascratestops(9000 / 60),
 | 
				
			||||||
	.date_format = NULL,
 | 
						ascrate50(9000 / 60),
 | 
				
			||||||
	.date_format_override = false,
 | 
						ascrate75(9000 / 60),
 | 
				
			||||||
	.date_format_short = NULL,
 | 
						bestmixend({ 30000 }),
 | 
				
			||||||
	.locale = {
 | 
						bottompo2(1400),
 | 
				
			||||||
		.use_system_language = true,
 | 
						bottomsac(20000),
 | 
				
			||||||
	},
 | 
						decopo2(1600),
 | 
				
			||||||
	.time_format = NULL,
 | 
						decosac(17000),
 | 
				
			||||||
	.time_format_override = false,
 | 
						descrate(18000 / 60),
 | 
				
			||||||
	.proxy_auth = false,
 | 
						display_duration(true),
 | 
				
			||||||
	.proxy_host = NULL,
 | 
						display_runtime(true),
 | 
				
			||||||
	.proxy_port = 0,
 | 
						display_transitions(true),
 | 
				
			||||||
	.proxy_type = 0,
 | 
						display_variations(false),
 | 
				
			||||||
	.proxy_user = NULL,
 | 
						doo2breaks(false),
 | 
				
			||||||
	.proxy_pass = NULL,
 | 
						dobailout(false),
 | 
				
			||||||
	.ascratelast6m = 9000 / 60,
 | 
						o2narcotic(true),
 | 
				
			||||||
	.ascratestops = 9000 / 60,
 | 
						drop_stone_mode(false),
 | 
				
			||||||
	.ascrate50 = 9000 / 60,
 | 
						last_stop(false),
 | 
				
			||||||
	.ascrate75 = 9000 / 60,
 | 
						min_switch_duration(60),
 | 
				
			||||||
	.bestmixend = { 30000 },
 | 
						surface_segment(0),
 | 
				
			||||||
	.bottompo2 = 1400,
 | 
						planner_deco_mode(BUEHLMANN),
 | 
				
			||||||
	.bottomsac = 20000,
 | 
						problemsolvingtime(4),
 | 
				
			||||||
	.decopo2 = 1600,
 | 
						reserve_gas(40000),
 | 
				
			||||||
	.decosac = 17000,
 | 
						sacfactor(400),
 | 
				
			||||||
	.descrate = 18000 / 60,
 | 
						safetystop(true),
 | 
				
			||||||
	.display_duration = true,
 | 
						switch_at_req_stop(false),
 | 
				
			||||||
	.display_runtime = true,
 | 
						verbatim_plan(false),
 | 
				
			||||||
	.display_transitions = true,
 | 
						calcalltissues(false),
 | 
				
			||||||
	.display_variations = false,
 | 
						calcceiling(false),
 | 
				
			||||||
	.doo2breaks = false,
 | 
						calcceiling3m(false),
 | 
				
			||||||
	.dobailout = false,
 | 
						calcndltts(false),
 | 
				
			||||||
	.o2narcotic = true,
 | 
						decoinfo(true),
 | 
				
			||||||
	.drop_stone_mode = false,
 | 
						dcceiling(true),
 | 
				
			||||||
	.last_stop = false,
 | 
						display_deco_mode(BUEHLMANN),
 | 
				
			||||||
	.min_switch_duration = 60,
 | 
						ead(false),
 | 
				
			||||||
	.surface_segment = 0,
 | 
						gfhigh(75),
 | 
				
			||||||
	.planner_deco_mode = BUEHLMANN,
 | 
						gflow(30),
 | 
				
			||||||
	.problemsolvingtime = 4,
 | 
						gf_low_at_maxdepth(false),
 | 
				
			||||||
	.reserve_gas=40000,
 | 
						hrgraph(false),
 | 
				
			||||||
	.sacfactor = 400,
 | 
						mod(false),
 | 
				
			||||||
	.safetystop = true,
 | 
						modpO2(1.6),
 | 
				
			||||||
	.switch_at_req_stop = false,
 | 
						percentagegraph(false),
 | 
				
			||||||
	.verbatim_plan = false,
 | 
						redceiling(false),
 | 
				
			||||||
	.calcalltissues = false,
 | 
						rulergraph(false),
 | 
				
			||||||
	.calcceiling = false,
 | 
						show_average_depth(true),
 | 
				
			||||||
	.calcceiling3m = false,
 | 
						show_ccr_sensors(false),
 | 
				
			||||||
	.calcndltts = false,
 | 
						show_ccr_setpoint(false),
 | 
				
			||||||
	.decoinfo = true,
 | 
						show_icd(false),
 | 
				
			||||||
	.dcceiling = true,
 | 
						show_pictures_in_profile(true),
 | 
				
			||||||
	.display_deco_mode = BUEHLMANN,
 | 
						show_sac(false),
 | 
				
			||||||
	.ead = false,
 | 
						show_scr_ocpo2(false),
 | 
				
			||||||
	.gfhigh = 75,
 | 
						tankbar(false),
 | 
				
			||||||
	.gflow = 30,
 | 
						vpmb_conservatism(3),
 | 
				
			||||||
	.gf_low_at_maxdepth = false,
 | 
						zoomed_plot(false),
 | 
				
			||||||
	.hrgraph = false,
 | 
						infobox(true),
 | 
				
			||||||
	.mod = false,
 | 
						coordinates_traditional(true),
 | 
				
			||||||
	.modpO2 = 1.6,
 | 
						unit_system(METRIC),
 | 
				
			||||||
	.percentagegraph = false,
 | 
						units(SI_UNITS)
 | 
				
			||||||
	.pp_graphs = {
 | 
					 | 
				
			||||||
		.po2 = false,
 | 
					 | 
				
			||||||
		.pn2 = false,
 | 
					 | 
				
			||||||
		.phe = false,
 | 
					 | 
				
			||||||
		.po2_threshold_min = 0.16,
 | 
					 | 
				
			||||||
		.po2_threshold_max = 1.6,
 | 
					 | 
				
			||||||
		.pn2_threshold = 4.0,
 | 
					 | 
				
			||||||
		.phe_threshold = 13.0,
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
	.redceiling = false,
 | 
					 | 
				
			||||||
	.rulergraph = false,
 | 
					 | 
				
			||||||
	.show_average_depth = true,
 | 
					 | 
				
			||||||
	.show_ccr_sensors = false,
 | 
					 | 
				
			||||||
	.show_ccr_setpoint = false,
 | 
					 | 
				
			||||||
	.show_icd = false,
 | 
					 | 
				
			||||||
	.show_pictures_in_profile = true,
 | 
					 | 
				
			||||||
	.show_sac = false,
 | 
					 | 
				
			||||||
	.show_scr_ocpo2 = false,
 | 
					 | 
				
			||||||
	.tankbar = false,
 | 
					 | 
				
			||||||
	.vpmb_conservatism = 3,
 | 
					 | 
				
			||||||
	.zoomed_plot = false,
 | 
					 | 
				
			||||||
	.infobox = true,
 | 
					 | 
				
			||||||
	.coordinates_traditional = true,
 | 
					 | 
				
			||||||
	.unit_system = METRIC,
 | 
					 | 
				
			||||||
	.units = SI_UNITS,
 | 
					 | 
				
			||||||
	.update_manager = { false, NULL, 0 }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* copy a preferences block, including making copies of all included strings */
 | 
					 | 
				
			||||||
void copy_prefs(struct preferences *src, struct preferences *dest)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	*dest = *src;
 | 
					 | 
				
			||||||
	dest->divelist_font = copy_string(src->divelist_font);
 | 
					 | 
				
			||||||
	dest->default_filename = copy_string(src->default_filename);
 | 
					 | 
				
			||||||
	dest->default_cylinder = copy_string(src->default_cylinder);
 | 
					 | 
				
			||||||
	dest->cloud_base_url = copy_string(src->cloud_base_url);
 | 
					 | 
				
			||||||
	dest->proxy_host = copy_string(src->proxy_host);
 | 
					 | 
				
			||||||
	dest->proxy_user = copy_string(src->proxy_user);
 | 
					 | 
				
			||||||
	dest->proxy_pass = copy_string(src->proxy_pass);
 | 
					 | 
				
			||||||
	dest->time_format = copy_string(src->time_format);
 | 
					 | 
				
			||||||
	dest->date_format = copy_string(src->date_format);
 | 
					 | 
				
			||||||
	dest->date_format_short = copy_string(src->date_format_short);
 | 
					 | 
				
			||||||
	dest->cloud_storage_password = copy_string(src->cloud_storage_password);
 | 
					 | 
				
			||||||
	dest->cloud_storage_email = copy_string(src->cloud_storage_email);
 | 
					 | 
				
			||||||
	dest->cloud_storage_email_encoded = copy_string(src->cloud_storage_email_encoded);
 | 
					 | 
				
			||||||
	dest->ffmpeg_executable = copy_string(src->ffmpeg_executable);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					preferences::~preferences() = default;
 | 
				
			||||||
 * Free strduped prefs before exit.
 | 
					
 | 
				
			||||||
 *
 | 
					void set_git_prefs(std::string_view prefs)
 | 
				
			||||||
 * These are not real leaks but they plug the holes found by eg.
 | 
					 | 
				
			||||||
 * valgrind so you can find the real leaks.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
void free_prefs()
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// nop
 | 
						if (contains(prefs, "TANKBAR"))
 | 
				
			||||||
 | 
							git_prefs.tankbar = 1;
 | 
				
			||||||
 | 
						if (contains(prefs, "SHOW_SETPOINT"))
 | 
				
			||||||
 | 
							git_prefs.show_ccr_setpoint = 1;
 | 
				
			||||||
 | 
						if (contains(prefs, "SHOW_SENSORS"))
 | 
				
			||||||
 | 
							git_prefs.show_ccr_sensors = 1;
 | 
				
			||||||
 | 
						if (contains(prefs, "PO2_GRAPH"))
 | 
				
			||||||
 | 
							git_prefs.pp_graphs.po2 = 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										82
									
								
								core/pref.h
									
										
									
									
									
								
							
							
						
						
									
										82
									
								
								core/pref.h
									
										
									
									
									
								
							| 
						 | 
					@ -5,24 +5,27 @@
 | 
				
			||||||
#include "units.h"
 | 
					#include "units.h"
 | 
				
			||||||
#include "taxonomy.h"
 | 
					#include "taxonomy.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					#include <string_view>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct partial_pressure_graphs_t {
 | 
					struct partial_pressure_graphs_t {
 | 
				
			||||||
	bool po2;
 | 
						bool po2 = false;
 | 
				
			||||||
	bool pn2;
 | 
						bool pn2 = false;
 | 
				
			||||||
	bool phe;
 | 
						bool phe = false;
 | 
				
			||||||
	double po2_threshold_min;
 | 
						double po2_threshold_min = 0.16;
 | 
				
			||||||
	double po2_threshold_max;
 | 
						double po2_threshold_max = 1.6;
 | 
				
			||||||
	double pn2_threshold;
 | 
						double pn2_threshold = 4.0;
 | 
				
			||||||
	double phe_threshold;
 | 
						double phe_threshold = 13.0;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct geocoding_prefs_t {
 | 
					struct geocoding_prefs_t {
 | 
				
			||||||
	enum taxonomy_category category[3];
 | 
						enum taxonomy_category category[3] = { TC_NONE, TC_NONE, TC_NONE };
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct locale_prefs_t {
 | 
					struct locale_prefs_t {
 | 
				
			||||||
	const char *language;
 | 
						std::string language;
 | 
				
			||||||
	const char *lang_locale;
 | 
						std::string lang_locale;
 | 
				
			||||||
	bool use_system_language;
 | 
						bool use_system_language = true;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum deco_mode {
 | 
					enum deco_mode {
 | 
				
			||||||
| 
						 | 
					@ -39,16 +42,16 @@ enum def_file_behavior {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct update_manager_prefs_t {
 | 
					struct update_manager_prefs_t {
 | 
				
			||||||
	bool dont_check_for_updates;
 | 
						bool dont_check_for_updates = false;
 | 
				
			||||||
	const char *last_version_used;
 | 
						std::string last_version_used;
 | 
				
			||||||
	int next_check;
 | 
						int next_check = 0;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct dive_computer_prefs_t {
 | 
					struct dive_computer_prefs_t {
 | 
				
			||||||
	const char *vendor;
 | 
						std::string vendor;
 | 
				
			||||||
	const char *product;
 | 
						std::string product;
 | 
				
			||||||
	const char *device;
 | 
						std::string device;
 | 
				
			||||||
	const char *device_name;
 | 
						std::string device_name;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NOTE: these enums are duplicated in mobile-widgets/qmlinterface.h
 | 
					// NOTE: these enums are duplicated in mobile-widgets/qmlinterface.h
 | 
				
			||||||
| 
						 | 
					@ -74,11 +77,11 @@ struct preferences {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// ********** CloudStorage **********
 | 
						// ********** CloudStorage **********
 | 
				
			||||||
	bool        cloud_auto_sync;
 | 
						bool        cloud_auto_sync;
 | 
				
			||||||
	const char *cloud_base_url;
 | 
						std::string cloud_base_url;
 | 
				
			||||||
	const char *cloud_storage_email;
 | 
						std::string cloud_storage_email;
 | 
				
			||||||
	const char *cloud_storage_email_encoded;
 | 
						std::string cloud_storage_email_encoded;
 | 
				
			||||||
	const char *cloud_storage_password;
 | 
						std::string cloud_storage_password;
 | 
				
			||||||
	const char *cloud_storage_pin;
 | 
						std::string cloud_storage_pin;
 | 
				
			||||||
	int         cloud_timeout;
 | 
						int         cloud_timeout;
 | 
				
			||||||
	int         cloud_verification_status;
 | 
						int         cloud_verification_status;
 | 
				
			||||||
	bool        save_password_local;
 | 
						bool        save_password_local;
 | 
				
			||||||
| 
						 | 
					@ -93,7 +96,7 @@ struct preferences {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// ********** Display *************
 | 
						// ********** Display *************
 | 
				
			||||||
	bool        display_invalid_dives;
 | 
						bool        display_invalid_dives;
 | 
				
			||||||
	const char *divelist_font;
 | 
						std::string divelist_font;
 | 
				
			||||||
	double      font_size;
 | 
						double      font_size;
 | 
				
			||||||
	double      mobile_scale;
 | 
						double      mobile_scale;
 | 
				
			||||||
	bool        show_developer;
 | 
						bool        show_developer;
 | 
				
			||||||
| 
						 | 
					@ -101,7 +104,7 @@ struct preferences {
 | 
				
			||||||
	bool        map_short_names;
 | 
						bool        map_short_names;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// ********** Equipment tab *******
 | 
						// ********** Equipment tab *******
 | 
				
			||||||
	const char *default_cylinder;
 | 
						std::string default_cylinder;
 | 
				
			||||||
	bool        include_unused_tanks;
 | 
						bool        include_unused_tanks;
 | 
				
			||||||
	bool        display_default_tank_infos;
 | 
						bool        display_default_tank_infos;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -109,9 +112,9 @@ struct preferences {
 | 
				
			||||||
	bool        auto_recalculate_thumbnails;
 | 
						bool        auto_recalculate_thumbnails;
 | 
				
			||||||
	bool	    extract_video_thumbnails;
 | 
						bool	    extract_video_thumbnails;
 | 
				
			||||||
	int	    extract_video_thumbnails_position; // position in stream: 0=first 100=last second
 | 
						int	    extract_video_thumbnails_position; // position in stream: 0=first 100=last second
 | 
				
			||||||
	const char *ffmpeg_executable; // path of ffmpeg binary
 | 
						std::string ffmpeg_executable; // path of ffmpeg binary
 | 
				
			||||||
	int         defaultsetpoint; // default setpoint in mbar
 | 
						int         defaultsetpoint; // default setpoint in mbar
 | 
				
			||||||
	const char *default_filename;
 | 
						std::string default_filename;
 | 
				
			||||||
	enum def_file_behavior default_file_behavior;
 | 
						enum def_file_behavior default_file_behavior;
 | 
				
			||||||
	int         o2consumption; // ml per min
 | 
						int         o2consumption; // ml per min
 | 
				
			||||||
	int         pscr_ratio; // dump ratio times 1000
 | 
						int         pscr_ratio; // dump ratio times 1000
 | 
				
			||||||
| 
						 | 
					@ -123,20 +126,20 @@ struct preferences {
 | 
				
			||||||
	geocoding_prefs_t geocoding;
 | 
						geocoding_prefs_t geocoding;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// ********** Language **********
 | 
						// ********** Language **********
 | 
				
			||||||
	const char     *date_format;
 | 
						std::string     date_format;
 | 
				
			||||||
	bool            date_format_override;
 | 
						bool            date_format_override;
 | 
				
			||||||
	const char     *date_format_short;
 | 
						std::string     date_format_short;
 | 
				
			||||||
	locale_prefs_t  locale; //: TODO: move the rest of locale based info here.
 | 
						locale_prefs_t  locale; //: TODO: move the rest of locale based info here.
 | 
				
			||||||
	const char     *time_format;
 | 
						std::string     time_format;
 | 
				
			||||||
	bool            time_format_override;
 | 
						bool            time_format_override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// ********** Network **********
 | 
						// ********** Network **********
 | 
				
			||||||
	bool        proxy_auth;
 | 
						bool        proxy_auth;
 | 
				
			||||||
	const char *proxy_host;
 | 
						std::string proxy_host;
 | 
				
			||||||
	int         proxy_port;
 | 
						int         proxy_port;
 | 
				
			||||||
	int         proxy_type;
 | 
						int         proxy_type;
 | 
				
			||||||
	const char *proxy_user;
 | 
						std::string proxy_user;
 | 
				
			||||||
	const char *proxy_pass;
 | 
						std::string proxy_pass;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// ********** Planner **********
 | 
						// ********** Planner **********
 | 
				
			||||||
	int             ascratelast6m;
 | 
						int             ascratelast6m;
 | 
				
			||||||
| 
						 | 
					@ -206,19 +209,22 @@ struct preferences {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// ********** UpdateManager **********
 | 
						// ********** UpdateManager **********
 | 
				
			||||||
	update_manager_prefs_t update_manager;
 | 
						update_manager_prefs_t update_manager;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						preferences();		// Initialize to default
 | 
				
			||||||
 | 
						~preferences();
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern struct preferences prefs, default_prefs, git_prefs;
 | 
					extern struct preferences prefs, default_prefs, git_prefs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern const char *system_divelist_default_font;
 | 
					extern std::string system_divelist_default_font;
 | 
				
			||||||
extern double system_divelist_default_font_size;
 | 
					extern double system_divelist_default_font_size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern const char *system_default_directory();
 | 
					extern std::string system_default_directory();
 | 
				
			||||||
extern const char *system_default_filename();
 | 
					extern std::string system_default_filename();
 | 
				
			||||||
extern bool subsurface_ignore_font(const char *font);
 | 
					extern bool subsurface_ignore_font(const std::string &font);
 | 
				
			||||||
extern void subsurface_OS_pref_setup();
 | 
					extern void subsurface_OS_pref_setup();
 | 
				
			||||||
extern void copy_prefs(struct preferences *src, struct preferences *dest);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern void set_informational_units(const char *units);
 | 
					extern void set_informational_units(const char *units);
 | 
				
			||||||
 | 
					extern void set_git_prefs(std::string_view prefs);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // PREF_H
 | 
					#endif // PREF_H
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,7 +9,7 @@
 | 
				
			||||||
#include "errorhelper.h"
 | 
					#include "errorhelper.h"
 | 
				
			||||||
#include "core/settings/qPref.h"
 | 
					#include "core/settings/qPref.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
char *settings_suffix = NULL;
 | 
					std::string settings_suffix;
 | 
				
			||||||
static QTranslator qtTranslator, ssrfTranslator, parentLanguageTranslator;
 | 
					static QTranslator qtTranslator, ssrfTranslator, parentLanguageTranslator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void init_qt_late()
 | 
					void init_qt_late()
 | 
				
			||||||
| 
						 | 
					@ -29,17 +29,17 @@ void init_qt_late()
 | 
				
			||||||
	QGuiApplication::setDesktopFileName("subsurface");
 | 
						QGuiApplication::setDesktopFileName("subsurface");
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	// enable user specific settings (based on command line argument)
 | 
						// enable user specific settings (based on command line argument)
 | 
				
			||||||
	if (settings_suffix) {
 | 
						if (!settings_suffix.empty()) {
 | 
				
			||||||
		if (verbose)
 | 
							if (verbose)
 | 
				
			||||||
#if defined(SUBSURFACE_MOBILE) && ((defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) || (defined(Q_OS_DARWIN) && !defined(Q_OS_IOS)))
 | 
					#if defined(SUBSURFACE_MOBILE) && ((defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) || (defined(Q_OS_DARWIN) && !defined(Q_OS_IOS)))
 | 
				
			||||||
			report_info("using custom config for Subsurface-Mobile-%s", settings_suffix);
 | 
								report_info("using custom config for Subsurface-Mobile-%s", settings_suffix.c_str());
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
			report_info("using custom config for Subsurface-%s", settings_suffix);
 | 
								report_info("using custom config for Subsurface-%s", settings_suffix.c_str());
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#if defined(SUBSURFACE_MOBILE) && ((defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) || (defined(Q_OS_DARWIN) && !defined(Q_OS_IOS)))
 | 
					#if defined(SUBSURFACE_MOBILE) && ((defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) || (defined(Q_OS_DARWIN) && !defined(Q_OS_IOS)))
 | 
				
			||||||
		QCoreApplication::setApplicationName(QString("Subsurface-Mobile-%1").arg(settings_suffix));
 | 
							QCoreApplication::setApplicationName(QString::fromStdString("Subsurface-Mobile-" + settings_suffix));
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
		QCoreApplication::setApplicationName(QString("Subsurface-%1").arg(settings_suffix));
 | 
							QCoreApplication::setApplicationName(QString::fromStdString("Subsurface-" + settings_suffix));
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
#if defined(SUBSURFACE_MOBILE) && ((defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) || (defined(Q_OS_DARWIN) && !defined(Q_OS_IOS)))
 | 
					#if defined(SUBSURFACE_MOBILE) && ((defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) || (defined(Q_OS_DARWIN) && !defined(Q_OS_IOS)))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -402,7 +402,7 @@ std::string subsurface_user_agent()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString getUiLanguage()
 | 
					QString getUiLanguage()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return prefs.locale.lang_locale;
 | 
						return QString::fromStdString(prefs.locale.lang_locale);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static std::vector<std::string> get_languages(const QLocale &loc)
 | 
					static std::vector<std::string> get_languages(const QLocale &loc)
 | 
				
			||||||
| 
						 | 
					@ -457,10 +457,9 @@ void initUiLanguage()
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	free((void*)prefs.locale.lang_locale);
 | 
						prefs.locale.lang_locale = uiLang;
 | 
				
			||||||
	prefs.locale.lang_locale = strdup(uiLang.c_str());
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!prefs.date_format_override || empty_string(prefs.date_format)) {
 | 
						if (!prefs.date_format_override || prefs.date_format.empty()) {
 | 
				
			||||||
		// derive our standard date format from what the locale gives us
 | 
							// derive our standard date format from what the locale gives us
 | 
				
			||||||
		// the long format uses long weekday and month names, so replace those with the short ones
 | 
							// the long format uses long weekday and month names, so replace those with the short ones
 | 
				
			||||||
		// for time we don't want the time zone designator and don't want leading zeroes on the hours
 | 
							// for time we don't want the time zone designator and don't want leading zeroes on the hours
 | 
				
			||||||
| 
						 | 
					@ -469,23 +468,20 @@ void initUiLanguage()
 | 
				
			||||||
		// special hack for Swedish as our switching from long weekday names to short weekday names
 | 
							// special hack for Swedish as our switching from long weekday names to short weekday names
 | 
				
			||||||
		// messes things up there
 | 
							// messes things up there
 | 
				
			||||||
		dateFormat.replace("'en' 'den' d:'e'", " d");
 | 
							dateFormat.replace("'en' 'den' d:'e'", " d");
 | 
				
			||||||
		free((void *)prefs.date_format);
 | 
							prefs.date_format = dateFormat.toStdString();
 | 
				
			||||||
		prefs.date_format = copy_qstring(dateFormat);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!prefs.date_format_override || empty_string(prefs.date_format_short)) {
 | 
						if (!prefs.date_format_override || prefs.date_format_short.empty()) {
 | 
				
			||||||
		// derive our standard date format from what the locale gives us
 | 
							// derive our standard date format from what the locale gives us
 | 
				
			||||||
		shortDateFormat = loc.dateFormat(QLocale::ShortFormat);
 | 
							shortDateFormat = loc.dateFormat(QLocale::ShortFormat);
 | 
				
			||||||
		free((void *)prefs.date_format_short);
 | 
							prefs.date_format_short = shortDateFormat.toStdString();
 | 
				
			||||||
		prefs.date_format_short = copy_qstring(shortDateFormat);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!prefs.time_format_override || empty_string(prefs.time_format)) {
 | 
						if (!prefs.time_format_override || prefs.time_format.empty()) {
 | 
				
			||||||
		timeFormat = loc.timeFormat();
 | 
							timeFormat = loc.timeFormat();
 | 
				
			||||||
		timeFormat.replace("(t)", "").replace(" t", "").replace("t", "").replace("hh", "h").replace("HH", "H").replace("'kl'.", "");
 | 
							timeFormat.replace("(t)", "").replace(" t", "").replace("t", "").replace("hh", "h").replace("HH", "H").replace("'kl'.", "");
 | 
				
			||||||
		timeFormat.replace(".ss", "").replace(":ss", "").replace("ss", "");
 | 
							timeFormat.replace(".ss", "").replace(":ss", "").replace("ss", "");
 | 
				
			||||||
		free((void *)prefs.time_format);
 | 
							prefs.time_format = timeFormat.toStdString();
 | 
				
			||||||
		prefs.time_format = copy_qstring(timeFormat);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -683,7 +679,7 @@ static const char *printing_templates = "printing_templates";
 | 
				
			||||||
QString getPrintingTemplatePathUser()
 | 
					QString getPrintingTemplatePathUser()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// Function-local statics are initialized on first invocation
 | 
						// Function-local statics are initialized on first invocation
 | 
				
			||||||
	static QString path(QString(system_default_directory()) +
 | 
						static QString path(QString::fromStdString(system_default_directory()) +
 | 
				
			||||||
			    QDir::separator() +
 | 
								    QDir::separator() +
 | 
				
			||||||
			    QString(printing_templates));
 | 
								    QString(printing_templates));
 | 
				
			||||||
	return path;
 | 
						return path;
 | 
				
			||||||
| 
						 | 
					@ -958,7 +954,7 @@ QString get_dive_date_string(timestamp_t when)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QDateTime ts;
 | 
						QDateTime ts;
 | 
				
			||||||
	ts.setMSecsSinceEpoch(when * 1000L);
 | 
						ts.setMSecsSinceEpoch(when * 1000L);
 | 
				
			||||||
	return loc.toString(ts.toUTC(), QString(prefs.date_format) + " " + prefs.time_format);
 | 
						return loc.toString(ts.toUTC(), QString::fromStdString(prefs.date_format + " " + prefs.time_format));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Get local seconds since Epoch from ISO formatted UTC date time + offset string
 | 
					// Get local seconds since Epoch from ISO formatted UTC date time + offset string
 | 
				
			||||||
| 
						 | 
					@ -971,7 +967,7 @@ QString get_short_dive_date_string(timestamp_t when)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QDateTime ts;
 | 
						QDateTime ts;
 | 
				
			||||||
	ts.setMSecsSinceEpoch(when * 1000L);
 | 
						ts.setMSecsSinceEpoch(when * 1000L);
 | 
				
			||||||
	return loc.toString(ts.toUTC(), QString(prefs.date_format_short) + " " + prefs.time_format);
 | 
						return loc.toString(ts.toUTC(), QString::fromStdString(prefs.date_format_short + " " + prefs.time_format));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
std::string get_dive_date_c_string(timestamp_t when)
 | 
					std::string get_dive_date_c_string(timestamp_t when)
 | 
				
			||||||
| 
						 | 
					@ -983,7 +979,7 @@ static QString get_dive_only_date_string(timestamp_t when)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QDateTime ts;
 | 
						QDateTime ts;
 | 
				
			||||||
	ts.setMSecsSinceEpoch(when * 1000L);
 | 
						ts.setMSecsSinceEpoch(when * 1000L);
 | 
				
			||||||
	return loc.toString(ts.toUTC(), QString(prefs.date_format));
 | 
						return loc.toString(ts.toUTC(), QString::fromStdString(prefs.date_format));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString get_first_dive_date_string()
 | 
					QString get_first_dive_date_string()
 | 
				
			||||||
| 
						 | 
					@ -1003,7 +999,7 @@ std::string get_current_date()
 | 
				
			||||||
	QDateTime ts(QDateTime::currentDateTime());;
 | 
						QDateTime ts(QDateTime::currentDateTime());;
 | 
				
			||||||
	QString current_date;
 | 
						QString current_date;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	current_date = loc.toString(ts, QString(prefs.date_format_short));
 | 
						current_date = loc.toString(ts, QString::fromStdString(prefs.date_format_short));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return current_date.toStdString();
 | 
						return current_date.toStdString();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1018,7 +1014,7 @@ std::string hashfile_name()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static QString thumbnailDir()
 | 
					static QString thumbnailDir()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return QString(system_default_directory()) + "/thumbnails/";
 | 
						return QString::fromStdString(system_default_directory() + "/thumbnails/");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Calculate thumbnail filename by hashing name of file.
 | 
					// Calculate thumbnail filename by hashing name of file.
 | 
				
			||||||
| 
						 | 
					@ -1329,14 +1325,11 @@ std::optional<std::string> getCloudURL()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	std::string email(prefs.cloud_storage_email);
 | 
						std::string email(prefs.cloud_storage_email);
 | 
				
			||||||
	sanitize_email(email);
 | 
						sanitize_email(email);
 | 
				
			||||||
	if (email.empty() || empty_string(prefs.cloud_storage_password)) {
 | 
						if (email.empty() || prefs.cloud_storage_password.empty()) {
 | 
				
			||||||
		report_error("Please configure Cloud storage email and password in the preferences");
 | 
							report_error("Please configure Cloud storage email and password in the preferences");
 | 
				
			||||||
		return {};
 | 
							return {};
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (email != prefs.cloud_storage_email_encoded) {
 | 
						prefs.cloud_storage_email_encoded = email;
 | 
				
			||||||
		free((void *)prefs.cloud_storage_email_encoded);
 | 
					 | 
				
			||||||
		prefs.cloud_storage_email_encoded = strdup(email.c_str());
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	std::string filename = std::string(prefs.cloud_base_url) + "git/" + email + "[" + email + "]";
 | 
						std::string filename = std::string(prefs.cloud_base_url) + "git/" + email + "[" + email + "]";
 | 
				
			||||||
	if (verbose)
 | 
						if (verbose)
 | 
				
			||||||
		report_info("returning cloud URL %s", filename.c_str());
 | 
							report_info("returning cloud URL %s", filename.c_str());
 | 
				
			||||||
| 
						 | 
					@ -1359,11 +1352,11 @@ void init_proxy()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QNetworkProxy proxy;
 | 
						QNetworkProxy proxy;
 | 
				
			||||||
	proxy.setType(QNetworkProxy::ProxyType(prefs.proxy_type));
 | 
						proxy.setType(QNetworkProxy::ProxyType(prefs.proxy_type));
 | 
				
			||||||
	proxy.setHostName(prefs.proxy_host);
 | 
						proxy.setHostName(QString::fromStdString(prefs.proxy_host));
 | 
				
			||||||
	proxy.setPort(prefs.proxy_port);
 | 
						proxy.setPort(prefs.proxy_port);
 | 
				
			||||||
	if (prefs.proxy_auth) {
 | 
						if (prefs.proxy_auth) {
 | 
				
			||||||
		proxy.setUser(prefs.proxy_user);
 | 
							proxy.setUser(QString::fromStdString(prefs.proxy_user));
 | 
				
			||||||
		proxy.setPassword(prefs.proxy_pass);
 | 
							proxy.setPassword(QString::fromStdString(prefs.proxy_pass));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	QNetworkProxy::setApplicationProxy(proxy);
 | 
						QNetworkProxy::setApplicationProxy(proxy);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,11 +27,10 @@ HANDLE_PREFERENCE_BOOL(CloudStorage, "cloud_auto_sync", cloud_auto_sync);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void qPrefCloudStorage::set_cloud_base_url(const QString &value)
 | 
					void qPrefCloudStorage::set_cloud_base_url(const QString &value)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (value != prefs.cloud_base_url) {
 | 
						if (value.toStdString() != prefs.cloud_base_url) {
 | 
				
			||||||
		// only free and set if not default
 | 
							// only free and set if not default
 | 
				
			||||||
		if (prefs.cloud_base_url != default_prefs.cloud_base_url) {
 | 
							if (prefs.cloud_base_url != default_prefs.cloud_base_url)
 | 
				
			||||||
			qPrefPrivate::copy_txt(&prefs.cloud_base_url, value);
 | 
								prefs.cloud_base_url = value.toStdString();
 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		disk_cloud_base_url(true);
 | 
							disk_cloud_base_url(true);
 | 
				
			||||||
		emit instance()->cloud_base_urlChanged(value);
 | 
							emit instance()->cloud_base_urlChanged(value);
 | 
				
			||||||
| 
						 | 
					@ -42,14 +41,15 @@ void qPrefCloudStorage::store_cloud_base_url(const QString &value)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// this is used if we want to update the on-disk settings without changing
 | 
						// this is used if we want to update the on-disk settings without changing
 | 
				
			||||||
	// the runtime preference
 | 
						// the runtime preference
 | 
				
			||||||
	qPrefPrivate::propSetValue(keyFromGroupAndName(group, "cloud_base_url"), value, default_prefs.cloud_base_url);
 | 
						qPrefPrivate::propSetValue(keyFromGroupAndName(group, "cloud_base_url"), value, QString::fromStdString(default_prefs.cloud_base_url));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
void qPrefCloudStorage::disk_cloud_base_url(bool doSync)
 | 
					void qPrefCloudStorage::disk_cloud_base_url(bool doSync)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// we don't allow to automatically write back the prefs value for the cloud_base_url.
 | 
						// we don't allow to automatically write back the prefs value for the cloud_base_url.
 | 
				
			||||||
	// in order to do that you need to use the explicit function above store_cloud_base_url()
 | 
						// in order to do that you need to use the explicit function above store_cloud_base_url()
 | 
				
			||||||
	if (!doSync)
 | 
						if (!doSync)
 | 
				
			||||||
		prefs.cloud_base_url = copy_qstring(qPrefPrivate::propValue(keyFromGroupAndName(group, "cloud_base_url"), default_prefs.cloud_base_url).toString());
 | 
							prefs.cloud_base_url = qPrefPrivate::propValue(keyFromGroupAndName(group, "cloud_base_url"),
 | 
				
			||||||
 | 
									QString::fromStdString(default_prefs.cloud_base_url)).toString().toStdString();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HANDLE_PREFERENCE_TXT(CloudStorage, "email", cloud_storage_email);
 | 
					HANDLE_PREFERENCE_TXT(CloudStorage, "email", cloud_storage_email);
 | 
				
			||||||
| 
						 | 
					@ -58,8 +58,8 @@ HANDLE_PREFERENCE_TXT(CloudStorage, "email_encoded", cloud_storage_email_encoded
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void qPrefCloudStorage::set_cloud_storage_password(const QString &value)
 | 
					void qPrefCloudStorage::set_cloud_storage_password(const QString &value)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (value != prefs.cloud_storage_password) {
 | 
						if (value.toStdString() != prefs.cloud_storage_password) {
 | 
				
			||||||
		qPrefPrivate::copy_txt(&prefs.cloud_storage_password, value);
 | 
							prefs.cloud_storage_password = value.toStdString();
 | 
				
			||||||
		disk_cloud_storage_password(true);
 | 
							disk_cloud_storage_password(true);
 | 
				
			||||||
		emit instance()->cloud_storage_passwordChanged(value);
 | 
							emit instance()->cloud_storage_passwordChanged(value);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -68,9 +68,11 @@ void qPrefCloudStorage::disk_cloud_storage_password(bool doSync)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (doSync) {
 | 
						if (doSync) {
 | 
				
			||||||
		if (prefs.save_password_local)
 | 
							if (prefs.save_password_local)
 | 
				
			||||||
			qPrefPrivate::propSetValue(keyFromGroupAndName(group, "password"), prefs.cloud_storage_password, default_prefs.cloud_storage_password);
 | 
								qPrefPrivate::propSetValue(keyFromGroupAndName(group, "password"), prefs.cloud_storage_password,
 | 
				
			||||||
 | 
										default_prefs.cloud_storage_password);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		prefs.cloud_storage_password = copy_qstring(qPrefPrivate::propValue(keyFromGroupAndName(group, "password"), default_prefs.cloud_storage_password).toString());
 | 
							prefs.cloud_storage_password = qPrefPrivate::propValue(keyFromGroupAndName(group, "password"),
 | 
				
			||||||
 | 
									default_prefs.cloud_storage_password).toString().toStdString();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -84,17 +86,17 @@ HANDLE_PREFERENCE_BOOL(CloudStorage, "save_password_local", save_password_local)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString qPrefCloudStorage::diveshare_uid()
 | 
					QString qPrefCloudStorage::diveshare_uid()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return qPrefPrivate::propValue(keyFromGroupAndName("", "diveshareExport/uid"), "").toString();
 | 
						return qPrefPrivate::propValue(keyFromGroupAndName("", "diveshareExport/uid"), QString()).toString();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
void qPrefCloudStorage::set_diveshare_uid(const QString &value)
 | 
					void qPrefCloudStorage::set_diveshare_uid(const QString &value)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	qPrefPrivate::propSetValue(keyFromGroupAndName("", "diveshareExport/uid"), value, "");
 | 
						qPrefPrivate::propSetValue(keyFromGroupAndName("", "diveshareExport/uid"), value, QString());
 | 
				
			||||||
	emit instance()->diveshare_uidChanged(value);
 | 
						emit instance()->diveshare_uidChanged(value);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool qPrefCloudStorage::diveshare_private()
 | 
					bool qPrefCloudStorage::diveshare_private()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return qPrefPrivate::propValue(keyFromGroupAndName("", "diveshareExport/private"), "").toBool();
 | 
						return qPrefPrivate::propValue(keyFromGroupAndName("", "diveshareExport/private"), QString()).toBool();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
void qPrefCloudStorage::set_diveshare_private(bool value)
 | 
					void qPrefCloudStorage::set_diveshare_private(bool value)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -104,21 +106,20 @@ void qPrefCloudStorage::set_diveshare_private(bool value)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString qPrefCloudStorage::divelogde_user()
 | 
					QString qPrefCloudStorage::divelogde_user()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return qPrefPrivate::propValue(keyFromGroupAndName("", "divelogde_user"), "").toString();
 | 
						return qPrefPrivate::propValue(keyFromGroupAndName("", "divelogde_user"), QString()).toString();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
void qPrefCloudStorage::set_divelogde_user(const QString &value)
 | 
					void qPrefCloudStorage::set_divelogde_user(const QString &value)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	qPrefPrivate::propSetValue(keyFromGroupAndName("", "divelogde_user"), value, "");
 | 
						qPrefPrivate::propSetValue(keyFromGroupAndName("", "divelogde_user"), value, QString());
 | 
				
			||||||
	emit instance()->divelogde_userChanged(value);
 | 
						emit instance()->divelogde_userChanged(value);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
QString qPrefCloudStorage::divelogde_pass()
 | 
					QString qPrefCloudStorage::divelogde_pass()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return qPrefPrivate::propValue(keyFromGroupAndName("", "divelogde_pass"), "").toString();
 | 
						return qPrefPrivate::propValue(keyFromGroupAndName("", "divelogde_pass"), QString()).toString();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
void qPrefCloudStorage::set_divelogde_pass(const QString &value)
 | 
					void qPrefCloudStorage::set_divelogde_pass(const QString &value)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	qPrefPrivate::propSetValue(keyFromGroupAndName("", "divelogde_pass"), value, "");
 | 
						qPrefPrivate::propSetValue(keyFromGroupAndName("", "divelogde_pass"), value, QString());
 | 
				
			||||||
	emit instance()->divelogde_passChanged(value);
 | 
						emit instance()->divelogde_passChanged(value);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,11 +41,11 @@ public:
 | 
				
			||||||
	Q_ENUM(cloud_status);
 | 
						Q_ENUM(cloud_status);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	static bool cloud_auto_sync() { return prefs.cloud_auto_sync; }
 | 
						static bool cloud_auto_sync() { return prefs.cloud_auto_sync; }
 | 
				
			||||||
	static QString cloud_base_url() { return prefs.cloud_base_url; }
 | 
						static QString cloud_base_url() { return QString::fromStdString(prefs.cloud_base_url); }
 | 
				
			||||||
	static QString cloud_storage_email() { return prefs.cloud_storage_email; }
 | 
						static QString cloud_storage_email() { return QString::fromStdString(prefs.cloud_storage_email); }
 | 
				
			||||||
	static QString cloud_storage_email_encoded() { return prefs.cloud_storage_email_encoded; }
 | 
						static QString cloud_storage_email_encoded() { return QString::fromStdString(prefs.cloud_storage_email_encoded); }
 | 
				
			||||||
	static QString cloud_storage_password() { return prefs.cloud_storage_password; }
 | 
						static QString cloud_storage_password() { return QString::fromStdString(prefs.cloud_storage_password); }
 | 
				
			||||||
	static QString cloud_storage_pin() { return prefs.cloud_storage_pin; }
 | 
						static QString cloud_storage_pin() { return QString::fromStdString(prefs.cloud_storage_pin); }
 | 
				
			||||||
	static int cloud_timeout() { return prefs.cloud_timeout; }
 | 
						static int cloud_timeout() { return prefs.cloud_timeout; }
 | 
				
			||||||
	static int cloud_verification_status() { return prefs.cloud_verification_status; }
 | 
						static int cloud_verification_status() { return prefs.cloud_verification_status; }
 | 
				
			||||||
	static bool save_password_local() { return prefs.save_password_local; }
 | 
						static bool save_password_local() { return prefs.save_password_local; }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -77,9 +77,9 @@ void qPrefDisplay::set_divelist_font(const QString &value)
 | 
				
			||||||
	if (value.contains(","))
 | 
						if (value.contains(","))
 | 
				
			||||||
		newValue = value.left(value.indexOf(","));
 | 
							newValue = value.left(value.indexOf(","));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (newValue != prefs.divelist_font &&
 | 
						if (newValue.toStdString() != prefs.divelist_font &&
 | 
				
			||||||
	    !subsurface_ignore_font(qPrintable(newValue))) {
 | 
						    !subsurface_ignore_font(newValue.toStdString())) {
 | 
				
			||||||
		qPrefPrivate::copy_txt(&prefs.divelist_font, value);
 | 
							prefs.divelist_font = value.toStdString();
 | 
				
			||||||
		disk_divelist_font(true);
 | 
							disk_divelist_font(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		qApp->setFont(QFont(newValue));
 | 
							qApp->setFont(QFont(newValue));
 | 
				
			||||||
| 
						 | 
					@ -170,12 +170,10 @@ void qPrefDisplay::setCorrectFont()
 | 
				
			||||||
	QString fontName = defaultFont.toString();
 | 
						QString fontName = defaultFont.toString();
 | 
				
			||||||
	if (fontName.contains(","))
 | 
						if (fontName.contains(","))
 | 
				
			||||||
		fontName = fontName.left(fontName.indexOf(","));
 | 
							fontName = fontName.left(fontName.indexOf(","));
 | 
				
			||||||
	if (subsurface_ignore_font(qPrintable(fontName))) {
 | 
						if (subsurface_ignore_font(fontName.toStdString()))
 | 
				
			||||||
		defaultFont = QFont(prefs.divelist_font);
 | 
							defaultFont = QFont(QString::fromStdString(prefs.divelist_font));
 | 
				
			||||||
	} else {
 | 
						else
 | 
				
			||||||
		free((void *)prefs.divelist_font);
 | 
							prefs.divelist_font = fontName.toStdString();
 | 
				
			||||||
		prefs.divelist_font = copy_qstring(fontName);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	defaultFont.setPointSizeF(prefs.font_size * prefs.mobile_scale);
 | 
						defaultFont.setPointSizeF(prefs.font_size * prefs.mobile_scale);
 | 
				
			||||||
	qApp->setFont(defaultFont);
 | 
						qApp->setFont(defaultFont);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,7 +38,7 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	static int animation_speed() { return prefs.animation_speed; }
 | 
						static int animation_speed() { return prefs.animation_speed; }
 | 
				
			||||||
	static QString divelist_font() { return prefs.divelist_font; }
 | 
						static QString divelist_font() { return QString::fromStdString(prefs.divelist_font); }
 | 
				
			||||||
	static double font_size() { return prefs.font_size; }
 | 
						static double font_size() { return prefs.font_size; }
 | 
				
			||||||
	static double mobile_scale() { return prefs.mobile_scale; }
 | 
						static double mobile_scale() { return prefs.mobile_scale; }
 | 
				
			||||||
	static bool display_invalid_dives() { return prefs.display_invalid_dives; }
 | 
						static bool display_invalid_dives() { return prefs.display_invalid_dives; }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,11 +6,11 @@
 | 
				
			||||||
#include <QObject>
 | 
					#include <QObject>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define IMPLEMENT5GETTERS(name) \
 | 
					#define IMPLEMENT5GETTERS(name) \
 | 
				
			||||||
	static QString name() { return prefs.dive_computer.name; } \
 | 
						static QString name() { return QString::fromStdString(prefs.dive_computer.name); } \
 | 
				
			||||||
	static QString name##1() { return prefs.dive_computer##1 .name; } \
 | 
						static QString name##1() { return QString::fromStdString(prefs.dive_computer##1 .name); } \
 | 
				
			||||||
	static QString name##2() { return prefs.dive_computer##2 .name; } \
 | 
						static QString name##2() { return QString::fromStdString(prefs.dive_computer##2 .name); } \
 | 
				
			||||||
	static QString name##3() { return prefs.dive_computer##3 .name; } \
 | 
						static QString name##3() { return QString::fromStdString(prefs.dive_computer##3 .name); } \
 | 
				
			||||||
	static QString name##4() { return prefs.dive_computer##4 .name; }
 | 
						static QString name##4() { return QString::fromStdString(prefs.dive_computer##4 .name); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class qPrefDiveComputer : public QObject {
 | 
					class qPrefDiveComputer : public QObject {
 | 
				
			||||||
	Q_OBJECT
 | 
						Q_OBJECT
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,7 +20,7 @@ public:
 | 
				
			||||||
	static void sync() { loadSync(true); }
 | 
						static void sync() { loadSync(true); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	static QString default_cylinder() { return prefs.default_cylinder; }
 | 
						static QString default_cylinder() { return QString::fromStdString(prefs.default_cylinder); }
 | 
				
			||||||
	static bool include_unused_tanks() { return prefs.include_unused_tanks; }
 | 
						static bool include_unused_tanks() { return prefs.include_unused_tanks; }
 | 
				
			||||||
	static bool display_default_tank_infos() { return prefs.display_default_tank_infos; }
 | 
						static bool display_default_tank_infos() { return prefs.display_default_tank_infos; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,12 +25,12 @@ public:
 | 
				
			||||||
	static void sync() { loadSync(true); }
 | 
						static void sync() { loadSync(true); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	static const QString date_format() { return prefs.date_format; }
 | 
						static const QString date_format() { return QString::fromStdString(prefs.date_format); }
 | 
				
			||||||
	static bool date_format_override() { return prefs.date_format_override; }
 | 
						static bool date_format_override() { return prefs.date_format_override; }
 | 
				
			||||||
	static const QString date_format_short() { return prefs.date_format_short; }
 | 
						static const QString date_format_short() { return QString::fromStdString(prefs.date_format_short); }
 | 
				
			||||||
	static const QString language() { return prefs.locale.language; }
 | 
						static const QString language() { return QString::fromStdString(prefs.locale.language); }
 | 
				
			||||||
	static const QString lang_locale() { return prefs.locale.lang_locale; }
 | 
						static const QString lang_locale() { return QString::fromStdString(prefs.locale.lang_locale); }
 | 
				
			||||||
	static const QString time_format() { return prefs.time_format; }
 | 
						static const QString time_format() { return QString::fromStdString(prefs.time_format); }
 | 
				
			||||||
	static bool time_format_override() { return prefs.time_format_override; }
 | 
						static bool time_format_override() { return prefs.time_format_override; }
 | 
				
			||||||
	static bool use_system_language() { return prefs.locale.use_system_language; }
 | 
						static bool use_system_language() { return prefs.locale.use_system_language; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,7 +28,7 @@ void qPrefLog::set_default_file_behavior(enum def_file_behavior value)
 | 
				
			||||||
		if (value == UNDEFINED_DEFAULT_FILE) {
 | 
							if (value == UNDEFINED_DEFAULT_FILE) {
 | 
				
			||||||
			// undefined, so check if there's a filename set and
 | 
								// undefined, so check if there's a filename set and
 | 
				
			||||||
			// use that, otherwise go with no default file
 | 
								// use that, otherwise go with no default file
 | 
				
			||||||
			prefs.default_file_behavior = QString(prefs.default_filename).isEmpty() ? NO_DEFAULT_FILE : LOCAL_DEFAULT_FILE;
 | 
								prefs.default_file_behavior = prefs.default_filename.empty() ? NO_DEFAULT_FILE : LOCAL_DEFAULT_FILE;
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			prefs.default_file_behavior = value;
 | 
								prefs.default_file_behavior = value;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -45,7 +45,7 @@ void qPrefLog::disk_default_file_behavior(bool doSync)
 | 
				
			||||||
		if (prefs.default_file_behavior == UNDEFINED_DEFAULT_FILE)
 | 
							if (prefs.default_file_behavior == UNDEFINED_DEFAULT_FILE)
 | 
				
			||||||
			// undefined, so check if there's a filename set and
 | 
								// undefined, so check if there's a filename set and
 | 
				
			||||||
			// use that, otherwise go with no default file
 | 
								// use that, otherwise go with no default file
 | 
				
			||||||
			prefs.default_file_behavior = QString(prefs.default_filename).isEmpty() ? NO_DEFAULT_FILE : LOCAL_DEFAULT_FILE;
 | 
								prefs.default_file_behavior = prefs.default_filename.empty() ? NO_DEFAULT_FILE : LOCAL_DEFAULT_FILE;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,4 +58,3 @@ HANDLE_PREFERENCE_BOOL(Log, "use_default_file", use_default_file);
 | 
				
			||||||
HANDLE_PREFERENCE_BOOL(Log, "salinityEditDefault", salinityEditDefault);
 | 
					HANDLE_PREFERENCE_BOOL(Log, "salinityEditDefault", salinityEditDefault);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HANDLE_PREFERENCE_BOOL(Log, "show_average_depth", show_average_depth);
 | 
					HANDLE_PREFERENCE_BOOL(Log, "show_average_depth", show_average_depth);
 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,7 +23,7 @@ public:
 | 
				
			||||||
	static void sync() { return loadSync(true); }
 | 
						static void sync() { return loadSync(true); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	static QString default_filename() { return prefs.default_filename; }
 | 
						static QString default_filename() { return QString::fromStdString(prefs.default_filename); }
 | 
				
			||||||
	static enum def_file_behavior default_file_behavior() { return prefs.default_file_behavior; }
 | 
						static enum def_file_behavior default_file_behavior() { return prefs.default_file_behavior; }
 | 
				
			||||||
	static bool use_default_file() { return prefs.use_default_file; }
 | 
						static bool use_default_file() { return prefs.use_default_file; }
 | 
				
			||||||
	static bool extraEnvironmentalDefault() { return prefs.extraEnvironmentalDefault; }
 | 
						static bool extraEnvironmentalDefault() { return prefs.extraEnvironmentalDefault; }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,4 +23,3 @@ HANDLE_PREFERENCE_BOOL(Media, "auto_recalculate_thumbnails", auto_recalculate_th
 | 
				
			||||||
HANDLE_PREFERENCE_BOOL(Media, "extract_video_thumbnails", extract_video_thumbnails);
 | 
					HANDLE_PREFERENCE_BOOL(Media, "extract_video_thumbnails", extract_video_thumbnails);
 | 
				
			||||||
HANDLE_PREFERENCE_INT(Media, "extract_video_thumbnails_position", extract_video_thumbnails_position);
 | 
					HANDLE_PREFERENCE_INT(Media, "extract_video_thumbnails_position", extract_video_thumbnails_position);
 | 
				
			||||||
HANDLE_PREFERENCE_TXT(Media, "ffmpeg_executable", ffmpeg_executable);
 | 
					HANDLE_PREFERENCE_TXT(Media, "ffmpeg_executable", ffmpeg_executable);
 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,7 +24,7 @@ public:
 | 
				
			||||||
	static bool auto_recalculate_thumbnails() { return prefs.auto_recalculate_thumbnails; }
 | 
						static bool auto_recalculate_thumbnails() { return prefs.auto_recalculate_thumbnails; }
 | 
				
			||||||
	static bool extract_video_thumbnails() { return prefs.extract_video_thumbnails; }
 | 
						static bool extract_video_thumbnails() { return prefs.extract_video_thumbnails; }
 | 
				
			||||||
	static int extract_video_thumbnails_position() { return prefs.extract_video_thumbnails_position; }
 | 
						static int extract_video_thumbnails_position() { return prefs.extract_video_thumbnails_position; }
 | 
				
			||||||
	static QString ffmpeg_executable() { return prefs.ffmpeg_executable; }
 | 
						static QString ffmpeg_executable() { return QString::fromStdString(prefs.ffmpeg_executable); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public slots:
 | 
					public slots:
 | 
				
			||||||
	static void set_auto_recalculate_thumbnails(bool value);
 | 
						static void set_auto_recalculate_thumbnails(bool value);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,12 +4,6 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QSettings>
 | 
					#include <QSettings>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void qPrefPrivate::copy_txt(const char **name, const QString &string)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	free((void *)*name);
 | 
					 | 
				
			||||||
	*name = copy_qstring(string);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
QString keyFromGroupAndName(QString group, QString name)
 | 
					QString keyFromGroupAndName(QString group, QString name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QString slash = (group.endsWith('/') || name.startsWith('/')) ? "" : "/";
 | 
						QString slash = (group.endsWith('/') || name.startsWith('/')) ? "" : "/";
 | 
				
			||||||
| 
						 | 
					@ -35,8 +29,19 @@ void qPrefPrivate::propSetValue(const QString &key, const QVariant &value, const
 | 
				
			||||||
		s.remove(key);
 | 
							s.remove(key);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void qPrefPrivate::propSetValue(const QString &key, const std::string &value, const std::string &defaultValue)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						propSetValue(key, QString::fromStdString(value), QString::fromStdString(defaultValue));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QVariant qPrefPrivate::propValue(const QString &key, const QVariant &defaultValue)
 | 
					QVariant qPrefPrivate::propValue(const QString &key, const QVariant &defaultValue)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QSettings s;
 | 
						QSettings s;
 | 
				
			||||||
	return  s.value(key, defaultValue);
 | 
						return  s.value(key, defaultValue);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QVariant qPrefPrivate::propValue(const QString &key, const std::string &defaultValue)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						QSettings s;
 | 
				
			||||||
 | 
						return  s.value(key, QString::fromStdString(defaultValue));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,10 +16,10 @@ class qPrefPrivate {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	// Helper functions
 | 
						// Helper functions
 | 
				
			||||||
	static void copy_txt(const char **name, const QString &string);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	static void propSetValue(const QString &key, const QVariant &value, const QVariant &defaultValue);
 | 
						static void propSetValue(const QString &key, const QVariant &value, const QVariant &defaultValue);
 | 
				
			||||||
 | 
						static void propSetValue(const QString &key, const std::string &value, const std::string &defaultValue);
 | 
				
			||||||
	static QVariant propValue(const QString &key, const QVariant &defaultValue);
 | 
						static QVariant propValue(const QString &key, const QVariant &defaultValue);
 | 
				
			||||||
 | 
						static QVariant propValue(const QString &key, const std::string &defaultValue);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	qPrefPrivate() {}
 | 
						qPrefPrivate() {}
 | 
				
			||||||
| 
						 | 
					@ -134,29 +134,29 @@ extern QString keyFromGroupAndName(QString group, QString name);
 | 
				
			||||||
#define DISK_LOADSYNC_TXT_EXT(usegroup, name, field, usestruct) \
 | 
					#define DISK_LOADSYNC_TXT_EXT(usegroup, name, field, usestruct) \
 | 
				
			||||||
	void qPref##usegroup::disk_##field(bool doSync) \
 | 
						void qPref##usegroup::disk_##field(bool doSync) \
 | 
				
			||||||
	{ \
 | 
						{ \
 | 
				
			||||||
		static QString current_state; \
 | 
							static std::string current_state; \
 | 
				
			||||||
		if (doSync) { \
 | 
							if (doSync) { \
 | 
				
			||||||
			if (current_state != QString(prefs.usestruct field)) { \
 | 
								if (current_state != prefs.usestruct field) { \
 | 
				
			||||||
				current_state = QString(prefs.usestruct field); \
 | 
									current_state = prefs.usestruct field; \
 | 
				
			||||||
				qPrefPrivate::propSetValue(keyFromGroupAndName(group, name), prefs.usestruct field, default_prefs.usestruct field); \
 | 
									qPrefPrivate::propSetValue(keyFromGroupAndName(group, name), QString::fromStdString(prefs.usestruct field), QString::fromStdString(default_prefs.usestruct field)); \
 | 
				
			||||||
			} \
 | 
								} \
 | 
				
			||||||
		} else { \
 | 
							} else { \
 | 
				
			||||||
			prefs.usestruct field = copy_qstring(qPrefPrivate::propValue(keyFromGroupAndName(group, name), default_prefs.usestruct field).toString()); \
 | 
								prefs.usestruct field = qPrefPrivate::propValue(keyFromGroupAndName(group, name), QString::fromStdString(default_prefs.usestruct field)).toString().toStdString(); \
 | 
				
			||||||
			current_state = QString(prefs.usestruct field); \
 | 
								current_state = prefs.usestruct field; \
 | 
				
			||||||
		} \
 | 
							} \
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#define DISK_LOADSYNC_TXT_EXT_ALT(usegroup, name, field, usestruct, alt) \
 | 
					#define DISK_LOADSYNC_TXT_EXT_ALT(usegroup, name, field, usestruct, alt) \
 | 
				
			||||||
	void qPref##usegroup::disk_##field##alt(bool doSync) \
 | 
						void qPref##usegroup::disk_##field##alt(bool doSync) \
 | 
				
			||||||
	{ \
 | 
						{ \
 | 
				
			||||||
		static QString current_state; \
 | 
							static std::string current_state; \
 | 
				
			||||||
		if (doSync) { \
 | 
							if (doSync) { \
 | 
				
			||||||
			if (current_state != QString(prefs.usestruct ## alt .field)) { \
 | 
								if (current_state != prefs.usestruct ## alt .field) { \
 | 
				
			||||||
				current_state = QString(prefs.usestruct ## alt .field); \
 | 
									current_state = prefs.usestruct ## alt .field; \
 | 
				
			||||||
				qPrefPrivate::propSetValue(keyFromGroupAndName(group, name), prefs.usestruct ##alt .field, default_prefs.usestruct ##alt .field); \
 | 
									qPrefPrivate::propSetValue(keyFromGroupAndName(group, name), QString::fromStdString(prefs.usestruct ##alt .field), QString::fromStdString(default_prefs.usestruct ##alt .field)); \
 | 
				
			||||||
			} \
 | 
								} \
 | 
				
			||||||
		} else { \
 | 
							} else { \
 | 
				
			||||||
			prefs.usestruct ##alt .field = copy_qstring(qPrefPrivate::propValue(keyFromGroupAndName(group, name), default_prefs.usestruct ##alt .field).toString()); \
 | 
								prefs.usestruct ##alt .field = qPrefPrivate::propValue(keyFromGroupAndName(group, name), QString::fromStdString(default_prefs.usestruct ##alt .field)).toString().toStdString(); \
 | 
				
			||||||
			current_state = QString(prefs.usestruct ##alt .field); \
 | 
								current_state = prefs.usestruct ##alt .field; \
 | 
				
			||||||
		} \
 | 
							} \
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#define DISK_LOADSYNC_TXT(usegroup, name, field) \
 | 
					#define DISK_LOADSYNC_TXT(usegroup, name, field) \
 | 
				
			||||||
| 
						 | 
					@ -226,8 +226,8 @@ extern QString keyFromGroupAndName(QString group, QString name);
 | 
				
			||||||
#define SET_PREFERENCE_TXT_EXT(usegroup, field, usestruct) \
 | 
					#define SET_PREFERENCE_TXT_EXT(usegroup, field, usestruct) \
 | 
				
			||||||
	void qPref##usegroup::set_##field(const QString &value) \
 | 
						void qPref##usegroup::set_##field(const QString &value) \
 | 
				
			||||||
	{ \
 | 
						{ \
 | 
				
			||||||
		if (value != prefs.usestruct field) { \
 | 
							if (value.toStdString() != prefs.usestruct field) { \
 | 
				
			||||||
			qPrefPrivate::copy_txt(&prefs.usestruct field, value); \
 | 
								prefs.usestruct field = value.toStdString(); \
 | 
				
			||||||
			disk_##field(true); \
 | 
								disk_##field(true); \
 | 
				
			||||||
			emit instance()->field##Changed(value); \
 | 
								emit instance()->field##Changed(value); \
 | 
				
			||||||
		} \
 | 
							} \
 | 
				
			||||||
| 
						 | 
					@ -236,8 +236,8 @@ extern QString keyFromGroupAndName(QString group, QString name);
 | 
				
			||||||
#define SET_PREFERENCE_TXT_EXT_ALT(usegroup, field, usestruct, alt) \
 | 
					#define SET_PREFERENCE_TXT_EXT_ALT(usegroup, field, usestruct, alt) \
 | 
				
			||||||
	void qPref##usegroup::set_##field##alt(const QString &value) \
 | 
						void qPref##usegroup::set_##field##alt(const QString &value) \
 | 
				
			||||||
	{ \
 | 
						{ \
 | 
				
			||||||
		if (value != prefs.usestruct ##alt .field) { \
 | 
							if (value.toStdString() != prefs.usestruct ##alt .field) { \
 | 
				
			||||||
			qPrefPrivate::copy_txt(&prefs.usestruct ##alt .field, value); \
 | 
								prefs.usestruct ##alt .field = value.toStdString(); \
 | 
				
			||||||
			disk_##field##alt(true); \
 | 
								disk_##field##alt(true); \
 | 
				
			||||||
			emit instance()->field##alt##Changed(value); \
 | 
								emit instance()->field##alt##Changed(value); \
 | 
				
			||||||
		} \
 | 
							} \
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,11 +25,11 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	static bool proxy_auth() { return prefs.proxy_auth; }
 | 
						static bool proxy_auth() { return prefs.proxy_auth; }
 | 
				
			||||||
	static QString proxy_host() { return prefs.proxy_host; }
 | 
						static QString proxy_host() { return QString::fromStdString(prefs.proxy_host); }
 | 
				
			||||||
	static QString proxy_pass() { return prefs.proxy_pass; }
 | 
						static QString proxy_pass() { return QString::fromStdString(prefs.proxy_pass); }
 | 
				
			||||||
	static int proxy_port() { return prefs.proxy_port; }
 | 
						static int proxy_port() { return prefs.proxy_port; }
 | 
				
			||||||
	static int proxy_type() { return prefs.proxy_type; }
 | 
						static int proxy_type() { return prefs.proxy_type; }
 | 
				
			||||||
	static QString proxy_user() { return prefs.proxy_user; }
 | 
						static QString proxy_user() { return QString::fromStdString(prefs.proxy_user); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public slots:
 | 
					public slots:
 | 
				
			||||||
	static void set_proxy_auth(bool value);
 | 
						static void set_proxy_auth(bool value);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,7 +41,7 @@ void qPrefUpdateManager::disk_next_check(bool doSync)
 | 
				
			||||||
	if (doSync)
 | 
						if (doSync)
 | 
				
			||||||
		qPrefPrivate::propSetValue(keyFromGroupAndName(group, "NextCheck"), prefs.update_manager.next_check, default_prefs.update_manager.next_check);
 | 
							qPrefPrivate::propSetValue(keyFromGroupAndName(group, "NextCheck"), prefs.update_manager.next_check, default_prefs.update_manager.next_check);
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		prefs.update_manager.next_check = qPrefPrivate::propValue(keyFromGroupAndName(group, "NextCheck"), 0).toInt();
 | 
							prefs.update_manager.next_check = qPrefPrivate::propValue(keyFromGroupAndName(group, "NextCheck"), QVariant(0)).toInt();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HANDLE_PROP_QSTRING(UpdateManager, "UpdateManager/UUID", uuidString);
 | 
					HANDLE_PROP_QSTRING(UpdateManager, "UpdateManager/UUID", uuidString);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,7 +23,7 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	static bool dont_check_for_updates() { return prefs.update_manager.dont_check_for_updates; }
 | 
						static bool dont_check_for_updates() { return prefs.update_manager.dont_check_for_updates; }
 | 
				
			||||||
	static const QString last_version_used() { return prefs.update_manager.last_version_used; }
 | 
						static const QString last_version_used() { return QString::fromStdString(prefs.update_manager.last_version_used); }
 | 
				
			||||||
	static const QDate next_check() { return QDate::fromJulianDay(prefs.update_manager.next_check); }
 | 
						static const QDate next_check() { return QDate::fromJulianDay(prefs.update_manager.next_check); }
 | 
				
			||||||
	static const QString uuidString() { return st_uuidString; }
 | 
						static const QString uuidString() { return st_uuidString; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -241,20 +241,20 @@ QString formatDiveGPS(const dive *d)
 | 
				
			||||||
QString formatDiveDate(const dive *d)
 | 
					QString formatDiveDate(const dive *d)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QDateTime localTime = timestampToDateTime(d->when);
 | 
						QDateTime localTime = timestampToDateTime(d->when);
 | 
				
			||||||
	return localTime.date().toString(prefs.date_format_short);
 | 
						return localTime.date().toString(QString::fromStdString(prefs.date_format_short));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString formatDiveTime(const dive *d)
 | 
					QString formatDiveTime(const dive *d)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QDateTime localTime = timestampToDateTime(d->when);
 | 
						QDateTime localTime = timestampToDateTime(d->when);
 | 
				
			||||||
	return localTime.time().toString(prefs.time_format);
 | 
						return localTime.time().toString(QString::fromStdString(prefs.time_format));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString formatDiveDateTime(const dive *d)
 | 
					QString formatDiveDateTime(const dive *d)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QDateTime localTime = timestampToDateTime(d->when);
 | 
						QDateTime localTime = timestampToDateTime(d->when);
 | 
				
			||||||
	return QStringLiteral("%1 %2").arg(localTime.date().toString(prefs.date_format_short),
 | 
						return QStringLiteral("%1 %2").arg(localTime.date().toString(QString::fromStdString(prefs.date_format_short)),
 | 
				
			||||||
					   localTime.time().toString(prefs.time_format));
 | 
										   localTime.time().toString(QString::fromStdString(prefs.time_format)));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString formatDiveGasString(const dive *d)
 | 
					QString formatDiveGasString(const dive *d)
 | 
				
			||||||
| 
						 | 
					@ -308,7 +308,7 @@ QString formatTripTitle(const dive_trip &trip)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QString prefix = !trip.location.empty() ? QString::fromStdString(trip.location) + ", " : QString();
 | 
						QString prefix = !trip.location.empty() ? QString::fromStdString(trip.location) + ", " : QString();
 | 
				
			||||||
	if (getday)
 | 
						if (getday)
 | 
				
			||||||
		return prefix + loc.toString(localTime, prefs.date_format);
 | 
							return prefix + loc.toString(localTime, QString::fromStdString(prefs.date_format));
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		return prefix + loc.toString(localTime, "MMM yyyy");
 | 
							return prefix + loc.toString(localTime, "MMM yyyy");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,11 +27,6 @@ static inline bool empty_string(const char *s)
 | 
				
			||||||
	return !s || !*s;
 | 
						return !s || !*s;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline char *copy_string(const char *s)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return (s && *s) ? strdup(s) : NULL;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern double permissive_strtod(const char *str, const char **ptr);
 | 
					extern double permissive_strtod(const char *str, const char **ptr);
 | 
				
			||||||
extern double ascii_strtod(const char *str, const char **ptr);
 | 
					extern double ascii_strtod(const char *str, const char **ptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,6 +42,16 @@ inline bool contains(std::string_view s, char c)
 | 
				
			||||||
	return s.find(c) != std::string::npos;
 | 
						return s.find(c) != std::string::npos;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline bool contains(std::string_view haystack, const char *needle)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return haystack.find(needle) != std::string::npos;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline bool contains(std::string_view haystack, const std::string &needle)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return haystack.find(needle) != std::string::npos;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
std::string join(const std::vector<std::string> &l, const std::string &separator, bool skip_empty = false);
 | 
					std::string join(const std::vector<std::string> &l, const std::string &separator, bool skip_empty = false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // SUBSURFACE_STRING_H
 | 
					#endif // SUBSURFACE_STRING_H
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,8 +49,8 @@ void print_files()
 | 
				
			||||||
	std::optional<std::string> filename;
 | 
						std::optional<std::string> filename;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	printf("\nFile locations:\n\n");
 | 
						printf("\nFile locations:\n\n");
 | 
				
			||||||
	printf("Cloud email:%s\n", prefs.cloud_storage_email);
 | 
						printf("Cloud email:%s\n", prefs.cloud_storage_email.c_str());
 | 
				
			||||||
	if (!empty_string(prefs.cloud_storage_email) && !empty_string(prefs.cloud_storage_password)) {
 | 
						if (!prefs.cloud_storage_email.empty() && !prefs.cloud_storage_password.empty()) {
 | 
				
			||||||
		filename = getCloudURL();
 | 
							filename = getCloudURL();
 | 
				
			||||||
		if (filename)
 | 
							if (filename)
 | 
				
			||||||
			is_git_repository(filename->c_str(), &info);
 | 
								is_git_repository(filename->c_str(), &info);
 | 
				
			||||||
| 
						 | 
					@ -107,7 +107,7 @@ void parse_argument(const char *arg)
 | 
				
			||||||
			/* long options with -- */
 | 
								/* long options with -- */
 | 
				
			||||||
			/* first test for --user=bla which allows the use of user specific settings */
 | 
								/* first test for --user=bla which allows the use of user specific settings */
 | 
				
			||||||
			if (strncmp(arg, "--user=", sizeof("--user=") - 1) == 0) {
 | 
								if (strncmp(arg, "--user=", sizeof("--user=") - 1) == 0) {
 | 
				
			||||||
				settings_suffix = strdup(arg + sizeof("--user=") - 1);
 | 
									settings_suffix = arg + sizeof("--user=") - 1;
 | 
				
			||||||
				return;
 | 
									return;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if (strncmp(arg, "--cloud-timeout=", sizeof("--cloud-timeout=") - 1) == 0) {
 | 
								if (strncmp(arg, "--cloud-timeout=", sizeof("--cloud-timeout=") - 1) == 0) {
 | 
				
			||||||
| 
						 | 
					@ -144,15 +144,15 @@ void parse_argument(const char *arg)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
#if SUBSURFACE_DOWNLOADER
 | 
					#if SUBSURFACE_DOWNLOADER
 | 
				
			||||||
			if (strncmp(arg, "--dc-vendor=", sizeof("--dc-vendor=") - 1) == 0) {
 | 
								if (strncmp(arg, "--dc-vendor=", sizeof("--dc-vendor=") - 1) == 0) {
 | 
				
			||||||
				prefs.dive_computer.vendor = strdup(arg + sizeof("--dc-vendor=") - 1);
 | 
									prefs.dive_computer.vendor = arg + sizeof("--dc-vendor=") - 1;
 | 
				
			||||||
				return;
 | 
									return;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if (strncmp(arg, "--dc-product=", sizeof("--dc-product=") - 1) == 0) {
 | 
								if (strncmp(arg, "--dc-product=", sizeof("--dc-product=") - 1) == 0) {
 | 
				
			||||||
				prefs.dive_computer.product = strdup(arg + sizeof("--dc-product=") - 1);
 | 
									prefs.dive_computer.product = arg + sizeof("--dc-product=") - 1;
 | 
				
			||||||
				return;
 | 
									return;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if (strncmp(arg, "--device=", sizeof("--device=") - 1) == 0) {
 | 
								if (strncmp(arg, "--device=", sizeof("--device=") - 1) == 0) {
 | 
				
			||||||
				prefs.dive_computer.device = strdup(arg + sizeof("--device=") - 1);
 | 
									prefs.dive_computer.device = arg + sizeof("--device=") - 1;
 | 
				
			||||||
				return;
 | 
									return;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if (strncmp(arg, "--list-dc", sizeof("--list-dc") - 1) == 0) {
 | 
								if (strncmp(arg, "--list-dc", sizeof("--list-dc") - 1) == 0) {
 | 
				
			||||||
| 
						 | 
					@ -194,12 +194,12 @@ void setup_system_prefs()
 | 
				
			||||||
	const char *env;
 | 
						const char *env;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	subsurface_OS_pref_setup();
 | 
						subsurface_OS_pref_setup();
 | 
				
			||||||
	default_prefs.divelist_font = strdup(system_divelist_default_font);
 | 
						default_prefs.divelist_font = system_divelist_default_font;
 | 
				
			||||||
	default_prefs.font_size = system_divelist_default_font_size;
 | 
						default_prefs.font_size = system_divelist_default_font_size;
 | 
				
			||||||
	default_prefs.ffmpeg_executable = strdup("ffmpeg");
 | 
						default_prefs.ffmpeg_executable = "ffmpeg";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if !defined(SUBSURFACE_MOBILE)
 | 
					#if !defined(SUBSURFACE_MOBILE)
 | 
				
			||||||
	default_prefs.default_filename = copy_string(system_default_filename());
 | 
						default_prefs.default_filename = system_default_filename();
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	env = getenv("LC_MEASUREMENT");
 | 
						env = getenv("LC_MEASUREMENT");
 | 
				
			||||||
	if (!env)
 | 
						if (!env)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,19 +2,19 @@
 | 
				
			||||||
#ifndef SUBSURFACESTARTUP_H
 | 
					#ifndef SUBSURFACESTARTUP_H
 | 
				
			||||||
#define SUBSURFACESTARTUP_H
 | 
					#define SUBSURFACESTARTUP_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern bool imported;
 | 
					extern bool imported;
 | 
				
			||||||
extern int quit, force_root, ignore_bt;
 | 
					extern int quit, force_root, ignore_bt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void setup_system_prefs();
 | 
					void setup_system_prefs();
 | 
				
			||||||
void parse_argument(const char *arg);
 | 
					void parse_argument(const char *arg);
 | 
				
			||||||
void free_prefs();
 | 
					 | 
				
			||||||
void print_files();
 | 
					void print_files();
 | 
				
			||||||
void print_version();
 | 
					void print_version();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern char *settings_suffix;
 | 
					extern std::string settings_suffix;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef SUBSURFACE_MOBILE_DESKTOP
 | 
					#ifdef SUBSURFACE_MOBILE_DESKTOP
 | 
				
			||||||
#include <string>
 | 
					 | 
				
			||||||
extern std::string testqml;
 | 
					extern std::string testqml;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,9 +27,9 @@ extern const char *taxonomy_category_names[TC_NR_CATEGORIES];
 | 
				
			||||||
extern const char *taxonomy_api_names[TC_NR_CATEGORIES];
 | 
					extern const char *taxonomy_api_names[TC_NR_CATEGORIES];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct taxonomy {
 | 
					struct taxonomy {
 | 
				
			||||||
	taxonomy_category category;	/* the category for this tag: ocean, country, admin_l1, admin_l2, localname, etc */
 | 
						taxonomy_category category = TC_NONE;	/* the category for this tag: ocean, country, admin_l1, admin_l2, localname, etc */
 | 
				
			||||||
	std::string value;			/* the value returned, parsed, or manually entered for that category */
 | 
						std::string value;			/* the value returned, parsed, or manually entered for that category */
 | 
				
			||||||
	taxonomy_origin origin;
 | 
						taxonomy_origin origin = GEOCODED;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* the data block contains taxonomy structures - unused ones have a tag value of NONE */
 | 
					/* the data block contains taxonomy structures - unused ones have a tag value of NONE */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,8 +35,8 @@ static std::string make_default_filename()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// the DE should provide us with a default font and font size...
 | 
					// the DE should provide us with a default font and font size...
 | 
				
			||||||
const char unix_system_divelist_default_font[] = "Sans";
 | 
					using namespace std::string_literals;
 | 
				
			||||||
const char *system_divelist_default_font = unix_system_divelist_default_font;
 | 
					std::string system_divelist_default_font = "Sans"s;
 | 
				
			||||||
double system_divelist_default_font_size = -1.0;
 | 
					double system_divelist_default_font_size = -1.0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void subsurface_OS_pref_setup()
 | 
					void subsurface_OS_pref_setup()
 | 
				
			||||||
| 
						 | 
					@ -44,22 +44,22 @@ void subsurface_OS_pref_setup()
 | 
				
			||||||
	// nothing
 | 
						// nothing
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool subsurface_ignore_font(const char *)
 | 
					bool subsurface_ignore_font(const std::string &)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// there are no old default fonts to ignore
 | 
						// there are no old default fonts to ignore
 | 
				
			||||||
	return false;
 | 
						return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char *system_default_directory()
 | 
					std::string system_default_directory()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	static const std::string path = system_default_path();
 | 
						static const std::string path = system_default_path();
 | 
				
			||||||
	return path.c_str();
 | 
						return path;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char *system_default_filename()
 | 
					std::string system_default_filename()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	static const std::string fn = make_default_filename();
 | 
						static const std::string fn = make_default_filename();
 | 
				
			||||||
	return fn.c_str();
 | 
						return fn;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int enumerate_devices(device_callback_t callback, void *userdata, unsigned int transport)
 | 
					int enumerate_devices(device_callback_t callback, void *userdata, unsigned int transport)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -83,7 +83,7 @@ void VideoFrameExtractor::processItem(QString originalFilename, QString filename
 | 
				
			||||||
					       .arg(position.seconds % 60, 2, 10, QChar('0'));
 | 
										       .arg(position.seconds % 60, 2, 10, QChar('0'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QProcess ffmpeg;
 | 
						QProcess ffmpeg;
 | 
				
			||||||
	ffmpeg.start(prefs.ffmpeg_executable, QStringList {
 | 
						ffmpeg.start(prefs.ffmpeg_executable.c_str(), QStringList {
 | 
				
			||||||
		"-ss", posString, "-i", filename, "-vframes", "1", "-q:v", "2", "-f", "image2", "-"
 | 
							"-ss", posString, "-i", filename, "-vframes", "1", "-q:v", "2", "-f", "image2", "-"
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
	if (!ffmpeg.waitForStarted()) {
 | 
						if (!ffmpeg.waitForStarted()) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -99,40 +99,39 @@ static std::wstring make_default_filename()
 | 
				
			||||||
	return path + L"\\" + filename;
 | 
						return path + L"\\" + filename;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char non_standard_system_divelist_default_font[] = "Calibri";
 | 
					using namespace std::string_literals;
 | 
				
			||||||
const char current_system_divelist_default_font[] = "Segoe UI";
 | 
					static std::string non_standard_system_divelist_default_font = "Calibri"s;
 | 
				
			||||||
const char *system_divelist_default_font = non_standard_system_divelist_default_font;
 | 
					static std::string current_system_divelist_default_font = "Segoe UI"s;
 | 
				
			||||||
 | 
					std::string system_divelist_default_font;
 | 
				
			||||||
double system_divelist_default_font_size = -1;
 | 
					double system_divelist_default_font_size = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void subsurface_OS_pref_setup()
 | 
					void subsurface_OS_pref_setup()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (isWin7Or8())
 | 
						system_divelist_default_font = isWin7Or8() ? current_system_divelist_default_font
 | 
				
			||||||
		system_divelist_default_font = current_system_divelist_default_font;
 | 
											   : non_standard_system_divelist_default_font;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool subsurface_ignore_font(const char *font)
 | 
					bool subsurface_ignore_font(const std::string &font)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// if this is running on a recent enough version of Windows and the font
 | 
						// if this is running on a recent enough version of Windows and the font
 | 
				
			||||||
	// passed in is the pre 4.3 default font, ignore it
 | 
						// passed in is the pre 4.3 default font, ignore it
 | 
				
			||||||
	if (isWin7Or8() && strcmp(font, non_standard_system_divelist_default_font) == 0)
 | 
						return isWin7Or8() && font == non_standard_system_divelist_default_font;
 | 
				
			||||||
		return true;
 | 
					 | 
				
			||||||
	return false;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define utf8_to_utf16(s) utf8_to_utf16_fl(s, __FILE__, __LINE__)
 | 
					#define utf8_to_utf16(s) utf8_to_utf16_fl(s, __FILE__, __LINE__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* '\' not included at the end.
 | 
					/* '\' not included at the end.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
const char *system_default_directory()
 | 
					std::string system_default_directory()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	static std::string path = utf16_to_utf8(system_default_path());
 | 
						static std::string path = utf16_to_utf8(system_default_path());
 | 
				
			||||||
	return path.c_str();
 | 
						return path;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char *system_default_filename()
 | 
					std::string system_default_filename()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	static std::string path = utf16_to_utf8(make_default_filename());
 | 
						static std::string path = utf16_to_utf8(make_default_filename());
 | 
				
			||||||
	return path.c_str();
 | 
						return path;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int enumerate_devices(device_callback_t callback, void *userdata, unsigned int transport)
 | 
					int enumerate_devices(device_callback_t callback, void *userdata, unsigned int transport)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -162,8 +162,8 @@ void DivePlannerWidget::settingsChanged()
 | 
				
			||||||
	ui.atmHeight->setValue((int) get_depth_units((int) pressure_to_altitude(DivePlannerPointsModel::instance()->getSurfacePressure()), NULL, NULL));
 | 
						ui.atmHeight->setValue((int) get_depth_units((int) pressure_to_altitude(DivePlannerPointsModel::instance()->getSurfacePressure()), NULL, NULL));
 | 
				
			||||||
	ui.atmHeight->blockSignals(false);
 | 
						ui.atmHeight->blockSignals(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ui.dateEdit->setDisplayFormat(prefs.date_format);
 | 
						ui.dateEdit->setDisplayFormat(QString::fromStdString(prefs.date_format));
 | 
				
			||||||
	ui.startTime->setDisplayFormat(prefs.time_format);
 | 
						ui.startTime->setDisplayFormat(QString::fromStdString(prefs.time_format));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DivePlannerWidget::atmPressureChanged(const int pressure)
 | 
					void DivePlannerWidget::atmPressureChanged(const int pressure)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -283,13 +283,13 @@ void FilterConstraintWidget::update()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// The user might have changed the date and/or time format. Let's update the widgets.
 | 
						// The user might have changed the date and/or time format. Let's update the widgets.
 | 
				
			||||||
	if (dateFrom)
 | 
						if (dateFrom)
 | 
				
			||||||
		dateFrom->setDisplayFormat(prefs.date_format);
 | 
							dateFrom->setDisplayFormat(QString::fromStdString(prefs.date_format));
 | 
				
			||||||
	if (dateTo)
 | 
						if (dateTo)
 | 
				
			||||||
		dateTo->setDisplayFormat(prefs.date_format);
 | 
							dateTo->setDisplayFormat(QString::fromStdString(prefs.date_format));
 | 
				
			||||||
	if (timeFrom)
 | 
						if (timeFrom)
 | 
				
			||||||
		timeFrom->setDisplayFormat(prefs.time_format);
 | 
							timeFrom->setDisplayFormat(QString::fromStdString(prefs.time_format));
 | 
				
			||||||
	if (timeTo)
 | 
						if (timeTo)
 | 
				
			||||||
		timeTo->setDisplayFormat(prefs.time_format);
 | 
							timeTo->setDisplayFormat(QString::fromStdString(prefs.time_format));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QModelIndex idx = model->index(row, 0);
 | 
						QModelIndex idx = model->index(row, 0);
 | 
				
			||||||
	setIndex(negate.get(), idx, FilterConstraintModel::NEGATE_INDEX_ROLE);
 | 
						setIndex(negate.get(), idx, FilterConstraintModel::NEGATE_INDEX_ROLE);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -272,7 +272,7 @@ void LocationInformationWidget::initFields(dive_site *ds)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void LocationInformationWidget::on_GPSbutton_clicked()
 | 
					void LocationInformationWidget::on_GPSbutton_clicked()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QFileInfo finfo(system_default_directory());
 | 
						QFileInfo finfo(QString::fromStdString(system_default_directory()));
 | 
				
			||||||
	QString fileName = QFileDialog::getOpenFileName(this,
 | 
						QString fileName = QFileDialog::getOpenFileName(this,
 | 
				
			||||||
							tr("Select GPS file to open"),
 | 
												tr("Select GPS file to open"),
 | 
				
			||||||
							finfo.absolutePath(),
 | 
												finfo.absolutePath(),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -549,8 +549,8 @@ void MainWindow::updateLastUsedDir(const QString &dir)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static QString get_current_filename()
 | 
					static QString get_current_filename()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return existing_filename.empty() ? QString(prefs.default_filename)
 | 
						return QString::fromStdString(existing_filename.empty() ? prefs.default_filename
 | 
				
			||||||
					 : QString::fromStdString(existing_filename);
 | 
													: existing_filename);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
void MainWindow::on_actionPrint_triggered()
 | 
					void MainWindow::on_actionPrint_triggered()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -1100,7 +1100,7 @@ void MainWindow::loadRecentFiles()
 | 
				
			||||||
		QString file = s.value(key).toString();
 | 
							QString file = s.value(key).toString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// never add our cloud URL to the recent files
 | 
							// never add our cloud URL to the recent files
 | 
				
			||||||
		if (file.startsWith(prefs.cloud_base_url))
 | 
							if (file.startsWith(QString::fromStdString(prefs.cloud_base_url)))
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		// but allow local git repos
 | 
							// but allow local git repos
 | 
				
			||||||
		QRegularExpression gitrepo("(.*)\\[[^]]+]");
 | 
							QRegularExpression gitrepo("(.*)\\[[^]]+]");
 | 
				
			||||||
| 
						 | 
					@ -1138,7 +1138,7 @@ void MainWindow::updateRecentFilesMenu()
 | 
				
			||||||
void MainWindow::addRecentFile(const QString &file, bool update)
 | 
					void MainWindow::addRecentFile(const QString &file, bool update)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// never add Subsurface cloud file to the recent files - it has its own menu entry
 | 
						// never add Subsurface cloud file to the recent files - it has its own menu entry
 | 
				
			||||||
	if (file.startsWith(prefs.cloud_base_url))
 | 
						if (file.startsWith(QString::fromStdString(prefs.cloud_base_url)))
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	QString localFile = QDir::toNativeSeparators(file);
 | 
						QString localFile = QDir::toNativeSeparators(file);
 | 
				
			||||||
	int index = recentFiles.indexOf(localFile);
 | 
						int index = recentFiles.indexOf(localFile);
 | 
				
			||||||
| 
						 | 
					@ -1201,7 +1201,7 @@ int MainWindow::file_save_as()
 | 
				
			||||||
	selection_dialog.setFileMode(QFileDialog::AnyFile);
 | 
						selection_dialog.setFileMode(QFileDialog::AnyFile);
 | 
				
			||||||
	selection_dialog.setDefaultSuffix("");
 | 
						selection_dialog.setDefaultSuffix("");
 | 
				
			||||||
	if (default_filename.empty()) {
 | 
						if (default_filename.empty()) {
 | 
				
			||||||
		QFileInfo defaultFile(system_default_filename());
 | 
							QFileInfo defaultFile(QString::fromStdString(system_default_filename()));
 | 
				
			||||||
		selection_dialog.setDirectory(qPrintable(defaultFile.absolutePath()));
 | 
							selection_dialog.setDirectory(qPrintable(defaultFile.absolutePath()));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	/* if the exit/cancel button is pressed return */
 | 
						/* if the exit/cancel button is pressed return */
 | 
				
			||||||
| 
						 | 
					@ -1231,7 +1231,6 @@ int MainWindow::file_save_as()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int MainWindow::file_save()
 | 
					int MainWindow::file_save()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const char *current_default;
 | 
					 | 
				
			||||||
	bool is_cloud = false;
 | 
						bool is_cloud = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (existing_filename.empty())
 | 
						if (existing_filename.empty())
 | 
				
			||||||
| 
						 | 
					@ -1241,11 +1240,11 @@ int MainWindow::file_save()
 | 
				
			||||||
	if (is_cloud && !saveToCloudOK())
 | 
						if (is_cloud && !saveToCloudOK())
 | 
				
			||||||
		return -1;
 | 
							return -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	current_default = prefs.default_filename;
 | 
						const std::string ¤t_default = prefs.default_filename;
 | 
				
			||||||
	if (existing_filename == current_default) {
 | 
						if (existing_filename == current_default) {
 | 
				
			||||||
		/* if we are using the default filename the directory
 | 
							/* if we are using the default filename the directory
 | 
				
			||||||
		 * that we are creating the file in may not exist */
 | 
							 * that we are creating the file in may not exist */
 | 
				
			||||||
		QDir current_def_dir = QFileInfo(current_default).absoluteDir();
 | 
							QDir current_def_dir = QFileInfo(QString::fromStdString(current_default)).absoluteDir();
 | 
				
			||||||
		if (!current_def_dir.exists())
 | 
							if (!current_def_dir.exists())
 | 
				
			||||||
			current_def_dir.mkpath(current_def_dir.absolutePath());
 | 
								current_def_dir.mkpath(current_def_dir.absolutePath());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,8 +30,8 @@ void PreferencesCloud::on_resetPassword_clicked()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void PreferencesCloud::refreshSettings()
 | 
					void PreferencesCloud::refreshSettings()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	ui->cloud_storage_email->setText(prefs.cloud_storage_email);
 | 
						ui->cloud_storage_email->setText(QString::fromStdString(prefs.cloud_storage_email));
 | 
				
			||||||
	ui->cloud_storage_password->setText(prefs.cloud_storage_password);
 | 
						ui->cloud_storage_password->setText(QString::fromStdString(prefs.cloud_storage_password));
 | 
				
			||||||
	ui->save_password_local->setChecked(prefs.save_password_local);
 | 
						ui->save_password_local->setChecked(prefs.save_password_local);
 | 
				
			||||||
	updateCloudAuthenticationState();
 | 
						updateCloudAuthenticationState();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -57,19 +57,19 @@ void PreferencesCloud::syncSettings()
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if (!reg.match(email).hasMatch() || (!newpassword.isEmpty() && !reg.match(newpassword).hasMatch())) {
 | 
								if (!reg.match(email).hasMatch() || (!newpassword.isEmpty() && !reg.match(newpassword).hasMatch())) {
 | 
				
			||||||
				QMessageBox::warning(this, tr("Warning"), emailpasswordformatwarning);
 | 
									QMessageBox::warning(this, tr("Warning"), emailpasswordformatwarning);
 | 
				
			||||||
				ui->cloud_storage_new_passwd->setText("");
 | 
									ui->cloud_storage_new_passwd->setText(QString());
 | 
				
			||||||
				return;
 | 
									return;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
 | 
								CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
 | 
				
			||||||
			connect(cloudAuth, &CloudStorageAuthenticate::finishedAuthenticate, this, &PreferencesCloud::updateCloudAuthenticationState);
 | 
								connect(cloudAuth, &CloudStorageAuthenticate::finishedAuthenticate, this, &PreferencesCloud::updateCloudAuthenticationState);
 | 
				
			||||||
			connect(cloudAuth, &CloudStorageAuthenticate::passwordChangeSuccessful, this, &PreferencesCloud::passwordUpdateSuccessful);
 | 
								connect(cloudAuth, &CloudStorageAuthenticate::passwordChangeSuccessful, this, &PreferencesCloud::passwordUpdateSuccessful);
 | 
				
			||||||
			cloudAuth->backend(email, password, "", newpassword);
 | 
								cloudAuth->backend(email, password, "", newpassword);
 | 
				
			||||||
			ui->cloud_storage_new_passwd->setText("");
 | 
								ui->cloud_storage_new_passwd->setText(QString());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else if (prefs.cloud_verification_status == qPrefCloudStorage::CS_UNKNOWN ||
 | 
						} else if (prefs.cloud_verification_status == qPrefCloudStorage::CS_UNKNOWN ||
 | 
				
			||||||
		   prefs.cloud_verification_status == qPrefCloudStorage::CS_INCORRECT_USER_PASSWD ||
 | 
							   prefs.cloud_verification_status == qPrefCloudStorage::CS_INCORRECT_USER_PASSWD ||
 | 
				
			||||||
		   email != prefs.cloud_storage_email ||
 | 
							   email.toStdString() != prefs.cloud_storage_email ||
 | 
				
			||||||
		   password != prefs.cloud_storage_password) {
 | 
							   password.toStdString() != prefs.cloud_storage_password) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// different credentials - reset verification status
 | 
							// different credentials - reset verification status
 | 
				
			||||||
		int oldVerificationStatus = cloud->cloud_verification_status();
 | 
							int oldVerificationStatus = cloud->cloud_verification_status();
 | 
				
			||||||
| 
						 | 
					@ -104,7 +104,7 @@ void PreferencesCloud::syncSettings()
 | 
				
			||||||
	cloud->set_save_password_local(ui->save_password_local->isChecked());
 | 
						cloud->set_save_password_local(ui->save_password_local->isChecked());
 | 
				
			||||||
	cloud->set_cloud_storage_password(password);
 | 
						cloud->set_cloud_storage_password(password);
 | 
				
			||||||
	cloud->set_cloud_verification_status(prefs.cloud_verification_status);
 | 
						cloud->set_cloud_verification_status(prefs.cloud_verification_status);
 | 
				
			||||||
	cloud->set_cloud_base_url(prefs.cloud_base_url);
 | 
						cloud->set_cloud_base_url(QString::fromStdString(prefs.cloud_base_url));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void PreferencesCloud::updateCloudAuthenticationState()
 | 
					void PreferencesCloud::updateCloudAuthenticationState()
 | 
				
			||||||
| 
						 | 
					@ -131,5 +131,5 @@ void PreferencesCloud::updateCloudAuthenticationState()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void PreferencesCloud::passwordUpdateSuccessful()
 | 
					void PreferencesCloud::passwordUpdateSuccessful()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	ui->cloud_storage_password->setText(prefs.cloud_storage_password);
 | 
						ui->cloud_storage_password->setText(QString::fromStdString(prefs.cloud_storage_password));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,11 +54,11 @@ void PreferencesLanguage::refreshSettings()
 | 
				
			||||||
	ui->languageSystemDefault->setChecked(prefs.locale.use_system_language);
 | 
						ui->languageSystemDefault->setChecked(prefs.locale.use_system_language);
 | 
				
			||||||
	ui->timeFormatSystemDefault->setChecked(!prefs.time_format_override);
 | 
						ui->timeFormatSystemDefault->setChecked(!prefs.time_format_override);
 | 
				
			||||||
	ui->dateFormatSystemDefault->setChecked(!prefs.date_format_override);
 | 
						ui->dateFormatSystemDefault->setChecked(!prefs.date_format_override);
 | 
				
			||||||
	ui->timeFormatEntry->setCurrentText(prefs.time_format);
 | 
						ui->timeFormatEntry->setCurrentText(QString::fromStdString(prefs.time_format));
 | 
				
			||||||
	ui->dateFormatEntry->setCurrentText(prefs.date_format);
 | 
						ui->dateFormatEntry->setCurrentText(QString::fromStdString(prefs.date_format));
 | 
				
			||||||
	ui->shortDateFormatEntry->setText(prefs.date_format_short);
 | 
						ui->shortDateFormatEntry->setText(QString::fromStdString(prefs.date_format_short));
 | 
				
			||||||
	QAbstractItemModel *m = ui->languageDropdown->model();
 | 
						QAbstractItemModel *m = ui->languageDropdown->model();
 | 
				
			||||||
	QModelIndexList languages = m->match(m->index(0, 0), Qt::UserRole, QString(prefs.locale.lang_locale).replace("-", "_"));
 | 
						QModelIndexList languages = m->match(m->index(0, 0), Qt::UserRole, QString::fromStdString(prefs.locale.lang_locale).replace("-", "_"));
 | 
				
			||||||
	if (languages.count())
 | 
						if (languages.count())
 | 
				
			||||||
		ui->languageDropdown->setCurrentIndex(languages.first().row());
 | 
							ui->languageDropdown->setCurrentIndex(languages.first().row());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -69,9 +69,9 @@ void PreferencesLanguage::syncSettings()
 | 
				
			||||||
	QString currentText = ui->languageDropdown->currentText();
 | 
						QString currentText = ui->languageDropdown->currentText();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (useSystemLang != ui->languageSystemDefault->isChecked() ||
 | 
						if (useSystemLang != ui->languageSystemDefault->isChecked() ||
 | 
				
			||||||
		(!useSystemLang && currentText != prefs.locale.language)) {
 | 
							(!useSystemLang && currentText.toStdString() != prefs.locale.language)) {
 | 
				
			||||||
		// remove the googlemaps cache folder on language change
 | 
							// remove the googlemaps cache folder on language change
 | 
				
			||||||
		QDir googlecachedir(QString(system_default_directory()).append("/googlemaps"));
 | 
							QDir googlecachedir(QString::fromStdString(system_default_directory() + "/googlemaps"));
 | 
				
			||||||
		googlecachedir.removeRecursively();
 | 
							googlecachedir.removeRecursively();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		QMessageBox::warning(this, tr("Restart required"),
 | 
							QMessageBox::warning(this, tr("Restart required"),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,7 +24,7 @@ PreferencesLog::~PreferencesLog()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void PreferencesLog::on_chooseFile_clicked()
 | 
					void PreferencesLog::on_chooseFile_clicked()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QFileInfo fi(system_default_filename());
 | 
						QFileInfo fi(QString::fromStdString(system_default_filename()));
 | 
				
			||||||
	QString choosenFileName = QFileDialog::getOpenFileName(this, tr("Open default log file"), fi.absolutePath(), tr("Subsurface files") + " (*.ssrf *.xml)");
 | 
						QString choosenFileName = QFileDialog::getOpenFileName(this, tr("Open default log file"), fi.absolutePath(), tr("Subsurface files") + " (*.ssrf *.xml)");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!choosenFileName.isEmpty())
 | 
						if (!choosenFileName.isEmpty())
 | 
				
			||||||
| 
						 | 
					@ -34,7 +34,7 @@ void PreferencesLog::on_chooseFile_clicked()
 | 
				
			||||||
void PreferencesLog::on_btnUseDefaultFile_toggled(bool toggle)
 | 
					void PreferencesLog::on_btnUseDefaultFile_toggled(bool toggle)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (toggle) {
 | 
						if (toggle) {
 | 
				
			||||||
		ui->defaultfilename->setText(system_default_filename());
 | 
							ui->defaultfilename->setText(QString::fromStdString(system_default_filename()));
 | 
				
			||||||
		ui->defaultfilename->setEnabled(false);
 | 
							ui->defaultfilename->setEnabled(false);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		ui->defaultfilename->setEnabled(true);
 | 
							ui->defaultfilename->setEnabled(true);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,7 +41,7 @@ void PreferencesMedia::checkFfmpegExecutable()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void PreferencesMedia::on_ffmpegFile_clicked()
 | 
					void PreferencesMedia::on_ffmpegFile_clicked()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QFileInfo fi(system_default_filename());
 | 
						QFileInfo fi(QString::fromStdString(system_default_filename()));
 | 
				
			||||||
	QString ffmpegFileName = QFileDialog::getOpenFileName(this, tr("Select ffmpeg executable"));
 | 
						QString ffmpegFileName = QFileDialog::getOpenFileName(this, tr("Select ffmpeg executable"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!ffmpegFileName.isEmpty()) {
 | 
						if (!ffmpegFileName.isEmpty()) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,11 +27,11 @@ PreferencesNetwork::~PreferencesNetwork()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void PreferencesNetwork::refreshSettings()
 | 
					void PreferencesNetwork::refreshSettings()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	ui->proxyHost->setText(prefs.proxy_host);
 | 
						ui->proxyHost->setText(QString::fromStdString(prefs.proxy_host));
 | 
				
			||||||
	ui->proxyPort->setValue(prefs.proxy_port);
 | 
						ui->proxyPort->setValue(prefs.proxy_port);
 | 
				
			||||||
	ui->proxyAuthRequired->setChecked(prefs.proxy_auth);
 | 
						ui->proxyAuthRequired->setChecked(prefs.proxy_auth);
 | 
				
			||||||
	ui->proxyUsername->setText(prefs.proxy_user);
 | 
						ui->proxyUsername->setText(QString::fromStdString(prefs.proxy_user));
 | 
				
			||||||
	ui->proxyPassword->setText(prefs.proxy_pass);
 | 
						ui->proxyPassword->setText(QString::fromStdString(prefs.proxy_pass));
 | 
				
			||||||
	ui->proxyType->setCurrentIndex(ui->proxyType->findData(prefs.proxy_type));
 | 
						ui->proxyType->setCurrentIndex(ui->proxyType->findData(prefs.proxy_type));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,9 +49,8 @@ void PreferencesNetwork::syncSettings()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void PreferencesNetwork::proxyType_changed(int idx)
 | 
					void PreferencesNetwork::proxyType_changed(int idx)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (idx == -1) {
 | 
						if (idx < 0)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int proxyType = ui->proxyType->itemData(idx).toInt();
 | 
						int proxyType = ui->proxyType->itemData(idx).toInt();
 | 
				
			||||||
	bool hpEnabled = (proxyType == QNetworkProxy::Socks5Proxy || proxyType == QNetworkProxy::HttpProxy);
 | 
						bool hpEnabled = (proxyType == QNetworkProxy::Socks5Proxy || proxyType == QNetworkProxy::HttpProxy);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,12 +37,6 @@ static bool abstractpreferenceswidget_lessthan(const AbstractPreferencesWidget *
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PreferencesDialog::PreferencesDialog()
 | 
					PreferencesDialog::PreferencesDialog()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	//FIXME: This looks wrong.
 | 
					 | 
				
			||||||
	//QSettings s;
 | 
					 | 
				
			||||||
	//s.beginGroup("GeneralSettings");
 | 
					 | 
				
			||||||
	//s.setValue("default_directory", system_default_directory());
 | 
					 | 
				
			||||||
	//s.endGroup();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	setWindowIcon(QIcon(":subsurface-icon"));
 | 
						setWindowIcon(QIcon(":subsurface-icon"));
 | 
				
			||||||
	setWindowTitle(tr("Preferences"));
 | 
						setWindowTitle(tr("Preferences"));
 | 
				
			||||||
	pagesList = new QListWidget();
 | 
						pagesList = new QListWidget();
 | 
				
			||||||
| 
						 | 
					@ -130,7 +124,7 @@ void PreferencesDialog::cancelRequested()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void PreferencesDialog::defaultsRequested()
 | 
					void PreferencesDialog::defaultsRequested()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	copy_prefs(&default_prefs, &prefs);
 | 
						prefs = default_prefs;
 | 
				
			||||||
	refreshPages();
 | 
						refreshPages();
 | 
				
			||||||
	emit diveListNotifier.settingsChanged();
 | 
						emit diveListNotifier.settingsChanged();
 | 
				
			||||||
	accept();
 | 
						accept();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -85,8 +85,8 @@ TabDiveNotes::TabDiveNotes(MainTab *parent) : TabBase(parent),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TabDiveNotes::updateDateTimeFields()
 | 
					void TabDiveNotes::updateDateTimeFields()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	ui.dateEdit->setDisplayFormat(prefs.date_format);
 | 
						ui.dateEdit->setDisplayFormat(QString::fromStdString(prefs.date_format));
 | 
				
			||||||
	ui.timeEdit->setDisplayFormat(prefs.time_format);
 | 
						ui.timeEdit->setDisplayFormat(QString::fromStdString(prefs.time_format));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TabDiveNotes::closeWarning()
 | 
					void TabDiveNotes::closeWarning()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,7 +23,7 @@ int main(int argc, char **argv)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QApplication *application = new QApplication(argc, argv);
 | 
						QApplication *application = new QApplication(argc, argv);
 | 
				
			||||||
	git_libgit2_init();
 | 
						git_libgit2_init();
 | 
				
			||||||
	copy_prefs(&default_prefs, &prefs);
 | 
						prefs = default_prefs;
 | 
				
			||||||
	init_qt_late();
 | 
						init_qt_late();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QCommandLineParser parser;
 | 
						QCommandLineParser parser;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -250,7 +250,7 @@ bool MapWidgetHelper::editMode() const
 | 
				
			||||||
QString MapWidgetHelper::pluginObject()
 | 
					QString MapWidgetHelper::pluginObject()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QString lang = getUiLanguage().replace('_', '-');
 | 
						QString lang = getUiLanguage().replace('_', '-');
 | 
				
			||||||
	QString cacheFolder = QString(system_default_directory()).append("/googlemaps").replace("\\", "/");
 | 
						QString cacheFolder = QString::fromStdString(system_default_directory() + "/googlemaps").replace("\\", "/");
 | 
				
			||||||
	return QStringLiteral("import QtQuick 2.0;"
 | 
						return QStringLiteral("import QtQuick 2.0;"
 | 
				
			||||||
			      "import QtLocation 5.3;"
 | 
								      "import QtLocation 5.3;"
 | 
				
			||||||
			      "Plugin {"
 | 
								      "Plugin {"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -279,7 +279,7 @@ QMLManager::QMLManager() :
 | 
				
			||||||
	git_libgit2_version(&git_maj, &git_min, &git_rev);
 | 
						git_libgit2_version(&git_maj, &git_min, &git_rev);
 | 
				
			||||||
	appendTextToLog(QStringLiteral("built with libgit2 %1.%2.%3").arg(git_maj).arg(git_min).arg(git_rev));
 | 
						appendTextToLog(QStringLiteral("built with libgit2 %1.%2.%3").arg(git_maj).arg(git_min).arg(git_rev));
 | 
				
			||||||
	appendTextToLog(QStringLiteral("Running on %1").arg(QSysInfo::prettyProductName()));
 | 
						appendTextToLog(QStringLiteral("Running on %1").arg(QSysInfo::prettyProductName()));
 | 
				
			||||||
	appendTextToLog(QStringLiteral("Locale Languages offered %1, picked %2").arg(QLocale().uiLanguages().join(", ")).arg(prefs.locale.lang_locale));
 | 
						appendTextToLog(QStringLiteral("Locale Languages offered %1, picked %2").arg(QLocale().uiLanguages().join(", ")).arg(prefs.locale.lang_locale.c_str()));
 | 
				
			||||||
#if defined(Q_OS_ANDROID)
 | 
					#if defined(Q_OS_ANDROID)
 | 
				
			||||||
	extern QString getAndroidHWInfo();
 | 
						extern QString getAndroidHWInfo();
 | 
				
			||||||
	appendTextToLog(getAndroidHWInfo());
 | 
						appendTextToLog(getAndroidHWInfo());
 | 
				
			||||||
| 
						 | 
					@ -471,7 +471,7 @@ void QMLManager::updateAllGlobalLists()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static QString nocloud_localstorage()
 | 
					static QString nocloud_localstorage()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return QString(system_default_directory()) + "/cloudstorage/localrepo[master]";
 | 
						return QString::fromStdString(system_default_directory() + "/cloudstorage/localrepo[master]");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void QMLManager::mergeLocalRepo()
 | 
					void QMLManager::mergeLocalRepo()
 | 
				
			||||||
| 
						 | 
					@ -650,11 +650,11 @@ void QMLManager::saveCloudCredentials(const QString &newEmail, const QString &ne
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (!same_string(prefs.cloud_storage_email, qPrintable(email))) {
 | 
						if (prefs.cloud_storage_email != email.toStdString()) {
 | 
				
			||||||
		cloudCredentialsChanged = true;
 | 
							cloudCredentialsChanged = true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!same_string(prefs.cloud_storage_password, qPrintable(newPassword))) {
 | 
						if (prefs.cloud_storage_password != newPassword.toStdString()) {
 | 
				
			||||||
		cloudCredentialsChanged = true;
 | 
							cloudCredentialsChanged = true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -743,8 +743,8 @@ bool QMLManager::verifyCredentials(QString email, QString password, QString pin)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void QMLManager::deleteAccount()
 | 
					void QMLManager::deleteAccount()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QString email(prefs.cloud_storage_email);
 | 
						QString email = QString::fromStdString(prefs.cloud_storage_email);
 | 
				
			||||||
	QString passwd(prefs.cloud_storage_password);
 | 
						QString passwd = QString::fromStdString(prefs.cloud_storage_password);
 | 
				
			||||||
	if (email.isEmpty() || passwd.isEmpty())
 | 
						if (email.isEmpty() || passwd.isEmpty())
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -867,10 +867,8 @@ void QMLManager::revertToNoCloudIfNeeded()
 | 
				
			||||||
			appendTextToLog(QStringLiteral("taking things back offline since sync with cloud failed"));
 | 
								appendTextToLog(QStringLiteral("taking things back offline since sync with cloud failed"));
 | 
				
			||||||
			git_local_only = false;
 | 
								git_local_only = false;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		free((void *)prefs.cloud_storage_email);
 | 
							prefs.cloud_storage_email.clear();
 | 
				
			||||||
		prefs.cloud_storage_email = NULL;
 | 
							prefs.cloud_storage_password.clear();
 | 
				
			||||||
		free((void *)prefs.cloud_storage_password);
 | 
					 | 
				
			||||||
		prefs.cloud_storage_password = NULL;
 | 
					 | 
				
			||||||
		qPrefCloudStorage::set_cloud_storage_email("");
 | 
							qPrefCloudStorage::set_cloud_storage_email("");
 | 
				
			||||||
		qPrefCloudStorage::set_cloud_storage_password("");
 | 
							qPrefCloudStorage::set_cloud_storage_password("");
 | 
				
			||||||
		rememberOldStatus();
 | 
							rememberOldStatus();
 | 
				
			||||||
| 
						 | 
					@ -938,7 +936,7 @@ bool QMLManager::checkDate(struct dive *d, QString date)
 | 
				
			||||||
		// what a pain - Qt will not parse dates if the day of the week is incorrect
 | 
							// what a pain - Qt will not parse dates if the day of the week is incorrect
 | 
				
			||||||
		// so if the user changed the date but didn't update the day of the week (most likely behavior, actually),
 | 
							// so if the user changed the date but didn't update the day of the week (most likely behavior, actually),
 | 
				
			||||||
		// we need to make sure we don't try to parse that
 | 
							// we need to make sure we don't try to parse that
 | 
				
			||||||
		QString format(QString(prefs.date_format_short) + QChar(' ') + prefs.time_format);
 | 
							QString format = QString::fromStdString(prefs.date_format_short + ' ' + prefs.time_format);
 | 
				
			||||||
		if (format.contains(QLatin1String("ddd")) || format.contains(QLatin1String("dddd"))) {
 | 
							if (format.contains(QLatin1String("ddd")) || format.contains(QLatin1String("dddd"))) {
 | 
				
			||||||
			QString dateFormatToDrop = format.contains(QLatin1String("ddd")) ? QStringLiteral("ddd") : QStringLiteral("dddd");
 | 
								QString dateFormatToDrop = format.contains(QLatin1String("ddd")) ? QStringLiteral("ddd") : QStringLiteral("dddd");
 | 
				
			||||||
			QDateTime ts;
 | 
								QDateTime ts;
 | 
				
			||||||
| 
						 | 
					@ -1757,14 +1755,14 @@ void QMLManager::setVerboseEnabled(bool verboseMode)
 | 
				
			||||||
void QMLManager::syncLoadFromCloud()
 | 
					void QMLManager::syncLoadFromCloud()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QSettings s;
 | 
						QSettings s;
 | 
				
			||||||
	QString cloudMarker = QLatin1String("loadFromCloud") + QString(prefs.cloud_storage_email);
 | 
						QString cloudMarker = QLatin1String("loadFromCloud") + QString::fromStdString(prefs.cloud_storage_email);
 | 
				
			||||||
	m_loadFromCloud = s.contains(cloudMarker) && s.value(cloudMarker).toBool();
 | 
						m_loadFromCloud = s.contains(cloudMarker) && s.value(cloudMarker).toBool();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void QMLManager::setLoadFromCloud(bool done)
 | 
					void QMLManager::setLoadFromCloud(bool done)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QSettings s;
 | 
						QSettings s;
 | 
				
			||||||
	QString cloudMarker = QLatin1String("loadFromCloud") + QString(prefs.cloud_storage_email);
 | 
						QString cloudMarker = QLatin1String("loadFromCloud") + QString::fromStdString(prefs.cloud_storage_email);
 | 
				
			||||||
	s.setValue(cloudMarker, done);
 | 
						s.setValue(cloudMarker, done);
 | 
				
			||||||
	m_loadFromCloud = done;
 | 
						m_loadFromCloud = done;
 | 
				
			||||||
	emit loadFromCloudChanged();
 | 
						emit loadFromCloudChanged();
 | 
				
			||||||
| 
						 | 
					@ -2247,7 +2245,7 @@ void QMLManager::shareViaEmail(export_types type, bool anonymize)
 | 
				
			||||||
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
 | 
					#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
 | 
				
			||||||
	QString fileName = appLogFileName;
 | 
						QString fileName = appLogFileName;
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
	QString fileName = system_default_directory();
 | 
						QString fileName = QString::fromStdString(system_default_directory());
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	QString body;
 | 
						QString body;
 | 
				
			||||||
	switch (type) {
 | 
						switch (type) {
 | 
				
			||||||
| 
						 | 
					@ -2293,7 +2291,7 @@ void QMLManager::shareViaEmail(export_types type, bool anonymize)
 | 
				
			||||||
#elif defined(Q_OS_IOS)
 | 
					#elif defined(Q_OS_IOS)
 | 
				
			||||||
	// call into objC++ code to share on iOS
 | 
						// call into objC++ code to share on iOS
 | 
				
			||||||
	QString subject("Subsurface export");
 | 
						QString subject("Subsurface export");
 | 
				
			||||||
	QString emptyString("");
 | 
						QString emptyString;
 | 
				
			||||||
	iosshare.shareViaEmail(subject, emptyString, body, fileName, emptyString);
 | 
						iosshare.shareViaEmail(subject, emptyString, body, fileName, emptyString);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
	appendTextToLog("on a mobile platform this would send" + fileName + "via email with body" + body);
 | 
						appendTextToLog("on a mobile platform this would send" + fileName + "via email with body" + body);
 | 
				
			||||||
| 
						 | 
					@ -2355,7 +2353,7 @@ void QMLManager::setDiveListProcessing(bool value)
 | 
				
			||||||
void QMLManager::importCacheRepo(QString repo)
 | 
					void QMLManager::importCacheRepo(QString repo)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct divelog log;
 | 
						struct divelog log;
 | 
				
			||||||
	QString repoPath = QString("%1/cloudstorage/%2").arg(system_default_directory()).arg(repo);
 | 
						QString repoPath = QString::fromStdString(system_default_directory() + "/cloudstorage/") + repo;
 | 
				
			||||||
	appendTextToLog(QString("importing %1").arg(repoPath));
 | 
						appendTextToLog(QString("importing %1").arg(repoPath));
 | 
				
			||||||
	parse_file(qPrintable(repoPath), &log);
 | 
						parse_file(qPrintable(repoPath), &log);
 | 
				
			||||||
	add_imported_dives(log, IMPORT_MERGE_ALL_TRIPS);
 | 
						add_imported_dives(log, IMPORT_MERGE_ALL_TRIPS);
 | 
				
			||||||
| 
						 | 
					@ -2364,11 +2362,11 @@ void QMLManager::importCacheRepo(QString repo)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QStringList QMLManager::cloudCacheList() const
 | 
					QStringList QMLManager::cloudCacheList() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QDir localCacheDir(QString("%1/cloudstorage/").arg(system_default_directory()));
 | 
						QDir localCacheDir(QString("%1/cloudstorage/").arg(system_default_directory().c_str()));
 | 
				
			||||||
	QStringList dirs = localCacheDir.entryList();
 | 
						QStringList dirs = localCacheDir.entryList();
 | 
				
			||||||
	QStringList result;
 | 
						QStringList result;
 | 
				
			||||||
	for (const QString &dir: dirs) {
 | 
						for (const QString &dir: dirs) {
 | 
				
			||||||
		QString originsDir = QString("%1/cloudstorage/%2/.git/refs/remotes/origin/").arg(system_default_directory()).arg(dir);
 | 
							QString originsDir = QString::fromStdString(system_default_directory() + "/cloudstorage/%1/.git/refs/remotes/origin/").arg(dir);
 | 
				
			||||||
		QDir remote(originsDir);
 | 
							QDir remote(originsDir);
 | 
				
			||||||
		if (dir == "localrepo") {
 | 
							if (dir == "localrepo") {
 | 
				
			||||||
			result << QString("localrepo[master]");
 | 
								result << QString("localrepo[master]");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -251,7 +251,7 @@ static void addDurationToThumbnail(QImage &img, duration_t duration)
 | 
				
			||||||
		QStringLiteral("%1:%2").arg(seconds / 60, 2, 10, QChar('0'))
 | 
							QStringLiteral("%1:%2").arg(seconds / 60, 2, 10, QChar('0'))
 | 
				
			||||||
				       .arg(seconds % 60, 2, 10, QChar('0'));
 | 
									       .arg(seconds % 60, 2, 10, QChar('0'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QFont font(system_divelist_default_font, 30);
 | 
						QFont font(system_divelist_default_font.c_str(), 30);
 | 
				
			||||||
	QFontMetrics metrics(font);
 | 
						QFontMetrics metrics(font);
 | 
				
			||||||
	QSize size = metrics.size(Qt::TextSingleLine, s);
 | 
						QSize size = metrics.size(Qt::TextSingleLine, s);
 | 
				
			||||||
	QSize imgSize = img.size();
 | 
						QSize imgSize = img.size();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -572,7 +572,7 @@ static void inc(std::array<int, 3> &ymd)
 | 
				
			||||||
// the separator character. Returns a (day_first, separator) pair.
 | 
					// the separator character. Returns a (day_first, separator) pair.
 | 
				
			||||||
static std::pair<bool, char> day_format()
 | 
					static std::pair<bool, char> day_format()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const char *fmt = prefs.date_format;
 | 
						const char *fmt = prefs.date_format.c_str();
 | 
				
			||||||
	const char *d, *m, *sep;
 | 
						const char *d, *m, *sep;
 | 
				
			||||||
	for (d = fmt; *d && *d != 'd' && *d != 'D'; ++d)
 | 
						for (d = fmt; *d && *d != 'd' && *d != 'D'; ++d)
 | 
				
			||||||
		;
 | 
							;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,8 +45,7 @@ int main(int argc, char **argv)
 | 
				
			||||||
	std::vector<std::string> importedFiles;
 | 
						std::vector<std::string> importedFiles;
 | 
				
			||||||
	QStringList arguments = QCoreApplication::arguments();
 | 
						QStringList arguments = QCoreApplication::arguments();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const char *default_directory = system_default_directory();
 | 
						subsurface_mkdir(system_default_directory().c_str());
 | 
				
			||||||
	subsurface_mkdir(default_directory);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (int i = 1; i < arguments.length(); i++) {
 | 
						for (int i = 1; i < arguments.length(); i++) {
 | 
				
			||||||
		std::string a = arguments[i].toStdString();
 | 
							std::string a = arguments[i].toStdString();
 | 
				
			||||||
| 
						 | 
					@ -75,7 +74,7 @@ int main(int argc, char **argv)
 | 
				
			||||||
	git_libgit2_init();
 | 
						git_libgit2_init();
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	setup_system_prefs();
 | 
						setup_system_prefs();
 | 
				
			||||||
	copy_prefs(&default_prefs, &prefs);
 | 
						prefs = default_prefs;
 | 
				
			||||||
	CheckCloudConnection ccc;
 | 
						CheckCloudConnection ccc;
 | 
				
			||||||
	ccc.pickServer();
 | 
						ccc.pickServer();
 | 
				
			||||||
	fill_computer_list();
 | 
						fill_computer_list();
 | 
				
			||||||
| 
						 | 
					@ -85,8 +84,8 @@ int main(int argc, char **argv)
 | 
				
			||||||
	init_ui();
 | 
						init_ui();
 | 
				
			||||||
	if (no_filenames) {
 | 
						if (no_filenames) {
 | 
				
			||||||
		if (prefs.default_file_behavior == LOCAL_DEFAULT_FILE) {
 | 
							if (prefs.default_file_behavior == LOCAL_DEFAULT_FILE) {
 | 
				
			||||||
			if (!empty_string(prefs.default_filename))
 | 
								if (!prefs.default_filename.empty())
 | 
				
			||||||
				files.emplace_back(prefs.default_filename ? prefs.default_filename : "");
 | 
									files.push_back(prefs.default_filename);
 | 
				
			||||||
		} else if (prefs.default_file_behavior == CLOUD_DEFAULT_FILE) {
 | 
							} else if (prefs.default_file_behavior == CLOUD_DEFAULT_FILE) {
 | 
				
			||||||
			auto cloudURL = getCloudURL();
 | 
								auto cloudURL = getCloudURL();
 | 
				
			||||||
			if (cloudURL)
 | 
								if (cloudURL)
 | 
				
			||||||
| 
						 | 
					@ -112,7 +111,6 @@ int main(int argc, char **argv)
 | 
				
			||||||
	// Sync struct preferences to disk
 | 
						// Sync struct preferences to disk
 | 
				
			||||||
	qPref::sync();
 | 
						qPref::sync();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	free_prefs();
 | 
					 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,7 +21,7 @@
 | 
				
			||||||
#include <git2.h>
 | 
					#include <git2.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void messageHandler(QtMsgType type, const QMessageLogContext &ctx, const QString &msg);
 | 
					static void messageHandler(QtMsgType type, const QMessageLogContext &ctx, const QString &msg);
 | 
				
			||||||
extern void cliDownloader(const char *vendor, const char *product, const char *device);
 | 
					extern void cliDownloader(const std::string &vendor, const std::string &product, const std::string &device);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(int argc, char **argv)
 | 
					int main(int argc, char **argv)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -45,8 +45,7 @@ int main(int argc, char **argv)
 | 
				
			||||||
	// set a default logfile name for libdivecomputer so we always get a logfile
 | 
						// set a default logfile name for libdivecomputer so we always get a logfile
 | 
				
			||||||
	logfile_name = "subsurface-downloader.log";
 | 
						logfile_name = "subsurface-downloader.log";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const char *default_directory = system_default_directory();
 | 
						subsurface_mkdir(system_default_directory().c_str());
 | 
				
			||||||
	subsurface_mkdir(default_directory);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (subsurface_user_is_root() && !force_root) {
 | 
						if (subsurface_user_is_root() && !force_root) {
 | 
				
			||||||
		printf("You are running Subsurface as root. This is not recommended.\n");
 | 
							printf("You are running Subsurface as root. This is not recommended.\n");
 | 
				
			||||||
| 
						 | 
					@ -55,7 +54,7 @@ int main(int argc, char **argv)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	git_libgit2_init();
 | 
						git_libgit2_init();
 | 
				
			||||||
	setup_system_prefs();
 | 
						setup_system_prefs();
 | 
				
			||||||
	copy_prefs(&default_prefs, &prefs);
 | 
						prefs = default_prefs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// now handle the arguments
 | 
						// now handle the arguments
 | 
				
			||||||
	fill_computer_list();
 | 
						fill_computer_list();
 | 
				
			||||||
| 
						 | 
					@ -79,8 +78,8 @@ int main(int argc, char **argv)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (no_filenames) {
 | 
						if (no_filenames) {
 | 
				
			||||||
		if (prefs.default_file_behavior == LOCAL_DEFAULT_FILE) {
 | 
							if (prefs.default_file_behavior == LOCAL_DEFAULT_FILE) {
 | 
				
			||||||
			if (!empty_string(prefs.default_filename))
 | 
								if (!prefs.default_filename.empty())
 | 
				
			||||||
				files.emplace_back(prefs.default_filename ? prefs.default_filename : "");
 | 
									files.emplace_back(prefs.default_filename.c_str());
 | 
				
			||||||
		} else if (prefs.default_file_behavior == CLOUD_DEFAULT_FILE) {
 | 
							} else if (prefs.default_file_behavior == CLOUD_DEFAULT_FILE) {
 | 
				
			||||||
			auto cloudURL = getCloudURL();
 | 
								auto cloudURL = getCloudURL();
 | 
				
			||||||
			if (cloudURL)
 | 
								if (cloudURL)
 | 
				
			||||||
| 
						 | 
					@ -96,9 +95,10 @@ int main(int argc, char **argv)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	print_files();
 | 
						print_files();
 | 
				
			||||||
	if (!quit) {
 | 
						if (!quit) {
 | 
				
			||||||
		if (!empty_string(prefs.dive_computer.vendor) && !empty_string(prefs.dive_computer.product) && !empty_string(prefs.dive_computer.device)) {
 | 
							if (!prefs.dive_computer.vendor.empty() && !prefs.dive_computer.product.empty() && !prefs.dive_computer.device.empty()) {
 | 
				
			||||||
			// download from that dive computer
 | 
								// download from that dive computer
 | 
				
			||||||
			printf("Downloading dives from %s %s (via %s)\n", prefs.dive_computer.vendor, prefs.dive_computer.product, prefs.dive_computer.device);
 | 
								printf("Downloading dives from %s %s (via %s)\n", prefs.dive_computer.vendor.c_str(),
 | 
				
			||||||
 | 
										prefs.dive_computer.product.c_str(), prefs.dive_computer.device.c_str());
 | 
				
			||||||
			cliDownloader(prefs.dive_computer.vendor, prefs.dive_computer.product, prefs.dive_computer.device);
 | 
								cliDownloader(prefs.dive_computer.vendor, prefs.dive_computer.product, prefs.dive_computer.device);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -114,7 +114,6 @@ int main(int argc, char **argv)
 | 
				
			||||||
	// Sync struct preferences to disk
 | 
						// Sync struct preferences to disk
 | 
				
			||||||
	qPref::sync();
 | 
						qPref::sync();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	free_prefs();
 | 
					 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -56,7 +56,7 @@ int main(int argc, char **argv)
 | 
				
			||||||
		default_prefs.units = SI_units;
 | 
							default_prefs.units = SI_units;
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		default_prefs.units = IMPERIAL_units;
 | 
							default_prefs.units = IMPERIAL_units;
 | 
				
			||||||
	copy_prefs(&default_prefs, &prefs);
 | 
						prefs = default_prefs;
 | 
				
			||||||
	CheckCloudConnection ccc;
 | 
						CheckCloudConnection ccc;
 | 
				
			||||||
	ccc.pickServer();
 | 
						ccc.pickServer();
 | 
				
			||||||
	fill_computer_list();
 | 
						fill_computer_list();
 | 
				
			||||||
| 
						 | 
					@ -98,7 +98,6 @@ int main(int argc, char **argv)
 | 
				
			||||||
	// Sync struct preferences to disk
 | 
						// Sync struct preferences to disk
 | 
				
			||||||
	qPref::sync();
 | 
						qPref::sync();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	free_prefs();
 | 
					 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,7 +14,7 @@ void TestAirPressure::initTestCase()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	/* we need to manually tell that the resource exists, because we are using it as library. */
 | 
						/* we need to manually tell that the resource exists, because we are using it as library. */
 | 
				
			||||||
	Q_INIT_RESOURCE(subsurface);
 | 
						Q_INIT_RESOURCE(subsurface);
 | 
				
			||||||
	prefs.cloud_base_url = strdup(default_prefs.cloud_base_url);
 | 
						prefs.cloud_base_url = default_prefs.cloud_base_url;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TestAirPressure::get_dives()
 | 
					void TestAirPressure::get_dives()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,7 +7,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TestDiveSiteDuplication::testReadV2()
 | 
					void TestDiveSiteDuplication::testReadV2()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	prefs.cloud_base_url = strdup(default_prefs.cloud_base_url);
 | 
						prefs.cloud_base_url = default_prefs.cloud_base_url;
 | 
				
			||||||
	QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/TwoTimesTwo.ssrf", &divelog), 0);
 | 
						QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/TwoTimesTwo.ssrf", &divelog), 0);
 | 
				
			||||||
	QCOMPARE(divelog.sites.size(), 2);
 | 
						QCOMPARE(divelog.sites.size(), 2);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -77,7 +77,7 @@ void TestGitStorage::initTestCase()
 | 
				
			||||||
	QTextCodec::setCodecForLocale(QTextCodec::codecForMib(106));
 | 
						QTextCodec::setCodecForLocale(QTextCodec::codecForMib(106));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// first, setup the preferences an proxy information
 | 
						// first, setup the preferences an proxy information
 | 
				
			||||||
	copy_prefs(&default_prefs, &prefs);
 | 
						prefs = default_prefs;
 | 
				
			||||||
	QCoreApplication::setOrganizationName("Subsurface");
 | 
						QCoreApplication::setOrganizationName("Subsurface");
 | 
				
			||||||
	QCoreApplication::setOrganizationDomain("subsurface.hohndel.org");
 | 
						QCoreApplication::setOrganizationDomain("subsurface.hohndel.org");
 | 
				
			||||||
	QCoreApplication::setApplicationName("Subsurface");
 | 
						QCoreApplication::setApplicationName("Subsurface");
 | 
				
			||||||
| 
						 | 
					@ -108,8 +108,8 @@ void TestGitStorage::initTestCase()
 | 
				
			||||||
	if (gitUrl.empty() || gitUrl.back() != '/')
 | 
						if (gitUrl.empty() || gitUrl.back() != '/')
 | 
				
			||||||
		gitUrl += "/";
 | 
							gitUrl += "/";
 | 
				
			||||||
	gitUrl += "git";
 | 
						gitUrl += "git";
 | 
				
			||||||
	prefs.cloud_storage_email_encoded = strdup(email.c_str());
 | 
						prefs.cloud_storage_email_encoded = email;
 | 
				
			||||||
	prefs.cloud_storage_password = strdup(password.c_str());
 | 
						prefs.cloud_storage_password = password.c_str();
 | 
				
			||||||
	gitUrl += "/" + email;
 | 
						gitUrl += "/" + email;
 | 
				
			||||||
	// all user storage for historical reasons always uses the user's email both as
 | 
						// all user storage for historical reasons always uses the user's email both as
 | 
				
			||||||
	// repo name and as branch. To allow us to keep testing and not step on parallel
 | 
						// repo name and as branch. To allow us to keep testing and not step on parallel
 | 
				
			||||||
| 
						 | 
					@ -138,11 +138,11 @@ void TestGitStorage::initTestCase()
 | 
				
			||||||
	// make sure we deal with any proxy settings that are needed
 | 
						// make sure we deal with any proxy settings that are needed
 | 
				
			||||||
	QNetworkProxy proxy;
 | 
						QNetworkProxy proxy;
 | 
				
			||||||
	proxy.setType(QNetworkProxy::ProxyType(prefs.proxy_type));
 | 
						proxy.setType(QNetworkProxy::ProxyType(prefs.proxy_type));
 | 
				
			||||||
	proxy.setHostName(prefs.proxy_host);
 | 
						proxy.setHostName(QString::fromStdString(prefs.proxy_host));
 | 
				
			||||||
	proxy.setPort(prefs.proxy_port);
 | 
						proxy.setPort(prefs.proxy_port);
 | 
				
			||||||
	if (prefs.proxy_auth) {
 | 
						if (prefs.proxy_auth) {
 | 
				
			||||||
		proxy.setUser(prefs.proxy_user);
 | 
							proxy.setUser(QString::fromStdString(prefs.proxy_user));
 | 
				
			||||||
		proxy.setPassword(prefs.proxy_pass);
 | 
							proxy.setPassword(QString::fromStdString(prefs.proxy_pass));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	QNetworkProxy::setApplicationProxy(proxy);
 | 
						QNetworkProxy::setApplicationProxy(proxy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,7 +13,7 @@ void TestMerge::initTestCase()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	/* we need to manually tell that the resource exists, because we are using it as library. */
 | 
						/* we need to manually tell that the resource exists, because we are using it as library. */
 | 
				
			||||||
	Q_INIT_RESOURCE(subsurface);
 | 
						Q_INIT_RESOURCE(subsurface);
 | 
				
			||||||
	copy_prefs(&default_prefs, &prefs);
 | 
						prefs = default_prefs;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TestMerge::cleanup()
 | 
					void TestMerge::cleanup()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,7 +36,7 @@ void TestParse::initTestCase()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	/* we need to manually tell that the resource exists, because we are using it as library. */
 | 
						/* we need to manually tell that the resource exists, because we are using it as library. */
 | 
				
			||||||
	Q_INIT_RESOURCE(subsurface);
 | 
						Q_INIT_RESOURCE(subsurface);
 | 
				
			||||||
	copy_prefs(&default_prefs, &prefs);
 | 
						prefs = default_prefs;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TestParse::init()
 | 
					void TestParse::init()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,7 +24,7 @@ void TestParsePerformance::initTestCase()
 | 
				
			||||||
	QTextCodec::setCodecForLocale(QTextCodec::codecForMib(106));
 | 
						QTextCodec::setCodecForLocale(QTextCodec::codecForMib(106));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// first, setup the preferences an proxy information
 | 
						// first, setup the preferences an proxy information
 | 
				
			||||||
	copy_prefs(&default_prefs, &prefs);
 | 
						prefs = default_prefs;
 | 
				
			||||||
	QCoreApplication::setOrganizationName("Subsurface");
 | 
						QCoreApplication::setOrganizationName("Subsurface");
 | 
				
			||||||
	QCoreApplication::setOrganizationDomain("subsurface.hohndel.org");
 | 
						QCoreApplication::setOrganizationDomain("subsurface.hohndel.org");
 | 
				
			||||||
	QCoreApplication::setApplicationName("Subsurface");
 | 
						QCoreApplication::setApplicationName("Subsurface");
 | 
				
			||||||
| 
						 | 
					@ -33,11 +33,11 @@ void TestParsePerformance::initTestCase()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QNetworkProxy proxy;
 | 
						QNetworkProxy proxy;
 | 
				
			||||||
	proxy.setType(QNetworkProxy::ProxyType(prefs.proxy_type));
 | 
						proxy.setType(QNetworkProxy::ProxyType(prefs.proxy_type));
 | 
				
			||||||
	proxy.setHostName(prefs.proxy_host);
 | 
						proxy.setHostName(QString::fromStdString(prefs.proxy_host));
 | 
				
			||||||
	proxy.setPort(prefs.proxy_port);
 | 
						proxy.setPort(prefs.proxy_port);
 | 
				
			||||||
	if (prefs.proxy_auth) {
 | 
						if (prefs.proxy_auth) {
 | 
				
			||||||
		proxy.setUser(prefs.proxy_user);
 | 
							proxy.setUser(QString::fromStdString(prefs.proxy_user));
 | 
				
			||||||
		proxy.setPassword(prefs.proxy_pass);
 | 
							proxy.setPassword(QString::fromStdString(prefs.proxy_pass));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	QNetworkProxy::setApplicationProxy(proxy);
 | 
						QNetworkProxy::setApplicationProxy(proxy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,7 +14,7 @@ void TestPicture::initTestCase()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	/* we need to manually tell that the resource exists, because we are using it as library. */
 | 
						/* we need to manually tell that the resource exists, because we are using it as library. */
 | 
				
			||||||
	Q_INIT_RESOURCE(subsurface);
 | 
						Q_INIT_RESOURCE(subsurface);
 | 
				
			||||||
	prefs.cloud_base_url = strdup(default_prefs.cloud_base_url);
 | 
						prefs.cloud_base_url = default_prefs.cloud_base_url;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define PIC1_NAME "/dives/images/wreck.jpg"
 | 
					#define PIC1_NAME "/dives/images/wreck.jpg"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,7 @@ static struct deco_state test_deco_state;
 | 
				
			||||||
extern bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, int dcNr, int timestep, struct decostop *decostoptable, deco_state_cache &cache, bool is_planner, bool show_disclaimer);
 | 
					extern bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, int dcNr, int timestep, struct decostop *decostoptable, deco_state_cache &cache, bool is_planner, bool show_disclaimer);
 | 
				
			||||||
void setupPrefs()
 | 
					void setupPrefs()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	copy_prefs(&default_prefs, &prefs);
 | 
						prefs = default_prefs;
 | 
				
			||||||
	prefs.ascrate50 = feet_to_mm(30) / 60;
 | 
						prefs.ascrate50 = feet_to_mm(30) / 60;
 | 
				
			||||||
	prefs.ascrate75 = prefs.ascrate50;
 | 
						prefs.ascrate75 = prefs.ascrate50;
 | 
				
			||||||
	prefs.ascratestops = prefs.ascrate50;
 | 
						prefs.ascratestops = prefs.ascrate50;
 | 
				
			||||||
| 
						 | 
					@ -28,7 +28,7 @@ void setupPrefs()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void setupPrefsVpmb()
 | 
					void setupPrefsVpmb()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	copy_prefs(&default_prefs, &prefs);
 | 
						prefs = default_prefs;
 | 
				
			||||||
	prefs.ascrate50 = 10000 / 60;
 | 
						prefs.ascrate50 = 10000 / 60;
 | 
				
			||||||
	prefs.ascrate75 = prefs.ascrate50;
 | 
						prefs.ascrate75 = prefs.ascrate50;
 | 
				
			||||||
	prefs.ascratestops = prefs.ascrate50;
 | 
						prefs.ascratestops = prefs.ascrate50;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,7 +25,7 @@ void TestProfile::init()
 | 
				
			||||||
	QTextCodec::setCodecForLocale(QTextCodec::codecForMib(106));
 | 
						QTextCodec::setCodecForLocale(QTextCodec::codecForMib(106));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// first, setup the preferences
 | 
						// first, setup the preferences
 | 
				
			||||||
	copy_prefs(&default_prefs, &prefs);
 | 
						prefs = default_prefs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QCoreApplication::setOrganizationName("Subsurface");
 | 
						QCoreApplication::setOrganizationName("Subsurface");
 | 
				
			||||||
	QCoreApplication::setOrganizationDomain("subsurface.hohndel.org");
 | 
						QCoreApplication::setOrganizationDomain("subsurface.hohndel.org");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,21 +22,21 @@ void TestQPrefCloudStorage::test_struct_get()
 | 
				
			||||||
	auto tst = qPrefCloudStorage::instance();
 | 
						auto tst = qPrefCloudStorage::instance();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.cloud_auto_sync = true;
 | 
						prefs.cloud_auto_sync = true;
 | 
				
			||||||
	prefs.cloud_base_url = copy_qstring("new url");
 | 
						prefs.cloud_base_url = "new url";
 | 
				
			||||||
	prefs.cloud_storage_email = copy_qstring("myEmail");
 | 
						prefs.cloud_storage_email = "myEmail";
 | 
				
			||||||
	prefs.cloud_storage_email_encoded = copy_qstring("encodedMyEMail");
 | 
						prefs.cloud_storage_email_encoded = "encodedMyEMail";
 | 
				
			||||||
	prefs.cloud_storage_password = copy_qstring("more secret");
 | 
						prefs.cloud_storage_password = "more secret";
 | 
				
			||||||
	prefs.cloud_storage_pin = copy_qstring("a pin");
 | 
						prefs.cloud_storage_pin = "a pin";
 | 
				
			||||||
	prefs.cloud_timeout = 117;
 | 
						prefs.cloud_timeout = 117;
 | 
				
			||||||
	prefs.cloud_verification_status = qPrefCloudStorage::CS_NOCLOUD;
 | 
						prefs.cloud_verification_status = qPrefCloudStorage::CS_NOCLOUD;
 | 
				
			||||||
	prefs.save_password_local = true;
 | 
						prefs.save_password_local = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QCOMPARE(tst->cloud_auto_sync(), prefs.cloud_auto_sync);
 | 
						QCOMPARE(tst->cloud_auto_sync(), prefs.cloud_auto_sync);
 | 
				
			||||||
	QCOMPARE(tst->cloud_base_url(), QString(prefs.cloud_base_url));
 | 
						QCOMPARE(tst->cloud_base_url(), QString::fromStdString(prefs.cloud_base_url));
 | 
				
			||||||
	QCOMPARE(tst->cloud_storage_email(), QString(prefs.cloud_storage_email));
 | 
						QCOMPARE(tst->cloud_storage_email(), QString::fromStdString(prefs.cloud_storage_email));
 | 
				
			||||||
	QCOMPARE(tst->cloud_storage_email_encoded(), QString(prefs.cloud_storage_email_encoded));
 | 
						QCOMPARE(tst->cloud_storage_email_encoded(), QString::fromStdString(prefs.cloud_storage_email_encoded));
 | 
				
			||||||
	QCOMPARE(tst->cloud_storage_password(), QString(prefs.cloud_storage_password));
 | 
						QCOMPARE(tst->cloud_storage_password(), QString::fromStdString(prefs.cloud_storage_password));
 | 
				
			||||||
	QCOMPARE(tst->cloud_storage_pin(), QString(prefs.cloud_storage_pin));
 | 
						QCOMPARE(tst->cloud_storage_pin(), QString::fromStdString(prefs.cloud_storage_pin));
 | 
				
			||||||
	QCOMPARE(tst->cloud_timeout(), (int)prefs.cloud_timeout);
 | 
						QCOMPARE(tst->cloud_timeout(), (int)prefs.cloud_timeout);
 | 
				
			||||||
	QCOMPARE(tst->cloud_verification_status(), (int)prefs.cloud_verification_status);
 | 
						QCOMPARE(tst->cloud_verification_status(), (int)prefs.cloud_verification_status);
 | 
				
			||||||
	QCOMPARE(tst->save_password_local(), prefs.save_password_local);
 | 
						QCOMPARE(tst->save_password_local(), prefs.save_password_local);
 | 
				
			||||||
| 
						 | 
					@ -59,11 +59,11 @@ void TestQPrefCloudStorage::test_set_struct()
 | 
				
			||||||
	tst->set_save_password_local(false);
 | 
						tst->set_save_password_local(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QCOMPARE(prefs.cloud_auto_sync, false);
 | 
						QCOMPARE(prefs.cloud_auto_sync, false);
 | 
				
			||||||
	QCOMPARE(QString(prefs.cloud_base_url), QString("t2 base"));
 | 
						QCOMPARE(QString::fromStdString(prefs.cloud_base_url), QString("t2 base"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.cloud_storage_email), QString("t2 email"));
 | 
						QCOMPARE(QString::fromStdString(prefs.cloud_storage_email), QString("t2 email"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.cloud_storage_email_encoded), QString("t2 email2"));
 | 
						QCOMPARE(QString::fromStdString(prefs.cloud_storage_email_encoded), QString("t2 email2"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.cloud_storage_password), QString("t2 pass2"));
 | 
						QCOMPARE(QString::fromStdString(prefs.cloud_storage_password), QString("t2 pass2"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.cloud_storage_pin), QString("t2 pin"));
 | 
						QCOMPARE(QString::fromStdString(prefs.cloud_storage_pin), QString("t2 pin"));
 | 
				
			||||||
	QCOMPARE((int)prefs.cloud_timeout, 123);
 | 
						QCOMPARE((int)prefs.cloud_timeout, 123);
 | 
				
			||||||
	QCOMPARE((int)prefs.cloud_verification_status, (int)qPrefCloudStorage::CS_VERIFIED);
 | 
						QCOMPARE((int)prefs.cloud_verification_status, (int)qPrefCloudStorage::CS_VERIFIED);
 | 
				
			||||||
	QCOMPARE(prefs.save_password_local, false);
 | 
						QCOMPARE(prefs.save_password_local, false);
 | 
				
			||||||
| 
						 | 
					@ -87,22 +87,22 @@ void TestQPrefCloudStorage::test_set_load_struct()
 | 
				
			||||||
	tst->set_cloud_verification_status(qPrefCloudStorage::CS_NOCLOUD);
 | 
						tst->set_cloud_verification_status(qPrefCloudStorage::CS_NOCLOUD);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.cloud_auto_sync = false;
 | 
						prefs.cloud_auto_sync = false;
 | 
				
			||||||
	prefs.cloud_base_url = copy_qstring("error1");
 | 
						prefs.cloud_base_url = "error1";
 | 
				
			||||||
	prefs.cloud_storage_email = copy_qstring("error1");
 | 
						prefs.cloud_storage_email = "error1";
 | 
				
			||||||
	prefs.cloud_storage_email_encoded = copy_qstring("error1");
 | 
						prefs.cloud_storage_email_encoded = "error1";
 | 
				
			||||||
	prefs.cloud_storage_password = copy_qstring("error1");
 | 
						prefs.cloud_storage_password = "error1";
 | 
				
			||||||
	prefs.cloud_storage_pin = copy_qstring("error1");
 | 
						prefs.cloud_storage_pin = "error1";
 | 
				
			||||||
	prefs.cloud_timeout = 324;
 | 
						prefs.cloud_timeout = 324;
 | 
				
			||||||
	prefs.cloud_verification_status = qPrefCloudStorage::CS_VERIFIED;
 | 
						prefs.cloud_verification_status = qPrefCloudStorage::CS_VERIFIED;
 | 
				
			||||||
	prefs.save_password_local = false;
 | 
						prefs.save_password_local = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->load();
 | 
						tst->load();
 | 
				
			||||||
	QCOMPARE(prefs.cloud_auto_sync, true);
 | 
						QCOMPARE(prefs.cloud_auto_sync, true);
 | 
				
			||||||
	QCOMPARE(QString(prefs.cloud_base_url), QString("t3 base"));
 | 
						QCOMPARE(QString::fromStdString(prefs.cloud_base_url), QString("t3 base"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.cloud_storage_email), QString("t3 email"));
 | 
						QCOMPARE(QString::fromStdString(prefs.cloud_storage_email), QString("t3 email"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.cloud_storage_email_encoded), QString("t3 email2"));
 | 
						QCOMPARE(QString::fromStdString(prefs.cloud_storage_email_encoded), QString("t3 email2"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.cloud_storage_password), QString("t3 pass2"));
 | 
						QCOMPARE(QString::fromStdString(prefs.cloud_storage_password), QString("t3 pass2"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.cloud_storage_pin), QString("t3 pin"));
 | 
						QCOMPARE(QString::fromStdString(prefs.cloud_storage_pin), QString("t3 pin"));
 | 
				
			||||||
	QCOMPARE((int)prefs.cloud_timeout, 321);
 | 
						QCOMPARE((int)prefs.cloud_timeout, 321);
 | 
				
			||||||
	QCOMPARE((int)prefs.cloud_verification_status, (int)qPrefCloudStorage::CS_NOCLOUD);
 | 
						QCOMPARE((int)prefs.cloud_verification_status, (int)qPrefCloudStorage::CS_NOCLOUD);
 | 
				
			||||||
	QCOMPARE(prefs.save_password_local, true);
 | 
						QCOMPARE(prefs.save_password_local, true);
 | 
				
			||||||
| 
						 | 
					@ -114,25 +114,25 @@ void TestQPrefCloudStorage::test_struct_disk()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto tst = qPrefCloudStorage::instance();
 | 
						auto tst = qPrefCloudStorage::instance();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.cloud_base_url = copy_qstring("t4 base");
 | 
						prefs.cloud_base_url = "t4 base";
 | 
				
			||||||
	tst->store_cloud_base_url("t4 base"); // the base URL is no longer automatically saved to disk
 | 
						tst->store_cloud_base_url("t4 base"); // the base URL is no longer automatically saved to disk
 | 
				
			||||||
	prefs.cloud_storage_email = copy_qstring("t4 email");
 | 
						prefs.cloud_storage_email =("t4 email");
 | 
				
			||||||
	prefs.cloud_storage_email_encoded = copy_qstring("t4 email2");
 | 
						prefs.cloud_storage_email_encoded = "t4 email2";
 | 
				
			||||||
	prefs.save_password_local = true;
 | 
						prefs.save_password_local = true;
 | 
				
			||||||
	prefs.cloud_auto_sync = true;
 | 
						prefs.cloud_auto_sync = true;
 | 
				
			||||||
	prefs.cloud_storage_password = copy_qstring("t4 pass2");
 | 
						prefs.cloud_storage_password = "t4 pass2";
 | 
				
			||||||
	prefs.cloud_storage_pin = copy_qstring("t4 pin");
 | 
						prefs.cloud_storage_pin = "t4 pin";
 | 
				
			||||||
	prefs.cloud_timeout = 123;
 | 
						prefs.cloud_timeout = 123;
 | 
				
			||||||
	prefs.cloud_verification_status = qPrefCloudStorage::CS_VERIFIED;
 | 
						prefs.cloud_verification_status = qPrefCloudStorage::CS_VERIFIED;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->sync();
 | 
						tst->sync();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.cloud_auto_sync = false;
 | 
						prefs.cloud_auto_sync = false;
 | 
				
			||||||
	prefs.cloud_base_url = copy_qstring("error1");
 | 
						prefs.cloud_base_url = "error1";
 | 
				
			||||||
	prefs.cloud_storage_email = copy_qstring("error1");
 | 
						prefs.cloud_storage_email = "error1";
 | 
				
			||||||
	prefs.cloud_storage_email_encoded = copy_qstring("error1");
 | 
						prefs.cloud_storage_email_encoded = "error1";
 | 
				
			||||||
	prefs.cloud_storage_password = copy_qstring("error1");
 | 
						prefs.cloud_storage_password = "error1";
 | 
				
			||||||
	prefs.cloud_storage_pin = copy_qstring("error1");
 | 
						prefs.cloud_storage_pin = "error1";
 | 
				
			||||||
	prefs.cloud_timeout = 324;
 | 
						prefs.cloud_timeout = 324;
 | 
				
			||||||
	prefs.cloud_verification_status = qPrefCloudStorage::CS_VERIFIED;
 | 
						prefs.cloud_verification_status = qPrefCloudStorage::CS_VERIFIED;
 | 
				
			||||||
	prefs.save_password_local = false;
 | 
						prefs.save_password_local = false;
 | 
				
			||||||
| 
						 | 
					@ -140,11 +140,11 @@ void TestQPrefCloudStorage::test_struct_disk()
 | 
				
			||||||
	tst->load();
 | 
						tst->load();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QCOMPARE(prefs.cloud_auto_sync, true);
 | 
						QCOMPARE(prefs.cloud_auto_sync, true);
 | 
				
			||||||
	QCOMPARE(QString(prefs.cloud_base_url), QString("t4 base"));
 | 
						QCOMPARE(QString::fromStdString(prefs.cloud_base_url), QString("t4 base"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.cloud_storage_email), QString("t4 email"));
 | 
						QCOMPARE(QString::fromStdString(prefs.cloud_storage_email), QString("t4 email"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.cloud_storage_email_encoded), QString("t4 email2"));
 | 
						QCOMPARE(QString::fromStdString(prefs.cloud_storage_email_encoded), QString("t4 email2"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.cloud_storage_password), QString("t4 pass2"));
 | 
						QCOMPARE(QString::fromStdString(prefs.cloud_storage_password), QString("t4 pass2"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.cloud_storage_pin), QString("t4 pin"));
 | 
						QCOMPARE(QString::fromStdString(prefs.cloud_storage_pin), QString("t4 pin"));
 | 
				
			||||||
	QCOMPARE((int)prefs.cloud_timeout, 123);
 | 
						QCOMPARE((int)prefs.cloud_timeout, 123);
 | 
				
			||||||
	QCOMPARE((int)prefs.cloud_verification_status, (int)qPrefCloudStorage::CS_VERIFIED);
 | 
						QCOMPARE((int)prefs.cloud_verification_status, (int)qPrefCloudStorage::CS_VERIFIED);
 | 
				
			||||||
	QCOMPARE(prefs.save_password_local, true);
 | 
						QCOMPARE(prefs.save_password_local, true);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,13 +24,13 @@ void TestQPrefDisplay::test_struct_get()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.animation_speed = 17;
 | 
						prefs.animation_speed = 17;
 | 
				
			||||||
	prefs.display_invalid_dives = true;
 | 
						prefs.display_invalid_dives = true;
 | 
				
			||||||
	prefs.divelist_font = copy_qstring("comic");
 | 
						prefs.divelist_font = "comic";
 | 
				
			||||||
	prefs.font_size = 12.0;
 | 
						prefs.font_size = 12.0;
 | 
				
			||||||
	prefs.show_developer = false;
 | 
						prefs.show_developer = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QCOMPARE(display->animation_speed(), prefs.animation_speed);
 | 
						QCOMPARE(display->animation_speed(), prefs.animation_speed);
 | 
				
			||||||
	QCOMPARE(display->display_invalid_dives(), prefs.display_invalid_dives);
 | 
						QCOMPARE(display->display_invalid_dives(), prefs.display_invalid_dives);
 | 
				
			||||||
	QCOMPARE(display->divelist_font(), QString(prefs.divelist_font));
 | 
						QCOMPARE(display->divelist_font(), QString::fromStdString(prefs.divelist_font));
 | 
				
			||||||
	QCOMPARE(display->font_size(), prefs.font_size);
 | 
						QCOMPARE(display->font_size(), prefs.font_size);
 | 
				
			||||||
	QCOMPARE(display->show_developer(), prefs.show_developer);
 | 
						QCOMPARE(display->show_developer(), prefs.show_developer);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -98,7 +98,7 @@ void TestQPrefDisplay::test_set_load_struct()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.animation_speed = 17;
 | 
						prefs.animation_speed = 17;
 | 
				
			||||||
	prefs.display_invalid_dives = false;
 | 
						prefs.display_invalid_dives = false;
 | 
				
			||||||
	prefs.divelist_font = copy_qstring("doNotCareAtAll");
 | 
						prefs.divelist_font = "doNotCareAtAll";
 | 
				
			||||||
	prefs.font_size = 12.0;
 | 
						prefs.font_size = 12.0;
 | 
				
			||||||
	prefs.show_developer = false;
 | 
						prefs.show_developer = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -131,14 +131,14 @@ void TestQPrefDisplay::test_struct_disk()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.animation_speed = 27;
 | 
						prefs.animation_speed = 27;
 | 
				
			||||||
	prefs.display_invalid_dives = true;
 | 
						prefs.display_invalid_dives = true;
 | 
				
			||||||
	prefs.divelist_font = copy_qstring("doNotCareAtAll");
 | 
						prefs.divelist_font = "doNotCareAtAll";
 | 
				
			||||||
	prefs.font_size = 17.0;
 | 
						prefs.font_size = 17.0;
 | 
				
			||||||
	prefs.show_developer = false;
 | 
						prefs.show_developer = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	display->sync();
 | 
						display->sync();
 | 
				
			||||||
	prefs.animation_speed = 35;
 | 
						prefs.animation_speed = 35;
 | 
				
			||||||
	prefs.display_invalid_dives = false;
 | 
						prefs.display_invalid_dives = false;
 | 
				
			||||||
	prefs.divelist_font = copy_qstring("noString");
 | 
						prefs.divelist_font = "noString";
 | 
				
			||||||
	prefs.font_size = 11.0;
 | 
						prefs.font_size = 11.0;
 | 
				
			||||||
	prefs.show_developer = true;
 | 
						prefs.show_developer = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -156,7 +156,7 @@ void TestQPrefDisplay::test_struct_disk()
 | 
				
			||||||
void TestQPrefDisplay::test_multiple()
 | 
					void TestQPrefDisplay::test_multiple()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// test multiple instances have the same information
 | 
						// test multiple instances have the same information
 | 
				
			||||||
	prefs.divelist_font = copy_qstring("comic");
 | 
						prefs.divelist_font = "comic";
 | 
				
			||||||
	auto display = qPrefDisplay::instance();
 | 
						auto display = qPrefDisplay::instance();
 | 
				
			||||||
	prefs.font_size = 15.0;
 | 
						prefs.font_size = 15.0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,15 +21,15 @@ void TestQPrefDiveComputer::test_struct_get()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto tst = qPrefDiveComputer::instance();
 | 
						auto tst = qPrefDiveComputer::instance();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.dive_computer.device = copy_qstring("my device");
 | 
						prefs.dive_computer.device = "my device";
 | 
				
			||||||
	prefs.dive_computer.device_name = copy_qstring("my device name");
 | 
						prefs.dive_computer.device_name = "my device name";
 | 
				
			||||||
	prefs.dive_computer.product = copy_qstring("my product");
 | 
						prefs.dive_computer.product = "my product";
 | 
				
			||||||
	prefs.dive_computer.vendor = copy_qstring("my vendor");
 | 
						prefs.dive_computer.vendor = "my vendor";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QCOMPARE(tst->device(), QString(prefs.dive_computer.device));
 | 
						QCOMPARE(tst->device(), QString::fromStdString(prefs.dive_computer.device));
 | 
				
			||||||
	QCOMPARE(tst->device_name(), QString(prefs.dive_computer.device_name));
 | 
						QCOMPARE(tst->device_name(), QString::fromStdString(prefs.dive_computer.device_name));
 | 
				
			||||||
	QCOMPARE(tst->product(), QString(prefs.dive_computer.product));
 | 
						QCOMPARE(tst->product(), QString::fromStdString(prefs.dive_computer.product));
 | 
				
			||||||
	QCOMPARE(tst->vendor(), QString(prefs.dive_computer.vendor));
 | 
						QCOMPARE(tst->vendor(), QString::fromStdString(prefs.dive_computer.vendor));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TestQPrefDiveComputer::test_set_struct()
 | 
					void TestQPrefDiveComputer::test_set_struct()
 | 
				
			||||||
| 
						 | 
					@ -43,10 +43,10 @@ void TestQPrefDiveComputer::test_set_struct()
 | 
				
			||||||
	tst->set_product("t2 product");
 | 
						tst->set_product("t2 product");
 | 
				
			||||||
	tst->set_vendor("t2 vendor");
 | 
						tst->set_vendor("t2 vendor");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QCOMPARE(QString(prefs.dive_computer.device), QString("t2 device"));
 | 
						QCOMPARE(QString::fromStdString(prefs.dive_computer.device), QString("t2 device"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.dive_computer.device_name), QString("t2 device name"));
 | 
						QCOMPARE(QString::fromStdString(prefs.dive_computer.device_name), QString("t2 device name"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.dive_computer.product), QString("t2 product"));
 | 
						QCOMPARE(QString::fromStdString(prefs.dive_computer.product), QString("t2 product"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.dive_computer.vendor), QString("t2 vendor"));
 | 
						QCOMPARE(QString::fromStdString(prefs.dive_computer.vendor), QString("t2 vendor"));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TestQPrefDiveComputer::test_set_load_struct()
 | 
					void TestQPrefDiveComputer::test_set_load_struct()
 | 
				
			||||||
| 
						 | 
					@ -60,16 +60,16 @@ void TestQPrefDiveComputer::test_set_load_struct()
 | 
				
			||||||
	tst->set_product("t3 product");
 | 
						tst->set_product("t3 product");
 | 
				
			||||||
	tst->set_vendor("t3 vendor");
 | 
						tst->set_vendor("t3 vendor");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.dive_computer.device = copy_qstring("error1");
 | 
						prefs.dive_computer.device = "error1";
 | 
				
			||||||
	prefs.dive_computer.device_name = copy_qstring("error2");
 | 
						prefs.dive_computer.device_name = "error2";
 | 
				
			||||||
	prefs.dive_computer.product = copy_qstring("error3");
 | 
						prefs.dive_computer.product = "error3";
 | 
				
			||||||
	prefs.dive_computer.vendor = copy_qstring("error4");
 | 
						prefs.dive_computer.vendor = "error4";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->load();
 | 
						tst->load();
 | 
				
			||||||
	QCOMPARE(QString(prefs.dive_computer.device), QString("t3 device"));
 | 
						QCOMPARE(QString::fromStdString(prefs.dive_computer.device), QString("t3 device"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.dive_computer.device_name), QString("t3 device name"));
 | 
						QCOMPARE(QString::fromStdString(prefs.dive_computer.device_name), QString("t3 device name"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.dive_computer.product), QString("t3 product"));
 | 
						QCOMPARE(QString::fromStdString(prefs.dive_computer.product), QString("t3 product"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.dive_computer.vendor), QString("t3 vendor"));
 | 
						QCOMPARE(QString::fromStdString(prefs.dive_computer.vendor), QString("t3 vendor"));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TestQPrefDiveComputer::test_struct_disk()
 | 
					void TestQPrefDiveComputer::test_struct_disk()
 | 
				
			||||||
| 
						 | 
					@ -78,24 +78,24 @@ void TestQPrefDiveComputer::test_struct_disk()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto tst = qPrefDiveComputer::instance();
 | 
						auto tst = qPrefDiveComputer::instance();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.dive_computer.device = copy_qstring("t4 device");
 | 
						prefs.dive_computer.device = "t4 device";
 | 
				
			||||||
	prefs.dive_computer.device_name = copy_qstring("t4 device name");
 | 
						prefs.dive_computer.device_name = "t4 device name";
 | 
				
			||||||
	prefs.dive_computer.product = copy_qstring("t4 product");
 | 
						prefs.dive_computer.product = "t4 product";
 | 
				
			||||||
	prefs.dive_computer.vendor = copy_qstring("t4 vendor");
 | 
						prefs.dive_computer.vendor = "t4 vendor";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->sync();
 | 
						tst->sync();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.dive_computer.device = copy_qstring("error");
 | 
						prefs.dive_computer.device = "error";
 | 
				
			||||||
	prefs.dive_computer.device_name = copy_qstring("error");
 | 
						prefs.dive_computer.device_name = "error";
 | 
				
			||||||
	prefs.dive_computer.product = copy_qstring("error");
 | 
						prefs.dive_computer.product = "error";
 | 
				
			||||||
	prefs.dive_computer.vendor = copy_qstring("error");
 | 
						prefs.dive_computer.vendor = "error";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->load();
 | 
						tst->load();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QCOMPARE(QString(prefs.dive_computer.device), QString("t4 device"));
 | 
						QCOMPARE(QString::fromStdString(prefs.dive_computer.device), QString("t4 device"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.dive_computer.device_name), QString("t4 device name"));
 | 
						QCOMPARE(QString::fromStdString(prefs.dive_computer.device_name), QString("t4 device name"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.dive_computer.product), QString("t4 product"));
 | 
						QCOMPARE(QString::fromStdString(prefs.dive_computer.product), QString("t4 product"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.dive_computer.vendor), QString("t4 vendor"));
 | 
						QCOMPARE(QString::fromStdString(prefs.dive_computer.vendor), QString("t4 vendor"));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TestQPrefDiveComputer::test_multiple()
 | 
					void TestQPrefDiveComputer::test_multiple()
 | 
				
			||||||
| 
						 | 
					@ -103,7 +103,7 @@ void TestQPrefDiveComputer::test_multiple()
 | 
				
			||||||
	// test multiple instances have the same information
 | 
						// test multiple instances have the same information
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto tst = qPrefDiveComputer::instance();
 | 
						auto tst = qPrefDiveComputer::instance();
 | 
				
			||||||
	prefs.dive_computer.device = copy_qstring("mine");
 | 
						prefs.dive_computer.device = "mine";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QCOMPARE(tst->device(), qPrefDiveComputer::device());
 | 
						QCOMPARE(tst->device(), qPrefDiveComputer::device());
 | 
				
			||||||
	QCOMPARE(tst->device(), QString("mine"));
 | 
						QCOMPARE(tst->device(), QString("mine"));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,8 +22,8 @@ void TestQPrefEquipment::test_struct_get()
 | 
				
			||||||
	// Test struct pref -> get func.
 | 
						// Test struct pref -> get func.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto tst = qPrefEquipment::instance();
 | 
						auto tst = qPrefEquipment::instance();
 | 
				
			||||||
	prefs.default_cylinder = copy_qstring("new base11");
 | 
						prefs.default_cylinder = "new base11";
 | 
				
			||||||
	QCOMPARE(tst->default_cylinder(), QString(prefs.default_cylinder));
 | 
						QCOMPARE(tst->default_cylinder(), QString::fromStdString(prefs.default_cylinder));
 | 
				
			||||||
	prefs.include_unused_tanks = true;
 | 
						prefs.include_unused_tanks = true;
 | 
				
			||||||
	QCOMPARE(tst->include_unused_tanks(), prefs.include_unused_tanks);
 | 
						QCOMPARE(tst->include_unused_tanks(), prefs.include_unused_tanks);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -34,7 +34,7 @@ void TestQPrefEquipment::test_set_struct()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto tst = qPrefEquipment::instance();
 | 
						auto tst = qPrefEquipment::instance();
 | 
				
			||||||
	tst->set_default_cylinder("new base21");
 | 
						tst->set_default_cylinder("new base21");
 | 
				
			||||||
	QCOMPARE(QString(prefs.default_cylinder), QString("new base21"));
 | 
						QCOMPARE(QString::fromStdString(prefs.default_cylinder), QString("new base21"));
 | 
				
			||||||
	tst->set_include_unused_tanks(false);
 | 
						tst->set_include_unused_tanks(false);
 | 
				
			||||||
	QCOMPARE(prefs.include_unused_tanks, false);
 | 
						QCOMPARE(prefs.include_unused_tanks, false);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -46,11 +46,11 @@ void TestQPrefEquipment::test_set_load_struct()
 | 
				
			||||||
	auto tst = qPrefEquipment::instance();
 | 
						auto tst = qPrefEquipment::instance();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->set_default_cylinder("new base31");
 | 
						tst->set_default_cylinder("new base31");
 | 
				
			||||||
	prefs.default_cylinder = copy_qstring("error");
 | 
						prefs.default_cylinder = "error";
 | 
				
			||||||
	tst->set_include_unused_tanks(false);
 | 
						tst->set_include_unused_tanks(false);
 | 
				
			||||||
	prefs.include_unused_tanks = true;
 | 
						prefs.include_unused_tanks = true;
 | 
				
			||||||
	tst->load();
 | 
						tst->load();
 | 
				
			||||||
	QCOMPARE(QString(prefs.default_cylinder), QString("new base31"));
 | 
						QCOMPARE(QString::fromStdString(prefs.default_cylinder), QString("new base31"));
 | 
				
			||||||
	QCOMPARE(prefs.include_unused_tanks, false);
 | 
						QCOMPARE(prefs.include_unused_tanks, false);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -59,15 +59,15 @@ void TestQPrefEquipment::test_struct_disk()
 | 
				
			||||||
	// test struct prefs -> disk
 | 
						// test struct prefs -> disk
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto tst = qPrefEquipment::instance();
 | 
						auto tst = qPrefEquipment::instance();
 | 
				
			||||||
	prefs.default_cylinder = copy_qstring("base41");
 | 
						prefs.default_cylinder = "base41";
 | 
				
			||||||
	prefs.include_unused_tanks = true;
 | 
						prefs.include_unused_tanks = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->sync();
 | 
						tst->sync();
 | 
				
			||||||
	prefs.default_cylinder = copy_qstring("error");
 | 
						prefs.default_cylinder = "error";
 | 
				
			||||||
	prefs.include_unused_tanks = false;
 | 
						prefs.include_unused_tanks = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->load();
 | 
						tst->load();
 | 
				
			||||||
	QCOMPARE(QString(prefs.default_cylinder), QString("base41"));
 | 
						QCOMPARE(QString::fromStdString(prefs.default_cylinder), QString("base41"));
 | 
				
			||||||
	QCOMPARE(prefs.include_unused_tanks, true);
 | 
						QCOMPARE(prefs.include_unused_tanks, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,21 +21,21 @@ void TestQPrefLanguage::test_struct_get()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto tst = qPrefLanguage::instance();
 | 
						auto tst = qPrefLanguage::instance();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.date_format = copy_qstring("new date format");
 | 
						prefs.date_format = "new date format";
 | 
				
			||||||
	prefs.date_format_override = true;
 | 
						prefs.date_format_override = true;
 | 
				
			||||||
	prefs.date_format_short = copy_qstring("new short format");
 | 
						prefs.date_format_short = "new short format";
 | 
				
			||||||
	prefs.locale.language = copy_qstring("new lang format");
 | 
						prefs.locale.language = "new lang format";
 | 
				
			||||||
	prefs.locale.lang_locale = copy_qstring("new loc lang format");
 | 
						prefs.locale.lang_locale = "new loc lang format";
 | 
				
			||||||
	prefs.time_format = copy_qstring("new time format");
 | 
						prefs.time_format = "new time format";
 | 
				
			||||||
	prefs.time_format_override = true;
 | 
						prefs.time_format_override = true;
 | 
				
			||||||
	prefs.locale.use_system_language = true;
 | 
						prefs.locale.use_system_language = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QCOMPARE(tst->date_format(), QString(prefs.date_format));
 | 
						QCOMPARE(tst->date_format(), QString::fromStdString(prefs.date_format));
 | 
				
			||||||
	QCOMPARE(tst->date_format_override(), prefs.date_format_override);
 | 
						QCOMPARE(tst->date_format_override(), prefs.date_format_override);
 | 
				
			||||||
	QCOMPARE(tst->date_format_short(), QString(prefs.date_format_short));
 | 
						QCOMPARE(tst->date_format_short(), QString::fromStdString(prefs.date_format_short));
 | 
				
			||||||
	QCOMPARE(tst->language(), QString(prefs.locale.language));
 | 
						QCOMPARE(tst->language(), QString::fromStdString(prefs.locale.language));
 | 
				
			||||||
	QCOMPARE(tst->lang_locale(), QString(prefs.locale.lang_locale));
 | 
						QCOMPARE(tst->lang_locale(), QString::fromStdString(prefs.locale.lang_locale));
 | 
				
			||||||
	QCOMPARE(tst->time_format(), QString(prefs.time_format));
 | 
						QCOMPARE(tst->time_format(), QString::fromStdString(prefs.time_format));
 | 
				
			||||||
	QCOMPARE(tst->time_format_override(), prefs.time_format_override);
 | 
						QCOMPARE(tst->time_format_override(), prefs.time_format_override);
 | 
				
			||||||
	QCOMPARE(tst->use_system_language(), prefs.locale.use_system_language);
 | 
						QCOMPARE(tst->use_system_language(), prefs.locale.use_system_language);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -80,22 +80,22 @@ void TestQPrefLanguage::test_set_load_struct()
 | 
				
			||||||
	tst->set_time_format_override(true);
 | 
						tst->set_time_format_override(true);
 | 
				
			||||||
	tst->set_use_system_language(true);
 | 
						tst->set_use_system_language(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.date_format = copy_qstring("error3");
 | 
						prefs.date_format = "error3";
 | 
				
			||||||
	prefs.date_format_override = false;
 | 
						prefs.date_format_override = false;
 | 
				
			||||||
	prefs.date_format_short = copy_qstring("error3");
 | 
						prefs.date_format_short = "error3";
 | 
				
			||||||
	prefs.locale.language = copy_qstring("error3");
 | 
						prefs.locale.language = "error3";
 | 
				
			||||||
	prefs.locale.lang_locale = copy_qstring("error3");
 | 
						prefs.locale.lang_locale = "error3";
 | 
				
			||||||
	prefs.time_format = copy_qstring("error3");
 | 
						prefs.time_format = "error3";
 | 
				
			||||||
	prefs.time_format_override = false;
 | 
						prefs.time_format_override = false;
 | 
				
			||||||
	prefs.locale.use_system_language = false;
 | 
						prefs.locale.use_system_language = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->load();
 | 
						tst->load();
 | 
				
			||||||
	QCOMPARE(QString(prefs.date_format), QString("new date3"));
 | 
						QCOMPARE(QString::fromStdString(prefs.date_format), QString("new date3"));
 | 
				
			||||||
	QCOMPARE(prefs.date_format_override, true);
 | 
						QCOMPARE(prefs.date_format_override, true);
 | 
				
			||||||
	QCOMPARE(QString(prefs.date_format_short), QString("new short3"));
 | 
						QCOMPARE(QString::fromStdString(prefs.date_format_short), QString("new short3"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.locale.language), QString("new lang format3"));
 | 
						QCOMPARE(QString::fromStdString(prefs.locale.language), QString("new lang format3"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.locale.lang_locale), QString("new loc lang3"));
 | 
						QCOMPARE(QString::fromStdString(prefs.locale.lang_locale), QString("new loc lang3"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.time_format), QString("new time3"));
 | 
						QCOMPARE(QString::fromStdString(prefs.time_format), QString("new time3"));
 | 
				
			||||||
	QCOMPARE(prefs.time_format_override, true);
 | 
						QCOMPARE(prefs.time_format_override, true);
 | 
				
			||||||
	QCOMPARE(prefs.locale.use_system_language, true);
 | 
						QCOMPARE(prefs.locale.use_system_language, true);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -106,32 +106,32 @@ void TestQPrefLanguage::test_struct_disk()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto tst = qPrefLanguage::instance();
 | 
						auto tst = qPrefLanguage::instance();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.date_format = copy_qstring("new date format");
 | 
						prefs.date_format = "new date format";
 | 
				
			||||||
	prefs.date_format_override = true;
 | 
						prefs.date_format_override = true;
 | 
				
			||||||
	prefs.date_format_short = copy_qstring("new short format");
 | 
						prefs.date_format_short = "new short format";
 | 
				
			||||||
	prefs.locale.language = copy_qstring("new lang format");
 | 
						prefs.locale.language = "new lang format";
 | 
				
			||||||
	prefs.locale.lang_locale = copy_qstring("new loc lang format");
 | 
						prefs.locale.lang_locale = "new loc lang format";
 | 
				
			||||||
	prefs.time_format = copy_qstring("new time format");
 | 
						prefs.time_format = "new time format";
 | 
				
			||||||
	prefs.time_format_override = true;
 | 
						prefs.time_format_override = true;
 | 
				
			||||||
	prefs.locale.use_system_language = true;
 | 
						prefs.locale.use_system_language = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->sync();
 | 
						tst->sync();
 | 
				
			||||||
	prefs.date_format = copy_qstring("error3");
 | 
						prefs.date_format = "error3";
 | 
				
			||||||
	prefs.date_format_override = false;
 | 
						prefs.date_format_override = false;
 | 
				
			||||||
	prefs.date_format_short = copy_qstring("error3");
 | 
						prefs.date_format_short = "error3";
 | 
				
			||||||
	prefs.locale.language = copy_qstring("error3");
 | 
						prefs.locale.language = "error3";
 | 
				
			||||||
	prefs.locale.lang_locale = copy_qstring("error3");
 | 
						prefs.locale.lang_locale = "error3";
 | 
				
			||||||
	prefs.time_format = copy_qstring("error3");
 | 
						prefs.time_format = "error3";
 | 
				
			||||||
	prefs.time_format_override = false;
 | 
						prefs.time_format_override = false;
 | 
				
			||||||
	prefs.locale.use_system_language = false;
 | 
						prefs.locale.use_system_language = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->load();
 | 
						tst->load();
 | 
				
			||||||
	QCOMPARE(QString(prefs.date_format), QString("new date format"));
 | 
						QCOMPARE(QString::fromStdString(prefs.date_format), QString("new date format"));
 | 
				
			||||||
	QCOMPARE(prefs.date_format_override, true);
 | 
						QCOMPARE(prefs.date_format_override, true);
 | 
				
			||||||
	QCOMPARE(QString(prefs.date_format_short), QString("new short format"));
 | 
						QCOMPARE(QString::fromStdString(prefs.date_format_short), QString("new short format"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.locale.language), QString("new lang format"));
 | 
						QCOMPARE(QString::fromStdString(prefs.locale.language), QString("new lang format"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.locale.lang_locale), QString("new loc lang format"));
 | 
						QCOMPARE(QString::fromStdString(prefs.locale.lang_locale), QString("new loc lang format"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.time_format), QString("new time format"));
 | 
						QCOMPARE(QString::fromStdString(prefs.time_format), QString("new time format"));
 | 
				
			||||||
	QCOMPARE(prefs.time_format_override, true);
 | 
						QCOMPARE(prefs.time_format_override, true);
 | 
				
			||||||
	QCOMPARE(prefs.locale.use_system_language, true);
 | 
						QCOMPARE(prefs.locale.use_system_language, true);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,13 +23,13 @@ void TestQPrefLog::test_struct_get()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto tst = qPrefLog::instance();
 | 
						auto tst = qPrefLog::instance();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.default_filename = copy_qstring("new base12");
 | 
						prefs.default_filename = "new base12";
 | 
				
			||||||
	prefs.default_file_behavior = UNDEFINED_DEFAULT_FILE;
 | 
						prefs.default_file_behavior = UNDEFINED_DEFAULT_FILE;
 | 
				
			||||||
	prefs.use_default_file = true;
 | 
						prefs.use_default_file = true;
 | 
				
			||||||
	prefs.show_average_depth = true;
 | 
						prefs.show_average_depth = true;
 | 
				
			||||||
	prefs.extraEnvironmentalDefault = true;
 | 
						prefs.extraEnvironmentalDefault = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QCOMPARE(tst->default_filename(), QString(prefs.default_filename));
 | 
						QCOMPARE(tst->default_filename(), QString::fromStdString(prefs.default_filename));
 | 
				
			||||||
	QCOMPARE(tst->default_file_behavior(), prefs.default_file_behavior);
 | 
						QCOMPARE(tst->default_file_behavior(), prefs.default_file_behavior);
 | 
				
			||||||
	QCOMPARE(tst->use_default_file(), prefs.use_default_file);
 | 
						QCOMPARE(tst->use_default_file(), prefs.use_default_file);
 | 
				
			||||||
	QCOMPARE(tst->show_average_depth(), prefs.show_average_depth);
 | 
						QCOMPARE(tst->show_average_depth(), prefs.show_average_depth);
 | 
				
			||||||
| 
						 | 
					@ -48,7 +48,7 @@ void TestQPrefLog::test_set_struct()
 | 
				
			||||||
	tst->set_show_average_depth(false);
 | 
						tst->set_show_average_depth(false);
 | 
				
			||||||
	tst->set_extraEnvironmentalDefault(false);
 | 
						tst->set_extraEnvironmentalDefault(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QCOMPARE(QString(prefs.default_filename), QString("new base22"));
 | 
						QCOMPARE(QString::fromStdString(prefs.default_filename), QString("new base22"));
 | 
				
			||||||
	QCOMPARE(prefs.default_file_behavior, LOCAL_DEFAULT_FILE);
 | 
						QCOMPARE(prefs.default_file_behavior, LOCAL_DEFAULT_FILE);
 | 
				
			||||||
	QCOMPARE(prefs.use_default_file, false);
 | 
						QCOMPARE(prefs.use_default_file, false);
 | 
				
			||||||
	QCOMPARE(prefs.show_average_depth, false);
 | 
						QCOMPARE(prefs.show_average_depth, false);
 | 
				
			||||||
| 
						 | 
					@ -67,14 +67,14 @@ void TestQPrefLog::test_set_load_struct()
 | 
				
			||||||
	tst->set_show_average_depth(true);
 | 
						tst->set_show_average_depth(true);
 | 
				
			||||||
	tst->set_extraEnvironmentalDefault(true);
 | 
						tst->set_extraEnvironmentalDefault(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.default_filename = copy_qstring("error");
 | 
						prefs.default_filename = "error";
 | 
				
			||||||
	prefs.default_file_behavior = UNDEFINED_DEFAULT_FILE;
 | 
						prefs.default_file_behavior = UNDEFINED_DEFAULT_FILE;
 | 
				
			||||||
	prefs.use_default_file = false;
 | 
						prefs.use_default_file = false;
 | 
				
			||||||
	prefs.show_average_depth = false;
 | 
						prefs.show_average_depth = false;
 | 
				
			||||||
	prefs.extraEnvironmentalDefault = false;
 | 
						prefs.extraEnvironmentalDefault = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->load();
 | 
						tst->load();
 | 
				
			||||||
	QCOMPARE(QString(prefs.default_filename), QString("new base32"));
 | 
						QCOMPARE(QString::fromStdString(prefs.default_filename), QString("new base32"));
 | 
				
			||||||
	QCOMPARE(prefs.default_file_behavior, NO_DEFAULT_FILE);
 | 
						QCOMPARE(prefs.default_file_behavior, NO_DEFAULT_FILE);
 | 
				
			||||||
	QCOMPARE(prefs.use_default_file, true);
 | 
						QCOMPARE(prefs.use_default_file, true);
 | 
				
			||||||
	QCOMPARE(prefs.show_average_depth, true);
 | 
						QCOMPARE(prefs.show_average_depth, true);
 | 
				
			||||||
| 
						 | 
					@ -87,21 +87,21 @@ void TestQPrefLog::test_struct_disk()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto tst = qPrefLog::instance();
 | 
						auto tst = qPrefLog::instance();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.default_filename = copy_qstring("base42");
 | 
						prefs.default_filename = "base42";
 | 
				
			||||||
	prefs.default_file_behavior = CLOUD_DEFAULT_FILE;
 | 
						prefs.default_file_behavior = CLOUD_DEFAULT_FILE;
 | 
				
			||||||
	prefs.use_default_file = true;
 | 
						prefs.use_default_file = true;
 | 
				
			||||||
	prefs.show_average_depth = true;
 | 
						prefs.show_average_depth = true;
 | 
				
			||||||
	prefs.extraEnvironmentalDefault = true;
 | 
						prefs.extraEnvironmentalDefault = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->sync();
 | 
						tst->sync();
 | 
				
			||||||
	prefs.default_filename = copy_qstring("error");
 | 
						prefs.default_filename = "error";
 | 
				
			||||||
	prefs.default_file_behavior = UNDEFINED_DEFAULT_FILE;
 | 
						prefs.default_file_behavior = UNDEFINED_DEFAULT_FILE;
 | 
				
			||||||
	prefs.use_default_file = false;
 | 
						prefs.use_default_file = false;
 | 
				
			||||||
	prefs.show_average_depth = false;
 | 
						prefs.show_average_depth = false;
 | 
				
			||||||
	prefs.extraEnvironmentalDefault = false;
 | 
						prefs.extraEnvironmentalDefault = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->load();
 | 
						tst->load();
 | 
				
			||||||
	QCOMPARE(QString(prefs.default_filename), QString("base42"));
 | 
						QCOMPARE(QString::fromStdString(prefs.default_filename), QString("base42"));
 | 
				
			||||||
	QCOMPARE(prefs.default_file_behavior, CLOUD_DEFAULT_FILE);
 | 
						QCOMPARE(prefs.default_file_behavior, CLOUD_DEFAULT_FILE);
 | 
				
			||||||
	QCOMPARE(prefs.use_default_file, true);
 | 
						QCOMPARE(prefs.use_default_file, true);
 | 
				
			||||||
	QCOMPARE(prefs.show_average_depth, true);
 | 
						QCOMPARE(prefs.show_average_depth, true);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,12 +26,12 @@ void TestQPrefMedia::test_struct_get()
 | 
				
			||||||
	prefs.auto_recalculate_thumbnails = true;
 | 
						prefs.auto_recalculate_thumbnails = true;
 | 
				
			||||||
	prefs.extract_video_thumbnails = true;
 | 
						prefs.extract_video_thumbnails = true;
 | 
				
			||||||
	prefs.extract_video_thumbnails_position = 15;
 | 
						prefs.extract_video_thumbnails_position = 15;
 | 
				
			||||||
	prefs.ffmpeg_executable = copy_qstring("new base16");
 | 
						prefs.ffmpeg_executable = "new base16";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QCOMPARE(tst->auto_recalculate_thumbnails(), prefs.auto_recalculate_thumbnails);
 | 
						QCOMPARE(tst->auto_recalculate_thumbnails(), prefs.auto_recalculate_thumbnails);
 | 
				
			||||||
	QCOMPARE(tst->extract_video_thumbnails(), prefs.extract_video_thumbnails);
 | 
						QCOMPARE(tst->extract_video_thumbnails(), prefs.extract_video_thumbnails);
 | 
				
			||||||
	QCOMPARE(tst->extract_video_thumbnails_position(), prefs.extract_video_thumbnails_position);
 | 
						QCOMPARE(tst->extract_video_thumbnails_position(), prefs.extract_video_thumbnails_position);
 | 
				
			||||||
	QCOMPARE(tst->ffmpeg_executable(), QString(prefs.ffmpeg_executable));
 | 
						QCOMPARE(tst->ffmpeg_executable(), QString::fromStdString(prefs.ffmpeg_executable));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TestQPrefMedia::test_set_struct()
 | 
					void TestQPrefMedia::test_set_struct()
 | 
				
			||||||
| 
						 | 
					@ -48,7 +48,7 @@ void TestQPrefMedia::test_set_struct()
 | 
				
			||||||
	QCOMPARE(prefs.auto_recalculate_thumbnails, false);
 | 
						QCOMPARE(prefs.auto_recalculate_thumbnails, false);
 | 
				
			||||||
	QCOMPARE(prefs.extract_video_thumbnails, false);
 | 
						QCOMPARE(prefs.extract_video_thumbnails, false);
 | 
				
			||||||
	QCOMPARE(prefs.extract_video_thumbnails_position, 25);
 | 
						QCOMPARE(prefs.extract_video_thumbnails_position, 25);
 | 
				
			||||||
	QCOMPARE(QString(prefs.ffmpeg_executable), QString("new base26"));
 | 
						QCOMPARE(QString::fromStdString(prefs.ffmpeg_executable), QString("new base26"));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TestQPrefMedia::test_set_load_struct()
 | 
					void TestQPrefMedia::test_set_load_struct()
 | 
				
			||||||
| 
						 | 
					@ -65,13 +65,13 @@ void TestQPrefMedia::test_set_load_struct()
 | 
				
			||||||
	prefs.auto_recalculate_thumbnails = false;
 | 
						prefs.auto_recalculate_thumbnails = false;
 | 
				
			||||||
	prefs.extract_video_thumbnails = false;
 | 
						prefs.extract_video_thumbnails = false;
 | 
				
			||||||
	prefs.extract_video_thumbnails_position = 15;
 | 
						prefs.extract_video_thumbnails_position = 15;
 | 
				
			||||||
	prefs.ffmpeg_executable = copy_qstring("error");
 | 
						prefs.ffmpeg_executable = "error";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->load();
 | 
						tst->load();
 | 
				
			||||||
	QCOMPARE(prefs.auto_recalculate_thumbnails, true);
 | 
						QCOMPARE(prefs.auto_recalculate_thumbnails, true);
 | 
				
			||||||
	QCOMPARE(prefs.extract_video_thumbnails, true);
 | 
						QCOMPARE(prefs.extract_video_thumbnails, true);
 | 
				
			||||||
	QCOMPARE(prefs.extract_video_thumbnails_position, 35);
 | 
						QCOMPARE(prefs.extract_video_thumbnails_position, 35);
 | 
				
			||||||
	QCOMPARE(QString(prefs.ffmpeg_executable), QString("new base36"));
 | 
						QCOMPARE(QString::fromStdString(prefs.ffmpeg_executable), QString("new base36"));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TestQPrefMedia::test_struct_disk()
 | 
					void TestQPrefMedia::test_struct_disk()
 | 
				
			||||||
| 
						 | 
					@ -83,19 +83,19 @@ void TestQPrefMedia::test_struct_disk()
 | 
				
			||||||
	prefs.auto_recalculate_thumbnails = true;
 | 
						prefs.auto_recalculate_thumbnails = true;
 | 
				
			||||||
	prefs.extract_video_thumbnails = true;
 | 
						prefs.extract_video_thumbnails = true;
 | 
				
			||||||
	prefs.extract_video_thumbnails_position = 45;
 | 
						prefs.extract_video_thumbnails_position = 45;
 | 
				
			||||||
	prefs.ffmpeg_executable = copy_qstring("base46");
 | 
						prefs.ffmpeg_executable = "base46";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->sync();
 | 
						tst->sync();
 | 
				
			||||||
	prefs.auto_recalculate_thumbnails = false;
 | 
						prefs.auto_recalculate_thumbnails = false;
 | 
				
			||||||
	prefs.extract_video_thumbnails = false;
 | 
						prefs.extract_video_thumbnails = false;
 | 
				
			||||||
	prefs.extract_video_thumbnails_position = 15;
 | 
						prefs.extract_video_thumbnails_position = 15;
 | 
				
			||||||
	prefs.ffmpeg_executable = copy_qstring("error");
 | 
						prefs.ffmpeg_executable = "error";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->load();
 | 
						tst->load();
 | 
				
			||||||
	QCOMPARE(prefs.auto_recalculate_thumbnails, true);
 | 
						QCOMPARE(prefs.auto_recalculate_thumbnails, true);
 | 
				
			||||||
	QCOMPARE(prefs.extract_video_thumbnails, true);
 | 
						QCOMPARE(prefs.extract_video_thumbnails, true);
 | 
				
			||||||
	QCOMPARE(prefs.extract_video_thumbnails_position, 45);
 | 
						QCOMPARE(prefs.extract_video_thumbnails_position, 45);
 | 
				
			||||||
	QCOMPARE(QString(prefs.ffmpeg_executable), QString("base46"));
 | 
						QCOMPARE(QString::fromStdString(prefs.ffmpeg_executable), QString("base46"));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define TEST(METHOD, VALUE)      \
 | 
					#define TEST(METHOD, VALUE)      \
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,18 +22,18 @@ void TestQPrefProxy::test_struct_get()
 | 
				
			||||||
	auto tst = qPrefProxy::instance();
 | 
						auto tst = qPrefProxy::instance();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.proxy_auth = true;
 | 
						prefs.proxy_auth = true;
 | 
				
			||||||
	prefs.proxy_host = copy_qstring("t1 host");
 | 
						prefs.proxy_host = "t1 host";
 | 
				
			||||||
	prefs.proxy_pass = copy_qstring("t1 pass");
 | 
						prefs.proxy_pass = "t1 pass";
 | 
				
			||||||
	prefs.proxy_port = 512;
 | 
						prefs.proxy_port = 512;
 | 
				
			||||||
	prefs.proxy_type = 3;
 | 
						prefs.proxy_type = 3;
 | 
				
			||||||
	prefs.proxy_user = copy_qstring("t1 user");
 | 
						prefs.proxy_user = "t1 user";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QCOMPARE(tst->proxy_auth(), true);
 | 
						QCOMPARE(tst->proxy_auth(), true);
 | 
				
			||||||
	QCOMPARE(tst->proxy_host(), QString(prefs.proxy_host));
 | 
						QCOMPARE(tst->proxy_host(), QString::fromStdString(prefs.proxy_host));
 | 
				
			||||||
	QCOMPARE(tst->proxy_pass(), QString(prefs.proxy_pass));
 | 
						QCOMPARE(tst->proxy_pass(), QString::fromStdString(prefs.proxy_pass));
 | 
				
			||||||
	QCOMPARE(tst->proxy_port(), 512);
 | 
						QCOMPARE(tst->proxy_port(), 512);
 | 
				
			||||||
	QCOMPARE(tst->proxy_type(), 3);
 | 
						QCOMPARE(tst->proxy_type(), 3);
 | 
				
			||||||
	QCOMPARE(tst->proxy_user(), QString(prefs.proxy_user));
 | 
						QCOMPARE(tst->proxy_user(), QString::fromStdString(prefs.proxy_user));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TestQPrefProxy::test_set_struct()
 | 
					void TestQPrefProxy::test_set_struct()
 | 
				
			||||||
| 
						 | 
					@ -50,11 +50,11 @@ void TestQPrefProxy::test_set_struct()
 | 
				
			||||||
	tst->set_proxy_user("t2 user");
 | 
						tst->set_proxy_user("t2 user");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QCOMPARE(prefs.proxy_auth, false);
 | 
						QCOMPARE(prefs.proxy_auth, false);
 | 
				
			||||||
	QCOMPARE(QString(prefs.proxy_host), QString("t2 host"));
 | 
						QCOMPARE(QString::fromStdString(prefs.proxy_host), QString("t2 host"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.proxy_pass), QString("t2 pass"));
 | 
						QCOMPARE(QString::fromStdString(prefs.proxy_pass), QString("t2 pass"));
 | 
				
			||||||
	QCOMPARE(prefs.proxy_port, 524);
 | 
						QCOMPARE(prefs.proxy_port, 524);
 | 
				
			||||||
	QCOMPARE(prefs.proxy_type, 2);
 | 
						QCOMPARE(prefs.proxy_type, 2);
 | 
				
			||||||
	QCOMPARE(QString(prefs.proxy_user), QString("t2 user"));
 | 
						QCOMPARE(QString::fromStdString(prefs.proxy_user), QString("t2 user"));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TestQPrefProxy::test_set_load_struct()
 | 
					void TestQPrefProxy::test_set_load_struct()
 | 
				
			||||||
| 
						 | 
					@ -72,19 +72,19 @@ void TestQPrefProxy::test_set_load_struct()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->sync();
 | 
						tst->sync();
 | 
				
			||||||
	prefs.proxy_auth = false;
 | 
						prefs.proxy_auth = false;
 | 
				
			||||||
	prefs.proxy_host = copy_qstring("error1");
 | 
						prefs.proxy_host = "error1";
 | 
				
			||||||
	prefs.proxy_pass = copy_qstring("error1");
 | 
						prefs.proxy_pass = "error1";
 | 
				
			||||||
	prefs.proxy_port = 128;
 | 
						prefs.proxy_port = 128;
 | 
				
			||||||
	prefs.proxy_type = 0;
 | 
						prefs.proxy_type = 0;
 | 
				
			||||||
	prefs.proxy_user = copy_qstring("error1");
 | 
						prefs.proxy_user = "error1";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->load();
 | 
						tst->load();
 | 
				
			||||||
	QCOMPARE(prefs.proxy_auth, true);
 | 
						QCOMPARE(prefs.proxy_auth, true);
 | 
				
			||||||
	QCOMPARE(QString(prefs.proxy_host), QString("t3 host"));
 | 
						QCOMPARE(QString::fromStdString(prefs.proxy_host), QString("t3 host"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.proxy_pass), QString("t3 pass"));
 | 
						QCOMPARE(QString::fromStdString(prefs.proxy_pass), QString("t3 pass"));
 | 
				
			||||||
	QCOMPARE(prefs.proxy_port, 532);
 | 
						QCOMPARE(prefs.proxy_port, 532);
 | 
				
			||||||
	QCOMPARE(prefs.proxy_type, 1);
 | 
						QCOMPARE(prefs.proxy_type, 1);
 | 
				
			||||||
	QCOMPARE(QString(prefs.proxy_user), QString("t3 user"));
 | 
						QCOMPARE(QString::fromStdString(prefs.proxy_user), QString("t3 user"));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TestQPrefProxy::test_struct_disk()
 | 
					void TestQPrefProxy::test_struct_disk()
 | 
				
			||||||
| 
						 | 
					@ -94,27 +94,27 @@ void TestQPrefProxy::test_struct_disk()
 | 
				
			||||||
	auto tst = qPrefProxy::instance();
 | 
						auto tst = qPrefProxy::instance();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.proxy_auth = false;
 | 
						prefs.proxy_auth = false;
 | 
				
			||||||
	prefs.proxy_host = copy_qstring("t4 host");
 | 
						prefs.proxy_host = "t4 host";
 | 
				
			||||||
	prefs.proxy_pass = copy_qstring("t4 pass");
 | 
						prefs.proxy_pass = "t4 pass";
 | 
				
			||||||
	prefs.proxy_port = 544;
 | 
						prefs.proxy_port = 544;
 | 
				
			||||||
	prefs.proxy_type = 4;
 | 
						prefs.proxy_type = 4;
 | 
				
			||||||
	prefs.proxy_user = copy_qstring("t4 user");
 | 
						prefs.proxy_user = "t4 user";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->sync();
 | 
						tst->sync();
 | 
				
			||||||
	prefs.proxy_auth = true;
 | 
						prefs.proxy_auth = true;
 | 
				
			||||||
	prefs.proxy_host = copy_qstring("error1");
 | 
						prefs.proxy_host = "error1";
 | 
				
			||||||
	prefs.proxy_pass = copy_qstring("error1");
 | 
						prefs.proxy_pass = "error1";
 | 
				
			||||||
	prefs.proxy_port = 128;
 | 
						prefs.proxy_port = 128;
 | 
				
			||||||
	prefs.proxy_type = 5;
 | 
						prefs.proxy_type = 5;
 | 
				
			||||||
	prefs.proxy_user = copy_qstring("error1");
 | 
						prefs.proxy_user = "error1";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->load();
 | 
						tst->load();
 | 
				
			||||||
	QCOMPARE(prefs.proxy_auth, false);
 | 
						QCOMPARE(prefs.proxy_auth, false);
 | 
				
			||||||
	QCOMPARE(QString(prefs.proxy_host), QString("t4 host"));
 | 
						QCOMPARE(QString::fromStdString(prefs.proxy_host), QString("t4 host"));
 | 
				
			||||||
	QCOMPARE(QString(prefs.proxy_pass), QString("t4 pass"));
 | 
						QCOMPARE(QString::fromStdString(prefs.proxy_pass), QString("t4 pass"));
 | 
				
			||||||
	QCOMPARE(prefs.proxy_port, 544);
 | 
						QCOMPARE(prefs.proxy_port, 544);
 | 
				
			||||||
	QCOMPARE(prefs.proxy_type, 4);
 | 
						QCOMPARE(prefs.proxy_type, 4);
 | 
				
			||||||
	QCOMPARE(QString(prefs.proxy_user), QString("t4 user"));
 | 
						QCOMPARE(QString::fromStdString(prefs.proxy_user), QString("t4 user"));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TestQPrefProxy::test_multiple()
 | 
					void TestQPrefProxy::test_multiple()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,7 +22,7 @@ void TestQPrefUpdateManager::test_struct_get()
 | 
				
			||||||
	auto tst = qPrefUpdateManager::instance();
 | 
						auto tst = qPrefUpdateManager::instance();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.update_manager.dont_check_for_updates = true;
 | 
						prefs.update_manager.dont_check_for_updates = true;
 | 
				
			||||||
	prefs.update_manager.last_version_used = copy_qstring("last_version");
 | 
						prefs.update_manager.last_version_used = "last_version";
 | 
				
			||||||
	prefs.update_manager.next_check = QDate::fromString("11/09/1957", "dd/MM/yyyy").toJulianDay();
 | 
						prefs.update_manager.next_check = QDate::fromString("11/09/1957", "dd/MM/yyyy").toJulianDay();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QCOMPARE(tst->dont_check_for_updates(), true);
 | 
						QCOMPARE(tst->dont_check_for_updates(), true);
 | 
				
			||||||
| 
						 | 
					@ -42,7 +42,7 @@ void TestQPrefUpdateManager::test_set_struct()
 | 
				
			||||||
	tst->set_uuidString("uuid");
 | 
						tst->set_uuidString("uuid");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QCOMPARE(prefs.update_manager.dont_check_for_updates, false);
 | 
						QCOMPARE(prefs.update_manager.dont_check_for_updates, false);
 | 
				
			||||||
	QCOMPARE(QString(prefs.update_manager.last_version_used), QString("last_version2"));
 | 
						QCOMPARE(QString::fromStdString(prefs.update_manager.last_version_used), QString("last_version2"));
 | 
				
			||||||
	QCOMPARE(QDate::fromJulianDay(prefs.update_manager.next_check), QDate::fromString("11/09/1957", "dd/MM/yyyy"));
 | 
						QCOMPARE(QDate::fromJulianDay(prefs.update_manager.next_check), QDate::fromString("11/09/1957", "dd/MM/yyyy"));
 | 
				
			||||||
	QCOMPARE(tst->uuidString(), QString("uuid"));
 | 
						QCOMPARE(tst->uuidString(), QString("uuid"));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -63,12 +63,12 @@ void TestQPrefUpdateManager::test_set_load_struct()
 | 
				
			||||||
	tst->set_uuidString("uuid2");
 | 
						tst->set_uuidString("uuid2");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.update_manager.dont_check_for_updates = true;
 | 
						prefs.update_manager.dont_check_for_updates = true;
 | 
				
			||||||
	prefs.update_manager.last_version_used = copy_qstring("last_version");
 | 
						prefs.update_manager.last_version_used = "last_version";
 | 
				
			||||||
	prefs.update_manager.next_check = 1000;
 | 
						prefs.update_manager.next_check = 1000;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->load();
 | 
						tst->load();
 | 
				
			||||||
	QCOMPARE(prefs.update_manager.dont_check_for_updates, false);
 | 
						QCOMPARE(prefs.update_manager.dont_check_for_updates, false);
 | 
				
			||||||
	QCOMPARE(QString(prefs.update_manager.last_version_used), QString("last_version2"));
 | 
						QCOMPARE(QString::fromStdString(prefs.update_manager.last_version_used), QString("last_version2"));
 | 
				
			||||||
	QCOMPARE(QDate::fromJulianDay(prefs.update_manager.next_check), QDate::fromString("11/09/1957", "dd/MM/yyyy"));
 | 
						QCOMPARE(QDate::fromJulianDay(prefs.update_manager.next_check), QDate::fromString("11/09/1957", "dd/MM/yyyy"));
 | 
				
			||||||
	QCOMPARE(tst->uuidString(), QString("uuid2"));
 | 
						QCOMPARE(tst->uuidString(), QString("uuid2"));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -80,12 +80,12 @@ void TestQPrefUpdateManager::test_struct_disk()
 | 
				
			||||||
	auto tst = qPrefUpdateManager::instance();
 | 
						auto tst = qPrefUpdateManager::instance();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prefs.update_manager.dont_check_for_updates = true;
 | 
						prefs.update_manager.dont_check_for_updates = true;
 | 
				
			||||||
	prefs.update_manager.last_version_used = copy_qstring("last_version");
 | 
						prefs.update_manager.last_version_used = "last_version";
 | 
				
			||||||
	prefs.update_manager.next_check = QDate::fromString("11/09/1957", "dd/MM/yyyy").toJulianDay();
 | 
						prefs.update_manager.next_check = QDate::fromString("11/09/1957", "dd/MM/yyyy").toJulianDay();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->sync();
 | 
						tst->sync();
 | 
				
			||||||
	prefs.update_manager.dont_check_for_updates = false;
 | 
						prefs.update_manager.dont_check_for_updates = false;
 | 
				
			||||||
	prefs.update_manager.last_version_used = copy_qstring("");
 | 
						prefs.update_manager.last_version_used.clear();
 | 
				
			||||||
	prefs.update_manager.next_check = 1000;
 | 
						prefs.update_manager.next_check = 1000;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tst->load();
 | 
						tst->load();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TestRenumber::setup()
 | 
					void TestRenumber::setup()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	prefs.cloud_base_url = strdup(default_prefs.cloud_base_url);
 | 
						prefs.cloud_base_url = default_prefs.cloud_base_url;
 | 
				
			||||||
	QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47.xml", &divelog), 0);
 | 
						QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47.xml", &divelog), 0);
 | 
				
			||||||
	process_loaded_dives();
 | 
						process_loaded_dives();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue