-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresizer.qml
130 lines (124 loc) · 3.76 KB
/
resizer.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
import QtQuick 2.3
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.2
import QtQuick.Dialogs 1.2
ApplicationWindow {
title: qsTr("Batch resizer")
width: 1280
height: 800
visible: true
FileDialog {
id: fileChooserDialog
title: qsTr("Please choose files for batch processing")
selectExisting: true
selectMultiple: true
onAccepted: {
imageMagickDispatcher.add(fileChooserDialog.fileUrls)
}
}
DropArea {
anchors.fill: parent
id: dropArea;
onEntered: {
drag.accept (Qt.LinkAction);
}
onDropped: {
imageMagickDispatcher.add(drop.urls)
}
}
ColumnLayout {
anchors.fill: parent
RowLayout {
Layout.margins: 3
Button {
text: qsTr("Browse")
onClicked: fileChooserDialog.open()
}
Label {
text: qsTr("Output format")
}
TextField {
Layout.fillWidth: true
placeholderText: "%n -- file name"
text: imageMagickDispatcher.outputFormat
onEditingFinished: imageMagickDispatcher.setOutputFormat(text)
}
}
RowLayout {
Layout.margins: 3
Label {
text: qsTr("Scale value")
}
Slider {
id: percentSlider
value: imageMagickDispatcher.scale
minimumValue: 0
maximumValue: 100
onValueChanged: imageMagickDispatcher.setScale(value)
}
TextField {
text: percentSlider.value.toFixed(1)
onEditingFinished: imageMagickDispatcher.setScale(parseFloat(text))
validator: DoubleValidator { bottom: 0; top: 100; }
}
}
TableView {
Layout.margins: 3
id: fileListView
Layout.fillHeight: true
Layout.fillWidth: true
model: imageMagickDispatcher.images
selectionMode: SelectionMode.ExtendedSelection
headerVisible: false
TableViewColumn {
width: 24
delegate: Rectangle {
anchors.fill: parent
color: fileListView.model[styleData.row].status === "Ok" ?
"green" : "red"
opacity: fileListView.model[styleData.row].status === "Waiting" ?
0 : 1
}
}
TableViewColumn {
role: 'name'
width: 400
}
TableViewColumn {
role: 'output'
width: 400
}
TableViewColumn {
role: 'status'
width: 400
}
Keys.onPressed: {
if (event.key === Qt.Key_Delete) {
var idxList = []
fileListView.selection.forEach(function (idx) {idxList.push(idx)})
imageMagickDispatcher.remove(idxList)
}
}
}
RowLayout {
Layout.margins: 3
Button {
text: qsTr("Run")
onClicked: imageMagickDispatcher.run()
}
Button {
text: qsTr("Reset")
onClicked: imageMagickDispatcher.reset()
}
Button {
text: qsTr("Clear")
onClicked: imageMagickDispatcher.clear()
}
Item { opacity: 0; Layout.fillWidth: true }
Button {
text: qsTr("Close")
onClicked: Qt.quit()
}
}
}
}