-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.qml
157 lines (129 loc) · 4.55 KB
/
main.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
148
149
150
151
152
153
154
155
156
157
import QtQuick 2.15
import QtQuick.Controls 2.15
ApplicationWindow {
width: 600
height: 800
visible: true
title: qsTr("EndeavourOS QuickStart Installer")
SystemPalette { id: systemPalette; colorGroup: SystemPalette.Active }
ListView {
id: lvPackages
property var expandMap: ({})
model: packageModel
delegate: Item {
property bool expanded: lvPackages.isSectionExpanded( model.category )
width: lvPackages.width - sbListview.width
implicitHeight: expanded ? check.implicitHeight : 0
Row {
height: parent.height
width: parent.width
clip: true
CheckDelegate {
id: check
width: parent.width
text: " " + model.name + " - " + model.description + (model.isInstalled ? " (" + qsTr("Installed") + ")" : "")
checkable: model.isInstalled ? false : true
checked: model.isChecked
font.bold: model.isInstalled ? true : false
onCheckStateChanged: model.isChecked = checked
}
}
Behavior on height {
NumberAnimation { duration: 200 }
}
}
width: Window.width
height: Window.height - installButton.height - 10
focus: true
clip: true
section.property: "category"
section.criteria: ViewSection.FullString
section.delegate: Rectangle {
width: parent.width - sbListview.width
implicitHeight: text.implicitHeight + 2
color: systemPalette.window
Text {
id: text
anchors.left: parent.left
font.bold: true
text: section
padding: 5
color: systemPalette.windowText
}
Canvas {
id: indicator
x: parent.width-width-5
y: (parent.height-height)/2
width: 12
height: 8
onPaint: {
var context = getContext( "2d" );
paintTriangle( context, lvPackages.isSectionExpanded( section ) )
}
function paintTriangle( context, expanded ) {
if ( expanded ) {
context.reset();
context.moveTo(width/2, 0);
context.lineTo(width, height);
context.lineTo(0, height);
context.closePath();
context.fillStyle = systemPalette.windowText;
context.fill();
} else {
context.reset();
context.moveTo(0, 0);
context.lineTo(width, 0);
context.lineTo(width/2, height);
context.closePath();
context.fillStyle = systemPalette.windowText;
context.fill();
}
}
}
MouseArea {
anchors.fill: parent
onClicked: toggleSection( section )
}
function toggleSection( section ) {
if ( lvPackages.isSectionExpanded( section ) ) {
lvPackages.hideSection( section )
} else {
lvPackages.showSection( section )
}
indicator.requestPaint()
}
}
function isSectionExpanded( section ) {
return (section in expandMap);
}
function hideSection( section ) {
delete expandMap[section]
expandMapChanged();
}
function showSection( section ) {
expandMap[section] = true
expandMapChanged();
}
// We need to make sure our selections don't become unchecked as we scroll
cacheBuffer: 50000
ScrollBar.vertical: ScrollBar {
id: sbListview
active: true
}
}
Button {
id: installButton
height: 40
anchors {
bottom: parent.bottom
bottomMargin: 5
horizontalCenter: parent.horizontalCenter;
}
onClicked: packageManager.installPackages()
text: qsTr("Install Now")
palette {
button: systemPalette.button
buttonText: systemPalette.buttonText
}
}
}