2018-08-12 15:57:45 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2018-08-14 10:25:15 +00:00
|
|
|
#include "qPrefGeneral.h"
|
2018-08-12 15:57:45 +00:00
|
|
|
#include "qPrefPrivate.h"
|
|
|
|
|
|
|
|
|
|
|
|
static const QString group = QStringLiteral("GeneralSettings");
|
|
|
|
|
2018-08-20 10:50:21 +00:00
|
|
|
QString qPrefGeneral::st_diveshareExport_uid;
|
2019-04-01 21:17:17 +00:00
|
|
|
static const QString st_diveshareExport_uid_default;
|
2018-08-20 10:50:21 +00:00
|
|
|
|
|
|
|
bool qPrefGeneral::st_diveshareExport_private;
|
|
|
|
static const bool st_diveshareExport_private_default = false;
|
|
|
|
|
2018-08-12 15:57:45 +00:00
|
|
|
qPrefGeneral::qPrefGeneral(QObject *parent) : QObject(parent)
|
|
|
|
{
|
|
|
|
}
|
2018-09-02 09:50:55 +00:00
|
|
|
|
2018-08-12 15:57:45 +00:00
|
|
|
qPrefGeneral *qPrefGeneral::instance()
|
|
|
|
{
|
|
|
|
static qPrefGeneral *self = new qPrefGeneral;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void qPrefGeneral::loadSync(bool doSync)
|
|
|
|
{
|
|
|
|
disk_auto_recalculate_thumbnails(doSync);
|
|
|
|
disk_auto_recalculate_thumbnails(doSync);
|
|
|
|
disk_default_cylinder(doSync);
|
|
|
|
disk_default_filename(doSync);
|
|
|
|
disk_default_file_behavior(doSync);
|
|
|
|
disk_defaultsetpoint(doSync);
|
|
|
|
disk_extract_video_thumbnails(doSync);
|
|
|
|
disk_extract_video_thumbnails_position(doSync);
|
|
|
|
disk_ffmpeg_executable(doSync);
|
|
|
|
disk_o2consumption(doSync);
|
|
|
|
disk_pscr_ratio(doSync);
|
|
|
|
disk_use_default_file(doSync);
|
2018-10-20 00:50:40 +00:00
|
|
|
disk_filterFullTextNotes(doSync);
|
|
|
|
disk_filterCaseSensitive(doSync);
|
|
|
|
|
2018-08-20 10:50:21 +00:00
|
|
|
if (!doSync) {
|
|
|
|
load_diveshareExport_uid();
|
|
|
|
load_diveshareExport_private();
|
|
|
|
}
|
2018-08-12 15:57:45 +00:00
|
|
|
}
|
|
|
|
|
2018-09-07 16:06:00 +00:00
|
|
|
HANDLE_PREFERENCE_BOOL(General, "auto_recalculate_thumbnails", auto_recalculate_thumbnails);
|
2018-08-12 15:57:45 +00:00
|
|
|
|
2018-09-07 16:06:00 +00:00
|
|
|
HANDLE_PREFERENCE_TXT(General, "default_cylinder", default_cylinder);
|
2018-08-12 15:57:45 +00:00
|
|
|
|
2018-09-07 16:06:00 +00:00
|
|
|
HANDLE_PREFERENCE_TXT(General, "default_filename", default_filename);
|
2018-08-12 15:57:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
void qPrefGeneral::set_default_file_behavior(enum def_file_behavior value)
|
|
|
|
{
|
|
|
|
if (value != prefs.default_file_behavior ||
|
|
|
|
prefs.default_file_behavior != UNDEFINED_DEFAULT_FILE) {
|
|
|
|
|
|
|
|
if (value == UNDEFINED_DEFAULT_FILE) {
|
|
|
|
// undefined, so check if there's a filename set and
|
|
|
|
// use that, otherwise go with no default file
|
|
|
|
prefs.default_file_behavior = QString(prefs.default_filename).isEmpty() ? NO_DEFAULT_FILE : LOCAL_DEFAULT_FILE;
|
|
|
|
} else {
|
|
|
|
prefs.default_file_behavior = value;
|
|
|
|
}
|
|
|
|
disk_default_file_behavior(true);
|
2018-09-08 14:44:51 +00:00
|
|
|
emit instance()->default_file_behaviorChanged(value);
|
2018-08-12 15:57:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
void qPrefGeneral::disk_default_file_behavior(bool doSync)
|
|
|
|
{
|
|
|
|
if (doSync) {
|
2018-09-07 16:06:00 +00:00
|
|
|
qPrefPrivate::propSetValue(keyFromGroupAndName(group, "default_file_behavior"), prefs.default_file_behavior, default_prefs.default_file_behavior);
|
2018-08-12 15:57:45 +00:00
|
|
|
} else {
|
2018-09-07 16:06:00 +00:00
|
|
|
prefs.default_file_behavior = (enum def_file_behavior)qPrefPrivate::propValue(keyFromGroupAndName(group, "default_file_behavior"), default_prefs.default_file_behavior).toInt();
|
2018-08-12 15:57:45 +00:00
|
|
|
if (prefs.default_file_behavior == UNDEFINED_DEFAULT_FILE)
|
|
|
|
// undefined, so check if there's a filename set and
|
|
|
|
// use that, otherwise go with no default file
|
|
|
|
prefs.default_file_behavior = QString(prefs.default_filename).isEmpty() ? NO_DEFAULT_FILE : LOCAL_DEFAULT_FILE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-07 16:06:00 +00:00
|
|
|
HANDLE_PREFERENCE_INT(General, "defaultsetpoint", defaultsetpoint);
|
2018-08-12 15:57:45 +00:00
|
|
|
|
2018-09-07 16:06:00 +00:00
|
|
|
HANDLE_PREFERENCE_BOOL(General, "extract_video_thumbnails", extract_video_thumbnails);
|
2018-08-12 15:57:45 +00:00
|
|
|
|
2018-09-07 16:06:00 +00:00
|
|
|
HANDLE_PREFERENCE_INT(General, "extract_video_thumbnails_position", extract_video_thumbnails_position);
|
2018-08-12 15:57:45 +00:00
|
|
|
|
2018-09-07 16:06:00 +00:00
|
|
|
HANDLE_PREFERENCE_TXT(General, "ffmpeg_executable", ffmpeg_executable);
|
2018-08-12 15:57:45 +00:00
|
|
|
|
2018-09-07 16:06:00 +00:00
|
|
|
HANDLE_PREFERENCE_INT(General, "o2consumption", o2consumption);
|
2018-08-12 15:57:45 +00:00
|
|
|
|
2018-09-07 16:06:00 +00:00
|
|
|
HANDLE_PREFERENCE_INT(General, "pscr_ratio", pscr_ratio);
|
2018-08-12 15:57:45 +00:00
|
|
|
|
2018-09-07 16:06:00 +00:00
|
|
|
HANDLE_PREFERENCE_BOOL(General, "use_default_file", use_default_file);
|
2018-08-20 10:50:21 +00:00
|
|
|
|
|
|
|
HANDLE_PROP_QSTRING(General, "diveshareExport/uid", diveshareExport_uid);
|
|
|
|
|
|
|
|
HANDLE_PROP_BOOL(General, "diveshareExport/private", diveshareExport_private);
|
2018-10-20 00:50:40 +00:00
|
|
|
|
|
|
|
HANDLE_PREFERENCE_BOOL(General, "filterFullTextNotes", filterFullTextNotes);
|
|
|
|
|
|
|
|
HANDLE_PREFERENCE_BOOL(General, "filterCaseSensitive", filterCaseSensitive);
|