-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.qml
200 lines (180 loc) · 5.67 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
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.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
import Qt.labs.platform 1.1
import Qt.labs.folderlistmodel 2.15
Window {
id: window
width: 640
height: 560
visible: true
FolderDialog {
id: folderDialog
onAccepted: {
folderModel.folder = folderDialog.folder;
showCurrentView();
}
}
FolderListModel {
id: folderModel
showDirs: false
nameFilters: [ "*.png", "*.jpeg", "*.jpg", "*.gif" ]
}
Button {
id: buttonSelectFolder
text: "Select folder"
anchors.left: parent.left
anchors.rightMargin: 3
width: parent.width / 2 - 3
onClicked: folderDialog.open();
}
function makeViewsInvisible() {
listViewContainer.visible = false;
listView.focus = false;
gridViewContainer.visible = false;
gridView.focus = false;
pathViewContainer.visible = false;
pathView.focus = false;
}
function showCurrentView() {
switch(comboBox.currentIndex) {
case 0:
listViewContainer.visible = true;
listView.focus = true;
break;
case 1:
gridViewContainer.visible = true;
gridView.focus = true;
break;
case 2:
pathViewContainer.visible = true;
pathView.focus = true;
break;
}
}
ComboBox {
id: comboBox
anchors.left: buttonSelectFolder.right
anchors.leftMargin: 3
width: parent.width / 2
model: [ "list", "grid", "path" ]
onCurrentIndexChanged: {
makeViewsInvisible();
showCurrentView();
}
}
function maximizeImage(img) {
makeViewsInvisible();
maxemizedImage.source = img.source
maxemizedImage.visible = true;
maxemizedImage.focus = true;
}
Rectangle {
id: listViewContainer
width: parent.width
height: parent.height - comboBox.height
anchors.top: comboBox.bottom
clip: true
ListView {
id: listView
anchors.fill: parent
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
model: folderModel
delegate: Item {
width: listView.width; height: 140
Keys.onSpacePressed: maximizeImage(listViewItemImage);
Image {
id: listViewItemImage
x: 5; y: 5
width: 128; height: 128
source: fileUrl
}
Text {
y: 5
anchors.left: listViewItemImage.right
anchors.leftMargin: 10
text: fileName
font.pointSize: 16
}
MouseArea { anchors.fill: parent; onReleased: maximizeImage(listViewItemImage); }
}
}
}
Rectangle {
id: gridViewContainer
width: parent.width
height: parent.height - comboBox.height - 5
anchors.top: comboBox.bottom
anchors.topMargin: 5
clip: true
GridView {
id: gridView
anchors.fill: parent
cellWidth: 140; cellHeight: 150
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
model: folderModel
delegate: Column {
Keys.onSpacePressed: maximizeImage(gridViewItemImage);
width: gridView.cellWidth; height: gridView.cellHeight
Image {
id: gridViewItemImage
source: fileUrl
width: 128; height: 128
anchors.horizontalCenter: parent.horizontalCenter
MouseArea { anchors.fill: parent; onReleased: maximizeImage(parent); }
}
Text { text: fileName; anchors.horizontalCenter: parent.horizontalCenter }
}
}
}
Rectangle {
id: pathViewContainer
width: 240; height: 200
anchors.centerIn: parent
PathView {
id: pathView
anchors.fill: parent
Keys.onLeftPressed: decrementCurrentIndex();
Keys.onRightPressed: incrementCurrentIndex();
model: folderModel
delegate: Column {
Keys.onSpacePressed: maximizeImage(pathViewItemImage);
opacity: PathView.isCurrentItem ? 1 : 0.1
z: PathView.isCurrentItem ? 1 : 0
Image {
id: pathViewItemImage
anchors.horizontalCenter: pathViewItemText.horizontalCenter
width: 256; height: 256
source: fileUrl
MouseArea { anchors.fill: parent; onReleased: maximizeImage(parent); }
}
Text {
id: pathViewItemText
text: fileName
font.pointSize: 16
}
}
path: Path {
startX: 200; startY: 100
PathQuad { x: 200; y: 25; controlX: 560; controlY: 75 }
PathQuad { x: 200; y: 100; controlX: -200; controlY: 75 }
}
}
}
function minimizeImage() {
maxemizedImage.visible = false;
showCurrentView();
}
Image {
id: maxemizedImage
width: parent.width
height: parent.height - comboBox.height
anchors.top: comboBox.bottom
visible: false
Keys.onSpacePressed: minimizeImage();
MouseArea {
anchors.fill: parent
onReleased: minimizeImage();
}
}
}