blob: ff2e3cfddb5a7c7186b0f69acce336a0b06c4e3c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
import QtQuick
import QtQuick.Templates as T
import QtQuick.Controls.impl
import QtQuick.Controls.iOS.impl
T.MenuItem {
id: control
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
implicitContentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
implicitContentHeight + topPadding + bottomPadding,
implicitIndicatorHeight + topPadding + bottomPadding)
leftPadding: 12
rightPadding: 12
topPadding: 11
bottomPadding: 11
spacing: 9
icon.width: 19
icon.height: 19
icon.color: control.palette.text
readonly property bool __isSingleItem: control.menu && control.menu.count === 1
readonly property bool __isFirstItem: !__isSingleItem && control.menu && control.menu.itemAt(0) === control ? true : false
readonly property bool __isLastItem: !__isSingleItem && control.menu && control.menu.itemAt(control.menu.count - 1) === control ? true : false
readonly property real __indicatorWidth: 12
contentItem: IconLabel {
readonly property real padding: control.__indicatorWidth + control.spacing
leftPadding: !control.mirrored ? padding : 0
rightPadding: control.mirrored ? padding : 0
spacing: control.spacing
mirrored: control.mirrored
display: control.display
alignment: Qt.AlignLeft
icon: control.icon
text: control.text
font: control.font
color: control.palette.text
}
arrow: ColorImage {
x: control.mirrored ? control.width - width - control.rightPadding : control.leftPadding
y: control.topPadding + (control.availableHeight - height) / 2
width: 7
height: 12
rotation: control.subMenu && (control.down || control.subMenu.visible) ? 90 : 0
visible: control.subMenu
opacity: control.enabled ? 1 : 0.5
mirror: control.mirrored
color: control.palette.text
source: control.subMenu ? IOS.url + "arrow-indicator-light.png" : ""
Behavior on rotation { RotationAnimation { duration: 100 } }
}
indicator: ColorImage {
x: control.mirrored ? control.width - width - control.rightPadding : control.leftPadding
y: control.topPadding + (control.availableHeight - height) / 2
scale: 0.8
visible: control.checked
source: control.checked ? IOS.url + "radiodelegate-indicator-light.png" : ""
color: control.palette.text
}
background: Item {
implicitHeight: 44
implicitWidth: 250
NinePatchImage {
y: control.__isLastItem ? -1 : 0
width: parent.width
height: control.__isLastItem ? parent.height + 1 : parent.height
rotation: control.__isLastItem ? 180 : 0
visible: !(control.__isSingleItem && !control.down)
source: IOS.url + "menuitem-background"
NinePatchImageSelector on source {
states: [
{"edge": control.__isFirstItem || control.__isLastItem},
{"single": control.__isSingleItem},
{"light": Application.styleHints.colorScheme === Qt.Light},
{"dark": Application.styleHints.colorScheme === Qt.Dark},
{"pressed": control.down}
]
}
}
}
states: [
State {
name: "submenu-opened"
when: control.subMenu && control.subMenu.visible
PropertyChanges { target: control.menu; scale: 0.9 }
}
]
}
|