-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExportPage.qml
executable file
·256 lines (205 loc) · 8.03 KB
/
ExportPage.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
Component {
id: exportPage
Item {
id: exportPageRectangle
RowLayout {
id: exportPageTopRowLayout
spacing: 2
width: parent.width
z: Infinity
TextField {
id: exportPagePathTextField
Layout.fillWidth: true
text: stackView.oExportFilesListModel.fnGetCurrentPath()
selectByMouse: true
anchors {
}
Keys.onEnterPressed: {
oExportFilesListModel.fnSetPath(exportPagePathTextField.text);
oExportFilesListModel.fnUpdate();
}
Keys.onReturnPressed: {
oExportFilesListModel.fnSetPath(exportPagePathTextField.text);
oExportFilesListModel.fnUpdate();
}
}
Button {
id: exportPageUpButton
text: "Up"
onClicked: {
oExportFilesListModel.fnUp();
exportPagePathTextField.text = oExportFilesListModel.fnGetCurrentPath();
oExportFilesListModel.fnUpdate();
}
}
}
ScrollView {
id: exportPageScrollView
anchors {
right: parent.right
top: exportPageTopRowLayout.bottom
left: parent.left
bottom: exportPageBottomColumnLayout.top
}
clip: true
padding: {
top: 2
bottom: 2
}
ListView {
id: exportPageListView
width: parent.width
orientation: ListView.Vertical
model: stackView.oExportFilesListModel
focus: true
highlightFollowsCurrentItem: false
highlight: Rectangle {
opacity: 0.5
color: "skyblue"
width: ListView.view ? ListView.view.width : 0
height: 20+exportPageFontMetrics.height
y: ListView.view && ListView.view.currentItem ? ListView.view.currentItem.y : 0
//z: Infinity
}
FontMetrics {
id: exportPageFontMetrics
font.pixelSize: 12
}
delegate: Item {
id: exportPageDelegate
property var view: ListView.view
property bool isCurrent: ListView.isCurrentItem
width: view.width
height: 20+exportPageFontMetrics.height
Image {
id: icon
source: isDir ? "qrc:/images/folder.svg" : "qrc:/images/none.svg"
width: 32
height: 32
anchors {
left: parent.left
}
}
Label {
padding: 10
anchors {
top: parent.top
left: icon.right
bottom: parent.bottom
right: parent.right
}
font.pixelSize: exportPageFontMetrics.font.pixelSize
//anchors.centerIn: parent
renderType: Text.NativeRendering
text: fileName
}
MouseArea {
anchors.fill: parent
onClicked: {
view.currentIndex = model.index;
/*
if (!model.isDir) {
exportPageFileNameTextField.text = fileName;
}
*/
}
onDoubleClicked: {
view.currentIndex = model.index;
if (model.isDir) {
oExportFilesListModel.fnOpenDir(model.index);
exportPagePathTextField.text = oExportFilesListModel.fnGetCurrentPath();
} else {
exportPageFileNameTextField.text = fileName;
}
oExportFilesListModel.fnUpdate();
}
}
}
}
}
ColumnLayout {
id: exportPageBottomColumnLayout
anchors {
right: parent.right
bottom: parent.bottom
left: parent.left
}
TextField {
id: exportPageFileNameTextField
Layout.fillWidth: true
text: ''
selectByMouse: true
onTextChanged: {
if (text.indexOf('/')!=-1
|| text.indexOf('\\')!=-1
|| !text.length) {
exportPageExportButton.enabled = false;
} else {
exportPageExportButton.enabled = true;
}
}
}
ComboBox {
id: exportPageNameFilterComboBox
Layout.fillWidth: true
model: [ "JSON (*.json)", "TEXT (*.txt)" ]
delegate: ItemDelegate {
id: control
width: parent.width
contentItem: Text {
text: modelData
color: "#000000"
font: control.font
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
}
background: Rectangle {
anchors.fill: control
color: control.highlighted ? "skyblue" : "transparent"
}
highlighted: exportPageNameFilterComboBox.highlightedIndex === index
}
}
RowLayout {
Layout.fillHeight: true
Button {
id: exportPageBackButton
Layout.minimumWidth: (stackView.width)/2
text: "Back"
//Layout.fillWidth: true
onClicked: {
stackView.pop();
}
}
Button {
id: exportPageExportButton
Layout.minimumWidth: (stackView.width)/2
text: "Export"
//Layout.fillWidth: true
enabled: false
property var oFilterExtension: [
".json",
".txt"
]
onClicked: {
var sExtension = oFilterExtension[exportPageNameFilterComboBox.currentIndex];
if (exportPageFileNameTextField.text.lastIndexOf(sExtension)!=-1
&& exportPageFileNameTextField.text.length==exportPageFileNameTextField.text.lastIndexOf(sExtension)+sExtension.length) {
sExtension = "";
}
console.log(oExportFilesListModel.fnGetCurrentPath(), exportPageFileNameTextField.text, sExtension);
oPasswordListModel.fnExport(
oExportFilesListModel.fnGetCurrentPath()+'/'+exportPageFileNameTextField.text+sExtension,
exportPageNameFilterComboBox.currentIndex
);
oExportFilesListModel.fnUpdate();
stackView.pop();
}
}
}
}
}
}