blob: 8b05c33d45d61e08ac38df858a4fb96b913a1d67 (
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
|
// 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
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: 18
spacing: 9
icon.width: 19
icon.height: 19
icon.color: control.palette.windowText
property bool isSingleItem: control.menu && control.menu.count === 1
property bool isFirstItem: !isSingleItem && control.menu && control.menu.itemAt(0) === control ? true : false
property bool isLastItem: !isSingleItem && control.menu && control.menu.itemAt(control.menu.count - 1) === control ? true : false
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.windowText
}
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.windowText
source: control.subMenu ? "qrc:/qt-project.org/imports/QtQuick/Controls/iOS/images/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
width: control.indicatorWidth
height: control.indicatorWidth
visible: control.checked
source: control.checkable ? "qrc:/qt-project.org/imports/QtQuick/Controls/iOS/images/radiodelegate-indicator-light.png" : ""
color: control.palette.windowText
}
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: !(isSingleItem && !control.down)
source: control.IOS.url + "menuitem-background"
NinePatchImageSelector on source {
states: [
{"edge": control.isFirstItem || control.isLastItem},
{"single": control.isSingleItem},
{"light": control.IOS.theme === IOS.Light},
{"dark": control.IOS.theme === IOS.Dark},
{"pressed": control.down}
]
}
}
}
states: [
State {
name: "submenu-opened"
when: control.subMenu && control.subMenu.visible
PropertyChanges { target: control.menu; scale: 0.9 }
}
]
}
|