blob: 7f8ce68c6dd7c002a6014a9ae00698087e91e9c7 (
plain) (
blame)
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
Rectangle {
id: dropFilesForm
color: "#eeeeee"
property alias dropFilesArea: dropFilesArea
property alias fileGridView: fileGridView
property alias fileGridContainer: fileGridContainer
property alias browseButton: browseButton
property alias bottomBrowseButton: bottomBrowseButton
property alias nextButton: nextButton
property alias dropFilesContainer: dropFilesColumn
property alias bottomButtonsContainer: bottomButtonsContainer
signal keyPressed(var event)
DropArea {
id: dropFilesArea
anchors.fill: parent
onEntered: {
background.color = "#cccccc";
}
onDropped: {
background.color = "#eeeeee";
}
onExited: {
background.color = "#eeeeee";
}
}
Column {
id: dropFilesColumn
spacing: 12
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
Text {
id: dragFilesText
text: qsTr("Drop firmware files here")
anchors.horizontalCenter: parent.horizontalCenter
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignLeft
font.pixelSize: 18
}
Image {
width: 100
height: 100
anchors.horizontalCenter: parent.horizontalCenter
source: "drop_zone.svg"
}
Button {
id: browseButton
text: qsTr("Browse")
isDefault: true
anchors.horizontalCenter: parent.horizontalCenter
}
}
Item {
id: fileGridContainer
visible: false
anchors.fill: parent
anchors.bottomMargin: 36
ScrollView {
anchors.fill: parent
GridView {
id: fileGridView
flow: GridView.FlowLeftToRight
cellWidth: 148
cellHeight: 120
boundsBehavior: Flickable.StopAtBounds
focus: true
anchors {
fill: parent
margins: 4
}
highlight: Rectangle {
color: "#ccddff"
radius: 8
}
delegate: Item {
width: 148
height: 120
Column {
spacing: 8
anchors.centerIn: parent
Image {
width: 80
anchors.horizontalCenter: parent.horizontalCenter
fillMode: Image.PreserveAspectFit
source: model.icon
}
Text {
width: 140
anchors.horizontalCenter: parent.horizontalCenter
wrapMode: Text.NoWrap
horizontalAlignment: Text.AlignHCenter
text: model.text
elide: Text.ElideMiddle
}
}
MouseArea {
anchors.fill: parent
onClicked: {
fileGridView.currentIndex = index
fileGridView.forceActiveFocus()
}
}
}
Keys.onPressed: {
var columns = Math.floor(fileGridView.width / fileGridView.cellWidth);
var index = fileGridView.currentIndex;
switch (event.key) {
case Qt.Key_Left:
index--;
break;
case Qt.Key_Right:
index++;
break;
case Qt.Key_Up:
index -= columns;
break;
case Qt.Key_Down:
index += columns;
break;
}
var upperBound = fileGridView.model.count - 1;
var partialRowCount = fileGridView.model.count % columns;
if (partialRowCount > 0) {
upperBound += columns - partialRowCount;
}
if (index >= 0 && index <= upperBound) {
index = Math.min(fileGridView.model.count - 1, index);
fileGridView.currentIndex = index;
}
dropFilesForm.keyPressed(event);
}
}
}
}
Rectangle {
id: bottomButtonsContainer
height: 36
color: "#dddddd"
visible: false
anchors {
bottom: parent.bottom
left: parent.left
right: parent.right
}
Button {
id: bottomBrowseButton
text: qsTr("Browse")
anchors {
bottom: parent.bottom
bottomMargin: 4
left: parent.left
leftMargin: 8
verticalCenter: parent.verticalCenter
}
}
Button {
id: nextButton
text: qsTr("Next")
isDefault: true
anchors {
bottom: parent.bottom
bottomMargin: 4
right: parent.right
rightMargin: 8
verticalCenter: parent.verticalCenter
}
}
}
}
|