RinUI 0.0.11__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 (115) hide show
  1. RinUI/__init__.py +4 -4
  2. RinUI/assets/fonts/FluentSystemIcons-Index.js +5255 -5255
  3. RinUI/assets/img/default_app_icon.png +0 -0
  4. RinUI/components/Base.qml +78 -78
  5. RinUI/components/BasicInput/Button.qml +146 -147
  6. RinUI/components/BasicInput/CheckBox.qml +98 -98
  7. RinUI/components/BasicInput/ComboBox.qml +159 -159
  8. RinUI/components/BasicInput/DropDownButton.qml +20 -20
  9. RinUI/components/BasicInput/Hyperlink.qml +17 -17
  10. RinUI/components/BasicInput/PillButton.qml +10 -10
  11. RinUI/components/BasicInput/RadioButton.qml +94 -94
  12. RinUI/components/BasicInput/RoundButton.qml +26 -26
  13. RinUI/components/BasicInput/Slider.qml +212 -212
  14. RinUI/components/BasicInput/Switch.qml +101 -101
  15. RinUI/components/BasicInput/ToggleButton.qml +10 -10
  16. RinUI/components/BasicInput/ToolButton.qml +30 -30
  17. RinUI/components/ContextMenu.qml +183 -183
  18. RinUI/components/DateAndTime/DatePicker.qml +142 -140
  19. RinUI/components/DateAndTime/PickerView.qml +223 -223
  20. RinUI/components/DateAndTime/TimePicker.qml +114 -114
  21. RinUI/components/DialogsAndFlyouts/Dialog.qml +106 -106
  22. RinUI/components/DialogsAndFlyouts/DialogButtonBox.qml +47 -47
  23. RinUI/components/DialogsAndFlyouts/Flyout.qml +87 -144
  24. RinUI/components/DialogsAndFlyouts/Popup.qml +110 -106
  25. RinUI/components/FocusIndicator.qml +33 -33
  26. RinUI/components/IconWidget.qml +52 -52
  27. RinUI/components/Indicator.qml +89 -89
  28. RinUI/components/Layout/Expander.qml +159 -159
  29. RinUI/components/Layout/SettingExpander.qml +66 -66
  30. RinUI/components/Layout/SettingItem.qml +70 -70
  31. RinUI/components/ListAndCollections/Clip.qml +21 -21
  32. RinUI/components/ListAndCollections/Frame.qml +43 -43
  33. RinUI/components/ListAndCollections/ListView.qml +104 -104
  34. RinUI/components/ListAndCollections/ListViewDelegate.qml +82 -82
  35. RinUI/components/ListAndCollections/SettingCard.qml +72 -72
  36. RinUI/components/ListAndCollections/TableView.qml +81 -81
  37. RinUI/components/ListAndCollections/TableViewDelegate.qml +88 -88
  38. RinUI/components/Media/Avatar.qml +83 -0
  39. RinUI/components/MenusAndToolbars/Menu.qml +150 -150
  40. RinUI/components/MenusAndToolbars/MenuBar.qml +42 -42
  41. RinUI/components/MenusAndToolbars/MenuItem.qml +131 -131
  42. RinUI/components/MenusAndToolbars/MenuItemGroup.qml +43 -43
  43. RinUI/components/MenusAndToolbars/MenuSeparator.qml +13 -13
  44. RinUI/components/MenusAndToolbars/TextInputMenu.qml +37 -37
  45. RinUI/components/MenusAndToolbars/ToolSeparator.qml +16 -16
  46. RinUI/components/Navigation/ErrorPage.qml +48 -48
  47. RinUI/components/Navigation/NavigationBar.qml +179 -179
  48. RinUI/components/Navigation/NavigationItem.qml +193 -193
  49. RinUI/components/Navigation/NavigationSubItem.qml +103 -103
  50. RinUI/components/Navigation/NavigationView.qml +228 -227
  51. RinUI/components/Navigation/Segmented.qml +17 -0
  52. RinUI/components/Navigation/SegmentedItem.qml +108 -0
  53. RinUI/components/Navigation/SelectorBar.qml +12 -57
  54. RinUI/components/Navigation/SelectorBarItem.qml +89 -0
  55. RinUI/components/ScrollBar.qml +204 -204
  56. RinUI/components/ScrollView.qml +12 -12
  57. RinUI/components/Shadow.qml +47 -47
  58. RinUI/components/StatusAndInfo/InfoBadge.qml +77 -77
  59. RinUI/components/StatusAndInfo/InfoBar.qml +256 -251
  60. RinUI/components/StatusAndInfo/ProgressBar.qml +126 -126
  61. RinUI/components/StatusAndInfo/ProgressRing.qml +149 -0
  62. RinUI/components/StatusAndInfo/Toast.qml +236 -236
  63. RinUI/components/StatusAndInfo/ToolTip.qml +93 -93
  64. RinUI/components/Text/SpinBox.qml +150 -133
  65. RinUI/components/Text/Text.qml +44 -44
  66. RinUI/components/Text/TextArea.qml +117 -117
  67. RinUI/components/Text/TextField.qml +113 -113
  68. RinUI/components/Text/TextInput.qml +47 -47
  69. RinUI/components/qmldir +80 -77
  70. RinUI/core/__init__.py +4 -4
  71. RinUI/core/config.py +129 -129
  72. RinUI/core/launcher.py +129 -129
  73. RinUI/core/theme.py +339 -339
  74. RinUI/core/translator.py +25 -25
  75. RinUI/hooks/__init__.py +3 -3
  76. RinUI/hooks/hook-RinUI.py +3 -3
  77. RinUI/qmldir +108 -97
  78. RinUI/themes/Appearance.qml +36 -0
  79. RinUI/themes/Colors.qml +36 -0
  80. RinUI/themes/dark.qml +145 -136
  81. RinUI/themes/light.qml +145 -136
  82. RinUI/themes/qmldir +9 -6
  83. RinUI/themes/theme.qml +151 -149
  84. RinUI/themes/utils.qml +37 -37
  85. RinUI/utils/Animation.qml +12 -12
  86. RinUI/utils/FloatLayer.qml +132 -123
  87. RinUI/utils/FontIconLoader.qml +13 -13
  88. RinUI/utils/Position.qml +19 -19
  89. RinUI/utils/Severity.qml +13 -13
  90. RinUI/utils/Typography.qml +17 -17
  91. RinUI/utils/qmldir +4 -4
  92. RinUI/windows/CtrlBtn.qml +118 -118
  93. RinUI/windows/FluentPage.qml +92 -92
  94. RinUI/windows/FluentWindow.qml +31 -30
  95. RinUI/windows/FluentWindowBase.qml +158 -158
  96. RinUI/windows/TitleBar.qml +135 -135
  97. RinUI/windows/qmldir +7 -7
  98. RinUI/windows/window/ApplicationWindow.qml +8 -8
  99. RinUI/windows/window/Window.qml +118 -118
  100. {rinui-0.0.11.data → rinui-0.1.1.data}/data/LICENSE +21 -21
  101. {rinui-0.0.11.data → rinui-0.1.1.data}/data/README.md +100 -97
  102. {rinui-0.0.11.dist-info → rinui-0.1.1.dist-info}/METADATA +116 -112
  103. rinui-0.1.1.dist-info/RECORD +112 -0
  104. {rinui-0.0.11.dist-info → rinui-0.1.1.dist-info}/WHEEL +1 -1
  105. {rinui-0.0.11.dist-info → rinui-0.1.1.dist-info/licenses}/LICENSE +21 -21
  106. RinUI/__pycache__/__init__.cpython-38.pyc +0 -0
  107. RinUI/config/rin_ui.json +0 -8
  108. RinUI/core/__pycache__/__init__.cpython-38.pyc +0 -0
  109. RinUI/core/__pycache__/config.cpython-38.pyc +0 -0
  110. RinUI/core/__pycache__/launcher.cpython-38.pyc +0 -0
  111. RinUI/core/__pycache__/theme.cpython-38.pyc +0 -0
  112. RinUI/core/__pycache__/translator.cpython-38.pyc +0 -0
  113. rinui-0.0.11.dist-info/RECORD +0 -112
  114. {rinui-0.0.11.dist-info → rinui-0.1.1.dist-info}/entry_points.txt +0 -0
  115. {rinui-0.0.11.dist-info → rinui-0.1.1.dist-info}/top_level.txt +0 -0
RinUI/themes/light.qml CHANGED
@@ -1,137 +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 controlBorderColor: Qt.alpha("#000000", 0.06)
20
- property color controlBottomBorderColor: Qt.alpha("#000000", 0.16)
21
- property color controlAccentBottomBorderColor: Qt.alpha("#000000", 0.4)
22
- property color controlBorderStrongColor: Qt.alpha("#000000", 0.6063)
23
- property color controlBorderAccentColor: Qt.alpha("#000000", 0.3)
24
- property color textControlBorderColor: Qt.alpha("#000000", 0.45)
25
- property color textControlBorderFocusedColor: Utils.primaryColor
26
- property color flyoutBorderColor: Qt.alpha("#000000", 0.0578)
27
-
28
- property color controlSolidColor: "#ffffff"
29
- property color dividerBorderColor: Qt.alpha("#000000", 0.0803)
30
- // Accessibility
31
- property color focusBorderOuter: Qt.alpha("#000000", 0.8956)
32
- property color focusBorderInner: "#ffffff"
33
-
34
- // Card
35
- property color cardColor: Qt.alpha("#ffffff", 0.7)
36
- property color cardSecondaryColor: Qt.alpha("#F6F6F6", 0.5)
37
- property color cardTertiaryColor: Qt.alpha("#ffffff", 1)
38
- property color cardBorderColor: Qt.alpha("#000000", 0.0578)
39
-
40
- // Background
41
- property color backgroundColor: "#F3F3F3"
42
- property color windowBorderColor: Qt.alpha("#757575", 0.0924)
43
- property color backgroundAcrylicColor: "#F9F9F9"
44
- property color backgroundSmokeColor: Qt.alpha("#000000", 0.3)
45
-
46
- property color subtleColor: "transparent"
47
- property color subtleSecondaryColor: Qt.alpha("#000000", 0.0373)
48
- property color subtleTertiaryColor: Qt.alpha("#000000", 0.0241)
49
- property color captionCloseColor: "#c42b1c"
50
- property color captionCloseTextColor: "#ffffff"
51
-
52
- // Layer
53
- property color layerColor: Qt.alpha("#ffffff", 0.5)
54
-
55
- // Text
56
- property color textColor: "#1b1b1b"
57
- property color textSecondaryColor: Qt.alpha("#000000", 0.6063)
58
- property color textAccentColor: primaryColor
59
- property color textOnAccentColor: "#ffffff"
60
- property color textSelectedColor: "#ffffff"
61
-
62
- property color primaryColor: Utils.primaryColor
63
- property color disabledColor: "#000000"
64
-
65
- // System Colors
66
- property color systemAttentionColor: primaryColor
67
- property color systemSuccessColor: "#0f7b0f"
68
- property color systemCautionColor: "#9d5d00"
69
- property color systemCriticalColor: "#c42b1c"
70
- property color systemNeutralColor: "#8d8d8d"
71
-
72
- property color systemAttentionBackgroundColor: "#fbfbfb"
73
- property color systemSuccessBackgroundColor: "#dff6dd"
74
- property color systemCautionBackgroundColor: "#fff4ce"
75
- property color systemCriticalBackgroundColor: "#fde7e9"
76
- property color systemNeutralBackgroundColor: "#f9f9f9"
77
- }
78
-
79
- // Appearance //
80
- property QtObject appearance: QtObject {
81
- property int buttonRadius: 5
82
- property int borderWidth: 1
83
- property real borderFactor: 0.9
84
- property real borderOnAccentFactor: 1.08
85
- property int smallRadius: 3
86
-
87
- property int dialogTitleBarHeight: 32
88
- property int windowTitleBarHeight: 48
89
- property int windowRadius: 7
90
- property int windowButtonWidth: 46
91
-
92
- property int scrollBarMinWidth: 2
93
- property int scrollBarWidth: 6
94
- property int scrollBarPadding: 3
95
-
96
- property int sliderHandleSize: 20
97
- }
98
-
99
- // Shadows //
100
- property var shadows: {
101
- "dialog": {
102
- "color": Qt.alpha("#000000", 0.19), // 模糊颜色
103
- "blur": 64, // 模糊度
104
- "offsetY": 32
105
- },
106
- "tooltip": {
107
- "color": Qt.alpha("#000000", 0.14),
108
- "blur": 8,
109
- "offsetY": 4
110
- },
111
- "cardRest": {
112
- "color": Qt.alpha("#000000", 0.04),
113
- "blur": 4,
114
- "offsetY": 2
115
- },
116
- "flyout": {
117
- "color": Qt.alpha("#000000", 0.14),
118
- "blur": 24,
119
- "offsetY": 8
120
- },
121
- }
122
-
123
- // Typography //
124
- property QtObject typography: QtObject {
125
- // property string fontFamily: "Segoe UI"
126
- // property string fontIcon: "FluentSystemIcons-Resizeable.ttf" // 字体图标路径 / font icon (put it in the "assets/fonts" folder)
127
- // Font Sizes
128
- property int displaySize: 68
129
- property int titleLargeSize: 40
130
- property int titleSize: 28
131
- property int subtitleSize: 20
132
- property int bodyLargeSize: 18
133
- property int bodySize: 14
134
- property int bodyStrongSize: 14
135
- property int captionSize: 12
136
- }
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
+ }
137
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
  }