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
@@ -1,212 +1,212 @@
1
- import QtQuick 2.15
2
- import QtQuick.Controls.Basic 2.15
3
- import "../../themes"
4
- import "../../components"
5
-
6
- // thanks JerryQAQ
7
-
8
- Slider {
9
- id: root
10
- // 尺寸属性
11
- property real handleSize: Theme.currentTheme.appearance.sliderHandleSize // 手柄基础尺寸
12
- property real borderWidth: 3 // 边框宽度
13
- property int ticksPadding: 4 // 刻度线间距
14
- property real trackHeight: 4
15
- property bool showTooltip: true
16
- property bool tickmarks: false
17
- property real tickFrequency: 0 // 刻度线频率
18
- property color primaryColor: Theme.currentTheme.colors.primaryColor
19
-
20
- // accessibility
21
- FocusIndicator {
22
- control: parent
23
- }
24
-
25
- // auto enable snap
26
- snapMode: Slider.SnapAlways
27
-
28
- // 自适应高度和宽度
29
- implicitHeight: orientation === Qt.Horizontal ? 32 : 150
30
- implicitWidth: orientation === Qt.Horizontal ? 150 : 32
31
-
32
-
33
- // Background / 背景 //
34
- background: Rectangle {
35
- anchors.centerIn: parent
36
- width: root.orientation === Qt.Horizontal ? parent.width - handle.width : trackHeight
37
- height: root.orientation === Qt.Horizontal ? trackHeight : parent.height - handle.width
38
- radius: 99
39
- color: Theme.currentTheme.colors.controlStrongColor
40
-
41
- Behavior on color {
42
- ColorAnimation {
43
- duration: Utils.appearanceSpeed
44
- easing.type: Easing.OutQuart
45
- }
46
- }
47
-
48
- // 进度条
49
- Rectangle {
50
- width: root.orientation === Qt.Horizontal ? root.visualPosition * parent.width : trackHeight
51
- height: root.orientation === Qt.Horizontal ? trackHeight : (1 - root.visualPosition) * parent.height
52
- anchors.bottom: root.orientation === Qt.Vertical ? parent.bottom : undefined
53
- radius: 99
54
- color: Theme.currentTheme.colors.primaryColor
55
-
56
- Behavior on width {
57
- NumberAnimation {
58
- duration: Utils.animationSpeedFaster
59
- easing.type: Easing.OutCubic
60
- }
61
- }
62
- Behavior on color {
63
- ColorAnimation {
64
- duration: Utils.appearanceSpeed
65
- easing.type: Easing.OutQuart
66
- }
67
- }
68
- Behavior on height {
69
- NumberAnimation {
70
- duration: Utils.animationSpeedFaster
71
- easing.type: Easing.OutCubic
72
- }
73
- }
74
- }
75
-
76
- // 刻度线 / Repeater //
77
- Repeater {
78
- model: (to - from) / (tickFrequency !== 0 ? tickFrequency : stepSize)
79
-
80
- delegate: Column {
81
- x: root.orientation === Qt.Horizontal ?
82
- index * parent.width / (to - from) * (tickFrequency !== 0 ? tickFrequency : stepSize) - width / 2
83
- : ticksPadding + trackHeight
84
- y: root.orientation === Qt.Vertical ?
85
- index * parent.height / (to - from) * (tickFrequency !== 0 ? tickFrequency : stepSize) - height / 2
86
- : ticksPadding + trackHeight
87
- spacing: 2
88
- Rectangle {
89
- anchors.horizontalCenter: parent.horizontalCenter
90
- width: root.orientation === Qt.Horizontal ? 1 : 4
91
- height: root.orientation === Qt.Horizontal ? 4 : 1
92
- color: Theme.currentTheme.colors.controlStrongColor
93
-
94
- visible: root.tickmarks && index !== 0 && index !== ((to - from) / stepSize)
95
- }
96
- }
97
- }
98
- }
99
-
100
-
101
- // 手柄 / Handle //
102
- handle: Item {
103
- id: handle
104
- property bool hovered: false
105
- width: handleSize + 2
106
- height: handleSize + 2
107
-
108
- // 动态调整手柄位置:根据 orientation 切换 x/y 轴逻辑
109
- x: root.orientation === Qt.Horizontal
110
- ? root.visualPosition * (parent.width - width) // 横向:x 受 visualPosition 控制
111
- : (parent.width - width) / 2 // 竖向
112
- y: root.orientation === Qt.Vertical
113
- ? (root.visualPosition) * (parent.height - height) // 竖向:y 受 visualPosition 控制
114
- : (parent.height - height) / 2 // 横向
115
-
116
-
117
- ToolTip {
118
- text: root.value.toString()
119
- visible: root.showTooltip ? (handle.hovered || root.pressed) : false
120
- delay: 50
121
- }
122
-
123
- // MouseArea
124
- MouseArea {
125
- anchors.fill: parent
126
- hoverEnabled: true
127
- acceptedButtons: Qt.NoButton
128
- onEntered: handle.hovered = true
129
- onExited: handle.hovered = false
130
- }
131
-
132
- // border
133
- Rectangle {
134
- anchors.fill: parent
135
- radius: width / 2
136
- color: Theme.currentTheme.colors.controlQuaternaryColor
137
- }
138
-
139
- // border middle(?)
140
- Rectangle {
141
- anchors.centerIn: parent
142
- width: handleSize
143
- height: handleSize
144
- radius: width / 2
145
- color: Theme.currentTheme.colors.controlSolidColor
146
-
147
- Behavior on color {
148
- ColorAnimation {
149
- duration: Utils.appearanceSpeed
150
- easing.type: Easing.OutQuart
151
- }
152
- }
153
- }
154
-
155
- // dot 主题色圆点
156
- Rectangle {
157
- id: dot
158
- anchors.centerIn: parent
159
- // 取偶数
160
- width: Math.round(handleSize * 0.55) & ~1
161
- height: Math.round(handleSize * 0.55) & ~1
162
- radius: width / 2
163
-
164
- // 悬停
165
- scale: root.pressed ? 0.83 :
166
- handle.hovered ? 1.16 : 1.0
167
- color: root.pressed ? Qt.alpha(Theme.currentTheme.colors.primaryColor, 0.8) :
168
- handle.hovered ? Qt.alpha(Theme.currentTheme.colors.primaryColor, 0.9) : Theme.currentTheme.colors.primaryColor
169
-
170
- // 动画
171
- Behavior on color {
172
- ColorAnimation {
173
- duration: Utils.appearanceSpeed
174
- easing.type: Easing.OutCubic
175
- }
176
- }
177
- Behavior on scale {
178
- NumberAnimation {
179
- duration: Utils.animationSpeed
180
- easing.type: Easing.OutBack
181
- }
182
- }
183
- }
184
-
185
- Behavior on x {
186
- NumberAnimation {
187
- duration: Utils.animationSpeedFaster
188
- easing.type: Easing.OutCubic
189
- }
190
- }
191
- Behavior on y {
192
- NumberAnimation {
193
- duration: Utils.animationSpeedFaster
194
- easing.type: Easing.OutCubic
195
- }
196
- }
197
- }
198
-
199
-
200
- // 状态管理
201
- states: [
202
- State {
203
- name: "disabled"
204
- when: !root.enabled
205
- PropertyChanges {
206
- target: handle
207
- color: Theme.currentTheme.colors.textDisabled
208
- opacity: 0.6
209
- }
210
- }
211
- ]
212
- }
1
+ import QtQuick 2.15
2
+ import QtQuick.Controls.Basic 2.15
3
+ import "../../themes"
4
+ import "../../components"
5
+
6
+ // thanks JerryQAQ
7
+
8
+ Slider {
9
+ id: root
10
+ // 尺寸属性
11
+ property real handleSize: Theme.currentTheme.appearance.sliderHandleSize // 手柄基础尺寸
12
+ property real borderWidth: 3 // 边框宽度
13
+ property int ticksPadding: 4 // 刻度线间距
14
+ property real trackHeight: 4
15
+ property bool showTooltip: true
16
+ property bool tickmarks: false
17
+ property real tickFrequency: 0 // 刻度线频率
18
+ property color primaryColor: Theme.currentTheme.colors.primaryColor
19
+
20
+ // accessibility
21
+ FocusIndicator {
22
+ control: parent
23
+ }
24
+
25
+ // auto enable snap
26
+ snapMode: Slider.SnapAlways
27
+
28
+ // 自适应高度和宽度
29
+ implicitHeight: orientation === Qt.Horizontal ? 32 : 150
30
+ implicitWidth: orientation === Qt.Horizontal ? 150 : 32
31
+
32
+
33
+ // Background / 背景 //
34
+ background: Rectangle {
35
+ anchors.centerIn: parent
36
+ width: root.orientation === Qt.Horizontal ? parent.width - handle.width : trackHeight
37
+ height: root.orientation === Qt.Horizontal ? trackHeight : parent.height - handle.width
38
+ radius: 99
39
+ color: Theme.currentTheme.colors.controlStrongColor
40
+
41
+ Behavior on color {
42
+ ColorAnimation {
43
+ duration: Utils.appearanceSpeed
44
+ easing.type: Easing.OutQuart
45
+ }
46
+ }
47
+
48
+ // 进度条
49
+ Rectangle {
50
+ width: root.orientation === Qt.Horizontal ? root.visualPosition * parent.width : trackHeight
51
+ height: root.orientation === Qt.Horizontal ? trackHeight : (1 - root.visualPosition) * parent.height
52
+ anchors.bottom: root.orientation === Qt.Vertical ? parent.bottom : undefined
53
+ radius: 99
54
+ color: Theme.currentTheme.colors.primaryColor
55
+
56
+ Behavior on width {
57
+ NumberAnimation {
58
+ duration: Utils.animationSpeedFaster
59
+ easing.type: Easing.OutCubic
60
+ }
61
+ }
62
+ Behavior on color {
63
+ ColorAnimation {
64
+ duration: Utils.appearanceSpeed
65
+ easing.type: Easing.OutQuart
66
+ }
67
+ }
68
+ Behavior on height {
69
+ NumberAnimation {
70
+ duration: Utils.animationSpeedFaster
71
+ easing.type: Easing.OutCubic
72
+ }
73
+ }
74
+ }
75
+
76
+ // 刻度线 / Repeater //
77
+ Repeater {
78
+ model: (to - from) / (tickFrequency !== 0 ? tickFrequency : stepSize)
79
+
80
+ delegate: Column {
81
+ x: root.orientation === Qt.Horizontal ?
82
+ index * parent.width / (to - from) * (tickFrequency !== 0 ? tickFrequency : stepSize) - width / 2
83
+ : ticksPadding + trackHeight
84
+ y: root.orientation === Qt.Vertical ?
85
+ index * parent.height / (to - from) * (tickFrequency !== 0 ? tickFrequency : stepSize) - height / 2
86
+ : ticksPadding + trackHeight
87
+ spacing: 2
88
+ Rectangle {
89
+ anchors.horizontalCenter: parent.horizontalCenter
90
+ width: root.orientation === Qt.Horizontal ? 1 : 4
91
+ height: root.orientation === Qt.Horizontal ? 4 : 1
92
+ color: Theme.currentTheme.colors.controlStrongColor
93
+
94
+ visible: root.tickmarks && index !== 0 && index !== ((to - from) / stepSize)
95
+ }
96
+ }
97
+ }
98
+ }
99
+
100
+
101
+ // 手柄 / Handle //
102
+ handle: Item {
103
+ id: handle
104
+ property bool hovered: false
105
+ width: handleSize + 2
106
+ height: handleSize + 2
107
+
108
+ // 动态调整手柄位置:根据 orientation 切换 x/y 轴逻辑
109
+ x: root.orientation === Qt.Horizontal
110
+ ? root.visualPosition * (parent.width - width) // 横向:x 受 visualPosition 控制
111
+ : (parent.width - width) / 2 // 竖向
112
+ y: root.orientation === Qt.Vertical
113
+ ? (root.visualPosition) * (parent.height - height) // 竖向:y 受 visualPosition 控制
114
+ : (parent.height - height) / 2 // 横向
115
+
116
+
117
+ ToolTip {
118
+ text: root.value.toString()
119
+ visible: root.showTooltip ? (handle.hovered || root.pressed) : false
120
+ delay: 50
121
+ }
122
+
123
+ // MouseArea
124
+ MouseArea {
125
+ anchors.fill: parent
126
+ hoverEnabled: true
127
+ acceptedButtons: Qt.NoButton
128
+ onEntered: handle.hovered = true
129
+ onExited: handle.hovered = false
130
+ }
131
+
132
+ // border
133
+ Rectangle {
134
+ anchors.fill: parent
135
+ radius: width / 2
136
+ color: Theme.currentTheme.colors.controlQuaternaryColor
137
+ }
138
+
139
+ // border middle(?)
140
+ Rectangle {
141
+ anchors.centerIn: parent
142
+ width: handleSize
143
+ height: handleSize
144
+ radius: width / 2
145
+ color: Theme.currentTheme.colors.controlSolidColor
146
+
147
+ Behavior on color {
148
+ ColorAnimation {
149
+ duration: Utils.appearanceSpeed
150
+ easing.type: Easing.OutQuart
151
+ }
152
+ }
153
+ }
154
+
155
+ // dot 主题色圆点
156
+ Rectangle {
157
+ id: dot
158
+ anchors.centerIn: parent
159
+ // 取偶数
160
+ width: Math.round(handleSize * 0.55) & ~1
161
+ height: Math.round(handleSize * 0.55) & ~1
162
+ radius: width / 2
163
+
164
+ // 悬停
165
+ scale: root.pressed ? 0.83 :
166
+ handle.hovered ? 1.16 : 1.0
167
+ color: root.pressed ? Qt.alpha(Theme.currentTheme.colors.primaryColor, 0.8) :
168
+ handle.hovered ? Qt.alpha(Theme.currentTheme.colors.primaryColor, 0.9) : Theme.currentTheme.colors.primaryColor
169
+
170
+ // 动画
171
+ Behavior on color {
172
+ ColorAnimation {
173
+ duration: Utils.appearanceSpeed
174
+ easing.type: Easing.OutCubic
175
+ }
176
+ }
177
+ Behavior on scale {
178
+ NumberAnimation {
179
+ duration: Utils.animationSpeed
180
+ easing.type: Easing.OutBack
181
+ }
182
+ }
183
+ }
184
+
185
+ Behavior on x {
186
+ NumberAnimation {
187
+ duration: Utils.animationSpeedFaster
188
+ easing.type: Easing.OutCubic
189
+ }
190
+ }
191
+ Behavior on y {
192
+ NumberAnimation {
193
+ duration: Utils.animationSpeedFaster
194
+ easing.type: Easing.OutCubic
195
+ }
196
+ }
197
+ }
198
+
199
+
200
+ // 状态管理
201
+ states: [
202
+ State {
203
+ name: "disabled"
204
+ when: !root.enabled
205
+ PropertyChanges {
206
+ target: handle
207
+ color: Theme.currentTheme.colors.textDisabled
208
+ opacity: 0.6
209
+ }
210
+ }
211
+ ]
212
+ }
@@ -1,102 +1,102 @@
1
- import QtQuick 2.15
2
- import QtQuick.Controls 2.15
3
- import "../../themes"
4
- import "../../components"
5
-
6
-
7
- Switch {
8
- id: root
9
-
10
- // width: 40
11
- implicitHeight: 20
12
-
13
- property color backgroundColor: Theme.currentTheme.colors.controlSecondaryColor
14
- property color primaryColor: Theme.currentTheme.colors.primaryColor
15
- property string checkedText: qsTr("On")
16
- property string uncheckedText: qsTr("Off")
17
-
18
- // accessibility
19
- FocusIndicator {
20
- control: parent
21
- // radius: 999
22
- }
23
-
24
- // 背景 / Background
25
- background: Rectangle {
26
- id: background
27
- width: 40
28
- height: 20
29
- radius: height / 2
30
- color: checked ? primaryColor :
31
- hovered ? Theme.currentTheme.colors.controlTertiaryColor : backgroundColor
32
-
33
- // 边框 / Border
34
- border.color: checked ? "transparent" : Theme.currentTheme.colors.controlBorderStrongColor
35
- border.width: Theme.currentTheme.appearance.borderWidth
36
-
37
- Behavior on color { ColorAnimation { duration: Utils.animationSpeed; easing.type: Easing.OutQuart } }
38
- }
39
-
40
- // 指示器 / Indicator //
41
- indicator: Rectangle {
42
- id: indicator
43
- width: pressed && enabled ? background.height - 3:
44
- hovered && enabled ? background.height - 3 * 2 : background.height - 4 * 2
45
- height: (hovered || pressed) && enabled ? background.height - 3 * 2 : background.height - 4 * 2
46
-
47
- anchors.verticalCenter: background.verticalCenter
48
- radius: height / 2
49
- color: checked ? Theme.currentTheme.colors.textOnAccentColor : Theme.currentTheme.colors.controlBorderStrongColor
50
-
51
- Behavior on color { ColorAnimation { duration: Utils.animationSpeed; easing.type: Easing.OutQuart } }
52
-
53
- Behavior on x { NumberAnimation { duration: Utils.animationSpeed; easing.type: Easing.OutQuint } }
54
- Behavior on height { NumberAnimation { duration: Utils.animationSpeed; easing.type: Easing.OutQuint } }
55
-
56
- x: (hovered || pressed) && enabled
57
- ? visualPosition * (background.width - 3 - width) + (checked ? 0 : 3)
58
- : visualPosition * (background.width - 8 - width) + 4
59
- }
60
-
61
- contentItem: Row {
62
- anchors.fill: parent
63
- spacing: 12
64
- Rectangle { width: 40; height: 20; color: "transparent" } // 占位符
65
-
66
- Text {
67
- text: (root.text === '') ? root.checked ? checkedText : uncheckedText : root.text
68
- }
69
- }
70
-
71
- // 状态变化
72
- states: [
73
- State {
74
- name: "disabledSwitch"
75
- when: !root.enabled
76
- PropertyChanges {
77
- target: root
78
- opacity: 0.2169
79
- primaryColor: Theme.currentTheme.colors.disabledColor
80
- }
81
- },
82
- State {
83
- name: "pressedSwitch"
84
- when: pressed
85
- PropertyChanges {
86
- target: background
87
- opacity: 0.8
88
- }
89
- },
90
- State {
91
- name: "hoveredSwitch"
92
- when: hovered
93
- PropertyChanges {
94
- target: background
95
- opacity: 0.9
96
- }
97
- }
98
- ]
99
-
100
- // 动画
101
- Behavior on opacity { NumberAnimation { duration: Utils.appearanceSpeed; easing.type: Easing.OutQuart } }
1
+ import QtQuick 2.15
2
+ import QtQuick.Controls 2.15
3
+ import "../../themes"
4
+ import "../../components"
5
+
6
+
7
+ Switch {
8
+ id: root
9
+
10
+ // width: 40
11
+ implicitHeight: 20
12
+
13
+ property color backgroundColor: Theme.currentTheme.colors.controlSecondaryColor
14
+ property color primaryColor: Theme.currentTheme.colors.primaryColor
15
+ property string checkedText: qsTr("On")
16
+ property string uncheckedText: qsTr("Off")
17
+
18
+ // accessibility
19
+ FocusIndicator {
20
+ control: parent
21
+ // radius: 999
22
+ }
23
+
24
+ // 背景 / Background
25
+ background: Rectangle {
26
+ id: background
27
+ width: 40
28
+ height: 20
29
+ radius: height / 2
30
+ color: checked ? primaryColor :
31
+ hovered ? Theme.currentTheme.colors.controlTertiaryColor : backgroundColor
32
+
33
+ // 边框 / Border
34
+ border.color: checked ? "transparent" : Theme.currentTheme.colors.controlBorderStrongColor
35
+ border.width: Theme.currentTheme.appearance.borderWidth
36
+
37
+ Behavior on color { ColorAnimation { duration: Utils.animationSpeed; easing.type: Easing.OutQuart } }
38
+ }
39
+
40
+ // 指示器 / Indicator //
41
+ indicator: Rectangle {
42
+ id: indicator
43
+ width: pressed && enabled ? background.height - 3:
44
+ hovered && enabled ? background.height - 3 * 2 : background.height - 4 * 2
45
+ height: (hovered || pressed) && enabled ? background.height - 3 * 2 : background.height - 4 * 2
46
+
47
+ anchors.verticalCenter: background.verticalCenter
48
+ radius: height / 2
49
+ color: checked ? Theme.currentTheme.colors.textOnAccentColor : Theme.currentTheme.colors.controlBorderStrongColor
50
+
51
+ Behavior on color { ColorAnimation { duration: Utils.animationSpeed; easing.type: Easing.OutQuart } }
52
+
53
+ Behavior on x { NumberAnimation { duration: Utils.animationSpeed; easing.type: Easing.OutQuint } }
54
+ Behavior on height { NumberAnimation { duration: Utils.animationSpeed; easing.type: Easing.OutQuint } }
55
+
56
+ x: (hovered || pressed) && enabled
57
+ ? visualPosition * (background.width - 3 - width) + (checked ? 0 : 3)
58
+ : visualPosition * (background.width - 8 - width) + 4
59
+ }
60
+
61
+ contentItem: Row {
62
+ anchors.fill: parent
63
+ spacing: 12
64
+ Rectangle { width: 40; height: 20; color: "transparent" } // 占位符
65
+
66
+ Text {
67
+ text: (root.text === '') ? root.checked ? checkedText : uncheckedText : root.text
68
+ }
69
+ }
70
+
71
+ // 状态变化
72
+ states: [
73
+ State {
74
+ name: "disabledSwitch"
75
+ when: !root.enabled
76
+ PropertyChanges {
77
+ target: root
78
+ opacity: 0.2169
79
+ primaryColor: Theme.currentTheme.colors.disabledColor
80
+ }
81
+ },
82
+ State {
83
+ name: "pressedSwitch"
84
+ when: pressed
85
+ PropertyChanges {
86
+ target: background
87
+ opacity: 0.8
88
+ }
89
+ },
90
+ State {
91
+ name: "hoveredSwitch"
92
+ when: hovered
93
+ PropertyChanges {
94
+ target: background
95
+ opacity: 0.9
96
+ }
97
+ }
98
+ ]
99
+
100
+ // 动画
101
+ Behavior on opacity { NumberAnimation { duration: Utils.appearanceSpeed; easing.type: Easing.OutQuart } }
102
102
  }
@@ -1,11 +1,11 @@
1
- import QtQuick 2.15
2
- import QtQuick.Controls.Basic 2.15
3
- import QtQuick.Layouts 2.15
4
- import "../../themes"
5
- import "../../components"
6
-
7
- Button {
8
- id: root
9
- highlighted: checked
10
- checkable: true
1
+ import QtQuick 2.15
2
+ import QtQuick.Controls.Basic 2.15
3
+ import QtQuick.Layouts 2.15
4
+ import "../../themes"
5
+ import "../../components"
6
+
7
+ Button {
8
+ id: root
9
+ highlighted: checked
10
+ checkable: true
11
11
  }