Skip to content

Settings

Base classes

Name Children Inherits
Settings_
prettyqt.core.settings
Persistent platform-independent application settings.

⋔ Inheritance diagram

graph TD
  1565004359["core.Settings"]
  3241361353["core.Settings_"]
  3227531497["core.ObjectMixin"]
  2751680898["builtins.object"]
  2563025020["QtCore.QSettings"]
  3984060476["QtCore.QObject"]
  37984305["Shiboken.Object"]
  1799060090["abc.MutableMapping"]
  4016029557["abc.Mapping"]
  2852422536["abc.Collection"]
  4051874921["abc.Sized"]
  2021119437["abc.Iterable"]
  1031828782["abc.Container"]
  3241361353 --> 1565004359
  3227531497 --> 3241361353
  2751680898 --> 3227531497
  2563025020 --> 3241361353
  3984060476 --> 2563025020
  37984305 --> 3984060476
  2751680898 --> 37984305
  1799060090 --> 3241361353
  4016029557 --> 1799060090
  2852422536 --> 4016029557
  4051874921 --> 2852422536
  2751680898 --> 4051874921
  2021119437 --> 2852422536
  2751680898 --> 2021119437
  1031828782 --> 2852422536
  2751680898 --> 1031828782

🛈 DocStrings

Bases: Settings_

Settings class which wraps everything into a dict to preserve data types.

Source code in prettyqt/core/settings.py
class Settings(Settings_):
    """Settings class which wraps everything into a dict to preserve data types."""

    def set_value(self, key: str, value):
        match value:
            case Settings_():
                setting = dict(value=dict(value), typ="subsetting")
            case _:
                setting = dict(value=value, typ="regular")
        super().set_value(key, setting)

    def get_value(self, key: str, default=None):
        if not self.contains(key):
            return default
        val = self.value(key)
        # TODO: convert settings dicts back?
        match val:
            case {"value": setting}:
                return setting
            case _:
                # this is for migration
                self.set_value(key, val)
                return val

:fa-brands-github: Show source on GitHub