RodTracker.backend.settings

Classes which contain RodTracker GUI user settings.

Author: Adrian Niemann (adrian.niemann@ovgu.de)

Date: 2022-2024

class Configuration[source]

Bases: QObject

Generic class that shall hold configurations/settings.

path: str = '/home/docs/.config/RodTracker/configurations.json'

Path to the file for storing this configuration.

Type:

str

read(path: str | None = None)[source]

Reads configurations from a file and saves them in this object.

Parameters:

path (str, optional) – Path of the file to read. If no path is given the classes saved path is used, this might be the default path or a programmatically exchanged path.

Returns:

None

abstract reset_to_default()[source]

Resets the configuration values to their defaults.

classmethod save(new_path: str | None = None, new_data: dict | None = None)[source]

Saves the contents to a location on disk.

The saving location is determined by the objects property path if the parameter is left out.

Parameters:
  • new_path (str, optional) – Location to save the contents to. If this parameter is left blank the Configuration object’s path property is used.

  • new_data (dict, optional) – Configuration data, that is supposed to be saved and therefore replace the old configuration data.

Returns:

None

abstract show_dialog(parent)[source]

Displays a dialog for the user to change the configuration(s).

class Settings(path: str | None = None)[source]

Bases: Configuration

Holds settings for the GUI.

Parameters:

path (str, optional) – Location and name where the settings are saved as a *.json file. The default location is used, if no path is given.

parent
Type:

QWidget

path: str = '/home/docs/.config/RodTracker/settings.json'

Location and name where the settings are saved as a *.json file.

Type:

str

read(path: str | None = None)[source]

Reads configurations from a file and saves them in this object.

Parameters:

path (str, optional) – Path of the file to read. If no path is given the classes saved path is used, this might be the default path or a programmatically exchanged path.

Returns:

None

reset_to_default()[source]

Resets the configuration values to their defaults.

send_settings()[source]

Sends the current settings as one signal per settings category.

Hint

Emits

settings_changed

Propagates settings that have potentially been changed.

Type:

pyqtSignal(dict)

update_field(category: str, field: str, value)[source]

Update one of the settings and notify other objects about it.

Parameters:
  • category (str) – Category of settings.

  • field (str) – Field/setting within the category.

  • value (any) – New value of the setting.