-
Notifications
You must be signed in to change notification settings - Fork 5
/
SessionFrame.qml
147 lines (133 loc) · 3.92 KB
/
SessionFrame.qml
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
import QtQuick 2.7
import QtGraphicalEffects 1.0
import QtQuick.Controls 2.0
Item {
id: frame
signal selected(var index)
signal needClose()
property bool shouldShowBG: true
property alias currentItem: sessionList.currentItem
function isMultipleSessions() {
return sessionList.count > 1
}
onFocusChanged: {
// Active by mouse click
if (focus) {
sessionList.currentItem.focus = false
}
}
Item {
anchors.fill: parent
Item {
id: layered
opacity: 0.8
layer.enabled: true
anchors {
centerIn: parent
fill: parent
}
Rectangle {
id: rec1
width: parent.width / 3
height: parent.height - 35
anchors.centerIn: parent
color: "#f0f0f0"
radius: 2
}
DropShadow {
id: drop
anchors.fill: rec1
source: rec1
horizontalOffset: 0
verticalOffset: 3
radius: 10
samples: 21
color: "#55000000"
transparentBorder: true
}
}
}
Text {
id: sessionTitle
anchors {
top: parent.top
topMargin: 50
horizontalCenter: parent.horizontalCenter
}
text: "Session"
color: "#000000"
font {
pointSize: 18
bold: true
family: config.font
}
wrapMode: Text.Wrap
}
ListView {
id: sessionList
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: sessionTitle.bottom
width: parent.width / 3
clip: true
height: parent.height - 100
model: sessionModel
currentIndex: sessionModel.lastIndex
orientation: ListView.Vertical
spacing: 5
delegate: Button {
property bool activeBG: sessionList.currentIndex === index && shouldShowBG
background: Rectangle {
color: activeBG || focus ? "#55000000" : "transparent"
border.width: 3
border.color: activeBG || focus ? "#33ffffff" : "transparent"
}
width: parent.width
height: 35
Text {
width: parent.width
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: name
font.family: config.font
font.pointSize: 15
color: "black"
wrapMode: Text.WordWrap
}
Keys.onLeftPressed: {
sessionList.decrementCurrentIndex()
sessionList.currentItem.forceActiveFocus()
}
Keys.onRightPressed: {
sessionList.incrementCurrentIndex()
sessionList.currentItem.forceActiveFocus()
}
Keys.onEscapePressed: needClose()
Keys.onEnterPressed: {
selected(index)
sessionList.currentIndex = index
}
Keys.onReturnPressed: {
selected(index)
sessionList.currentIndex = index
}
onClicked: {
selected(index)
sessionList.currentIndex = index
}
}
ScrollBar.vertical: ScrollBar {
parent: sessionList.parent
anchors.top: sessionList.top
anchors.left: sessionList.right
anchors.bottom: sessionList.bottom
}
}
MouseArea {
z: -1
anchors.fill: parent
onClicked: needClose()
}
Keys.onEscapePressed: needClose()
}