subsurface/core/settings
willemferguson 3e853e37a5 Preferences UI: create new equipment tab
Remove the "Show unused cylinders" checkbox (Profile tab) and the
"Set default cylinder" qTextEdit box (General tab) and put them in a
separate and new Equipment tab. This sounds like a simple task but,
as can be seen from the files changed, was actually a complex matter.
Adapt the existing test programs (General and TechDetails) for creating
a test program that tests parts of the Equipment tab.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-25 02:57:42 +09:00
..
qPref.cpp Preferences UI: create new equipment tab 2019-12-25 02:57:42 +09:00
qPref.h Cleanup: don't instantiate a QPref object 2019-04-04 09:29:45 -07:00
qPrefCloudStorage.cpp core/settings: extend qPrefCloudStorage with divelogsde user info 2019-12-11 12:36:43 -05:00
qPrefCloudStorage.h core/settings: qPrefCloudStorage, correct diveshare_uid naming 2019-12-12 10:10:01 -05:00
qPrefDisplay.cpp core/settings: make qPref* constructors private 2019-12-05 11:48:26 -08:00
qPrefDisplay.h core/settings: remove Q_PROPERTY warning in qPref headers 2019-12-05 11:48:26 -08:00
qPrefDiveComputer.cpp core/settings: make qPref* constructors private 2019-12-05 11:48:26 -08:00
qPrefDiveComputer.h core/settings: make qPref* constructors private 2019-12-05 11:48:26 -08:00
qPrefDivePlanner.cpp core/settings: make qPref* constructors private 2019-12-05 11:48:26 -08:00
qPrefDivePlanner.h core/settings: remove Q_PROPERTY warning in qPref headers 2019-12-05 11:48:26 -08:00
qPrefEquipment.cpp Preferences UI: create new equipment tab 2019-12-25 02:57:42 +09:00
qPrefEquipment.h Preferences UI: create new equipment tab 2019-12-25 02:57:42 +09:00
qPrefGeneral.cpp Preferences UI: create new equipment tab 2019-12-25 02:57:42 +09:00
qPrefGeneral.h Preferences UI: create new equipment tab 2019-12-25 02:57:42 +09:00
qPrefGeocoding.cpp core/settings: make qPref* constructors private 2019-12-05 11:48:26 -08:00
qPrefGeocoding.h core/settings: remove Q_PROPERTY warning in qPref headers 2019-12-05 11:48:26 -08:00
qPrefLanguage.cpp core/settings: make qPref* constructors private 2019-12-05 11:48:26 -08:00
qPrefLanguage.h core/settings: remove Q_PROPERTY warning in qPref headers 2019-12-05 11:48:26 -08:00
qPrefLocationService.cpp core/settings: make qPref* constructors private 2019-12-05 11:48:26 -08:00
qPrefLocationService.h core/settings: remove Q_PROPERTY warning in qPref headers 2019-12-05 11:48:26 -08:00
qPrefPartialPressureGas.cpp core/settings: make qPref* constructors private 2019-12-05 11:48:26 -08:00
qPrefPartialPressureGas.h core/settings: remove Q_PROPERTY warning in qPref headers 2019-12-05 11:48:26 -08:00
qPrefPrivate.cpp qPref: don't compare doubles for equality 2018-09-25 15:58:17 +02:00
qPrefPrivate.h qPref: add ability to remember recently used dive computers 2018-09-23 11:49:30 -07:00
qPrefProxy.cpp core/settings: make qPref* constructors private 2019-12-05 11:48:26 -08:00
qPrefProxy.h core/settings: remove Q_PROPERTY warning in qPref headers 2019-12-05 11:48:26 -08:00
qPrefTechnicalDetails.cpp Preferences UI: create new equipment tab 2019-12-25 02:57:42 +09:00
qPrefTechnicalDetails.h Preferences UI: create new equipment tab 2019-12-25 02:57:42 +09:00
qPrefUnit.cpp core/settings: make qPref* constructors private 2019-12-05 11:48:26 -08:00
qPrefUnit.h core/settings: remove Q_PROPERTY warning in qPref headers 2019-12-05 11:48:26 -08:00
qPrefUpdateManager.cpp core/settings: make qPref* constructors private 2019-12-05 11:48:26 -08:00
qPrefUpdateManager.h core/settings: remove Q_PROPERTY warning in qPref headers 2019-12-05 11:48:26 -08:00
README.md

Short explanation of how qPref works

System startup:

core/qt-init.cpp init_qt_late()

does

qPref::load();

to load all properties from all qPref* classes

System shutdown:

subsurface-mobile-main.cpp and subsurface-desktop-main.cpp main()

calls

call qPref::sync()

to save all changes to disk, this is needed because part of the program modifies struct preferences instead of calling the set method.

EXCEPTION:

Variables not present in struct preferences (local static variables in the class are not written, see later.

System startup/shutdown common handling:

qPref::load() calls qPref::doSync(false)
qPref::sync() calls qPref::doSync(true)

qPrefDoSync()

qPref::doSync() calls qPref::doSync() for all qPref* classes Meaning qPref knows which classes exist, but not which variables

qPref*::doSync() calls

disk_<variable name>() for each variable

EXCEPTION:

some variables are not in struct preferences, but local static variables which can only be accessed through the set/get functions, therefore there are no need to sync them

	if (!doSync) // meaining load
		load_<variable_name>()

qPref*::disk_*()

qPref*::disk_*() calls qPrefPrivate::propSetValue to save a property, and qPrefPrivate::propValue() to read a property. The function also keeps struct preferences in sync.

qPrefPrivate::propSetValue()

qPrefPrivate::propSetValue() is static and calls QSettings to write property

qPrefPrivate::propValue()

qPrefPrivate::propValue() is static and calls QSettings to read property

macros

the macros are defined in qPrefPrivate.h

the macros are used in qPref*cpp

Reading properties

Reading a property is done through an inline function, and thus no more expensive than accessing the variable directly.

qPref*::<variable_name>()

Setting properties

Setting a property is done through a dedicated set function which are static to simplify the call:

qPref<class>::set_<variable_name>(value)

like:

qPrefDisplay::animation_speed(500);

the set function updates struct preferences (if not a local variable), and saves the property to disk, however save is only done if the variable is changed.

Updating struct preferences

When a program part updates struct preferences directly, changes are NOT saved to disk if the programm crashes, otherwise all variables are saved to disk with the program exists.