1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# Copyright (C) 2023 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import json
from pathlib import Path
from PySide6.QtCore import Slot, QObject, Property, Signal
from PySide6.QtGui import QColor
from PySide6.QtQml import QmlNamedElement, QmlSingleton
QML_IMPORT_NAME = "FileSystemModule"
QML_IMPORT_MAJOR_VERSION = 1
@QmlNamedElement("Colors")
@QmlSingleton
class SchemeManager(QObject):
schemeChanged = Signal()
def __init__(self, parent=None):
super().__init__(parent=parent)
with open(Path(__file__).parent / "schemes.json", 'r') as f:
self.m_schemes = json.load(f)
self.m_activeScheme = {}
self.m_activeSchemeName = "Catppuccin"
self.setScheme(self.m_activeSchemeName)
@Slot(str)
def setScheme(self, theme):
for k, v in self.m_schemes[theme].items():
self.m_activeScheme[k] = QColor.fromString(v)
self.m_activeSchemeName = theme
self.schemeChanged.emit()
@Slot(result='QStringList')
def getKeys(self):
return self.m_schemes.keys()
@Property('QStringList', notify=schemeChanged)
def currentColors(self):
return self.m_schemes[self.m_activeSchemeName].values()
@Property(QColor, notify=schemeChanged)
def background(self):
return self.m_activeScheme["background"]
@Property(QColor, notify=schemeChanged)
def surface1(self):
return self.m_activeScheme["surface1"]
@Property(QColor, notify=schemeChanged)
def surface2(self):
return self.m_activeScheme["surface2"]
@Property(QColor, notify=schemeChanged)
def text(self):
return self.m_activeScheme["text"]
@Property(QColor, notify=schemeChanged)
def textFile(self):
return self.m_activeScheme["textFile"]
@Property(QColor, notify=schemeChanged)
def disabledText(self):
return self.m_activeScheme["disabledText"]
@Property(QColor, notify=schemeChanged)
def selection(self):
return self.m_activeScheme["selection"]
@Property(QColor, notify=schemeChanged)
def active(self):
return self.m_activeScheme["active"]
@Property(QColor, notify=schemeChanged)
def inactive(self):
return self.m_activeScheme["inactive"]
@Property(QColor, notify=schemeChanged)
def folder(self):
return self.m_activeScheme["folder"]
@Property(QColor, notify=schemeChanged)
def icon(self):
return self.m_activeScheme["icon"]
@Property(QColor, notify=schemeChanged)
def iconIndicator(self):
return self.m_activeScheme["iconIndicator"]
@Property(QColor, notify=schemeChanged)
def color1(self):
return self.m_activeScheme["color1"]
@Property(QColor, notify=schemeChanged)
def color2(self):
return self.m_activeScheme["color2"]
|