config ====== .. py:module:: qfluentwidgets.common.config Module Contents --------------- .. autoapisummary:: qfluentwidgets.common.config.Theme qfluentwidgets.common.config.ConfigValidator qfluentwidgets.common.config.RangeValidator qfluentwidgets.common.config.OptionsValidator qfluentwidgets.common.config.BoolValidator qfluentwidgets.common.config.FolderValidator qfluentwidgets.common.config.FolderListValidator qfluentwidgets.common.config.ColorValidator qfluentwidgets.common.config.ConfigSerializer qfluentwidgets.common.config.EnumSerializer qfluentwidgets.common.config.ColorSerializer qfluentwidgets.common.config.ConfigItem qfluentwidgets.common.config.RangeConfigItem qfluentwidgets.common.config.OptionsConfigItem qfluentwidgets.common.config.ColorConfigItem qfluentwidgets.common.config.QConfig .. autoapisummary:: qfluentwidgets.common.config.isDarkTheme qfluentwidgets.common.config.theme qfluentwidgets.common.config.isDarkThemeMode .. autoapisummary:: qfluentwidgets.common.config.ALERT qfluentwidgets.common.config.qconfig .. py:data:: ALERT :value: Multiline-String .. raw:: html
Show Value .. code-block:: python """ 📢 Tips: QFluentWidgets Pro is now released. Click https://qfluentwidgets.com/pages/pro to learn more about it. """ .. raw:: html
.. py:class:: Theme Bases: :py:obj:`enum.Enum` Theme enumeration .. py:attribute:: LIGHT :value: 'Light' .. py:attribute:: DARK :value: 'Dark' .. py:attribute:: AUTO :value: 'Auto' .. py:class:: ConfigValidator Config validator .. py:method:: validate(value) Verify whether the value is legal .. py:method:: correct(value) correct illegal value .. py:class:: RangeValidator(min, max) Bases: :py:obj:`ConfigValidator` Range validator .. py:attribute:: min .. py:attribute:: max .. py:attribute:: range .. py:method:: validate(value) Verify whether the value is legal .. py:method:: correct(value) correct illegal value .. py:class:: OptionsValidator(options) Bases: :py:obj:`ConfigValidator` Options validator .. py:attribute:: options .. py:method:: validate(value) Verify whether the value is legal .. py:method:: correct(value) correct illegal value .. py:class:: BoolValidator Bases: :py:obj:`OptionsValidator` Boolean validator .. py:class:: FolderValidator Bases: :py:obj:`ConfigValidator` Folder validator .. py:method:: validate(value) Verify whether the value is legal .. py:method:: correct(value) correct illegal value .. py:class:: FolderListValidator Bases: :py:obj:`ConfigValidator` Folder list validator .. py:method:: validate(value) Verify whether the value is legal .. py:method:: correct(value: List[str]) correct illegal value .. py:class:: ColorValidator(default) Bases: :py:obj:`ConfigValidator` RGB color validator .. py:attribute:: default .. py:method:: validate(color) Verify whether the value is legal .. py:method:: correct(value) correct illegal value .. py:class:: ConfigSerializer Config serializer .. py:method:: serialize(value) serialize config value .. py:method:: deserialize(value) deserialize config from config file's value .. py:class:: EnumSerializer(enumClass) Bases: :py:obj:`ConfigSerializer` enumeration class serializer .. py:attribute:: enumClass .. py:method:: serialize(value) serialize config value .. py:method:: deserialize(value) deserialize config from config file's value .. py:class:: ColorSerializer Bases: :py:obj:`ConfigSerializer` QColor serializer .. py:method:: serialize(value: PyQt5.QtGui.QColor) serialize config value .. py:method:: deserialize(value) deserialize config from config file's value .. py:class:: ConfigItem(group, name, default, validator=None, serializer=None, restart=False) Bases: :py:obj:`PyQt5.QtCore.QObject` Config item .. py:attribute:: valueChanged .. py:attribute:: group .. py:attribute:: name .. py:attribute:: validator .. py:attribute:: serializer .. py:property:: value get the value of config item .. py:attribute:: restart :value: False .. py:attribute:: defaultValue .. py:property:: key get the config key separated by `.` .. py:method:: __str__() .. py:method:: serialize() .. py:method:: deserializeFrom(value) .. py:class:: RangeConfigItem(group, name, default, validator=None, serializer=None, restart=False) Bases: :py:obj:`ConfigItem` Config item of range .. py:property:: range get the available range of config .. py:method:: __str__() .. py:class:: OptionsConfigItem(group, name, default, validator=None, serializer=None, restart=False) Bases: :py:obj:`ConfigItem` Config item with options .. py:property:: options .. py:method:: __str__() .. py:class:: ColorConfigItem(group, name, default, restart=False) Bases: :py:obj:`ConfigItem` Color config item .. py:method:: __str__() .. py:class:: QConfig Bases: :py:obj:`PyQt5.QtCore.QObject` Config of app .. py:attribute:: appRestartSig .. py:attribute:: themeChanged .. py:attribute:: themeChangedFinished .. py:attribute:: themeColorChanged .. py:attribute:: themeMode .. py:attribute:: themeColor .. py:attribute:: fontFamilies .. py:attribute:: file .. py:method:: get(item) get the value of config item .. py:method:: set(item, value, save=True, copy=True) set the value of config item Parameters ---------- item: ConfigItem config item value: the new value of config item save: bool whether to save the change to config file copy: bool whether to deep copy the new value .. py:method:: toDict(serialize=True) convert config items to `dict` .. py:method:: save() save config .. py:method:: load(file=None, config=None) load config Parameters ---------- file: str or Path the path of json config file config: Config config object to be initialized .. py:property:: theme get theme mode, can be `Theme.Light` or `Theme.Dark` .. py:data:: qconfig .. py:function:: isDarkTheme() whether the theme is dark mode .. py:function:: theme() get theme mode .. py:function:: isDarkThemeMode(theme=Theme.AUTO) whether the theme is dark mode