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.
- RinUI/__init__.py +4 -4
- RinUI/assets/fonts/FluentSystemIcons-Index.js +5255 -5255
- RinUI/assets/img/default_app_icon.png +0 -0
- RinUI/components/Base.qml +78 -78
- RinUI/components/BasicInput/Button.qml +146 -147
- RinUI/components/BasicInput/CheckBox.qml +98 -98
- RinUI/components/BasicInput/ComboBox.qml +159 -159
- RinUI/components/BasicInput/DropDownButton.qml +20 -20
- RinUI/components/BasicInput/Hyperlink.qml +17 -17
- RinUI/components/BasicInput/PillButton.qml +10 -10
- RinUI/components/BasicInput/RadioButton.qml +94 -94
- RinUI/components/BasicInput/RoundButton.qml +26 -26
- RinUI/components/BasicInput/Slider.qml +212 -212
- RinUI/components/BasicInput/Switch.qml +101 -101
- RinUI/components/BasicInput/ToggleButton.qml +10 -10
- RinUI/components/BasicInput/ToolButton.qml +30 -30
- RinUI/components/ContextMenu.qml +183 -183
- RinUI/components/DateAndTime/DatePicker.qml +142 -140
- RinUI/components/DateAndTime/PickerView.qml +223 -223
- RinUI/components/DateAndTime/TimePicker.qml +114 -114
- RinUI/components/DialogsAndFlyouts/Dialog.qml +106 -106
- RinUI/components/DialogsAndFlyouts/DialogButtonBox.qml +47 -47
- RinUI/components/DialogsAndFlyouts/Flyout.qml +87 -144
- RinUI/components/DialogsAndFlyouts/Popup.qml +110 -106
- RinUI/components/FocusIndicator.qml +33 -33
- RinUI/components/IconWidget.qml +52 -52
- RinUI/components/Indicator.qml +89 -89
- RinUI/components/Layout/Expander.qml +159 -159
- RinUI/components/Layout/SettingExpander.qml +66 -66
- RinUI/components/Layout/SettingItem.qml +70 -70
- RinUI/components/ListAndCollections/Clip.qml +21 -21
- RinUI/components/ListAndCollections/Frame.qml +43 -43
- RinUI/components/ListAndCollections/ListView.qml +104 -104
- RinUI/components/ListAndCollections/ListViewDelegate.qml +82 -82
- RinUI/components/ListAndCollections/SettingCard.qml +72 -72
- RinUI/components/ListAndCollections/TableView.qml +81 -81
- RinUI/components/ListAndCollections/TableViewDelegate.qml +88 -88
- RinUI/components/Media/Avatar.qml +83 -0
- RinUI/components/MenusAndToolbars/Menu.qml +150 -150
- RinUI/components/MenusAndToolbars/MenuBar.qml +42 -42
- RinUI/components/MenusAndToolbars/MenuItem.qml +131 -131
- RinUI/components/MenusAndToolbars/MenuItemGroup.qml +43 -43
- RinUI/components/MenusAndToolbars/MenuSeparator.qml +13 -13
- RinUI/components/MenusAndToolbars/TextInputMenu.qml +37 -37
- RinUI/components/MenusAndToolbars/ToolSeparator.qml +16 -16
- RinUI/components/Navigation/ErrorPage.qml +48 -48
- RinUI/components/Navigation/NavigationBar.qml +179 -179
- RinUI/components/Navigation/NavigationItem.qml +193 -193
- RinUI/components/Navigation/NavigationSubItem.qml +103 -103
- RinUI/components/Navigation/NavigationView.qml +228 -227
- RinUI/components/Navigation/Segmented.qml +17 -0
- RinUI/components/Navigation/SegmentedItem.qml +108 -0
- RinUI/components/Navigation/SelectorBar.qml +12 -57
- RinUI/components/Navigation/SelectorBarItem.qml +89 -0
- RinUI/components/ScrollBar.qml +204 -204
- RinUI/components/ScrollView.qml +12 -12
- RinUI/components/Shadow.qml +47 -47
- RinUI/components/StatusAndInfo/InfoBadge.qml +77 -77
- RinUI/components/StatusAndInfo/InfoBar.qml +256 -251
- RinUI/components/StatusAndInfo/ProgressBar.qml +126 -126
- RinUI/components/StatusAndInfo/ProgressRing.qml +149 -0
- RinUI/components/StatusAndInfo/Toast.qml +236 -236
- RinUI/components/StatusAndInfo/ToolTip.qml +93 -93
- RinUI/components/Text/SpinBox.qml +150 -133
- RinUI/components/Text/Text.qml +44 -44
- RinUI/components/Text/TextArea.qml +117 -117
- RinUI/components/Text/TextField.qml +113 -113
- RinUI/components/Text/TextInput.qml +47 -47
- RinUI/components/qmldir +80 -77
- RinUI/core/__init__.py +4 -4
- RinUI/core/config.py +129 -129
- RinUI/core/launcher.py +129 -129
- RinUI/core/theme.py +339 -339
- RinUI/core/translator.py +25 -25
- RinUI/hooks/__init__.py +3 -3
- RinUI/hooks/hook-RinUI.py +3 -3
- RinUI/qmldir +108 -97
- RinUI/themes/Appearance.qml +36 -0
- RinUI/themes/Colors.qml +36 -0
- RinUI/themes/dark.qml +145 -136
- RinUI/themes/light.qml +145 -136
- RinUI/themes/qmldir +9 -6
- RinUI/themes/theme.qml +151 -149
- RinUI/themes/utils.qml +37 -37
- RinUI/utils/Animation.qml +12 -12
- RinUI/utils/FloatLayer.qml +132 -123
- RinUI/utils/FontIconLoader.qml +13 -13
- RinUI/utils/Position.qml +19 -19
- RinUI/utils/Severity.qml +13 -13
- RinUI/utils/Typography.qml +17 -17
- RinUI/utils/qmldir +4 -4
- RinUI/windows/CtrlBtn.qml +118 -118
- RinUI/windows/FluentPage.qml +92 -92
- RinUI/windows/FluentWindow.qml +31 -30
- RinUI/windows/FluentWindowBase.qml +158 -158
- RinUI/windows/TitleBar.qml +135 -135
- RinUI/windows/qmldir +7 -7
- RinUI/windows/window/ApplicationWindow.qml +8 -8
- RinUI/windows/window/Window.qml +118 -118
- {rinui-0.0.11.data → rinui-0.1.1.data}/data/LICENSE +21 -21
- {rinui-0.0.11.data → rinui-0.1.1.data}/data/README.md +100 -97
- {rinui-0.0.11.dist-info → rinui-0.1.1.dist-info}/METADATA +116 -112
- rinui-0.1.1.dist-info/RECORD +112 -0
- {rinui-0.0.11.dist-info → rinui-0.1.1.dist-info}/WHEEL +1 -1
- {rinui-0.0.11.dist-info → rinui-0.1.1.dist-info/licenses}/LICENSE +21 -21
- RinUI/__pycache__/__init__.cpython-38.pyc +0 -0
- RinUI/config/rin_ui.json +0 -8
- RinUI/core/__pycache__/__init__.cpython-38.pyc +0 -0
- RinUI/core/__pycache__/config.cpython-38.pyc +0 -0
- RinUI/core/__pycache__/launcher.cpython-38.pyc +0 -0
- RinUI/core/__pycache__/theme.cpython-38.pyc +0 -0
- RinUI/core/__pycache__/translator.cpython-38.pyc +0 -0
- rinui-0.0.11.dist-info/RECORD +0 -112
- {rinui-0.0.11.dist-info → rinui-0.1.1.dist-info}/entry_points.txt +0 -0
- {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
|
20
|
-
property color
|
21
|
-
property color
|
22
|
-
|
23
|
-
property color
|
24
|
-
property color
|
25
|
-
property color
|
26
|
-
property color
|
27
|
-
|
28
|
-
property color
|
29
|
-
property color
|
30
|
-
|
31
|
-
property color
|
32
|
-
property color
|
33
|
-
|
34
|
-
|
35
|
-
property color
|
36
|
-
|
37
|
-
property color
|
38
|
-
property color
|
39
|
-
|
40
|
-
|
41
|
-
property color
|
42
|
-
|
43
|
-
|
44
|
-
property color
|
45
|
-
|
46
|
-
property color
|
47
|
-
property color
|
48
|
-
|
49
|
-
|
50
|
-
property color
|
51
|
-
|
52
|
-
|
53
|
-
property color
|
54
|
-
|
55
|
-
|
56
|
-
property color
|
57
|
-
property color
|
58
|
-
property color
|
59
|
-
property color
|
60
|
-
|
61
|
-
|
62
|
-
property color
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
property color
|
67
|
-
property color
|
68
|
-
property color
|
69
|
-
property color
|
70
|
-
|
71
|
-
|
72
|
-
property color
|
73
|
-
|
74
|
-
|
75
|
-
property color
|
76
|
-
property color
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
property
|
82
|
-
property
|
83
|
-
property
|
84
|
-
property
|
85
|
-
property
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
property int
|
91
|
-
|
92
|
-
property
|
93
|
-
property
|
94
|
-
property int
|
95
|
-
|
96
|
-
property int
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
"
|
113
|
-
"
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
"
|
118
|
-
"
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
property
|
135
|
-
property
|
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
|
-
|
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
|
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
|
-
if (
|
65
|
-
console.error("
|
66
|
-
return -1
|
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
|
-
|
98
|
-
|
99
|
-
theme_mode = mode.
|
100
|
-
}
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
console.
|
134
|
-
}
|
135
|
-
|
136
|
-
|
137
|
-
}
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
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
|
}
|