-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContextMenuTemplate.qml
More file actions
123 lines (98 loc) · 3.6 KB
/
ContextMenuTemplate.qml
File metadata and controls
123 lines (98 loc) · 3.6 KB
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
import QtQuick
import QtQuick.Layouts
TibiaFrame3PixelFilled {
id: root
readonly property int contentStartMargin: borderWidth + 1
property QtObject controller: null
width: contextContent.width + 2*contentStartMargin
height: contextContent.height + 2*contentStartMargin
ColumnLayout {
id: contextContent
anchors {left: parent.left; bottom: parent.bottom}
anchors.margins: root.contentStartMargin
spacing: TibiaStyle.entrySpacingVertical
Repeater {
id: entryRepeater
model: controller != null ? controller.entries : undefined
onCountChanged: {
if(count == 0) {
contextContent.width = 0;
}
} //onCountChanged
ColumnLayout {
spacing: 0
TibiaHorizontalSeparator {
Layout.fillWidth: true
Layout.bottomMargin: TibiaStyle.entrySpacingVertical
visible: modelData.isSeparator
} //TibiaHorizontalSeparator
Rectangle { //Mouse over highlight
implicitHeight: 16
implicitWidth: contextContent.width
color: mouseArea.containsMouse ? TibiaStyle.contextMenuSelectedBackgroundColor : "transparent"
visible: !modelData.isSeparator
MouseArea {
id: mouseArea
anchors.fill:parent
hoverEnabled: true
onClicked: {
modelData.toggled(!checkBox.checked);
modelData.triggered();
} //onClicked
} //MouseArea
RowLayout {
spacing: 0
height: parent.height
onWidthChanged: {
let newWidth = Math.max(contextContent.width, width);
if (newWidth != contextContent.width) {
contextContent.width = newWidth;
}
} //onWidthChanged
//this layout is here to provide the possibility to set width bounds
RowLayout {
id: entryContent
spacing: 0
Layout.alignment: Qt.AlignVCenter
Layout.minimumWidth: contextContent.width
Item { //Spacing entry to left boarder
Layout.minimumWidth: TibiaStyle.entryPartMargin
Layout.fillHeight: true
} //Item
TibiaCheckBox {
id: checkBox
checked: modelData.checked
visible: modelData.checkable
onToggled: {
modelData.toggled(checked);
modelData.triggered();
} //onClicked
} //TibiaCheckBox
TibiaCachedOutlineText {
id: entryText
text: modelData.text
styleType: modelData.styleType
styleColor: TibiaStyle.contextMenuOutlineColor
} //TibiaOutlineText
Item { //spacing entry to shortcut, also extra with
Layout.minimumWidth: TibiaStyle.minAfterEntrySpace
Layout.fillWidth: true
Layout.fillHeight: true
} //Item
TibiaCachedOutlineText {
text:modelData.shortcutString
styleType: modelData.styleType
styleColor: TibiaStyle.contextMenuOutlineColor
visible: text.length > 0
} //TibiaOutlineText
Item { //spacing on right side
Layout.minimumWidth: TibiaStyle.entryPartMargin
Layout.fillHeight: true
} //Item
} //RowLayout
} //RowLayout
} //Rectangle
} //ColumnLayout
} //Repeater
} //ColumnLayout
} //TibiaFrame3PixelFilled