eric7/Preferences/ThemeManager.py

Wed, 08 Dec 2021 19:52:00 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 08 Dec 2021 19:52:00 +0100
branch
eric7
changeset 8817
92214d84beef
child 8819
982fb074be98
permissions
-rw-r--r--

Started implementing a manager for color themes.

# -*- coding: utf-8 -*-

# Copyright (c) 2021 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing a manager object for color themes.
"""

import re

from PyQt6.QtCore import QObject

import Preferences


class ThemeManager(QObject):
    """
    Class implementing a manager object for color themes.
    """
    KeyPatternList = [
        "Diff/.*Color",
        "Editor/Colour/",
        "IRC/.*Colou?r",
        "Project/Colour",
        "Scintilla/.*color",
        "Scintilla/.*paper",
        "WebBrowser/.*Colou?r",
    ]
    KeyList = [
        "Debugger/BgColorChanged",
        "Debugger/BgColorNew",
        "UI/IconBarColor",
        "UI/LogStdErrColour",
        "UI/NotificationCriticalBackground",
        "UI/NotificationCriticalForeground",
        "UI/NotificationWarningBackground",
        "UI/NotificationWarningForeground",
    ]
    
    def __init__(self, parent=None):
        """
        Constructor
        
        @param parent reference to the parent object (defaults to None)
        @type QObject (optional)
        """
        super().__init__(parent)
    
    def importTheme(self):
        """
        Public method to import a theme file and set the colors.
        """
        # TODO: not yet implemented
    
    def exportTheme(self):
        """
        Public method to export the current colors to a theme file.
        """
        # TODO: not yet implemented
        settings = Preferences.getSettings()
        keyFilterRe = re.compile("|".join(
            ThemeManager.KeyPatternList + ThemeManager.KeyList))
        
        keys = [k for k in settings.allKeys() if keyFilterRe.match(k)]
        themeDict = {}
        for key in keys:
            themeDict[key] = settings.value(key)
        
        # TODO: save to a json file *.ethj

eric ide

mercurial