-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.qml
More file actions
329 lines (313 loc) · 9.98 KB
/
main.qml
File metadata and controls
329 lines (313 loc) · 9.98 KB
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.1
Rectangle {
id:main
visible: true
height:600
width: 800
y:0
anchors.centerIn: parent
SystemPalette {id: syspal}
color: "#D0DAD4"
Rectangle {
id: toolbar
width: parent.width
height: 27
anchors.top: parent.top
color: "#D0DAD4"
TextField{
id:searchField
placeholderText: "Buscar..."
anchors.right: buscarBoton.left
anchors.bottom: parent.bottom
anchors.bottomMargin: 4
height: buscarBoton.height - 2
}
Button{
id:buscarBoton
text: ""
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.bottomMargin: 3
width: 25
Image {
source: "media/lupa.png"
height: parent.height - 6
anchors.left: parent.left
anchors.leftMargin: 3
fillMode: Image.PreserveAspectFit
anchors.centerIn: parent
}
}
Rectangle{
height: 2
width: parent.width
anchors.bottom: parent.bottom
color: "#999"
}
}
Column{
id:huellaContainer
width: parent.width * 0.3
anchors.top: toolbar.bottom
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.margins: 8
Rectangle{
id:huellaHeader
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
height: 30
border.color: syspal.dark
color: syspal.window
Text{
anchors.centerIn: parent
text: "Coloque su dedo en el huellero"
}
}
Rectangle{
id: huella
anchors.top: huellaHeader.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 10
height: 350
border.color: syspal.dark
color: "#fff"
Image {
id:imgHuella
source: "media/huella.png"
anchors.fill: parent
fillMode: Image.PreserveAspectFit
anchors.margins: 2
opacity: 0.4
}
Text {
id: conteo
text: qsTr("-")
font.pointSize: 150
anchors.centerIn: parent
opacity: 0.8
}
}
Button{
id: guardarHuella
text: ""
height: 30
anchors.left: parent.left
anchors.right: parent.right
anchors.top: huella.bottom
anchors.topMargin: 10
enabled: false
Item{
height: parent.height - 8
anchors.centerIn: parent
width: 70
Image{
id:imgGuardar
source: "media/guardar.png"
height: parent.height - 6
anchors.left: parent.left
anchors.leftMargin: 3
fillMode: Image.PreserveAspectFit
anchors.verticalCenter:parent.verticalCenter
}
Text{
id:textGuardar
text: "Guardar"
anchors.left: imgGuardar.right
anchors.leftMargin: 3
anchors.verticalCenter: parent.verticalCenter
color:syspal.dark
}
}
onClicked: {
funcs.saveTemplate(templateDialog.pk)
}
}
Button{
id:reset
text: ""
height: 30
anchors.left: parent.left
anchors.right: parent.right
anchors.top: guardarHuella.bottom
anchors.topMargin: 10
enabled: false
onClicked: funcs.resetTemplate()
Item{
height: parent.height - 8
anchors.centerIn: parent
width: 74
Image{
id:imgReset
source: "media/reintentar.png"
height: parent.height - 6
anchors.left: parent.left
anchors.leftMargin: 3
fillMode: Image.PreserveAspectFit
anchors.verticalCenter:parent.verticalCenter
}
Text{
id:textReset
text: "Reintentar"
anchors.left: imgReset.right
anchors.leftMargin: 3
anchors.verticalCenter: parent.verticalCenter
color: syspal.dark
}
}
}
}
Column {
id:tabsContainer
anchors.top: toolbar.bottom
anchors.right: huellaContainer.left
anchors.left: parent.left
anchors.bottom: parent.bottom
anchors.margins: 8
TabView {
id:frame
focus:true
enabled: true
property int margins: Qt.platform.os === "osx" ? 16 : 0
height: parent.height - 34
anchors.right: parent.right
anchors.left: parent.left
anchors.margins: margins
}
}
Item {
id: funcs
objectName: "funcs"
signal saveValidable(int id, bool flag)
signal createTemplate(int id)
signal saveTemplate(int id)
signal resetTemplate()
function activarHuella(){
reset.enabled = true
textReset.color = syspal.windowText
guardarHuella.enabled = false
imgHuella.opacity = 1
conteo.text = "4"
}
function successTemplate(){
messageDialog.show("guardado correctamente");
imgHuella.opacity = 0.4
guardarHuella.enabled = false
textGuardar.color = syspal.dark
reset.enabled = false
textGuardar.color = syspal.dark
conteo.text = "-"
}
function finishTemplate(){
guardarHuella.enabled = true
textGuardar.color = syspal.windowText
reset.enabled = false
textReset.color = syspal.dark
conteo.text = "-"
}
function updateHuella(num){
conteo.text = num
}
function noTemplate(id){
templateDialog.show(id)
}
function getCurrentId(){
return templateDialog.pk
}
function savedValidable(s){
if(s){
messageDialog.show("guardado correctamente");
}else{
messageDialog.show("fallo al guardar");
}
}
signal getValidables()
function renderValidables(list){
for(var i in list){
var tab = "import QtQuick 2.2;
import QtQuick.Window 2.1;
import QtQuick.Controls 1.2;
Tab{ title:\""+ i +"\";";
tab +='TableView {
anchors.fill: parent;';
for(var key in list[i][0]){
if(key==="activo"){
tab +='TableViewColumn{ role: "activo" ; title: "activo" ; width: 51
delegate: CheckBox{
id:check'+ i +'
checked: model'+ i +'.get(styleData.row).activo
objectName:"model'+ i +'"
anchors.centerIn: parent
onClicked: {funcs.saveValidable(model'+ i +'.get(styleData.row).pk, checked);}
}
}';
}else if(!(key==="id")){
tab += 'TableViewColumn{ role: "'+ key +'" ; title: "'+key+'" ; width: 150 }';
}
}
tab+='model: ListModel {
id: model'+ i +';'
for(var j in list[i]){
tab+='ListElement{';
for(var k in list[i][j]){
if(k==="activo"){
tab += ''+k+': '+list[i][j][k]+' ; ';
}else if(k==="id"){
tab += 'pk: "'+list[i][j][k]+'" ; ';
}else{
tab += ''+k+': "'+list[i][j][k]+'" ; ';
}
}
tab+='}'
}
tab+='}
}';
tab += "}";
Qt.createQmlObject(tab,frame,'log');
}
}
}
Timer {
id:timer
interval: 800;
running: false;
repeat: false;
onTriggered: messageDialog.visible = false;
}
MessageDialog {
id: messageDialog
title: qsTr("Mensaje")
function show(caption) {
messageDialog.text = caption;
messageDialog.open();
timer.start();
}
}
MessageDialog{
property int pk: 0
id:templateDialog
text:"No se a asigando una huella a este usuario ¿desea hacerlo ahora?"
standardButtons: StandardButton.Yes | StandardButton.No
onYes: {
funcs.createTemplate(templateDialog.pk)
funcs.activarHuella()
}
onNo: {
console.log("dijeron que no ")
for(var i = frame.__tabs.count - 1; i >= 0; i--){
frame.removeTab(i);
}
funcs.getValidables();
}
function show(id) {
templateDialog.pk = id
templateDialog.open();
}
}
}