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,151 +1,151 @@
1
- import QtQuick 2.15
2
- import QtQuick.Controls 2.15
3
- import "../../themes"
4
- import "../../components"
5
-
6
-
7
- Menu {
8
- id: root
9
-
10
- property int position: Position.Bottom // 位置
11
-
12
- property real posX: {
13
- switch (position) {
14
- case Position.Top:
15
- case Position.Bottom:
16
- return (parent.width - root.width) / 2
17
- case Position.Left:
18
- return - root.width - 5
19
- case Position.Right:
20
- return parent.width + 5
21
- default:
22
- // return (parent.width - root.width) / 2
23
- return root.x
24
- }
25
- }
26
-
27
- property real posY: {
28
- switch (position) {
29
- case Position.Top:
30
- return -root.height - 5
31
- case Position.Bottom:
32
- return parent.height + 5
33
- case Position.Left:
34
- case Position.Right:
35
- return (parent.height - root.height) / 2
36
- default:
37
- // return -root.height + 5 // 默认顶部
38
- return root.y
39
- }
40
- }
41
-
42
- implicitWidth: Math.max(contentItem.implicitWidth, 80)
43
- implicitHeight: contentItem.implicitHeight
44
- // x: (parent.width - root.width) / 2
45
- // y: parent.height + 5
46
-
47
- enter: Transition {
48
- ParallelAnimation {
49
- NumberAnimation {
50
- target: root
51
- property: "opacity"
52
- from: 0
53
- to: 1
54
- duration: Utils.animationSpeed
55
- easing.type: Easing.InOutQuart
56
- }
57
- NumberAnimation {
58
- target: root
59
- property: "height"
60
- from: (position === Position.Top || position === Position.Bottom ? 0 : root.implicitHeight)
61
- to: root.implicitHeight
62
- duration: Utils.animationSpeed
63
- easing.type: Easing.OutQuart
64
- }
65
- NumberAnimation {
66
- target: root
67
- property: "x"
68
- from: posX + (position === Position.Left ? 5 : position === Position.Right ? -5 : 0)
69
- to: posX
70
- duration: Utils.animationSpeedMiddle
71
- easing.type: Easing.OutQuint
72
- onRunningChanged: {
73
- scrollBar.visible = true;
74
- }
75
- }
76
- NumberAnimation {
77
- target: root
78
- property: "y"
79
- from: posY + (position === Position.Top || position === Position.Bottom
80
- ? (position === Position.Top ? implicitHeight / 2 : position === Position.Bottom ? -implicitHeight / 2 : implicitHeight / 2)
81
- : 0)
82
- to: posY
83
- duration: Utils.animationSpeedMiddle
84
- easing.type: Easing.OutQuint
85
- onRunningChanged: {
86
- scrollBar.visible = true;
87
- }
88
- }
89
- }
90
- }
91
- exit: Transition {
92
- ParallelAnimation {
93
- NumberAnimation {
94
- target: root
95
- property: "opacity"
96
- from: 1
97
- to: 0
98
- duration: 150
99
- easing.type: Easing.InOutQuart
100
- }
101
- }
102
- }
103
-
104
- spacing: 5
105
- topPadding: 5
106
- bottomPadding: 5
107
-
108
- background: Rectangle {
109
- implicitWidth: 80
110
- implicitHeight: 36
111
- radius: Theme.currentTheme.appearance.windowRadius
112
- color: Theme.currentTheme.colors.backgroundAcrylicColor
113
- border.color: Theme.currentTheme.colors.flyoutBorderColor
114
-
115
- layer.enabled: true
116
- layer.effect: Shadow {
117
- id: shadow
118
- style: "flyout"
119
- source: background
120
- }
121
- }
122
-
123
- delegate: MenuItem { }
124
-
125
- contentItem: Flickable {
126
- id: flickable
127
- clip: true
128
- anchors.fill: parent
129
- // contentWidth: width
130
- // contentHeight: column.implicitHeight
131
- implicitWidth: column.implicitWidth
132
- implicitHeight: column.implicitHeight
133
- // interactive: column.implicitHeight > height
134
-
135
- Column {
136
- id: column
137
- topPadding: 5
138
- bottomPadding: 5
139
- Repeater {
140
- model: root.contentModel // 默认的 Menu 内容
141
- delegate: root.delegate
142
- }
143
- }
144
-
145
- ScrollBar.vertical: ScrollBar {
146
- id: scrollBar
147
- policy: ScrollBar.AsNeeded
148
- visible: false // 初始隐藏,在 enter 动画中显现
149
- }
150
- }
1
+ import QtQuick 2.15
2
+ import QtQuick.Controls 2.15
3
+ import "../../themes"
4
+ import "../../components"
5
+
6
+
7
+ Menu {
8
+ id: root
9
+
10
+ property int position: Position.Bottom // 位置
11
+
12
+ property real posX: {
13
+ switch (position) {
14
+ case Position.Top:
15
+ case Position.Bottom:
16
+ return (parent.width - root.width) / 2
17
+ case Position.Left:
18
+ return - root.width - 5
19
+ case Position.Right:
20
+ return parent.width + 5
21
+ default:
22
+ // return (parent.width - root.width) / 2
23
+ return root.x
24
+ }
25
+ }
26
+
27
+ property real posY: {
28
+ switch (position) {
29
+ case Position.Top:
30
+ return -root.height - 5
31
+ case Position.Bottom:
32
+ return parent.height + 5
33
+ case Position.Left:
34
+ case Position.Right:
35
+ return (parent.height - root.height) / 2
36
+ default:
37
+ // return -root.height + 5 // 默认顶部
38
+ return root.y
39
+ }
40
+ }
41
+
42
+ implicitWidth: Math.max(contentItem.implicitWidth, 80)
43
+ implicitHeight: contentItem.implicitHeight
44
+ // x: (parent.width - root.width) / 2
45
+ // y: parent.height + 5
46
+
47
+ enter: Transition {
48
+ ParallelAnimation {
49
+ NumberAnimation {
50
+ target: root
51
+ property: "opacity"
52
+ from: 0
53
+ to: 1
54
+ duration: Utils.animationSpeed
55
+ easing.type: Easing.InOutQuart
56
+ }
57
+ NumberAnimation {
58
+ target: root
59
+ property: "height"
60
+ from: (position === Position.Top || position === Position.Bottom ? 0 : root.implicitHeight)
61
+ to: root.implicitHeight
62
+ duration: Utils.animationSpeed
63
+ easing.type: Easing.OutQuart
64
+ }
65
+ NumberAnimation {
66
+ target: root
67
+ property: "x"
68
+ from: posX + (position === Position.Left ? 5 : position === Position.Right ? -5 : 0)
69
+ to: posX
70
+ duration: Utils.animationSpeedMiddle
71
+ easing.type: Easing.OutQuint
72
+ onRunningChanged: {
73
+ scrollBar.visible = true;
74
+ }
75
+ }
76
+ NumberAnimation {
77
+ target: root
78
+ property: "y"
79
+ from: posY + (position === Position.Top || position === Position.Bottom
80
+ ? (position === Position.Top ? implicitHeight / 2 : position === Position.Bottom ? -implicitHeight / 2 : implicitHeight / 2)
81
+ : 0)
82
+ to: posY
83
+ duration: Utils.animationSpeedMiddle
84
+ easing.type: Easing.OutQuint
85
+ onRunningChanged: {
86
+ scrollBar.visible = true;
87
+ }
88
+ }
89
+ }
90
+ }
91
+ exit: Transition {
92
+ ParallelAnimation {
93
+ NumberAnimation {
94
+ target: root
95
+ property: "opacity"
96
+ from: 1
97
+ to: 0
98
+ duration: 150
99
+ easing.type: Easing.InOutQuart
100
+ }
101
+ }
102
+ }
103
+
104
+ spacing: 5
105
+ topPadding: 5
106
+ bottomPadding: 5
107
+
108
+ background: Rectangle {
109
+ implicitWidth: 80
110
+ implicitHeight: 36
111
+ radius: Theme.currentTheme.appearance.windowRadius
112
+ color: Theme.currentTheme.colors.backgroundAcrylicColor
113
+ border.color: Theme.currentTheme.colors.flyoutBorderColor
114
+
115
+ layer.enabled: true
116
+ layer.effect: Shadow {
117
+ id: shadow
118
+ style: "flyout"
119
+ source: background
120
+ }
121
+ }
122
+
123
+ delegate: MenuItem { }
124
+
125
+ contentItem: Flickable {
126
+ id: flickable
127
+ clip: true
128
+ anchors.fill: parent
129
+ // contentWidth: width
130
+ // contentHeight: column.implicitHeight
131
+ implicitWidth: column.implicitWidth
132
+ implicitHeight: column.implicitHeight
133
+ // interactive: column.implicitHeight > height
134
+
135
+ Column {
136
+ id: column
137
+ topPadding: 5
138
+ bottomPadding: 5
139
+ Repeater {
140
+ model: root.contentModel // 默认的 Menu 内容
141
+ delegate: root.delegate
142
+ }
143
+ }
144
+
145
+ ScrollBar.vertical: ScrollBar {
146
+ id: scrollBar
147
+ policy: ScrollBar.AsNeeded
148
+ visible: false // 初始隐藏,在 enter 动画中显现
149
+ }
150
+ }
151
151
  }
@@ -1,43 +1,43 @@
1
- import QtQuick 2.15
2
- import QtQuick.Controls.Basic 2.15
3
- import "../../components"
4
- import "../../themes"
5
-
6
- MenuBar {
7
- id: menuBar
8
- padding: 4
9
-
10
- delegate: MenuBarItem {
11
- id: menuBarItem
12
- focusPolicy: Qt.StrongFocus // to get keyboard focus
13
-
14
- // accessibility
15
- FocusIndicator {
16
- control: parent
17
- }
18
-
19
- padding: 6
20
- topPadding: 5
21
- bottomPadding: 7
22
-
23
- contentItem: Text {
24
- id: text
25
- anchors.centerIn: parent
26
- typography: Typography.Body
27
- horizontalAlignment: Text.AlignHCenter
28
- text: menuBarItem.text
29
- }
30
-
31
- background: Rectangle {
32
- id: background
33
- implicitHeight: 32
34
- color: Theme.currentTheme.colors.subtleSecondaryColor
35
- radius: Theme.currentTheme.appearance.buttonRadius
36
-
37
- Behavior on color { ColorAnimation { duration: Utils.appearanceSpeed; easing.type: Easing.OutQuart } }
38
- opacity: !hovered ? 0 : 1
39
- }
40
- }
41
-
42
- background: Item {}
1
+ import QtQuick 2.15
2
+ import QtQuick.Controls.Basic 2.15
3
+ import "../../components"
4
+ import "../../themes"
5
+
6
+ MenuBar {
7
+ id: menuBar
8
+ padding: 4
9
+
10
+ delegate: MenuBarItem {
11
+ id: menuBarItem
12
+ focusPolicy: Qt.StrongFocus // to get keyboard focus
13
+
14
+ // accessibility
15
+ FocusIndicator {
16
+ control: parent
17
+ }
18
+
19
+ padding: 6
20
+ topPadding: 5
21
+ bottomPadding: 7
22
+
23
+ contentItem: Text {
24
+ id: text
25
+ anchors.centerIn: parent
26
+ typography: Typography.Body
27
+ horizontalAlignment: Text.AlignHCenter
28
+ text: menuBarItem.text
29
+ }
30
+
31
+ background: Rectangle {
32
+ id: background
33
+ implicitHeight: 32
34
+ color: Theme.currentTheme.colors.subtleSecondaryColor
35
+ radius: Theme.currentTheme.appearance.buttonRadius
36
+
37
+ Behavior on color { ColorAnimation { duration: Utils.appearanceSpeed; easing.type: Easing.OutQuart } }
38
+ opacity: !hovered ? 0 : 1
39
+ }
40
+ }
41
+
42
+ background: Item {}
43
43
  }
@@ -1,132 +1,132 @@
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
-
8
- MenuItem {
9
- id: root
10
- implicitWidth: {
11
- const leftMargin = 16;
12
- const arrowWidth = arrow.visible ? arrow.width + 16 : root.checked ? indicator.width + 16 : 0;
13
- const rightMargin = 16;
14
- return leftMargin + contentItem.implicitWidth + arrowWidth + rightMargin;
15
- }
16
- implicitHeight: Math.max(implicitContentHeight + topPadding + bottomPadding,
17
- 34)
18
-
19
- property MenuItemGroup group // 组
20
-
21
- checkable: group
22
- checked: group ? group.checkedButton === root : false
23
-
24
- onGroupChanged: {
25
- if (group)
26
- group.register(root)
27
- }
28
-
29
- Component.onDestruction: {
30
- if (group)
31
- group.unregister(root)
32
- }
33
-
34
- onTriggered: {
35
- if (group)
36
- group.updateCheck(root)
37
- }
38
-
39
- property var parentMenu: undefined
40
-
41
- // accessibility
42
- FocusIndicator {
43
- control: parent
44
- anchors.margins: 5
45
- anchors.topMargin: 0
46
- anchors.bottomMargin: 0
47
- }
48
-
49
- arrow: IconWidget {
50
- anchors.verticalCenter: parent.verticalCenter
51
- anchors.right: parent.right
52
- anchors.margins: 16
53
- color: Theme.currentTheme.colors.textSecondaryColor
54
- visible: root.subMenu
55
- icon: "ic_fluent_chevron_right_20_regular"
56
- size: 12
57
- }
58
-
59
- indicator: IconWidget {
60
- id: indicator
61
- anchors.verticalCenter: parent.verticalCenter
62
- anchors.left: parent.left
63
- anchors.margins: 18
64
- icon: group ? group.exclusive ? "ic_fluent_circle_20_filled" : "ic_fluent_checkmark_20_filled"
65
- : "ic_fluent_checkmark_20_filled"
66
- width: 16
67
- size: group ? group.exclusive ? 7 : 16 : 16
68
- visible: root.checked
69
- }
70
-
71
- // 内容 / Content //
72
- contentItem: RowLayout {
73
- id: row
74
- spacing: 16
75
- anchors.verticalCenter: parent.verticalCenter
76
- anchors.left: parent.left
77
- anchors.right: parent.right
78
- anchors.leftMargin: (iconWidget.size ? 16 : 0) + (checkable ? indicator.width + 16 : 0)
79
- anchors.margins: 16
80
-
81
- IconWidget {
82
- id: iconWidget
83
- size: icon || source ? menuText.font.pixelSize * 1.25 : 0 // 图标大小 / Icon Size
84
- icon: root.icon.name
85
- source: root.icon.source
86
- }
87
- Text {
88
- id: menuText
89
- Layout.fillWidth: true
90
- Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
91
- typography: Typography.Body
92
- text: root.text
93
- wrapMode: Text.NoWrap
94
- }
95
- Text {
96
- id: shortcutText
97
- Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
98
- typography: Typography.Caption
99
- text: root.action ? root.action.shortcut : ""
100
- color: Theme.currentTheme.colors.textSecondaryColor
101
- visible: text
102
- }
103
- }
104
-
105
- // 背景 / Background //
106
- background: Rectangle {
107
- anchors.fill: parent
108
- anchors.margins: 5
109
- anchors.topMargin: 0
110
- anchors.bottomMargin: 0
111
- radius: Theme.currentTheme.appearance.buttonRadius
112
- color: enabled ? pressed ? Theme.currentTheme.colors.subtleTertiaryColor
113
- : hovered
114
- ? Theme.currentTheme.colors.subtleSecondaryColor
115
- : "transparent" : "transparent"
116
-
117
- Behavior on color { ColorAnimation { duration: Utils.animationSpeed; easing.type: Easing.OutQuart } }
118
- }
119
-
120
- // States //
121
- // 状态变化
122
- states: [
123
- State {
124
- name: "disabled"
125
- when: !enabled
126
- PropertyChanges {
127
- target: root
128
- opacity: 0.3628
129
- }
130
- }
131
- ]
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
+
8
+ MenuItem {
9
+ id: root
10
+ implicitWidth: {
11
+ const leftMargin = 16;
12
+ const arrowWidth = arrow.visible ? arrow.width + 16 : root.checked ? indicator.width + 16 : 0;
13
+ const rightMargin = 16;
14
+ return leftMargin + contentItem.implicitWidth + arrowWidth + rightMargin;
15
+ }
16
+ implicitHeight: Math.max(implicitContentHeight + topPadding + bottomPadding,
17
+ 34)
18
+
19
+ property MenuItemGroup group // 组
20
+
21
+ checkable: group
22
+ checked: group ? group.checkedButton === root : false
23
+
24
+ onGroupChanged: {
25
+ if (group)
26
+ group.register(root)
27
+ }
28
+
29
+ Component.onDestruction: {
30
+ if (group)
31
+ group.unregister(root)
32
+ }
33
+
34
+ onTriggered: {
35
+ if (group)
36
+ group.updateCheck(root)
37
+ }
38
+
39
+ property var parentMenu: undefined
40
+
41
+ // accessibility
42
+ FocusIndicator {
43
+ control: parent
44
+ anchors.margins: 5
45
+ anchors.topMargin: 0
46
+ anchors.bottomMargin: 0
47
+ }
48
+
49
+ arrow: IconWidget {
50
+ anchors.verticalCenter: parent.verticalCenter
51
+ anchors.right: parent.right
52
+ anchors.margins: 16
53
+ color: Theme.currentTheme.colors.textSecondaryColor
54
+ visible: root.subMenu
55
+ icon: "ic_fluent_chevron_right_20_regular"
56
+ size: 12
57
+ }
58
+
59
+ indicator: IconWidget {
60
+ id: indicator
61
+ anchors.verticalCenter: parent.verticalCenter
62
+ anchors.left: parent.left
63
+ anchors.margins: 18
64
+ icon: group ? group.exclusive ? "ic_fluent_circle_20_filled" : "ic_fluent_checkmark_20_filled"
65
+ : "ic_fluent_checkmark_20_filled"
66
+ width: 16
67
+ size: group ? group.exclusive ? 7 : 16 : 16
68
+ visible: root.checked
69
+ }
70
+
71
+ // 内容 / Content //
72
+ contentItem: RowLayout {
73
+ id: row
74
+ spacing: 16
75
+ anchors.verticalCenter: parent.verticalCenter
76
+ anchors.left: parent.left
77
+ anchors.right: parent.right
78
+ anchors.leftMargin: (iconWidget.size ? 16 : 0) + (checkable ? indicator.width + 16 : 0)
79
+ anchors.margins: 16
80
+
81
+ IconWidget {
82
+ id: iconWidget
83
+ size: icon || source ? menuText.font.pixelSize * 1.25 : 0 // 图标大小 / Icon Size
84
+ icon: root.icon.name
85
+ source: root.icon.source
86
+ }
87
+ Text {
88
+ id: menuText
89
+ Layout.fillWidth: true
90
+ Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
91
+ typography: Typography.Body
92
+ text: root.text
93
+ wrapMode: Text.NoWrap
94
+ }
95
+ Text {
96
+ id: shortcutText
97
+ Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
98
+ typography: Typography.Caption
99
+ text: root.action ? root.action.shortcut : ""
100
+ color: Theme.currentTheme.colors.textSecondaryColor
101
+ visible: text
102
+ }
103
+ }
104
+
105
+ // 背景 / Background //
106
+ background: Rectangle {
107
+ anchors.fill: parent
108
+ anchors.margins: 5
109
+ anchors.topMargin: 0
110
+ anchors.bottomMargin: 0
111
+ radius: Theme.currentTheme.appearance.buttonRadius
112
+ color: enabled ? pressed ? Theme.currentTheme.colors.subtleTertiaryColor
113
+ : hovered
114
+ ? Theme.currentTheme.colors.subtleSecondaryColor
115
+ : "transparent" : "transparent"
116
+
117
+ Behavior on color { ColorAnimation { duration: Utils.animationSpeed; easing.type: Easing.OutQuart } }
118
+ }
119
+
120
+ // States //
121
+ // 状态变化
122
+ states: [
123
+ State {
124
+ name: "disabled"
125
+ when: !enabled
126
+ PropertyChanges {
127
+ target: root
128
+ opacity: 0.3628
129
+ }
130
+ }
131
+ ]
132
132
  }