diff python/ide/st-util.py @ 333:dcae6574c974

Increment to qt5
author Windel Bouwman
date Sun, 09 Feb 2014 15:27:57 +0100
parents 534b94b40aa8
children
line wrap: on
line diff
--- a/python/ide/st-util.py	Fri Feb 07 12:51:55 2014 +0100
+++ b/python/ide/st-util.py	Sun Feb 09 15:27:57 2014 +0100
@@ -1,14 +1,13 @@
 #!/usr/bin/python
 
 import sys
-from PyQt4.QtCore import *
-from PyQt4.QtGui import *
+from qtwrapper import QtGui, QtCore, QtWidgets, pyqtSignal, get_icon, Qt
 import stlink, devices, stm32, usb
 from devices import Interface, Device
 from hexedit import HexEdit
 
 
-class InformationDialog(QDialog):
+class InformationDialog(QtWidgets.QDialog):
    def __init__(self, parent):
       super().__init__(parent)
       self.setWindowTitle('Info')
@@ -20,7 +19,7 @@
          fl.addRow('Status:', QLabel(parent.stl.StatusString))
 
 
-class RegisterModel(QAbstractTableModel):
+class RegisterModel(QtCore.QAbstractTableModel):
     def __init__(self):
       super().__init__()
       self.regCount = 15
@@ -85,7 +84,7 @@
          self.dataChanged.emit(fromIndex, toIndex)
 
 
-class RegisterView(QTableView):
+class RegisterView(QtWidgets.QTableView):
     def __init__(self):
       super().__init__()
       self.mdl = RegisterModel()
@@ -97,20 +96,20 @@
       self.mdl.refresh()
 
 
-class MemoryView(QWidget):
+class MemoryView(QtWidgets.QWidget):
     BlockSize = 0x100
     def __init__(self):
       super().__init__()
-      l = QVBoxLayout(self)
-      l2 = QHBoxLayout()
-      l2.addWidget(QLabel('Address'))
-      self.addressLine = QLineEdit()
+      l = QtWidgets.QVBoxLayout(self)
+      l2 = QtWidgets.QHBoxLayout()
+      l2.addWidget(QtWidgets.QLabel('Address'))
+      self.addressLine = QtWidgets.QLineEdit()
       self.addressLine.setInputMask('Hhhhhhhh')
       l2.addWidget(self.addressLine)
-      upButton = QPushButton('up')
+      upButton = QtWidgets.QPushButton('up')
       l2.addWidget(upButton)
       upButton.clicked.connect(self.doUp)
-      downButton = QPushButton('down')
+      downButton = QtWidgets.QPushButton('down')
       downButton.clicked.connect(self.doDown)
       l2.addWidget(downButton)
       l.addLayout(l2)
@@ -148,15 +147,16 @@
       self.Address = 0x8000000
 
 
-class DebugToolbar(QToolBar):
-   statusChange = pyqtSignal()
-   codePosition = pyqtSignal(int)
-   def __init__(self):
+class DebugToolbar(QtWidgets.QToolBar):
+    statusChange = pyqtSignal()
+    codePosition = pyqtSignal(int)
+
+    def __init__(self):
       super().__init__()
       self.device = None
       # generate actions:
       def genAction(name, callback):
-         a = QAction(name, self)
+         a = QtWidgets.QAction(name, self)
          a.triggered.connect(callback)
          self.addAction(a)
          return a
@@ -166,7 +166,8 @@
       self.resetAction = genAction('Reset', self.doReset)
       self.enableTraceAction = genAction('Enable trace', self.doEnableTrace)
       self.updateEnables()
-   def updateEnables(self):
+
+    def updateEnables(self):
       if self.device:
          self.resetAction.setEnabled(True)
          self.enableTraceAction.setEnabled(True)
@@ -184,37 +185,43 @@
          self.runAction.setEnabled(False)
          self.stepAction.setEnabled(False)
          self.stopAction.setEnabled(False)
-   def doStep(self):
+
+    def doStep(self):
       self.device.iface.step()
       self.updateEnables()
-   def doReset(self):
+
+    def doReset(self):
       self.device.iface.reset()
       self.updateEnables()
-   def doRun(self):
+
+    def doRun(self):
       self.device.iface.run()
       self.updateEnables()
-   def doHalt(self):
+
+    def doHalt(self):
       self.device.iface.halt()
       self.updateEnables()
-   def doEnableTrace(self):
+
+    def doEnableTrace(self):
       self.device.iface.traceEnable()
       self.updateEnables()
-   def setDevice(self, dev):
+
+    def setDevice(self, dev):
       self.device = dev
       self.updateEnables()
 
 
-class FlashTool(QWidget):
+class FlashTool(QtWidgets.QWidget):
    def __init__(self):
       super().__init__()
       # TODO!
 
 
-class DeviceTreeModel(QAbstractItemModel):
+class DeviceTreeModel(QtCore.QAbstractItemModel):
    def __init__(self):
       super().__init__()
-      self.chipPixmap = QPixmap('icons/chip.png').scaled(32, 32)
-      self.hardwarePixmap = QPixmap('icons/hardware.png').scaled(32, 32)
+      self.chipPixmap = get_icon('chip.png').scaled(32, 32)
+      self.hardwarePixmap = get_icon('hardware.png').scaled(32, 32)
       self.refresh()
    def refresh(self):
       """ Check all usb interfaces for interfaces """
@@ -271,7 +278,7 @@
             if isinstance(ip, Device):
                return self.chipPixmap
 
-class DeviceExplorer(QTreeView):
+class DeviceExplorer(QtWidgets.QTreeView):
    """ Lists all interfaces plugged in and allows selection """
    deviceSelected = pyqtSignal(Device)
    def __init__(self):
@@ -320,7 +327,7 @@
       menu.exec(self.mapToGlobal(pt))
 
 
-class StUtil(QMainWindow):
+class StUtil(QtWidgets.QMainWindow):
    connected = pyqtSignal(bool)
    def __init__(self):
       super().__init__()