1445 loc = {"dict": dict} |
1445 loc = {"dict": dict} |
1446 exec('mdict = dict{0!s}.__dict__\nobj = dict{0!s}' |
1446 exec('mdict = dict{0!s}.__dict__\nobj = dict{0!s}' |
1447 .format(access), globals(), loc) |
1447 .format(access), globals(), loc) |
1448 mdict = loc["mdict"] |
1448 mdict = loc["mdict"] |
1449 obj = loc["obj"] |
1449 obj = loc["obj"] |
1450 if "PyQt4." in str(type(obj)): |
1450 if "PyQt4." in str(type(obj)) or \ |
|
1451 "PyQt5." in str(type(obj)): |
1451 qtVariable = True |
1452 qtVariable = True |
1452 qvar = obj |
1453 qvar = obj |
1453 qvtype = str(type(qvar))[1:-1].split()[1][1:-1] |
1454 qvtype = str(type(qvar))[1:-1].split()[1][1:-1] |
1454 ndict.update(mdict) |
1455 ndict.update(mdict) |
1455 except: |
1456 except: |
1510 globals(), loc) |
1513 globals(), loc) |
1511 except: |
1514 except: |
1512 pass |
1515 pass |
1513 ndict.update(loc["cdict"]) |
1516 ndict.update(loc["cdict"]) |
1514 obj = dict[var[i]] |
1517 obj = dict[var[i]] |
1515 if "PyQt4." in str(type(obj)): |
1518 if "PyQt4." in str(type(obj)) or \ |
|
1519 "PyQt5." in str(type(obj)): |
1516 qtVariable = True |
1520 qtVariable = True |
1517 qvar = obj |
1521 qvar = obj |
1518 qvtype = str(type(qvar))[1:-1].split()[1][1:-1] |
1522 qvtype = str(type(qvar))[1:-1].split()[1][1:-1] |
1519 except: |
1523 except: |
1520 pass |
1524 pass |
1521 odict = dict |
1525 odict = dict |
1522 dict = ndict |
1526 dict = ndict |
1523 i += 1 |
1527 i += 1 |
1524 |
1528 |
1525 if qtVariable: |
1529 if qtVariable: |
1526 vlist = self.__formatQt4Variable(qvar, qvtype) |
1530 vlist = self.__formatQtVariable(qvar, qvtype) |
1527 elif ("sipThis" in dict.keys() and len(dict) == 1) or \ |
1531 elif ("sipThis" in dict.keys() and len(dict) == 1) or \ |
1528 (len(dict) == 0 and len(udict) > 0): |
1532 (len(dict) == 0 and len(udict) > 0): |
1529 if access: |
1533 if access: |
1530 loc = {"udict": udict} |
1534 loc = {"udict": udict} |
1531 exec('qvar = udict{0!s}'.format(access), globals(), loc) |
1535 exec('qvar = udict{0!s}'.format(access), globals(), loc) |
1559 rvar[0][:-2], rvar[1]), globals(), loc) |
1563 rvar[0][:-2], rvar[1]), globals(), loc) |
1560 qvar = loc["qvar"] |
1564 qvar = loc["qvar"] |
1561 else: |
1565 else: |
1562 qvar = udict[var[-1]] |
1566 qvar = udict[var[-1]] |
1563 qvtype = str(type(qvar))[1:-1].split()[1][1:-1] |
1567 qvtype = str(type(qvar))[1:-1].split()[1][1:-1] |
1564 if qvtype.startswith("PyQt4"): |
1568 if qvtype.startswith(("PyQt4", "PyQt5")): |
1565 qtVariable = True |
1569 qtVariable = True |
1566 |
1570 |
1567 if qtVariable: |
1571 if qtVariable: |
1568 vlist = self.__formatQt4Variable(qvar, qvtype) |
1572 vlist = self.__formatQtVariable(qvar, qvtype) |
1569 else: |
1573 else: |
1570 # format the dictionary found |
1574 # format the dictionary found |
1571 if dictkeys is None: |
1575 if dictkeys is None: |
1572 dictkeys = dict.keys() |
1576 dictkeys = dict.keys() |
1573 else: |
1577 else: |
1602 pass |
1606 pass |
1603 |
1607 |
1604 self.write('{0}{1}\n'.format( |
1608 self.write('{0}{1}\n'.format( |
1605 DebugProtocol.ResponseVariable, str(varlist))) |
1609 DebugProtocol.ResponseVariable, str(varlist))) |
1606 |
1610 |
1607 def __formatQt4Variable(self, value, vtype): |
1611 def __formatQtVariable(self, value, vtype): |
1608 """ |
1612 """ |
1609 Private method to produce a formatted output of a simple Qt4/Qt5 type. |
1613 Private method to produce a formatted output of a simple Qt4/Qt5 type. |
1610 |
1614 |
1611 @param value variable to be formatted |
1615 @param value variable to be formatted |
1612 @param vtype type of the variable to be formatted (string) |
1616 @param vtype type of the variable to be formatted (string) |
1652 varlist.append(("height", "float", "{0:g}".format(value.height()))) |
1656 varlist.append(("height", "float", "{0:g}".format(value.height()))) |
1653 elif qttype == 'QColor': |
1657 elif qttype == 'QColor': |
1654 varlist.append(("name", "str", "{0}".format(value.name()))) |
1658 varlist.append(("name", "str", "{0}".format(value.name()))) |
1655 r, g, b, a = value.getRgb() |
1659 r, g, b, a = value.getRgb() |
1656 varlist.append( |
1660 varlist.append( |
1657 ("rgb", "int", |
1661 ("rgba", "int", |
1658 "{0:d}, {1:d}, {2:d}, {3:d}".format(r, g, b, a))) |
1662 "{0:d}, {1:d}, {2:d}, {3:d}".format(r, g, b, a))) |
1659 h, s, v, a = value.getHsv() |
1663 h, s, v, a = value.getHsv() |
1660 varlist.append( |
1664 varlist.append( |
1661 ("hsv", "int", |
1665 ("hsva", "int", |
1662 "{0:d}, {1:d}, {2:d}, {3:d}".format(h, s, v, a))) |
1666 "{0:d}, {1:d}, {2:d}, {3:d}".format(h, s, v, a))) |
1663 c, m, y, k, a = value.getCmyk() |
1667 c, m, y, k, a = value.getCmyk() |
1664 varlist.append( |
1668 varlist.append( |
1665 ("cmyk", "int", |
1669 ("cmyka", "int", |
1666 "{0:d}, {1:d}, {2:d}, {3:d}, {4:d}".format(c, m, y, k, a))) |
1670 "{0:d}, {1:d}, {2:d}, {3:d}, {4:d}".format(c, m, y, k, a))) |
1667 elif qttype == 'QDate': |
1671 elif qttype == 'QDate': |
1668 varlist.append(("", "QDate", "{0}".format(value.toString()))) |
1672 varlist.append(("", "QDate", "{0}".format(value.toString()))) |
1669 elif qttype == 'QTime': |
1673 elif qttype == 'QTime': |
1670 varlist.append(("", "QTime", "{0}".format(value.toString()))) |
1674 varlist.append(("", "QTime", "{0}".format(value.toString()))) |