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
@@ -1,224 +1,224 @@
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
- Popup {
8
- id: root
9
-
10
- width: 300
11
- height: 330
12
- implicitHeight: 330
13
- y: -height / 2 + buttonRow.height
14
- position: Position.Center // RinUI popup自定义属性
15
-
16
- property var value1: undefined
17
- property var value2: undefined
18
- property var value3: undefined
19
-
20
- property alias index1: hours.currentIndex
21
- property alias index2: minutes.currentIndex
22
- property alias index3: added.currentIndex
23
-
24
- property var model1: 12
25
- property var model2: 60
26
- property var model3: [qsTr("AM"), qsTr("PM")]
27
-
28
- property bool gotData: typeof value1!== "undefined" && typeof value2!== "undefined"
29
-
30
- signal valueChanged(var value1, var value2, var value3)
31
-
32
- function formatText(count, modelData) {
33
- let data = modelData;
34
- return data.toString().length < 2 && count === 60 ? "0" + data
35
- : data === 0 && count === 12 ? 12 : data
36
- }
37
-
38
- property int visibleItemCount: 7
39
-
40
- // 数字/文字 选择 //
41
- Component {
42
- id: delegateComponent
43
-
44
- Text {
45
- readonly property bool highlighted: Tumbler.displacement < 0.5 && Tumbler.displacement > -0.5
46
- text: formatText(Tumbler.tumbler.count, modelData)
47
- color: highlighted? Theme.currentTheme.colors.textOnAccentColor : Theme.currentTheme.colors.textColor
48
- horizontalAlignment: Text.AlignHCenter
49
- verticalAlignment: Text.AlignVCenter
50
-
51
- // 点击选择喵 看看啥时候把背景加上
52
- MouseArea {
53
- anchors.fill: parent
54
- onClicked: Tumbler.tumbler.currentIndex = index
55
- }
56
- }
57
- }
58
- padding: 0
59
-
60
- ColumnLayout {
61
- id: columnLayout
62
- anchors.fill: parent
63
- spacing: -2
64
-
65
- Frame {
66
- Layout.fillWidth: true
67
- Layout.fillHeight: true
68
- padding: 0
69
- leftPadding: 4
70
- rightPadding: 4
71
-
72
- frameless: true
73
- background: Rectangle {
74
- id: highlightBackground
75
- anchors.centerIn: parent
76
- height: 40
77
- radius: Theme.currentTheme.appearance.buttonRadius
78
- color: Theme.currentTheme.colors.primaryColor
79
- width: parent.width - parent.leftPadding - parent.rightPadding
80
- }
81
-
82
- RowLayout {
83
- id: tumblerRow
84
- anchors.fill: parent
85
-
86
- Tumbler {
87
- Layout.fillWidth: true
88
- Layout.fillHeight: true
89
- id: hours
90
- model: model1
91
- visibleItemCount: root.visibleItemCount
92
- delegate: delegateComponent
93
-
94
- }
95
- ToolSeparator {
96
- Layout.fillHeight: true
97
- }
98
- Tumbler {
99
- Layout.fillWidth: true
100
- Layout.fillHeight: true
101
- id: minutes
102
- model: model2
103
- visibleItemCount: root.visibleItemCount
104
- delegate: delegateComponent
105
- }
106
- ToolSeparator {
107
- Layout.fillHeight: true
108
- visible: added.visible
109
- }
110
- Tumbler {
111
- Layout.fillWidth: true
112
- Layout.fillHeight: true
113
- id: added
114
- model: model3
115
- visibleItemCount: root.visibleItemCount
116
- delegate: delegateComponent
117
- visible: typeof model3 !== "undefined"
118
- }
119
- }
120
- }
121
-
122
- Rectangle { // 分割线
123
- Layout.fillWidth: true
124
- implicitHeight: 1
125
- color: Theme.currentTheme.colors.dividerBorderColor
126
- }
127
-
128
- // 确认/取消 按钮区域
129
- RowLayout {
130
- id: buttonRow
131
- Layout.fillWidth: true
132
- Layout.leftMargin: 4
133
- Layout.rightMargin: 4
134
- spacing: 0
135
-
136
- // confirm
137
- ToolButton {
138
- Layout.fillWidth: true
139
- flat: true
140
- icon.name: "ic_fluent_checkmark_20_regular"
141
- onClicked: {
142
- value1 = hours.currentItem.text
143
- value2 = minutes.currentItem.text
144
- typeof model3 !== "undefined" ? value3 = added.currentItem.text : undefined
145
- valueChanged(value1, value2, value3)
146
- root.close()
147
- }
148
- }
149
- ToolSeparator {
150
- implicitHeight: 40
151
- }
152
- // cancel
153
- ToolButton {
154
- Layout.fillWidth: true
155
- flat: true
156
- icon.name: "ic_fluent_dismiss_20_regular"
157
- onClicked: {
158
- root.close()
159
- }
160
- }
161
- }
162
- }
163
-
164
- enter: Transition {
165
- ParallelAnimation {
166
- NumberAnimation {
167
- target: root
168
- property: "opacity"
169
- from: 0
170
- to: 1
171
- duration: Utils.appearanceSpeed
172
- easing.type: Easing.OutQuint
173
- }
174
- NumberAnimation {
175
- target: root
176
- property: "height"
177
- from: implicitHeight / 2
178
- to: implicitHeight
179
- duration: Utils.animationSpeedMiddle * 0.8
180
- easing.type: Easing.OutQuint
181
- }
182
- ScriptAction {
183
- script: {
184
- hours.positionViewAtIndex(
185
- typeof value1 === "undefined" ? 0
186
- : typeof model1 === "number" ? value1 : model1.indexOf(value1), Tumbler.Center
187
- )
188
- minutes.positionViewAtIndex(
189
- typeof value2 === "undefined" ? 0
190
- : typeof model2 === "number" ? value2 : model2.indexOf(value2), Tumbler.Center
191
- )
192
- added.positionViewAtIndex(
193
- typeof value3 === "undefined" ? 0
194
- : typeof model3 === "number" ? value3 : model3.indexOf(parseInt(value3)), Tumbler.Center
195
- )
196
- }
197
- }
198
- }
199
- }
200
-
201
- background: Rectangle {
202
- id: background
203
- anchors.fill: parent
204
- anchors.horizontalCenter: parent.horizontalCenter
205
- y: -6
206
-
207
- radius: Theme.currentTheme.appearance.windowRadius
208
- color: Theme.currentTheme.colors.backgroundAcrylicColor
209
- border.color: Theme.currentTheme.colors.flyoutBorderColor
210
-
211
- Behavior on color {
212
- ColorAnimation {
213
- duration: Utils.appearanceSpeed
214
- easing.type: Easing.OutQuart
215
- }
216
- }
217
-
218
- layer.enabled: true
219
- layer.effect: Shadow {
220
- style: "flyout"
221
- source: background
222
- }
223
- }
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
+ Popup {
8
+ id: root
9
+
10
+ width: 300
11
+ height: 330
12
+ implicitHeight: 330
13
+ y: -height / 2 + buttonRow.height
14
+ position: Position.Center // RinUI popup自定义属性
15
+
16
+ property var value1: undefined
17
+ property var value2: undefined
18
+ property var value3: undefined
19
+
20
+ property alias index1: hours.currentIndex
21
+ property alias index2: minutes.currentIndex
22
+ property alias index3: added.currentIndex
23
+
24
+ property var model1: 12
25
+ property var model2: 60
26
+ property var model3: [qsTr("AM"), qsTr("PM")]
27
+
28
+ property bool gotData: typeof value1!== "undefined" && typeof value2!== "undefined"
29
+
30
+ signal valueChanged(var value1, var value2, var value3)
31
+
32
+ function formatText(count, modelData) {
33
+ let data = modelData;
34
+ return data.toString().length < 2 && count === 60 ? "0" + data
35
+ : data === 0 && count === 12 ? 12 : data
36
+ }
37
+
38
+ property int visibleItemCount: 7
39
+
40
+ // 数字/文字 选择 //
41
+ Component {
42
+ id: delegateComponent
43
+
44
+ Text {
45
+ readonly property bool highlighted: Tumbler.displacement < 0.5 && Tumbler.displacement > -0.5
46
+ text: formatText(Tumbler.tumbler.count, modelData)
47
+ color: highlighted? Theme.currentTheme.colors.textOnAccentColor : Theme.currentTheme.colors.textColor
48
+ horizontalAlignment: Text.AlignHCenter
49
+ verticalAlignment: Text.AlignVCenter
50
+
51
+ // 点击选择喵 看看啥时候把背景加上
52
+ MouseArea {
53
+ anchors.fill: parent
54
+ onClicked: Tumbler.tumbler.currentIndex = index
55
+ }
56
+ }
57
+ }
58
+ padding: 0
59
+
60
+ ColumnLayout {
61
+ id: columnLayout
62
+ anchors.fill: parent
63
+ spacing: -2
64
+
65
+ Frame {
66
+ Layout.fillWidth: true
67
+ Layout.fillHeight: true
68
+ padding: 0
69
+ leftPadding: 4
70
+ rightPadding: 4
71
+
72
+ frameless: true
73
+ background: Rectangle {
74
+ id: highlightBackground
75
+ anchors.centerIn: parent
76
+ height: 40
77
+ radius: Theme.currentTheme.appearance.buttonRadius
78
+ color: Theme.currentTheme.colors.primaryColor
79
+ width: parent.width - parent.leftPadding - parent.rightPadding
80
+ }
81
+
82
+ RowLayout {
83
+ id: tumblerRow
84
+ anchors.fill: parent
85
+
86
+ Tumbler {
87
+ Layout.fillWidth: true
88
+ Layout.fillHeight: true
89
+ id: hours
90
+ model: model1
91
+ visibleItemCount: root.visibleItemCount
92
+ delegate: delegateComponent
93
+
94
+ }
95
+ ToolSeparator {
96
+ Layout.fillHeight: true
97
+ }
98
+ Tumbler {
99
+ Layout.fillWidth: true
100
+ Layout.fillHeight: true
101
+ id: minutes
102
+ model: model2
103
+ visibleItemCount: root.visibleItemCount
104
+ delegate: delegateComponent
105
+ }
106
+ ToolSeparator {
107
+ Layout.fillHeight: true
108
+ visible: added.visible
109
+ }
110
+ Tumbler {
111
+ Layout.fillWidth: true
112
+ Layout.fillHeight: true
113
+ id: added
114
+ model: model3
115
+ visibleItemCount: root.visibleItemCount
116
+ delegate: delegateComponent
117
+ visible: typeof model3 !== "undefined"
118
+ }
119
+ }
120
+ }
121
+
122
+ Rectangle { // 分割线
123
+ Layout.fillWidth: true
124
+ implicitHeight: 1
125
+ color: Theme.currentTheme.colors.dividerBorderColor
126
+ }
127
+
128
+ // 确认/取消 按钮区域
129
+ RowLayout {
130
+ id: buttonRow
131
+ Layout.fillWidth: true
132
+ Layout.leftMargin: 4
133
+ Layout.rightMargin: 4
134
+ spacing: 0
135
+
136
+ // confirm
137
+ ToolButton {
138
+ Layout.fillWidth: true
139
+ flat: true
140
+ icon.name: "ic_fluent_checkmark_20_regular"
141
+ onClicked: {
142
+ value1 = hours.currentItem.text
143
+ value2 = minutes.currentItem.text
144
+ typeof model3 !== "undefined" ? value3 = added.currentItem.text : undefined
145
+ valueChanged(value1, value2, value3)
146
+ root.close()
147
+ }
148
+ }
149
+ ToolSeparator {
150
+ implicitHeight: 40
151
+ }
152
+ // cancel
153
+ ToolButton {
154
+ Layout.fillWidth: true
155
+ flat: true
156
+ icon.name: "ic_fluent_dismiss_20_regular"
157
+ onClicked: {
158
+ root.close()
159
+ }
160
+ }
161
+ }
162
+ }
163
+
164
+ enter: Transition {
165
+ ParallelAnimation {
166
+ NumberAnimation {
167
+ target: root
168
+ property: "opacity"
169
+ from: 0
170
+ to: 1
171
+ duration: Utils.appearanceSpeed
172
+ easing.type: Easing.OutQuint
173
+ }
174
+ NumberAnimation {
175
+ target: root
176
+ property: "height"
177
+ from: implicitHeight / 2
178
+ to: implicitHeight
179
+ duration: Utils.animationSpeedMiddle * 0.8
180
+ easing.type: Easing.OutQuint
181
+ }
182
+ ScriptAction {
183
+ script: {
184
+ hours.positionViewAtIndex(
185
+ typeof value1 === "undefined" ? 0
186
+ : typeof model1 === "number" ? value1 : model1.indexOf(value1), Tumbler.Center
187
+ )
188
+ minutes.positionViewAtIndex(
189
+ typeof value2 === "undefined" ? 0
190
+ : typeof model2 === "number" ? value2 : model2.indexOf(value2), Tumbler.Center
191
+ )
192
+ added.positionViewAtIndex(
193
+ typeof value3 === "undefined" ? 0
194
+ : typeof model3 === "number" ? value3 : model3.indexOf(parseInt(value3)), Tumbler.Center
195
+ )
196
+ }
197
+ }
198
+ }
199
+ }
200
+
201
+ background: Rectangle {
202
+ id: background
203
+ anchors.fill: parent
204
+ anchors.horizontalCenter: parent.horizontalCenter
205
+ y: -6
206
+
207
+ radius: Theme.currentTheme.appearance.windowRadius
208
+ color: Theme.currentTheme.colors.backgroundAcrylicColor
209
+ border.color: Theme.currentTheme.colors.flyoutBorderColor
210
+
211
+ Behavior on color {
212
+ ColorAnimation {
213
+ duration: Utils.appearanceSpeed
214
+ easing.type: Easing.OutQuart
215
+ }
216
+ }
217
+
218
+ layer.enabled: true
219
+ layer.effect: Shadow {
220
+ style: "flyout"
221
+ source: background
222
+ }
223
+ }
224
224
  }
@@ -1,115 +1,115 @@
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: timePickerButton
9
-
10
- property string amText: qsTr("AM")
11
- property string pmText: qsTr("PM")
12
- property string hourText: qsTr("hour")
13
- property string minuteText: qsTr("minute")
14
-
15
- // 是否使用24小时制
16
- property bool use24Hour: false
17
-
18
- property alias hour: pickerView.value1
19
- property alias minute: pickerView.value2
20
- property alias hourSystem: pickerView.value3
21
-
22
- implicitWidth: 250
23
- padding: 0
24
-
25
- // 获取 / 设置时间 // Get / Set time (hh:mm)
26
- // 获取 / 设置时间 (hh:mm)
27
- property string time: {
28
- if (!pickerView.gotData) return ""
29
- let h = parseInt(hour)
30
- if (!use24Hour) {
31
- if (hourSystem === pmText && h < 12) h += 12
32
- if (hourSystem === amText && h === 12) h = 0
33
- }
34
- let hh = h < 10 ? "0" + h : "" + h
35
- let mm = parseInt(minute)
36
- let mmStr = mm < 10 ? "0" + mm : "" + mm
37
- return hh + ":" + mmStr
38
- }
39
-
40
- function setTime(hhmm) {
41
- if (!hhmm || typeof hhmm !== "string" || !hhmm.match(/^\d{2}:\d{2}$/)) return
42
-
43
- let parts = hhmm.split(":")
44
- let h = parseInt(parts[0])
45
- let m = parseInt(parts[1])
46
-
47
- if (h >= 0 && h < 24 && m >= 0 && m < 60) {
48
- if (use24Hour) {
49
- pickerView.value1 = h.toString()
50
- pickerView.value2 = m.toString()
51
- pickerView.value3 = undefined
52
- } else {
53
- pickerView.value1 = ((h % 12 === 0) ? 12 : h % 12).toString()
54
- pickerView.value2 = m.toString()
55
- pickerView.value3 = h >= 12 ? pmText : amText
56
- }
57
- pickerView.gotData = true
58
- }
59
- }
60
-
61
- // 重写按钮结果
62
- contentItem: RowLayout {
63
- anchors.fill: parent
64
- spacing: 0
65
-
66
- Text {
67
- Layout.fillWidth: true
68
- Layout.maximumWidth: use24Hour ? timePickerButton.implicitWidth / 2 : timePickerButton.implicitWidth / 3
69
- color: pickerView.gotData ? Theme.currentTheme.colors.textColor
70
- : Theme.currentTheme.colors.textSecondaryColor
71
- horizontalAlignment: Text.AlignHCenter
72
- verticalAlignment: Text.AlignVCenter
73
-
74
- text: pickerView.gotData ? pickerView.value1 : hourText
75
- }
76
- ToolSeparator {
77
- implicitHeight: 32
78
- }
79
- Text {
80
- Layout.fillWidth: true
81
- Layout.maximumWidth: use24Hour ? timePickerButton.implicitWidth / 2 : timePickerButton.implicitWidth / 3
82
- color: pickerView.gotData ? Theme.currentTheme.colors.textColor
83
- : Theme.currentTheme.colors.textSecondaryColor
84
- horizontalAlignment: Text.AlignHCenter
85
- verticalAlignment: Text.AlignVCenter
86
-
87
- text: pickerView.gotData ? pickerView.value2 : minuteText
88
- }
89
- ToolSeparator {
90
- implicitHeight: 32
91
- visible: !use24Hour
92
- }
93
- Text {
94
- Layout.fillWidth: true
95
- Layout.maximumWidth: timePickerButton.implicitWidth / 3
96
- color: pickerView.gotData ? Theme.currentTheme.colors.textColor
97
- : Theme.currentTheme.colors.textSecondaryColor
98
- horizontalAlignment: Text.AlignHCenter
99
- verticalAlignment: Text.AlignVCenter
100
-
101
- text: pickerView.gotData ? pickerView.value3 : amText
102
- visible: !use24Hour
103
- }
104
- }
105
-
106
- onClicked: pickerView.open()
107
-
108
- PickerView {
109
- id: pickerView
110
- width: parent.width
111
-
112
- model1: use24Hour ? 24 : 12
113
- model3: use24Hour ? undefined : [amText, pmText]
114
- }
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: timePickerButton
9
+
10
+ property string amText: qsTr("AM")
11
+ property string pmText: qsTr("PM")
12
+ property string hourText: qsTr("hour")
13
+ property string minuteText: qsTr("minute")
14
+
15
+ // 是否使用24小时制
16
+ property bool use24Hour: false
17
+
18
+ property alias hour: pickerView.value1
19
+ property alias minute: pickerView.value2
20
+ property alias hourSystem: pickerView.value3
21
+
22
+ implicitWidth: 250
23
+ padding: 0
24
+
25
+ // 获取 / 设置时间 // Get / Set time (hh:mm)
26
+ // 获取 / 设置时间 (hh:mm)
27
+ property string time: {
28
+ if (!pickerView.gotData) return ""
29
+ let h = parseInt(hour)
30
+ if (!use24Hour) {
31
+ if (hourSystem === pmText && h < 12) h += 12
32
+ if (hourSystem === amText && h === 12) h = 0
33
+ }
34
+ let hh = h < 10 ? "0" + h : "" + h
35
+ let mm = parseInt(minute)
36
+ let mmStr = mm < 10 ? "0" + mm : "" + mm
37
+ return hh + ":" + mmStr
38
+ }
39
+
40
+ function setTime(hhmm) {
41
+ if (!hhmm || typeof hhmm !== "string" || !hhmm.match(/^\d{2}:\d{2}$/)) return
42
+
43
+ let parts = hhmm.split(":")
44
+ let h = parseInt(parts[0])
45
+ let m = parseInt(parts[1])
46
+
47
+ if (h >= 0 && h < 24 && m >= 0 && m < 60) {
48
+ if (use24Hour) {
49
+ pickerView.value1 = h.toString()
50
+ pickerView.value2 = m.toString()
51
+ pickerView.value3 = undefined
52
+ } else {
53
+ pickerView.value1 = ((h % 12 === 0) ? 12 : h % 12).toString()
54
+ pickerView.value2 = m.toString()
55
+ pickerView.value3 = h >= 12 ? pmText : amText
56
+ }
57
+ pickerView.gotData = true
58
+ }
59
+ }
60
+
61
+ // 重写按钮结果
62
+ contentItem: RowLayout {
63
+ anchors.fill: parent
64
+ spacing: 0
65
+
66
+ Text {
67
+ Layout.fillWidth: true
68
+ Layout.maximumWidth: use24Hour ? timePickerButton.implicitWidth / 2 : timePickerButton.implicitWidth / 3
69
+ color: pickerView.gotData ? Theme.currentTheme.colors.textColor
70
+ : Theme.currentTheme.colors.textSecondaryColor
71
+ horizontalAlignment: Text.AlignHCenter
72
+ verticalAlignment: Text.AlignVCenter
73
+
74
+ text: pickerView.gotData ? pickerView.value1 : hourText
75
+ }
76
+ ToolSeparator {
77
+ implicitHeight: 32
78
+ }
79
+ Text {
80
+ Layout.fillWidth: true
81
+ Layout.maximumWidth: use24Hour ? timePickerButton.implicitWidth / 2 : timePickerButton.implicitWidth / 3
82
+ color: pickerView.gotData ? Theme.currentTheme.colors.textColor
83
+ : Theme.currentTheme.colors.textSecondaryColor
84
+ horizontalAlignment: Text.AlignHCenter
85
+ verticalAlignment: Text.AlignVCenter
86
+
87
+ text: pickerView.gotData ? pickerView.value2 : minuteText
88
+ }
89
+ ToolSeparator {
90
+ implicitHeight: 32
91
+ visible: !use24Hour
92
+ }
93
+ Text {
94
+ Layout.fillWidth: true
95
+ Layout.maximumWidth: timePickerButton.implicitWidth / 3
96
+ color: pickerView.gotData ? Theme.currentTheme.colors.textColor
97
+ : Theme.currentTheme.colors.textSecondaryColor
98
+ horizontalAlignment: Text.AlignHCenter
99
+ verticalAlignment: Text.AlignVCenter
100
+
101
+ text: pickerView.gotData ? pickerView.value3 : amText
102
+ visible: !use24Hour
103
+ }
104
+ }
105
+
106
+ onClicked: pickerView.open()
107
+
108
+ PickerView {
109
+ id: pickerView
110
+ width: parent.width
111
+
112
+ model1: use24Hour ? 24 : 12
113
+ model3: use24Hour ? undefined : [amText, pmText]
114
+ }
115
115
  }