blob: eceef0534fbf04557c082097db93ed570cfe8a37 (
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick 2.1
import QtQuick.Window 2.1
import QtQuick.Controls 1.1
import QtQuick.Controls.Private 1.0
/*!
\qmltype MenuStyle
\internal
\ingroup menusstyling
\inqmlmodule QtQuick.Controls.Styles
*/
Style {
id: styleRoot
property string __menuItemType: "menuitem"
property real maxPopupHeight: 600 // ### FIXME Screen.desktopAvailableHeight * 0.99
property Component frame: Rectangle {
width: (parent ? parent.contentWidth : 0) + 2
height: (parent ? parent.contentHeight : 0) + 2
color: "lightgray"
border { width: 1; color: "darkgray" }
property int subMenuOverlap: -1
property real maxHeight: maxPopupHeight
property int margin: 1
}
property Component menuItem: Rectangle {
x: 1
y: 1
implicitWidth: Math.max((parent ? parent.width : 0),
18 + text.paintedWidth + (rightDecoration.visible ? rightDecoration.width + 40 : 12))
implicitHeight: isSeparator ? text.font.pixelSize / 2 : !!scrollerDirection ? text.font.pixelSize * 0.75 : text.paintedHeight + 4
color: selected && enabled ? "" : backgroundColor
gradient: selected && enabled ? selectedGradient : undefined
border.width: 1
border.color: selected && enabled ? Qt.darker(selectedColor, 1) : color
readonly property int leftMargin: __menuItemType === "menuitem" ? 18 : 0
readonly property color backgroundColor: "#dcdcdc"
readonly property color selectedColor: "#49d"
Gradient {
id: selectedGradient
GradientStop {color: Qt.lighter(selectedColor, 1.3) ; position: -0.2}
GradientStop {color: selectedColor; position: 1.4}
}
antialiasing: true
SystemPalette {
id: syspal
colorGroup: enabled ? SystemPalette.Active : SystemPalette.Disabled
}
readonly property string itemText: parent ? parent.text : ""
readonly property bool mirrored: Qt.application.layoutDirection === Qt.RightToLeft
Loader {
id: checkMark
x: mirrored ? parent.width - width - 4 : 4
y: 6
active: __menuItemType === "menuitem" && !!menuItem && !!menuItem["checkable"]
sourceComponent: exclusive ? exclusiveCheckMark : nonExclusiveCheckMark
readonly property bool checked: !!menuItem && !!menuItem.checked
readonly property bool exclusive: !!menuItem && !!menuItem["exclusiveGroup"]
Component {
id: nonExclusiveCheckMark
BorderImage {
width: 12
height: 12
source: "images/editbox.png"
border.top: 6
border.bottom: 6
border.left: 6
border.right: 6
Rectangle {
antialiasing: true
visible: checkMark.checked
color: "#666"
radius: 1
anchors.margins: 4
anchors.fill: parent
anchors.topMargin: 3
anchors.bottomMargin: 5
border.color: "#222"
Rectangle {
anchors.fill: parent
anchors.margins: 1
color: "transparent"
border.color: "#33ffffff"
}
}
}
}
Component {
id: exclusiveCheckMark
Rectangle {
x: 1
width: 10
height: 10
color: "white"
border.color: "gray"
antialiasing: true
radius: height/2
Rectangle {
anchors.centerIn: parent
visible: checkMark.checked
width: 4
height: 4
color: "#666"
border.color: "#222"
antialiasing: true
radius: height/2
}
}
}
}
Text {
id: text
visible: !isSeparator
text: StyleHelpers.stylizeMnemonics(itemText)
readonly property real offset: __menuItemType === "menuitem" ? 24 : 6
x: mirrored ? parent.width - width - offset : offset
anchors.verticalCenter: parent.verticalCenter
renderType: Text.NativeRendering
color: selected && enabled ? "white" : syspal.text
}
Text {
id: rightDecoration
readonly property string shortcut: !!menuItem && menuItem["shortcut"] || ""
visible: isSubmenu || shortcut !== ""
text: isSubmenu ? mirrored ? "\u25c2" : "\u25b8" // BLACK LEFT/RIGHT-POINTING SMALL TRIANGLE
: shortcut
LayoutMirroring.enabled: mirrored
anchors {
right: parent.right
rightMargin: 6
baseline: isSubmenu ? undefined : text.baseline
}
font.pixelSize: isSubmenu ? text.font.pixelSize : text.font.pixelSize * 0.9
color: text.color
renderType: Text.NativeRendering
style: selected || !isSubmenu ? Text.Normal : Text.Raised; styleColor: Qt.lighter(color, 4)
}
Image {
id: scrollerDecoration
visible: !!scrollerDirection
anchors.centerIn: parent
source: scrollerDirection === "up" ? "images/arrow-up.png" : "images/arrow-down.png"
}
Rectangle {
visible: isSeparator
width: parent.width - 2
height: 1
x: 1
anchors.verticalCenter: parent.verticalCenter
color: "darkgray"
}
}
property Component scrollerStyle: Style {
padding { left: 0; right: 0; top: 0; bottom: 0 }
property bool scrollToClickedPosition: false
property Component frame: Item { visible: false }
property Component corner: Item { visible: false }
property Component __scrollbar: Item { visible: false }
property bool useScrollers: true
}
}
|