RinUI 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. RinUI/__init__.py +4 -4
  2. RinUI/assets/fonts/FluentSystemIcons-Index.js +5255 -5255
  3. RinUI/components/Base.qml +78 -78
  4. RinUI/components/BasicInput/Button.qml +146 -146
  5. RinUI/components/BasicInput/CheckBox.qml +98 -98
  6. RinUI/components/BasicInput/ComboBox.qml +159 -159
  7. RinUI/components/BasicInput/DropDownButton.qml +20 -20
  8. RinUI/components/BasicInput/Hyperlink.qml +17 -17
  9. RinUI/components/BasicInput/PillButton.qml +10 -10
  10. RinUI/components/BasicInput/RadioButton.qml +94 -94
  11. RinUI/components/BasicInput/RoundButton.qml +26 -26
  12. RinUI/components/BasicInput/Slider.qml +212 -212
  13. RinUI/components/BasicInput/Switch.qml +101 -101
  14. RinUI/components/BasicInput/ToggleButton.qml +10 -10
  15. RinUI/components/BasicInput/ToolButton.qml +30 -30
  16. RinUI/components/ContextMenu.qml +183 -183
  17. RinUI/components/DateAndTime/DatePicker.qml +142 -140
  18. RinUI/components/DateAndTime/PickerView.qml +223 -223
  19. RinUI/components/DateAndTime/TimePicker.qml +114 -114
  20. RinUI/components/DialogsAndFlyouts/Dialog.qml +106 -106
  21. RinUI/components/DialogsAndFlyouts/DialogButtonBox.qml +47 -47
  22. RinUI/components/DialogsAndFlyouts/Flyout.qml +87 -87
  23. RinUI/components/DialogsAndFlyouts/Popup.qml +110 -106
  24. RinUI/components/FocusIndicator.qml +33 -33
  25. RinUI/components/IconWidget.qml +52 -52
  26. RinUI/components/Indicator.qml +89 -89
  27. RinUI/components/Layout/Expander.qml +159 -159
  28. RinUI/components/Layout/SettingExpander.qml +66 -66
  29. RinUI/components/Layout/SettingItem.qml +70 -70
  30. RinUI/components/ListAndCollections/Clip.qml +21 -21
  31. RinUI/components/ListAndCollections/Frame.qml +43 -43
  32. RinUI/components/ListAndCollections/ListView.qml +104 -104
  33. RinUI/components/ListAndCollections/ListViewDelegate.qml +82 -82
  34. RinUI/components/ListAndCollections/SettingCard.qml +72 -72
  35. RinUI/components/ListAndCollections/TableView.qml +81 -81
  36. RinUI/components/ListAndCollections/TableViewDelegate.qml +88 -88
  37. RinUI/components/Media/Avatar.qml +82 -82
  38. RinUI/components/MenusAndToolbars/Menu.qml +150 -150
  39. RinUI/components/MenusAndToolbars/MenuBar.qml +42 -42
  40. RinUI/components/MenusAndToolbars/MenuItem.qml +131 -131
  41. RinUI/components/MenusAndToolbars/MenuItemGroup.qml +43 -43
  42. RinUI/components/MenusAndToolbars/MenuSeparator.qml +13 -13
  43. RinUI/components/MenusAndToolbars/TextInputMenu.qml +37 -37
  44. RinUI/components/MenusAndToolbars/ToolSeparator.qml +16 -16
  45. RinUI/components/Navigation/ErrorPage.qml +48 -48
  46. RinUI/components/Navigation/NavigationBar.qml +179 -179
  47. RinUI/components/Navigation/NavigationItem.qml +193 -193
  48. RinUI/components/Navigation/NavigationSubItem.qml +103 -103
  49. RinUI/components/Navigation/NavigationView.qml +228 -227
  50. RinUI/components/Navigation/Segmented.qml +16 -16
  51. RinUI/components/Navigation/SegmentedItem.qml +107 -107
  52. RinUI/components/Navigation/SelectorBar.qml +12 -12
  53. RinUI/components/Navigation/SelectorBarItem.qml +88 -88
  54. RinUI/components/ScrollBar.qml +204 -204
  55. RinUI/components/ScrollView.qml +12 -12
  56. RinUI/components/Shadow.qml +47 -47
  57. RinUI/components/StatusAndInfo/InfoBadge.qml +77 -77
  58. RinUI/components/StatusAndInfo/InfoBar.qml +256 -251
  59. RinUI/components/StatusAndInfo/ProgressBar.qml +126 -126
  60. RinUI/components/StatusAndInfo/ProgressRing.qml +149 -0
  61. RinUI/components/StatusAndInfo/Toast.qml +236 -236
  62. RinUI/components/StatusAndInfo/ToolTip.qml +93 -93
  63. RinUI/components/Text/SpinBox.qml +150 -133
  64. RinUI/components/Text/Text.qml +44 -44
  65. RinUI/components/Text/TextArea.qml +117 -117
  66. RinUI/components/Text/TextField.qml +113 -113
  67. RinUI/components/Text/TextInput.qml +47 -47
  68. RinUI/components/qmldir +80 -80
  69. RinUI/core/__init__.py +4 -4
  70. RinUI/core/config.py +129 -129
  71. RinUI/core/launcher.py +129 -129
  72. RinUI/core/theme.py +339 -339
  73. RinUI/core/translator.py +25 -25
  74. RinUI/hooks/__init__.py +3 -3
  75. RinUI/hooks/hook-RinUI.py +3 -3
  76. RinUI/qmldir +108 -104
  77. RinUI/themes/Appearance.qml +36 -0
  78. RinUI/themes/Colors.qml +36 -0
  79. RinUI/themes/dark.qml +145 -145
  80. RinUI/themes/light.qml +145 -145
  81. RinUI/themes/qmldir +9 -6
  82. RinUI/themes/theme.qml +151 -149
  83. RinUI/themes/utils.qml +37 -37
  84. RinUI/utils/Animation.qml +12 -12
  85. RinUI/utils/FloatLayer.qml +132 -123
  86. RinUI/utils/FontIconLoader.qml +13 -13
  87. RinUI/utils/Position.qml +19 -19
  88. RinUI/utils/Severity.qml +13 -13
  89. RinUI/utils/Typography.qml +17 -17
  90. RinUI/utils/qmldir +4 -4
  91. RinUI/windows/CtrlBtn.qml +118 -118
  92. RinUI/windows/FluentPage.qml +92 -92
  93. RinUI/windows/FluentWindow.qml +31 -30
  94. RinUI/windows/FluentWindowBase.qml +158 -158
  95. RinUI/windows/TitleBar.qml +135 -135
  96. RinUI/windows/qmldir +7 -7
  97. RinUI/windows/window/ApplicationWindow.qml +8 -8
  98. RinUI/windows/window/Window.qml +118 -118
  99. {rinui-0.1.0.data → rinui-0.1.1.data}/data/LICENSE +21 -21
  100. {rinui-0.1.0.data → rinui-0.1.1.data}/data/README.md +100 -100
  101. {rinui-0.1.0.dist-info → rinui-0.1.1.dist-info}/METADATA +116 -115
  102. rinui-0.1.1.dist-info/RECORD +112 -0
  103. {rinui-0.1.0.dist-info → rinui-0.1.1.dist-info}/WHEEL +1 -1
  104. {rinui-0.1.0.dist-info → rinui-0.1.1.dist-info/licenses}/LICENSE +21 -21
  105. RinUI/__pycache__/__init__.cpython-38.pyc +0 -0
  106. RinUI/config/rin_ui.json +0 -8
  107. RinUI/core/__pycache__/__init__.cpython-38.pyc +0 -0
  108. RinUI/core/__pycache__/config.cpython-38.pyc +0 -0
  109. RinUI/core/__pycache__/launcher.cpython-38.pyc +0 -0
  110. RinUI/core/__pycache__/theme.cpython-38.pyc +0 -0
  111. RinUI/core/__pycache__/translator.cpython-38.pyc +0 -0
  112. rinui-0.1.0.dist-info/RECORD +0 -116
  113. {rinui-0.1.0.dist-info → rinui-0.1.1.dist-info}/entry_points.txt +0 -0
  114. {rinui-0.1.0.dist-info → rinui-0.1.1.dist-info}/top_level.txt +0 -0
RinUI/themes/light.qml CHANGED
@@ -1,146 +1,146 @@
1
-
2
- import QtQuick 2.15
3
- import "../themes"
4
-
5
- QtObject {
6
- property string name: "Light"
7
- property bool isDark: false
8
-
9
- // Colors //
10
- property QtObject colors: QtObject {
11
- // Controls
12
- property color controlColor: Qt.alpha("#ffffff", 0.7)
13
- property color controlSecondaryColor: Qt.alpha("#F9F9F9", 0.5)
14
- property color controlTertiaryColor: Qt.alpha("#F9F9F9", 0.3)
15
- property color controlQuaternaryColor: Qt.alpha("#F3F3F3", 0.76)
16
- property color controlStrongColor: Qt.alpha("#000000", 0.4458)
17
- property color controlInputActiveColor: "#ffffff"
18
-
19
- property color controlAltSecondaryColor: Qt.alpha("#000000", 0.0241)
20
- property color controlAltTertiaryColor: Qt.alpha("#000000", 0.0578)
21
- property color controlAltQuaternaryColor: Qt.alpha("#000000", 0.0924)
22
-
23
- property color controlFillColor: Qt.alpha("#ffffff", 0.7)
24
- property color controlFillSecondaryColor: Qt.alpha("#F9F9F9", 0.5)
25
- property color controlFillTertiaryColor: Qt.alpha("#F9F9F9", 0.3)
26
- property color controlFillQuaternaryColor: Qt.alpha("#F3F3F3", 0.76)
27
-
28
- property color controlBorderColor: Qt.alpha("#000000", 0.06)
29
- property color controlBottomBorderColor: Qt.alpha("#000000", 0.16)
30
- property color controlAccentBottomBorderColor: Qt.alpha("#000000", 0.4)
31
- property color controlBorderStrongColor: Qt.alpha("#000000", 0.6063)
32
- property color controlBorderAccentColor: Qt.alpha("#000000", 0.3)
33
- property color textControlBorderColor: Qt.alpha("#000000", 0.45)
34
- property color textControlBorderFocusedColor: Utils.primaryColor
35
- property color flyoutBorderColor: Qt.alpha("#000000", 0.0578)
36
-
37
- property color controlSolidColor: "#ffffff"
38
- property color dividerBorderColor: Qt.alpha("#000000", 0.0803)
39
- // Accessibility
40
- property color focusBorderOuter: Qt.alpha("#000000", 0.8956)
41
- property color focusBorderInner: "#ffffff"
42
-
43
- // Card
44
- property color cardColor: Qt.alpha("#ffffff", 0.7)
45
- property color cardSecondaryColor: Qt.alpha("#F6F6F6", 0.5)
46
- property color cardTertiaryColor: Qt.alpha("#ffffff", 1)
47
- property color cardBorderColor: Qt.alpha("#000000", 0.0578)
48
-
49
- // Background
50
- property color backgroundColor: "#F3F3F3"
51
- property color windowBorderColor: Qt.alpha("#757575", 0.0924)
52
- property color backgroundAcrylicColor: "#F9F9F9"
53
- property color backgroundSmokeColor: Qt.alpha("#000000", 0.3)
54
-
55
- property color subtleColor: Qt.alpha("#ffffff", 0)
56
- property color subtleSecondaryColor: Qt.alpha("#000000", 0.0373)
57
- property color subtleTertiaryColor: Qt.alpha("#000000", 0.0241)
58
- property color captionCloseColor: "#c42b1c"
59
- property color captionCloseTextColor: "#ffffff"
60
-
61
- // Layer
62
- property color layerColor: Qt.alpha("#ffffff", 0.5)
63
-
64
- // Text
65
- property color textColor: "#1b1b1b"
66
- property color textSecondaryColor: Qt.alpha("#000000", 0.6063)
67
- property color textAccentColor: primaryColor
68
- property color textOnAccentColor: "#ffffff"
69
- property color textSelectedColor: "#ffffff"
70
-
71
- property color primaryColor: Utils.primaryColor
72
- property color disabledColor: "#000000"
73
-
74
- // System Colors
75
- property color systemAttentionColor: primaryColor
76
- property color systemSuccessColor: "#0f7b0f"
77
- property color systemCautionColor: "#9d5d00"
78
- property color systemCriticalColor: "#c42b1c"
79
- property color systemNeutralColor: "#8d8d8d"
80
-
81
- property color systemAttentionBackgroundColor: "#fbfbfb"
82
- property color systemSuccessBackgroundColor: "#dff6dd"
83
- property color systemCautionBackgroundColor: "#fff4ce"
84
- property color systemCriticalBackgroundColor: "#fde7e9"
85
- property color systemNeutralBackgroundColor: "#f9f9f9"
86
- }
87
-
88
- // Appearance //
89
- property QtObject appearance: QtObject {
90
- property int buttonRadius: 5
91
- property int borderWidth: 1
92
- property real borderFactor: 0.9
93
- property real borderOnAccentFactor: 1.08
94
- property int smallRadius: 3
95
-
96
- property int dialogTitleBarHeight: 32
97
- property int windowTitleBarHeight: 48
98
- property int windowRadius: 7
99
- property int windowButtonWidth: 46
100
-
101
- property int scrollBarMinWidth: 2
102
- property int scrollBarWidth: 6
103
- property int scrollBarPadding: 3
104
-
105
- property int sliderHandleSize: 20
106
- }
107
-
108
- // Shadows //
109
- property var shadows: {
110
- "dialog": {
111
- "color": Qt.alpha("#000000", 0.19), // 模糊颜色
112
- "blur": 64, // 模糊度
113
- "offsetY": 32
114
- },
115
- "tooltip": {
116
- "color": Qt.alpha("#000000", 0.14),
117
- "blur": 8,
118
- "offsetY": 4
119
- },
120
- "cardRest": {
121
- "color": Qt.alpha("#000000", 0.04),
122
- "blur": 4,
123
- "offsetY": 2
124
- },
125
- "flyout": {
126
- "color": Qt.alpha("#000000", 0.14),
127
- "blur": 24,
128
- "offsetY": 8
129
- },
130
- }
131
-
132
- // Typography //
133
- property QtObject typography: QtObject {
134
- // property string fontFamily: "Segoe UI"
135
- // property string fontIcon: "FluentSystemIcons-Resizeable.ttf" // 字体图标路径 / font icon (put it in the "assets/fonts" folder)
136
- // Font Sizes
137
- property int displaySize: 68
138
- property int titleLargeSize: 40
139
- property int titleSize: 28
140
- property int subtitleSize: 20
141
- property int bodyLargeSize: 18
142
- property int bodySize: 14
143
- property int bodyStrongSize: 14
144
- property int captionSize: 12
145
- }
1
+
2
+ import QtQuick 2.15
3
+ import "../themes"
4
+
5
+ QtObject {
6
+ property string name: "Light"
7
+ property bool isDark: false
8
+
9
+ // Colors //
10
+ property QtObject colors: QtObject {
11
+ // Controls
12
+ property color controlColor: Qt.alpha("#ffffff", 0.7)
13
+ property color controlSecondaryColor: Qt.alpha("#F9F9F9", 0.5)
14
+ property color controlTertiaryColor: Qt.alpha("#F9F9F9", 0.3)
15
+ property color controlQuaternaryColor: Qt.alpha("#F3F3F3", 0.76)
16
+ property color controlStrongColor: Qt.alpha("#000000", 0.4458)
17
+ property color controlInputActiveColor: "#ffffff"
18
+
19
+ property color controlAltSecondaryColor: Qt.alpha("#000000", 0.0241)
20
+ property color controlAltTertiaryColor: Qt.alpha("#000000", 0.0578)
21
+ property color controlAltQuaternaryColor: Qt.alpha("#000000", 0.0924)
22
+
23
+ property color controlFillColor: Qt.alpha("#ffffff", 0.7)
24
+ property color controlFillSecondaryColor: Qt.alpha("#F9F9F9", 0.5)
25
+ property color controlFillTertiaryColor: Qt.alpha("#F9F9F9", 0.3)
26
+ property color controlFillQuaternaryColor: Qt.alpha("#F3F3F3", 0.76)
27
+
28
+ property color controlBorderColor: Qt.alpha("#000000", 0.06)
29
+ property color controlBottomBorderColor: Qt.alpha("#000000", 0.16)
30
+ property color controlAccentBottomBorderColor: Qt.alpha("#000000", 0.4)
31
+ property color controlBorderStrongColor: Qt.alpha("#000000", 0.6063)
32
+ property color controlBorderAccentColor: Qt.alpha("#000000", 0.3)
33
+ property color textControlBorderColor: Qt.alpha("#000000", 0.45)
34
+ property color textControlBorderFocusedColor: Utils.primaryColor
35
+ property color flyoutBorderColor: Qt.alpha("#000000", 0.0578)
36
+
37
+ property color controlSolidColor: "#ffffff"
38
+ property color dividerBorderColor: Qt.alpha("#000000", 0.0803)
39
+ // Accessibility
40
+ property color focusBorderOuter: Qt.alpha("#000000", 0.8956)
41
+ property color focusBorderInner: "#ffffff"
42
+
43
+ // Card
44
+ property color cardColor: Qt.alpha("#ffffff", 0.7)
45
+ property color cardSecondaryColor: Qt.alpha("#F6F6F6", 0.5)
46
+ property color cardTertiaryColor: Qt.alpha("#ffffff", 1)
47
+ property color cardBorderColor: Qt.alpha("#000000", 0.0578)
48
+
49
+ // Background
50
+ property color backgroundColor: "#F3F3F3"
51
+ property color windowBorderColor: Qt.alpha("#757575", 0.0924)
52
+ property color backgroundAcrylicColor: "#F9F9F9"
53
+ property color backgroundSmokeColor: Qt.alpha("#000000", 0.3)
54
+
55
+ property color subtleColor: Qt.alpha("#ffffff", 0)
56
+ property color subtleSecondaryColor: Qt.alpha("#000000", 0.0373)
57
+ property color subtleTertiaryColor: Qt.alpha("#000000", 0.0241)
58
+ property color captionCloseColor: "#c42b1c"
59
+ property color captionCloseTextColor: "#ffffff"
60
+
61
+ // Layer
62
+ property color layerColor: Qt.alpha("#ffffff", 0.5)
63
+
64
+ // Text
65
+ property color textColor: "#1b1b1b"
66
+ property color textSecondaryColor: Qt.alpha("#000000", 0.6063)
67
+ property color textAccentColor: primaryColor
68
+ property color textOnAccentColor: "#ffffff"
69
+ property color textSelectedColor: "#ffffff"
70
+
71
+ property color primaryColor: Utils.primaryColor
72
+ property color disabledColor: "#000000"
73
+
74
+ // System Colors
75
+ property color systemAttentionColor: primaryColor
76
+ property color systemSuccessColor: "#0f7b0f"
77
+ property color systemCautionColor: "#9d5d00"
78
+ property color systemCriticalColor: "#c42b1c"
79
+ property color systemNeutralColor: "#8d8d8d"
80
+
81
+ property color systemAttentionBackgroundColor: "#fbfbfb"
82
+ property color systemSuccessBackgroundColor: "#dff6dd"
83
+ property color systemCautionBackgroundColor: "#fff4ce"
84
+ property color systemCriticalBackgroundColor: "#fde7e9"
85
+ property color systemNeutralBackgroundColor: "#f9f9f9"
86
+ }
87
+
88
+ // Appearance //
89
+ property QtObject appearance: QtObject {
90
+ property int buttonRadius: 5
91
+ property int borderWidth: 1
92
+ property real borderFactor: 0.9
93
+ property real borderOnAccentFactor: 1.08
94
+ property int smallRadius: 3
95
+
96
+ property int dialogTitleBarHeight: 32
97
+ property int windowTitleBarHeight: 48
98
+ property int windowRadius: 7
99
+ property int windowButtonWidth: 46
100
+
101
+ property int scrollBarMinWidth: 2
102
+ property int scrollBarWidth: 6
103
+ property int scrollBarPadding: 3
104
+
105
+ property int sliderHandleSize: 20
106
+ }
107
+
108
+ // Shadows //
109
+ property var shadows: {
110
+ "dialog": {
111
+ "color": Qt.alpha("#000000", 0.19), // 模糊颜色
112
+ "blur": 64, // 模糊度
113
+ "offsetY": 32
114
+ },
115
+ "tooltip": {
116
+ "color": Qt.alpha("#000000", 0.14),
117
+ "blur": 8,
118
+ "offsetY": 4
119
+ },
120
+ "cardRest": {
121
+ "color": Qt.alpha("#000000", 0.04),
122
+ "blur": 4,
123
+ "offsetY": 2
124
+ },
125
+ "flyout": {
126
+ "color": Qt.alpha("#000000", 0.14),
127
+ "blur": 24,
128
+ "offsetY": 8
129
+ },
130
+ }
131
+
132
+ // Typography //
133
+ property QtObject typography: QtObject {
134
+ // property string fontFamily: "Segoe UI"
135
+ // property string fontIcon: "FluentSystemIcons-Resizeable.ttf" // 字体图标路径 / font icon (put it in the "assets/fonts" folder)
136
+ // Font Sizes
137
+ property int displaySize: 68
138
+ property int titleLargeSize: 40
139
+ property int titleSize: 28
140
+ property int subtitleSize: 20
141
+ property int bodyLargeSize: 18
142
+ property int bodySize: 14
143
+ property int bodyStrongSize: 14
144
+ property int captionSize: 12
145
+ }
146
146
  }
RinUI/themes/qmldir CHANGED
@@ -1,7 +1,10 @@
1
- module RinUI.themes
2
-
3
- singleton Theme 1.0 theme.qml
4
- singleton Utils 1.0 utils.qml
5
-
6
- Light 1.0 light.qml
1
+ module RinUI.themes
2
+
3
+ singleton Theme 1.0 theme.qml
4
+ singleton Utils 1.0 utils.qml
5
+ singleton Colors Colors.qml
6
+ singleton Appearance Appearance.qml
7
+
8
+
9
+ Light 1.0 light.qml
7
10
  Dark 1.0 dark.qml
RinUI/themes/theme.qml CHANGED
@@ -1,150 +1,152 @@
1
- pragma Singleton
2
- import QtQuick 2.15
3
- // import "../themes"
4
-
5
- Item {
6
- id: themeManager
7
-
8
- property var currentTheme: null
9
- readonly property var mode: ({
10
- Light: "Light",
11
- Dark: "Dark",
12
- Auto: "Auto"
13
- })
14
- readonly property var effect: ({
15
- Mica: "mica",
16
- Acrylic: "acrylic",
17
- Tabbed: "tabbed",
18
- None: "none"
19
- })
20
-
21
- // 初始化时设置默认主题
22
- Component.onCompleted: {
23
- if (typeof ThemeManager === "undefined") {
24
- currentTheme = Qt.createQmlObject("import '../themes'; Light {}", themeManager)
25
- } else {
26
- Utils.primaryColor = getThemeColor()
27
- setTheme(ThemeManager.get_theme_name())
28
- }
29
- }
30
-
31
- function _isThemeMgrInitialized() {
32
- return typeof ThemeManager!== "undefined"
33
- }
34
-
35
- function setBackdropEffect(effect) {
36
- if (!_isThemeMgrInitialized()) {
37
- console.error("ThemeManager is not defined.")
38
- return -1
39
- }
40
- ThemeManager.apply_backdrop_effect(effect)
41
- }
42
-
43
- function sendDragWindowEvent(window) {
44
- if (!_isThemeMgrInitialized()) {
45
- console.error("ThemeManager is not defined.")
46
- return -1
47
- }
48
- ThemeManager.dragWindowEvent(ThemeManager.getWindowId(window))
49
- }
50
-
51
- function getBackdropEffect() {
52
- if (!_isThemeMgrInitialized()) {
53
- console.error("ThemeManager is not defined.")
54
- return -1
55
- }
56
- return ThemeManager.get_backdrop_effect()
57
- }
58
-
59
- function setThemeColor(color) {
60
- if (!_isThemeMgrInitialized()) {
61
- console.error("ThemeManager is not defined.")
62
- return -1
63
- }
64
- if (typeof color !== "string") {
65
- console.error("Invalid color format. Expected a string.")
66
- return -1
67
- }
68
- Utils.primaryColor = color
69
- ThemeManager.set_theme_color(color)
70
- }
71
-
72
- function getThemeColor() {
73
- if (!_isThemeMgrInitialized()) {
74
- console.error("ThemeManager is not defined.")
75
- return -1
76
- }
77
- return ThemeManager.get_theme_color()
78
- }
79
-
80
- function getTheme() {
81
- if (!_isThemeMgrInitialized()) {
82
- console.error("ThemeManager is not defined.")
83
- return -1
84
- }
85
- return ThemeManager.get_theme_name()
86
- }
87
-
88
- // 本来打算写多主题支持的()
89
-
90
- function toggleMode() {
91
- if (!_isThemeMgrInitialized()) {
92
- console.error("ThemeManager is not defined.")
93
- return -1
94
- }
95
- let theme_mode;
96
- if (!currentTheme.isDark) {
97
- theme_mode = mode.Dark
98
- } else {
99
- theme_mode = mode.Light
100
- }
101
- setTheme(theme_mode)
102
- }
103
-
104
- // 切换主题
105
- function setTheme(theme_mode: mode) {
106
- if (!_isThemeMgrInitialized()) {
107
- console.error("ThemeManager is not defined.")
108
- currentTheme = Qt.createQmlObject("import '../themes'; Light {}", themeManager)
109
- return
110
- }
111
-
112
- // Call Python backend to toggle theme
113
- ThemeManager.toggle_theme(theme_mode)
114
-
115
- // Get the actual theme name
116
- var themeName = ThemeManager.get_theme_name()
117
- if (themeName === mode.Auto) {
118
- // Get the actual theme applied (Light or Dark)
119
- themeName = ThemeManager.get_theme()
120
- }
121
- load_qml(themeName)
122
- return 0;
123
- }
124
-
125
- function load_qml(themeName) {
126
- if (themeName) {
127
- let themeObject = Qt.createQmlObject("import '../themes'; " + themeName + " {}", themeManager)
128
- let mode = ThemeManager.get_theme()
129
- if (themeObject) {
130
- currentTheme = themeObject
131
- console.log("Switched to", mode, "mode")
132
- } else {
133
- console.error("Failed to create theme object for mode:", mode)
134
- }
135
- } else {
136
- console.error("Invalid theme mode:", mode)
137
- }
138
- }
139
-
140
- // 监听系统主题变化
141
- Connections {
142
- target: ThemeManager
143
- function onThemeChanged(theme) {
144
- load_qml(theme)
145
- }
146
- function onBackdropChanged(effect) {
147
- Utils.backdropEnabled = effect !== "none";
148
- }
149
- }
1
+ pragma Singleton
2
+ import QtQuick 2.15
3
+ // import "../themes"
4
+
5
+ Item {
6
+ id: themeManager
7
+
8
+ property var currentTheme: null
9
+ readonly property var mode: ({
10
+ Light: "Light",
11
+ Dark: "Dark",
12
+ Auto: "Auto"
13
+ })
14
+ readonly property var effect: ({
15
+ Mica: "mica",
16
+ Acrylic: "acrylic",
17
+ Tabbed: "tabbed",
18
+ None: "none"
19
+ })
20
+
21
+ // 初始化时设置默认主题
22
+ Component.onCompleted: {
23
+ if (typeof ThemeManager === "undefined") {
24
+ currentTheme = Qt.createQmlObject("import '../themes'; Light {}", themeManager)
25
+ } else {
26
+ Utils.primaryColor = getThemeColor()
27
+ setTheme(ThemeManager.get_theme_name())
28
+ }
29
+ }
30
+
31
+ function _isThemeMgrInitialized() {
32
+ return typeof ThemeManager!== "undefined"
33
+ }
34
+
35
+ function isDark() {
36
+ return currentTheme.isDark
37
+ }
38
+
39
+ function setBackdropEffect(effect) {
40
+ if (!_isThemeMgrInitialized()) {
41
+ console.error("ThemeManager is not defined.")
42
+ return -1
43
+ }
44
+ ThemeManager.apply_backdrop_effect(effect)
45
+ }
46
+
47
+ function sendDragWindowEvent(window) {
48
+ if (!_isThemeMgrInitialized()) {
49
+ console.error("ThemeManager is not defined.")
50
+ return -1
51
+ }
52
+ ThemeManager.dragWindowEvent(ThemeManager.getWindowId(window))
53
+ }
54
+
55
+ function getBackdropEffect() {
56
+ if (!_isThemeMgrInitialized()) {
57
+ console.error("ThemeManager is not defined.")
58
+ return -1
59
+ }
60
+ return ThemeManager.get_backdrop_effect()
61
+ }
62
+
63
+ function setThemeColor(color) {
64
+ if (!_isThemeMgrInitialized()) {
65
+ console.error("ThemeManager is not defined.")
66
+ return -1
67
+ }
68
+ if (typeof color !== "string") {
69
+ console.error("Invalid color format. Expected a string.")
70
+ return -1
71
+ }
72
+ Utils.primaryColor = color
73
+ ThemeManager.set_theme_color(color)
74
+ }
75
+
76
+ function getThemeColor() {
77
+ if (!_isThemeMgrInitialized()) {
78
+ console.error("ThemeManager is not defined.")
79
+ return -1
80
+ }
81
+ return ThemeManager.get_theme_color()
82
+ }
83
+
84
+ function getTheme() {
85
+ if (!_isThemeMgrInitialized()) {
86
+ console.error("ThemeManager is not defined.")
87
+ return -1
88
+ }
89
+ return ThemeManager.get_theme_name()
90
+ }
91
+
92
+ function toggleMode() {
93
+ if (!_isThemeMgrInitialized()) {
94
+ console.error("ThemeManager is not defined.")
95
+ return -1
96
+ }
97
+ let theme_mode;
98
+ if (!currentTheme.isDark) {
99
+ theme_mode = mode.Dark
100
+ } else {
101
+ theme_mode = mode.Light
102
+ }
103
+ setTheme(theme_mode)
104
+ }
105
+
106
+ // 切换主题
107
+ function setTheme(theme_mode: mode) {
108
+ if (!_isThemeMgrInitialized()) {
109
+ console.error("ThemeManager is not defined.")
110
+ currentTheme = Qt.createQmlObject("import '../themes'; Light {}", themeManager)
111
+ return
112
+ }
113
+
114
+ // Call Python backend to toggle theme
115
+ ThemeManager.toggle_theme(theme_mode)
116
+
117
+ // Get the actual theme name
118
+ var themeName = ThemeManager.get_theme_name()
119
+ if (themeName === mode.Auto) {
120
+ // Get the actual theme applied (Light or Dark)
121
+ themeName = ThemeManager.get_theme()
122
+ }
123
+ load_qml(themeName)
124
+ return 0;
125
+ }
126
+
127
+ function load_qml(themeName) {
128
+ if (themeName) {
129
+ let themeObject = Qt.createQmlObject("import '../themes'; " + themeName + " {}", themeManager)
130
+ let mode = ThemeManager.get_theme()
131
+ if (themeObject) {
132
+ currentTheme = themeObject
133
+ console.log("Switched to", mode, "mode")
134
+ } else {
135
+ console.error("Failed to create theme object for mode:", mode)
136
+ }
137
+ } else {
138
+ console.error("Invalid theme mode:", mode)
139
+ }
140
+ }
141
+
142
+ // 监听系统主题变化
143
+ Connections {
144
+ target: ThemeManager
145
+ function onThemeChanged(theme) {
146
+ load_qml(theme)
147
+ }
148
+ function onBackdropChanged(effect) {
149
+ Utils.backdropEnabled = effect !== "none";
150
+ }
151
+ }
150
152
  }