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,237 +1,237 @@
1
- import QtQuick 2.15
2
- import QtQuick.Layouts 2.15
3
- import "../../themes"
4
- import "../../components"
5
-
6
-
7
- Frame {
8
- id: infoBar
9
- property string title: ""
10
- property string text: ""
11
- property int timeout: -1
12
- property int position: 0
13
- property bool isDynamic: false // 动态创建
14
- property bool closable: true // 显示关闭按钮
15
- property bool iconVisible: true // 显示图标
16
- property real startPosX: {
17
- switch (position) {
18
- case Position.TopLeft:
19
- case Position.BottomLeft:
20
- return -width / 2;
21
- case Position.TopRight:
22
- case Position.BottomRight:
23
- return width / 2;
24
- default:
25
- return 0;
26
- }
27
- }
28
-
29
- property real startPosY: 0
30
- readonly property real endPosX: x
31
-
32
-
33
- function calculateStartPosY() {
34
- switch (position) {
35
- case Position.Top:
36
- return -height / 2 ;
37
- case Position.Bottom:
38
- return height / 2 ;
39
- default:
40
- return 0;
41
- }
42
- }
43
-
44
- color: Theme.currentTheme.colors.backgroundAcrylicColor
45
- borderColor: Theme.currentTheme.colors.flyoutBorderColor
46
-
47
- // width: 200
48
- Layout.fillWidth: true
49
- padding: 5
50
- leftPadding: 15
51
- hoverable: false
52
- opacity: 0
53
-
54
- Timer {
55
- id: autoCloseTimer
56
- interval: timeout
57
- running: timeout >= 0
58
- repeat: false
59
- onTriggered: {
60
- // infoBar.visible = false
61
- // infoBar.destroy()
62
- exitAnimation.start()
63
- }
64
- }
65
-
66
- RowLayout {
67
- id: main
68
- anchors.fill: parent
69
- spacing: 13
70
-
71
- IconWidget {
72
- id: iconWidget
73
- Layout.preferredHeight: 38
74
- Layout.alignment: Qt.AlignTop
75
- size: 18
76
- icon: {
77
- switch (severity) {
78
- case Severity.Info: return "ic_fluent_info_20_filled";
79
- case Severity.Success: return "ic_fluent_checkmark_circle_20_filled";
80
- case Severity.Warning: return "ic_fluent_error_circle_20_filled";
81
- case Severity.Error: return "ic_fluent_dismiss_circle_20_filled";
82
- default: return "ic_fluent_question_circle_20_filled";
83
- }
84
- }
85
- color: {
86
- switch (severity) {
87
- case Severity.Info: return Theme.currentTheme.colors.systemAttentionColor;
88
- case Severity.Success: return Theme.currentTheme.colors.systemSuccessColor;
89
- case Severity.Warning: return Theme.currentTheme.colors.systemCautionColor;
90
- case Severity.Error: return Theme.currentTheme.colors.systemCriticalColor;
91
- default: return Theme.currentTheme.colors.systemNeutralColor;
92
- }
93
- }
94
- visible: iconVisible
95
- }
96
-
97
- Flow {
98
- Layout.alignment: Qt.AlignTop
99
- Layout.fillWidth: true
100
- Layout.topMargin: 3
101
- // Layout.bottomMargin: 8
102
- spacing: bodyText.wrap ? 0 :12
103
-
104
- Text {
105
- id: titleText
106
- typography: Typography.BodyStrong
107
- text: infoBar.title
108
- topPadding: 6
109
- }
110
- Text {
111
- id: bodyText
112
- property bool wrap: (parent.width - titleText.width - custom.width - 24) < implicitWidth
113
- width: wrap ?
114
- parent.width : implicitWidth
115
- typography: Typography.Body
116
- text: infoBar.text
117
- topPadding: wrap? 0 : 6
118
- }
119
-
120
- Item {
121
- width: parent.width
122
- height: bodyText.wrap && custom.children.length > 0 ? 16 : 0
123
- }
124
- Row {
125
- id: custom
126
- spacing: 6
127
- }
128
- Item {
129
- width: parent.width
130
- height: bodyText.wrap ? 9 : 0
131
- }
132
- }
133
-
134
- RowLayout {
135
- id: rights
136
- Layout.alignment: Qt.AlignTop
137
-
138
- ToolButton {
139
- Layout.alignment: Qt.AlignTop
140
- id: closeButton
141
- flat: true
142
- icon.name: "ic_fluent_dismiss_20_regular"
143
- size: 18
144
- Layout.preferredWidth: 38
145
- Layout.preferredHeight: 38
146
- visible: closable
147
- onClicked: {
148
- exitAnimation.start()
149
- // if (infoBar.isDynamic) {
150
- // infoBar.destroy()
151
- // } else {
152
- // infoBar.visible = false
153
- // }
154
- }
155
- ToolTip {
156
- text: qsTr("Close")
157
- parent: parent
158
- visible: parent.hovered
159
- }
160
- }
161
- }
162
- }
163
-
164
-
165
- // Animations
166
- Component.onCompleted: {
167
- startPosY = calculateStartPosY();
168
- enterAnimation.start()
169
- }
170
-
171
- // Behavior on y { NumberAnimation { duration: Utils.animationSpeed; easing.type: Easing.OutQuint } }
172
- transform: Translate {
173
- id: slideTransform
174
- y: 0
175
- }
176
-
177
- ParallelAnimation {
178
- id: enterAnimation
179
-
180
- NumberAnimation{
181
- target: infoBar
182
- property: "x"
183
- from: infoBar.startPosX
184
- to: infoBar.endPosX
185
- easing.type: Easing.OutQuart
186
- duration: Utils.animationSpeed
187
- }
188
- NumberAnimation {
189
- target: slideTransform
190
- property: "y"
191
- from: infoBar.startPosY
192
- to: 0
193
- easing.type: Easing.OutCubic
194
- duration: Utils.animationSpeed
195
- }
196
- NumberAnimation{
197
- target: infoBar
198
- property: "opacity"
199
- from: 0
200
- to: 1
201
- duration: Utils.appearanceSpeed
202
- }
203
- }
204
-
205
- SequentialAnimation{
206
- id: exitAnimation
207
-
208
- ParallelAnimation{
209
- NumberAnimation{
210
- target: infoBar
211
- property: "y"
212
- to: infoBar.startPosY
213
- easing.type: Easing.OutQuart
214
- duration: Utils.animationSpeed
215
- running: false
216
- }
217
- NumberAnimation{
218
- target: infoBar
219
- property: "opacity"
220
- from: 1
221
- to: 0
222
- duration: Utils.appearanceSpeed
223
- }
224
- }
225
- ScriptAction{
226
- script: {
227
- if (infoBar.isDynamic) {
228
- infoBar.destroy()
229
- } else {
230
- infoBar.visible = false
231
- infoBar.opacity = 1
232
- infoBar.y = 0
233
- }
234
- }
235
- }
236
- }
1
+ import QtQuick 2.15
2
+ import QtQuick.Layouts 2.15
3
+ import "../../themes"
4
+ import "../../components"
5
+
6
+
7
+ Frame {
8
+ id: infoBar
9
+ property string title: ""
10
+ property string text: ""
11
+ property int timeout: -1
12
+ property int position: 0
13
+ property bool isDynamic: false // 动态创建
14
+ property bool closable: true // 显示关闭按钮
15
+ property bool iconVisible: true // 显示图标
16
+ property real startPosX: {
17
+ switch (position) {
18
+ case Position.TopLeft:
19
+ case Position.BottomLeft:
20
+ return -width / 2;
21
+ case Position.TopRight:
22
+ case Position.BottomRight:
23
+ return width / 2;
24
+ default:
25
+ return 0;
26
+ }
27
+ }
28
+
29
+ property real startPosY: 0
30
+ readonly property real endPosX: x
31
+
32
+
33
+ function calculateStartPosY() {
34
+ switch (position) {
35
+ case Position.Top:
36
+ return -height / 2 ;
37
+ case Position.Bottom:
38
+ return height / 2 ;
39
+ default:
40
+ return 0;
41
+ }
42
+ }
43
+
44
+ color: Theme.currentTheme.colors.backgroundAcrylicColor
45
+ borderColor: Theme.currentTheme.colors.flyoutBorderColor
46
+
47
+ // width: 200
48
+ Layout.fillWidth: true
49
+ padding: 5
50
+ leftPadding: 15
51
+ hoverable: false
52
+ opacity: 0
53
+
54
+ Timer {
55
+ id: autoCloseTimer
56
+ interval: timeout
57
+ running: timeout >= 0
58
+ repeat: false
59
+ onTriggered: {
60
+ // infoBar.visible = false
61
+ // infoBar.destroy()
62
+ exitAnimation.start()
63
+ }
64
+ }
65
+
66
+ RowLayout {
67
+ id: main
68
+ anchors.fill: parent
69
+ spacing: 13
70
+
71
+ IconWidget {
72
+ id: iconWidget
73
+ Layout.preferredHeight: 38
74
+ Layout.alignment: Qt.AlignTop
75
+ size: 18
76
+ icon: {
77
+ switch (severity) {
78
+ case Severity.Info: return "ic_fluent_info_20_filled";
79
+ case Severity.Success: return "ic_fluent_checkmark_circle_20_filled";
80
+ case Severity.Warning: return "ic_fluent_error_circle_20_filled";
81
+ case Severity.Error: return "ic_fluent_dismiss_circle_20_filled";
82
+ default: return "ic_fluent_question_circle_20_filled";
83
+ }
84
+ }
85
+ color: {
86
+ switch (severity) {
87
+ case Severity.Info: return Theme.currentTheme.colors.systemAttentionColor;
88
+ case Severity.Success: return Theme.currentTheme.colors.systemSuccessColor;
89
+ case Severity.Warning: return Theme.currentTheme.colors.systemCautionColor;
90
+ case Severity.Error: return Theme.currentTheme.colors.systemCriticalColor;
91
+ default: return Theme.currentTheme.colors.systemNeutralColor;
92
+ }
93
+ }
94
+ visible: iconVisible
95
+ }
96
+
97
+ Flow {
98
+ Layout.alignment: Qt.AlignTop
99
+ Layout.fillWidth: true
100
+ Layout.topMargin: 3
101
+ // Layout.bottomMargin: 8
102
+ spacing: bodyText.wrap ? 0 :12
103
+
104
+ Text {
105
+ id: titleText
106
+ typography: Typography.BodyStrong
107
+ text: infoBar.title
108
+ topPadding: 6
109
+ }
110
+ Text {
111
+ id: bodyText
112
+ property bool wrap: (parent.width - titleText.width - custom.width - 24) < implicitWidth
113
+ width: wrap ?
114
+ parent.width : implicitWidth
115
+ typography: Typography.Body
116
+ text: infoBar.text
117
+ topPadding: wrap? 0 : 6
118
+ }
119
+
120
+ Item {
121
+ width: parent.width
122
+ height: bodyText.wrap && custom.children.length > 0 ? 16 : 0
123
+ }
124
+ Row {
125
+ id: custom
126
+ spacing: 6
127
+ }
128
+ Item {
129
+ width: parent.width
130
+ height: bodyText.wrap ? 9 : 0
131
+ }
132
+ }
133
+
134
+ RowLayout {
135
+ id: rights
136
+ Layout.alignment: Qt.AlignTop
137
+
138
+ ToolButton {
139
+ Layout.alignment: Qt.AlignTop
140
+ id: closeButton
141
+ flat: true
142
+ icon.name: "ic_fluent_dismiss_20_regular"
143
+ size: 18
144
+ Layout.preferredWidth: 38
145
+ Layout.preferredHeight: 38
146
+ visible: closable
147
+ onClicked: {
148
+ exitAnimation.start()
149
+ // if (infoBar.isDynamic) {
150
+ // infoBar.destroy()
151
+ // } else {
152
+ // infoBar.visible = false
153
+ // }
154
+ }
155
+ ToolTip {
156
+ text: qsTr("Close")
157
+ parent: parent
158
+ visible: parent.hovered
159
+ }
160
+ }
161
+ }
162
+ }
163
+
164
+
165
+ // Animations
166
+ Component.onCompleted: {
167
+ startPosY = calculateStartPosY();
168
+ enterAnimation.start()
169
+ }
170
+
171
+ // Behavior on y { NumberAnimation { duration: Utils.animationSpeed; easing.type: Easing.OutQuint } }
172
+ transform: Translate {
173
+ id: slideTransform
174
+ y: 0
175
+ }
176
+
177
+ ParallelAnimation {
178
+ id: enterAnimation
179
+
180
+ NumberAnimation{
181
+ target: infoBar
182
+ property: "x"
183
+ from: infoBar.startPosX
184
+ to: infoBar.endPosX
185
+ easing.type: Easing.OutQuart
186
+ duration: Utils.animationSpeed
187
+ }
188
+ NumberAnimation {
189
+ target: slideTransform
190
+ property: "y"
191
+ from: infoBar.startPosY
192
+ to: 0
193
+ easing.type: Easing.OutCubic
194
+ duration: Utils.animationSpeed
195
+ }
196
+ NumberAnimation{
197
+ target: infoBar
198
+ property: "opacity"
199
+ from: 0
200
+ to: 1
201
+ duration: Utils.appearanceSpeed
202
+ }
203
+ }
204
+
205
+ SequentialAnimation{
206
+ id: exitAnimation
207
+
208
+ ParallelAnimation{
209
+ NumberAnimation{
210
+ target: infoBar
211
+ property: "y"
212
+ to: infoBar.startPosY
213
+ easing.type: Easing.OutQuart
214
+ duration: Utils.animationSpeed
215
+ running: false
216
+ }
217
+ NumberAnimation{
218
+ target: infoBar
219
+ property: "opacity"
220
+ from: 1
221
+ to: 0
222
+ duration: Utils.appearanceSpeed
223
+ }
224
+ }
225
+ ScriptAction{
226
+ script: {
227
+ if (infoBar.isDynamic) {
228
+ infoBar.destroy()
229
+ } else {
230
+ infoBar.visible = false
231
+ infoBar.opacity = 1
232
+ infoBar.y = 0
233
+ }
234
+ }
235
+ }
236
+ }
237
237
  }
@@ -1,93 +1,93 @@
1
- import QtQuick 2.15
2
- import QtQuick.Controls.Basic 2.15
3
- import QtQuick.Shapes 1.15
4
- import "../../themes"
5
- import "../../components"
6
-
7
- ToolTip {
8
- id: tooltip
9
- timeout: -1 // 显示时长
10
- text: "Tooltip"
11
-
12
- // 公共属性 / Common Properties
13
- property color backgroundColor: Theme.currentTheme.colors.backgroundAcrylicColor
14
- property color borderColor: Theme.currentTheme.colors.cardBorderColor
15
- property color textColor: Theme.currentTheme.colors.textColor
16
- property real controlRadius: Theme.currentTheme.appearance.buttonRadius
17
-
18
- function updateStyle() {
19
- backgroundColor = Theme.currentTheme.colors.backgroundAcrylicColor
20
- borderColor = Theme.currentTheme.colors.cardBorderColor
21
- textColor = Theme.currentTheme.colors.textColor
22
- controlRadius = Theme.currentTheme.appearance.buttonRadius
23
- }
24
-
25
- // 主题切换 / Theme Switching
26
- Connections {
27
- target: Theme
28
- function onCurrentThemeChanged() {
29
- updateStyle()
30
- }
31
- }
32
-
33
- Component.onCompleted: updateStyle()
34
-
35
-
36
- // 颜色动画 / Color Animation
37
- Behavior on backgroundColor { ColorAnimation { duration: 150; easing.type: Easing.OutQuart } }
38
- Behavior on textColor { ColorAnimation { duration: 150; easing.type: Easing.OutQuart } }
39
- Behavior on borderColor { ColorAnimation { duration: 150; easing.type: Easing.OutQuart } }
40
-
41
- property string tipText: text // 传递 tip 文字
42
-
43
- contentItem: Text {
44
- id: tooltipText
45
- anchors.centerIn: background
46
- typography: Typography.Caption
47
- text: tipText
48
- }
49
-
50
- background: Rectangle {
51
- id: background
52
- width: tooltipText.width + 20
53
- height: tooltipText.height + 13
54
- anchors.horizontalCenter: parent.horizontalCenter
55
- y: -6
56
-
57
- radius: controlRadius
58
- color: backgroundColor
59
- border.color: borderColor
60
-
61
- layer.enabled: true
62
- layer.effect: Shadow {
63
- style: "tooltip"
64
- source: background
65
- }
66
- }
67
-
68
- // 动画 / Animation //
69
- enter: Transition {
70
- ParallelAnimation {
71
- NumberAnimation {
72
- target: tooltip
73
- property: "opacity"
74
- from: 0
75
- to: 1
76
- duration: 250
77
- easing.type: Easing.InOutQuart
78
- }
79
- }
80
- }
81
- exit: Transition {
82
- ParallelAnimation {
83
- NumberAnimation {
84
- target: tooltip
85
- property: "opacity"
86
- from: 1
87
- to: 0
88
- duration: 300
89
- easing.type: Easing.InOutQuart
90
- }
91
- }
92
- }
93
- }
1
+ import QtQuick 2.15
2
+ import QtQuick.Controls.Basic 2.15
3
+ import QtQuick.Shapes 1.15
4
+ import "../../themes"
5
+ import "../../components"
6
+
7
+ ToolTip {
8
+ id: tooltip
9
+ timeout: -1 // 显示时长
10
+ text: "Tooltip"
11
+
12
+ // 公共属性 / Common Properties
13
+ property color backgroundColor: Theme.currentTheme.colors.backgroundAcrylicColor
14
+ property color borderColor: Theme.currentTheme.colors.cardBorderColor
15
+ property color textColor: Theme.currentTheme.colors.textColor
16
+ property real controlRadius: Theme.currentTheme.appearance.buttonRadius
17
+
18
+ function updateStyle() {
19
+ backgroundColor = Theme.currentTheme.colors.backgroundAcrylicColor
20
+ borderColor = Theme.currentTheme.colors.cardBorderColor
21
+ textColor = Theme.currentTheme.colors.textColor
22
+ controlRadius = Theme.currentTheme.appearance.buttonRadius
23
+ }
24
+
25
+ // 主题切换 / Theme Switching
26
+ Connections {
27
+ target: Theme
28
+ function onCurrentThemeChanged() {
29
+ updateStyle()
30
+ }
31
+ }
32
+
33
+ Component.onCompleted: updateStyle()
34
+
35
+
36
+ // 颜色动画 / Color Animation
37
+ Behavior on backgroundColor { ColorAnimation { duration: 150; easing.type: Easing.OutQuart } }
38
+ Behavior on textColor { ColorAnimation { duration: 150; easing.type: Easing.OutQuart } }
39
+ Behavior on borderColor { ColorAnimation { duration: 150; easing.type: Easing.OutQuart } }
40
+
41
+ property string tipText: text // 传递 tip 文字
42
+
43
+ contentItem: Text {
44
+ id: tooltipText
45
+ anchors.centerIn: background
46
+ typography: Typography.Caption
47
+ text: tipText
48
+ }
49
+
50
+ background: Rectangle {
51
+ id: background
52
+ width: tooltipText.width + 20
53
+ height: tooltipText.height + 13
54
+ anchors.horizontalCenter: parent.horizontalCenter
55
+ y: -6
56
+
57
+ radius: controlRadius
58
+ color: backgroundColor
59
+ border.color: borderColor
60
+
61
+ layer.enabled: true
62
+ layer.effect: Shadow {
63
+ style: "tooltip"
64
+ source: background
65
+ }
66
+ }
67
+
68
+ // 动画 / Animation //
69
+ enter: Transition {
70
+ ParallelAnimation {
71
+ NumberAnimation {
72
+ target: tooltip
73
+ property: "opacity"
74
+ from: 0
75
+ to: 1
76
+ duration: 250
77
+ easing.type: Easing.InOutQuart
78
+ }
79
+ }
80
+ }
81
+ exit: Transition {
82
+ ParallelAnimation {
83
+ NumberAnimation {
84
+ target: tooltip
85
+ property: "opacity"
86
+ from: 1
87
+ to: 0
88
+ duration: 300
89
+ easing.type: Easing.InOutQuart
90
+ }
91
+ }
92
+ }
93
+ }