forked from cedricp/ddt4all
-
Notifications
You must be signed in to change notification settings - Fork 0
/
displaymod.py
699 lines (576 loc) · 25.4 KB
/
displaymod.py
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
import zipfile
import PyQt5.QtCore as core
import PyQt5.QtWidgets as widgets
import options
from uiutils import *
def unicode(a):
return str(a)
_ = options.translator('ddt4all')
class labelWidget(widgets.QLabel):
def __init__(self, parent, uiscale):
super(labelWidget, self).__init__(parent)
self.jsondata = None
self.ismovable = True
self.uiscale = uiscale
self.toggle_selected(False)
self.setWordWrap(True)
self.img = None
self.area = 0
def toggle_selected(self, sel):
if sel:
self.setFrameStyle(widgets.QFrame.Panel | widgets.QFrame.StyledPanel)
else:
self.setFrameStyle(widgets.QFrame.NoFrame)
def change_ratio(self, x):
return
def get_zip_graphic(self, name):
if os.path.exists("ecu.zip"):
zf = zipfile.ZipFile("ecu.zip", "r")
zname = "graphics/" + name + ".gif"
if not zname in zf.namelist():
zname = "graphics/" + name + ".GIF"
if zname in zf.namelist():
ba = core.QByteArray(zf.read(zname))
self.buffer = core.QBuffer()
self.buffer.setData(ba)
self.buffer.open(core.QIODevice.ReadOnly)
self.img = gui.QMovie(self.buffer, b"gif")
def initXML(self, xmldata):
text = xmldata.getAttribute("Text")
color = xmldata.getAttribute("Color")
alignment = xmldata.getAttribute("Alignment")
if text.startswith("::pic:"):
self.setScaledContents(True)
img_name = text.replace("::pic:", "").replace("\\", "/")
self.get_zip_graphic(img_name)
if self.img is None:
imgname = os.path.join(options.graphics_dir, img_name) + ".gif"
if not os.path.exists(imgname):
imgname = os.path.join(options.graphics_dir, img_name) + ".GIF"
self.img = gui.QMovie(imgname)
self.setMovie(self.img)
self.img.start()
else:
self.setText(text)
rect = getRectangleXML(getChildNodesByName(xmldata, "Rectangle")[0], self.uiscale)
qfnt = getXMLFont(xmldata, self.uiscale)
self.area = rect['width'] * rect['height']
self.setFont(qfnt)
self.resize(rect['width'], rect['height'])
self.setStyleSheet("background: %s; color: %s" % (colorConvert(color), getFontColor(xmldata)))
self.move(rect['left'], rect['top'])
if alignment == '2':
self.setAlignment(core.Qt.AlignHCenter)
elif alignment == '1':
self.setAlignment(core.Qt.AlignRight)
else:
self.setAlignment(core.Qt.AlignLeft)
def initJson(self, jsdata):
text = jsdata['text']
color = jsdata['color']
alignment = jsdata['alignment']
fontcolor = jsdata['fontcolor']
rect = jsdata['bbox']
self.area = rect['width'] * rect['height']
qfnt = jsonFont(jsdata['font'], self.uiscale)
self.ismovable = True
self.setFont(qfnt)
if text.startswith("::pic:"):
self.setScaledContents(True)
img_name = text.replace("::pic:", "").replace("\\", "/")
self.get_zip_graphic(img_name)
if self.img is None:
imgname = os.path.join(options.graphics_dir, img_name) + ".gif"
if not os.path.exists(imgname):
imgname = os.path.join(options.graphics_dir, img_name) + ".GIF"
self.img = gui.QMovie(imgname)
self.setMovie(self.img)
self.img.start()
else:
self.setText(text)
self.resize(rect['width'] / self.uiscale, rect['height'] / self.uiscale)
self.setStyleSheet("background: %s; color: %s" % (color, fontcolor))
self.move(rect['left'] / self.uiscale, rect['top'] / self.uiscale)
if alignment == '2':
self.setAlignment(core.Qt.AlignHCenter)
elif alignment == '1':
self.setAlignment(core.Qt.AlignRight)
else:
self.setAlignment(core.Qt.AlignLeft)
self.jsondata = jsdata
def resize(self, x, y):
super(labelWidget, self).resize(int(x), int(y))
self.update_json()
def move(self, x, y):
super(labelWidget, self).move(int(x), int(y))
self.update_json()
def update_json(self):
if self.jsondata:
# TODO : Manage colors and presend commands
self.jsondata['bbox']['width'] = self.width() * self.uiscale
self.jsondata['bbox']['height'] = self.height() * self.uiscale
self.jsondata['bbox']['left'] = self.pos().x() * self.uiscale
self.jsondata['bbox']['top'] = self.pos().y() * self.uiscale
class screenWidget(widgets.QFrame):
def __init__(self, parent, uiscale):
super(screenWidget, self).__init__(parent)
self.jsondata = None
self.ismovable = False
self.uiscale = uiscale
self.setContentsMargins(0, 0, 0, 0)
self.screen_height = 0
self.screen_width = 0
self.presend = []
self.toggle_selected(False)
def toggle_selected(self, sel):
if sel:
self.setFrameStyle(widgets.QFrame.Panel | widgets.QFrame.StyledPanel)
else:
self.setFrameStyle(widgets.QFrame.NoFrame)
def change_ratio(self, x):
return
def initXML(self, xmldata):
screencolorxml = xmldata.getAttribute("Color")
self.screencolor = colorConvert(screencolorxml)
self.screen_width = int(int(xmldata.getAttribute("Width")) / self.uiscale)
self.screen_height = int(int(xmldata.getAttribute("Height")) / self.uiscale)
self.setStyleSheet("background-color: %s" % self.screencolor)
self.resize(self.screen_width, self.screen_height)
for elem in getChildNodesByName(xmldata, u"Send"):
delay = elem.getAttribute('Delay')
req_name = elem.getAttribute('RequestName')
self.presend.append({'Delay': delay, 'RequestName': req_name})
def initJson(self, jsdata):
self.screen_width = int(int(jsdata['width']) / self.uiscale)
self.screen_height = int(int(jsdata['height']) / self.uiscale)
self.setStyleSheet("background-color: %s" % jsdata['color'])
self.resize(self.screen_width, self.screen_height)
self.presend = jsdata['presend']
self.jsondata = jsdata
def resize(self, x, y):
super(screenWidget, self).resize(int(x), int(y))
self.update_json()
def lock(self, lock):
pass
def move(self, x, y):
super(screenWidget, self).move(int(x), int(y))
self.update_json()
def update_json(self):
if self.jsondata:
# TODO : Manage colors and presend commands
self.jsondata['width'] = self.width() * self.uiscale
self.jsondata['height'] = self.height() * self.uiscale
class buttonRequest(widgets.QPushButton):
def __init__(self, parent, uiscale, ecureq, count):
super(buttonRequest, self).__init__(parent)
self.jsdata = None
self.ismovable = True
self.uiscale = uiscale
self.ecurequest = ecureq
self.count = count
self.messages = []
self.butname = ""
self.uniquename = ""
self.jsondata = None
self.toggle_selected(False)
def toggle_selected(self, sel):
if sel:
# self.setFrameStyle(widgets.QFrame.Panel | widgets.QFrame.StyledPanel)
pass
else:
# self.setFrameStyle(0)
pass
def change_ratio(self, x):
pass
def initXML(self, xmldata):
text = xmldata.getAttribute("Text")
rect = getRectangleXML(getChildNodesByName(xmldata, "Rectangle")[0], self.uiscale)
qfnt = getXMLFont(xmldata, self.uiscale)
self.messages = getChildNodesByName(xmldata, "Message")
self.setFont(qfnt)
self.setText(text)
self.resize(rect['width'], rect['height'])
self.setStyleSheet("background: yellow; color: black")
self.move(rect['left'], rect['top'])
self.butname = text + "_" + str(self.count)
def initJson(self, jsdata):
text = jsdata['text']
rect = jsdata['rect']
qfnt = jsonFont(jsdata['font'], self.uiscale)
self.messages = jsdata['messages']
self.setFont(qfnt)
self.setText(text)
self.resize(rect['width'] / self.uiscale, rect['height'] / self.uiscale)
self.setStyleSheet("background: yellow; color: black")
self.move(rect['left'] / self.uiscale, rect['top'] / self.uiscale)
self.butname = jsdata['text'] + "_" + str(self.count)
self.uniquename = jsdata['uniquename']
self.jsondata = jsdata
def mousePressEvent(self, event):
if options.simulation_mode and options.mode_edit:
self.parent().mousePressEvent(event)
return
return super(buttonRequest, self).mousePressEvent(event)
def resize(self, x, y):
super(buttonRequest, self).resize(int(x), int(y))
self.update_json()
def move(self, x, y):
super(buttonRequest, self).move(int(x), int(y))
self.update_json()
def update_json(self):
if self.jsondata:
self.jsondata['rect']['left'] = self.pos().x() * self.uiscale
self.jsondata['rect']['top'] = self.pos().y() * self.uiscale
self.jsondata['rect']['height'] = self.height() * self.uiscale
self.jsondata['rect']['width'] = self.width() * self.uiscale
class styleLabel(widgets.QLabel):
def __init__(self, parent):
super(styleLabel, self).__init__(parent)
self.defaultStyle = ""
def setDefaultStyle(self, style):
self.defaultStyle = style
self.setStyleSheet(self.defaultStyle)
def resetDefaultStyle(self):
self.setStyleSheet(self.defaultStyle)
class displayWidget(widgets.QWidget):
def __init__(self, parent, uiscale, ecureq):
super(displayWidget, self).__init__(parent)
self.uiscale = uiscale
self.ecurequestsparser = ecureq
self.ismovable = True
self.qlabel = None
self.qlabelval = None
self.jsondata = None
def toggle_selected(self, sel):
if sel:
self.qlabel.setFrameStyle(widgets.QFrame.Panel | widgets.QFrame.StyledPanel)
self.qlabelval.setFrameStyle(widgets.QFrame.Panel | widgets.QFrame.StyledPanel)
else:
self.qlabel.setFrameStyle(widgets.QFrame.NoFrame)
self.qlabelval.setFrameStyle(widgets.QFrame.Panel | widgets.QFrame.Sunken)
def lock(self, lock):
pass
def resize(self, x, y):
oldwidth = self.width()
super(displayWidget, self).resize(int(x), int(y))
newwidth = self.width()
if not self.qlabelval or not self.qlabel:
return
diff = newwidth - oldwidth
self.qlabel.resize(self.qlabel.width() + diff, self.height())
self.qlabelval.resize(self.qlabelval.width(), self.height())
self.qlabelval.move(self.qlabelval.pos().x() + diff, 0)
self.update_json()
def move(self, x, y):
super(displayWidget, self).move(int(x), int(y))
self.update_json()
def update_json(self):
if self.jsondata:
self.jsondata['width'] = self.qlabel.width() * self.uiscale
self.jsondata['rect']['left'] = self.pos().x() * self.uiscale
self.jsondata['rect']['top'] = self.pos().y() * self.uiscale
self.jsondata['rect']['height'] = self.height() * self.uiscale
self.jsondata['rect']['width'] = self.width() * self.uiscale
def change_ratio(self, x):
valnewx = self.qlabelval.pos().x() + x
if valnewx < 0:
return
if valnewx > self.width():
return
oldlabelsize = self.qlabel.width()
oldvalsize = self.qlabelval.width()
self.qlabel.resize(oldlabelsize + x, self.height())
self.qlabelval.resize(oldvalsize - x, self.height())
self.qlabelval.move(valnewx, 0)
self.update_json()
def initXML(self, display, displaydict):
text = display.getAttribute("DataName")
req_name = display.getAttribute("RequestName")
color = display.getAttribute("Color")
width = int(display.getAttribute("Width")) / self.uiscale
rect = getRectangleXML(getChildNodesByName(display, "Rectangle")[0], self.uiscale)
qfnt = getXMLFont(display, self.uiscale)
if req_name not in self.ecurequestsparser.requests:
print(_("No request named"), req_name)
return
req = self.ecurequestsparser.requests[req_name]
dataitem = None
if text in req.dataitems:
dataitem = req.dataitems[text]
else:
keys = req.dataitems.keys()
for k in keys:
if k.upper() == text.upper():
dataitem = req.dataitems[k]
print(_("Found similar"), k, " vs ", text)
break
if not dataitem:
print(_("DataItem not found"), text)
return
try:
data = self.ecurequestsparser.data[text]
except:
print(_("Cannot find data "), text)
return
if not color:
color = 0x55555
self.move(rect['left'], rect['top'])
self.resize(rect['width'], rect['height'])
self.qlabel = widgets.QLabel(self)
self.qlabel.setFont(qfnt)
self.qlabel.setText(text)
self.qlabel.resize(int(width), rect['height'])
self.qlabel.setStyleSheet("background-color: %s; color: %s" % (colorConvert(color), getFontColor(display)))
self.qlabel.setAlignment(core.Qt.AlignLeft)
self.qlabel.setWordWrap(True)
self.qlabelval = styleLabel(self)
self.qlabelval.setFont(qfnt)
self.qlabelval.setText("")
self.qlabelval.resize(rect['width'] - int(width), rect['height'])
self.qlabelval.setDefaultStyle("background-color: %s; color: %s" % (colorConvert(color), getFontColor(display)))
self.qlabelval.move(int(width), 0)
endianess = req.ecu_file.endianness
if dataitem.endian != "":
endianess = dataitem.endian
infos = req_name + u'\n'
if data.comment:
infos += data.comment + u'\n'
infos += u"Request=" + unicode(req.sentbytes) + u' ManualRequest=' + unicode(req.manualsend)
infos += u'\nNumBits=' + unicode(data.bitscount)
infos += u' FirstByte=' + unicode(dataitem.firstbyte)
infos += u' BitOffset=' + unicode(dataitem.bitoffset)
infos += u' Endianess=' + unicode(endianess)
self.qlabelval.setToolTip(infos)
ddata = displayData(data, self.qlabelval)
if not req_name in displaydict:
displaydict[req_name] = displayDict(req_name, req)
dd = displaydict[req_name]
dd.addData(ddata)
self.toggle_selected(False)
def initJson(self, display, displaydict):
text = display['text']
req_name = display['request']
color = display['color']
width = display['width'] / self.uiscale
rect = display['rect']
qfnt = jsonFont(display['font'], self.uiscale)
fontcolor = display['fontcolor']
req = self.ecurequestsparser.requests[req_name]
dataitem = None
if text in req.dataitems:
dataitem = req.dataitems[text]
else:
keys = req.dataitems.keys()
for k in keys:
if k.upper() == text.upper():
dataitem = req.dataitems[k]
print(_("Found similar"), k, _(" vs "), text)
break
if not dataitem:
print(_("DataItem not found"), text)
return
data = self.ecurequestsparser.data[text]
self.move(rect['left'] / self.uiscale, rect['top'] / self.uiscale)
self.resize(rect['width'] / self.uiscale, rect['height'] / self.uiscale)
self.qlabel = widgets.QLabel(self)
self.qlabel.setFont(qfnt)
self.qlabel.setText(text)
self.qlabel.resize(int(width), int(rect['height'] / self.uiscale))
self.qlabel.setStyleSheet("background-color: %s; color: %s" % (color, fontcolor))
self.qlabel.setAlignment(core.Qt.AlignLeft)
self.qlabel.setWordWrap(True)
self.qlabelval = styleLabel(self)
self.qlabelval.setFont(qfnt)
self.qlabelval.setText("")
self.qlabelval.resize(int(rect['width'] / self.uiscale - width), int(rect['height'] / self.uiscale))
self.qlabelval.setDefaultStyle("background-color: %s; color: %s" % (color, fontcolor))
self.qlabelval.move(int(width), 0)
infos = req_name + u'\n'
if data.comment:
infos += data.comment + u'\n'
endianess = req.ecu_file.endianness
if dataitem.endian != "":
endianess = dataitem.endian
infos += u"Request=" + unicode(req.sentbytes) + u' ManualRequest=' + unicode(req.manualsend)
infos += u'\nNumBits=' + unicode(data.bitscount)
infos += u' FirstByte=' + unicode(dataitem.firstbyte)
infos += u' BitOffset=' + unicode(dataitem.bitoffset)
infos += u' Endianess=' + unicode(endianess)
self.qlabelval.setToolTip(infos)
ddata = displayData(data, self.qlabelval)
if not req_name in displaydict:
displaydict[req_name] = displayDict(req_name, req)
dd = displaydict[req_name]
dd.addData(ddata)
self.jsondata = display
self.toggle_selected(False)
class inputWidget(widgets.QWidget):
def __init__(self, parent, uiscale, ecureq):
super(inputWidget, self).__init__(parent)
self.uiscale = uiscale
self.ecurequestsparser = ecureq
self.ismovable = True
self.qlabel = None
self.editwidget = None
self.jsondata = None
self.locked = False
def toggle_selected(self, sel):
if sel:
self.qlabel.setFrameStyle(widgets.QFrame.Panel | widgets.QFrame.StyledPanel)
else:
self.qlabel.setFrameStyle(widgets.QFrame.NoFrame)
def lock(self, lock):
self.locked = lock
def resize(self, x, y):
oldwidth = self.width()
super(inputWidget, self).resize(int(x), int(y))
newwidth = self.width()
if not self.qlabel or not self.editwidget:
return
diff = newwidth - oldwidth
self.qlabel.resize(self.qlabel.width() + diff, self.height())
self.editwidget.resize(self.editwidget.width(), self.height())
self.editwidget.move(self.editwidget.pos().x() + diff, 0)
self.update_json()
def move(self, x, y):
super(inputWidget, self).move(int(x), int(y))
self.update_json()
def update_json(self):
if self.jsondata:
scale = float(self.uiscale)
self.jsondata['width'] = int(self.qlabel.width() * scale)
self.jsondata['rect']['left'] = int(self.pos().x() * scale)
self.jsondata['rect']['top'] = int(self.pos().y() * scale)
self.jsondata['rect']['height'] = int(self.height() * scale)
self.jsondata['rect']['width'] = int(self.width() * scale)
def change_ratio(self, x):
valnewx = self.editwidget.pos().x() + x
if valnewx < 0:
return
if valnewx > self.width():
return
oldlabelsize = self.qlabel.width()
oldvalsize = self.editwidget.width()
self.qlabel.resize(oldlabelsize + x, self.height())
self.editwidget.resize(oldvalsize - x, self.height())
self.editwidget.move(valnewx, 0)
self.update_json()
def initXML(self, input, inputdict):
text = input.getAttribute("DataName")
req_name = input.getAttribute("RequestName")
color = input.getAttribute("Color")
width = int(input.getAttribute("Width")) / self.uiscale
rect = getRectangleXML(getChildNodesByName(input, "Rectangle")[0], self.uiscale)
qfnt = getXMLFont(input, self.uiscale)
if not color:
color = 0xAAAAAA
self.resize(rect['width'], rect['height'])
self.qlabel = widgets.QLabel(self)
self.qlabel.setWordWrap(True)
self.qlabel.setFont(qfnt)
self.qlabel.setText(text)
self.qlabel.setStyleSheet("background:%s; color:%s" % (colorConvert(color), getFontColor(input)))
self.qlabel.resize(int(width), int(rect['height']))
self.move(rect['left'], rect['top'])
try:
data = self.ecurequestsparser.data[text]
except:
print(_("Cannot draw input "), text)
return
if len(self.ecurequestsparser.data[text].items) > 0:
self.editwidget = widgets.QComboBox(self)
items_ref = self.ecurequestsparser.data[text].items
for key in sorted(items_ref.keys()):
self.editwidget.addItem(key)
self.editwidget.resize(rect['width'] - int(width), rect['height'])
self.editwidget.move(int(width), 0)
if data.comment:
infos = data.comment + u'\n' + req_name + u' : ' + text + u'\nNumBits=' + unicode(data.bitscount)
else:
infos = req_name + u' : ' + text + u'\nNumBits=' + unicode(data.bitscount)
self.editwidget.setToolTip(infos)
self.editwidget.setStyleSheet("background:%s; color:%s" % (colorConvert(color), getFontColor(input)))
ddata = displayData(data, self.editwidget, True)
else:
self.editwidget = widgets.QLineEdit(self)
if options.simulation_mode and options.mode_edit:
self.editwidget.setEnabled(False)
self.editwidget.setFont(qfnt)
self.editwidget.setText(_("No Value"))
self.editwidget.resize(rect['width'] - int(width), rect['height'])
self.editwidget.setStyleSheet("background:%s; color:%s" % (colorConvert(color), getFontColor(input)))
self.editwidget.move(int(width), 0)
if data.comment:
infos = data.comment + u'\n' + req_name + u' : ' + text + u'\nNumBits=' + unicode(data.bitscount)
else:
infos = req_name + u' : ' + text + u'\nNumBits=' + unicode(data.bitscount)
self.editwidget.setToolTip(infos)
ddata = displayData(data, self.editwidget)
if not req_name in inputdict:
req = self.ecurequestsparser.requests[req_name]
inputdict[req_name] = displayDict(req_name, req)
dd = inputdict[req_name]
dd.addData(ddata)
self.toggle_selected(False)
def initJson(self, jsoninput, inputdict):
text = jsoninput['text']
req_name = jsoninput['request']
color = jsoninput['color']
width = int(jsoninput['width'] / self.uiscale)
rect = jsoninput['rect']
qfnt = jsonFont(jsoninput['font'], self.uiscale)
fntcolor = jsoninput['fontcolor']
self.move(rect['left'] / self.uiscale, rect['top'] / self.uiscale)
self.resize(rect['width'] / self.uiscale, rect['height'] / self.uiscale)
self.qlabel = widgets.QLabel(self)
self.qlabel.setFont(qfnt)
self.qlabel.setText(text)
self.qlabel.setStyleSheet("background:%s; color:%s" % (color, jsoninput))
self.qlabel.setWordWrap(True)
self.qlabel.resize(int(width), int(rect['height'] / self.uiscale))
if not text in self.ecurequestsparser.data:
print(_("Cannot find data "), text)
return
data = self.ecurequestsparser.data[text]
if len(self.ecurequestsparser.data[text].items) > 0:
self.editwidget = widgets.QComboBox(self)
items_ref = self.ecurequestsparser.data[text].items
for key in sorted(items_ref.keys()):
self.editwidget.addItem(key)
self.editwidget.move(width, 0)
if data.comment:
infos = data.comment + u'\n' + req_name + u' : ' + text + u'\nNumBits=' + unicode(
data.bitscount)
else:
infos = req_name + u' : ' + text + u'\nNumBits=' + unicode(data.bitscount)
self.editwidget.setToolTip(infos)
self.editwidget.setStyleSheet(
"background:%s; color:%s" % (color, fntcolor))
ddata = displayData(data, self.editwidget, True)
else:
self.editwidget = widgets.QLineEdit(self)
self.editwidget.setFont(qfnt)
self.editwidget.setText("No Value")
self.editwidget.setStyleSheet(
"background:%s; color:%s" % (color, fntcolor))
if data.comment:
infos = data.comment + u'\n' + req_name + u' : ' + text + u'\nNumBits=' + unicode(
data.bitscount)
else:
infos = req_name + u' : ' + text + u'\nNumBits=' + unicode(data.bitscount)
self.editwidget.setToolTip(infos)
ddata = displayData(data, self.editwidget)
if options.simulation_mode and options.mode_edit:
self.editwidget.setEnabled(False)
self.editwidget.resize(int(rect['width'] / self.uiscale - width), int(rect['height'] / self.uiscale))
self.editwidget.move(int(width), 0)
if not req_name in inputdict:
req = self.ecurequestsparser.requests[req_name]
inputdict[req_name] = displayDict(req_name, req)
dd = inputdict[req_name]
dd.addData(ddata)
self.jsondata = jsoninput
self.toggle_selected(False)