eric6/HexEdit/HexEditWidget.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8205
4a0f1f896341
--- a/eric6/HexEdit/HexEditWidget.py	Mon Mar 01 17:48:43 2021 +0100
+++ b/eric6/HexEdit/HexEditWidget.py	Tue Mar 02 17:17:09 2021 +0100
@@ -134,10 +134,10 @@
             self.setFont(QFont("Monospace", 10))
         
         self.setAddressAreaColors(
-            self.palette().color(QPalette.WindowText),
+            self.palette().color(QPalette.ColorRole.WindowText),
             self.palette().alternateBase().color())
         self.setHighlightColors(
-            self.palette().color(QPalette.WindowText),
+            self.palette().color(QPalette.ColorRole.WindowText),
             QColor(0xff, 0xff, 0x99, 0xff))
         self.setSelectionColors(
             self.palette().highlightedText().color(),
@@ -1193,80 +1193,82 @@
         @type QKeyEvent
         """
         # Cursor movements
-        if evt.matches(QKeySequence.MoveToNextChar):
+        if evt.matches(QKeySequence.StandardKey.MoveToNextChar):
             self.moveCursorToNextChar()
-        elif evt.matches(QKeySequence.MoveToPreviousChar):
+        elif evt.matches(QKeySequence.StandardKey.MoveToPreviousChar):
             self.moveCursorToPreviousChar()
-        elif evt.matches(QKeySequence.MoveToEndOfLine):
+        elif evt.matches(QKeySequence.StandardKey.MoveToEndOfLine):
             self.moveCursorToEndOfLine()
-        elif evt.matches(QKeySequence.MoveToStartOfLine):
+        elif evt.matches(QKeySequence.StandardKey.MoveToStartOfLine):
             self.moveCursorToStartOfLine()
-        elif evt.matches(QKeySequence.MoveToPreviousLine):
+        elif evt.matches(QKeySequence.StandardKey.MoveToPreviousLine):
             self.moveCursorToPreviousLine()
-        elif evt.matches(QKeySequence.MoveToNextLine):
+        elif evt.matches(QKeySequence.StandardKey.MoveToNextLine):
             self.moveCursorToNextLine()
-        elif evt.matches(QKeySequence.MoveToNextPage):
+        elif evt.matches(QKeySequence.StandardKey.MoveToNextPage):
             self.moveCursorToNextPage()
-        elif evt.matches(QKeySequence.MoveToPreviousPage):
+        elif evt.matches(QKeySequence.StandardKey.MoveToPreviousPage):
             self.moveCursorToPreviousPage()
-        elif evt.matches(QKeySequence.MoveToEndOfDocument):
+        elif evt.matches(QKeySequence.StandardKey.MoveToEndOfDocument):
             self.moveCursorToEndOfDocument()
-        elif evt.matches(QKeySequence.MoveToStartOfDocument):
+        elif evt.matches(QKeySequence.StandardKey.MoveToStartOfDocument):
             self.moveCursorToStartOfDocument()
         
         # Selection commands
-        elif evt.matches(QKeySequence.SelectAll):
+        elif evt.matches(QKeySequence.StandardKey.SelectAll):
             self.selectAll()
-        elif evt.matches(QKeySequence.SelectNextChar):
+        elif evt.matches(QKeySequence.StandardKey.SelectNextChar):
             self.selectNextChar()
-        elif evt.matches(QKeySequence.SelectPreviousChar):
+        elif evt.matches(QKeySequence.StandardKey.SelectPreviousChar):
             self.selectPreviousChar()
-        elif evt.matches(QKeySequence.SelectEndOfLine):
+        elif evt.matches(QKeySequence.StandardKey.SelectEndOfLine):
             self.selectToEndOfLine()
-        elif evt.matches(QKeySequence.SelectStartOfLine):
+        elif evt.matches(QKeySequence.StandardKey.SelectStartOfLine):
             self.selectToStartOfLine()
-        elif evt.matches(QKeySequence.SelectPreviousLine):
+        elif evt.matches(QKeySequence.StandardKey.SelectPreviousLine):
             self.selectPreviousLine()
-        elif evt.matches(QKeySequence.SelectNextLine):
+        elif evt.matches(QKeySequence.StandardKey.SelectNextLine):
             self.selectNextLine()
-        elif evt.matches(QKeySequence.SelectNextPage):
+        elif evt.matches(QKeySequence.StandardKey.SelectNextPage):
             self.selectNextPage()
-        elif evt.matches(QKeySequence.SelectPreviousPage):
+        elif evt.matches(QKeySequence.StandardKey.SelectPreviousPage):
             self.selectPreviousPage()
-        elif evt.matches(QKeySequence.SelectEndOfDocument):
+        elif evt.matches(QKeySequence.StandardKey.SelectEndOfDocument):
             self.selectEndOfDocument()
-        elif evt.matches(QKeySequence.SelectStartOfDocument):
+        elif evt.matches(QKeySequence.StandardKey.SelectStartOfDocument):
             self.selectStartOfDocument()
         
         # Edit commands
-        elif evt.matches(QKeySequence.Copy):
+        elif evt.matches(QKeySequence.StandardKey.Copy):
             self.copy()
         elif (
-            evt.key() == Qt.Key_Insert and
-            evt.modifiers() == Qt.NoModifier
+            evt.key() == Qt.Key.Key_Insert and
+            evt.modifiers() == Qt.KeyboardModifier.NoModifier
         ):
             self.setOverwriteMode(not self.overwriteMode())
             self.setCursorPosition(self.__cursorPosition)
         
         elif not self.__readOnly:
-            if evt.matches(QKeySequence.Cut):
+            if evt.matches(QKeySequence.StandardKey.Cut):
                 self.cut()
-            elif evt.matches(QKeySequence.Paste):
+            elif evt.matches(QKeySequence.StandardKey.Paste):
                 self.paste()
-            elif evt.matches(QKeySequence.Delete):
+            elif evt.matches(QKeySequence.StandardKey.Delete):
                 self.deleteByte()
             elif (
-                evt.key() == Qt.Key_Backspace and
-                evt.modifiers() == Qt.NoModifier
+                evt.key() == Qt.Key.Key_Backspace and
+                evt.modifiers() == Qt.KeyboardModifier.NoModifier
             ):
                 self.deleteByteBack()
-            elif evt.matches(QKeySequence.Undo):
+            elif evt.matches(QKeySequence.StandardKey.Undo):
                 self.undo()
-            elif evt.matches(QKeySequence.Redo):
+            elif evt.matches(QKeySequence.StandardKey.Redo):
                 self.redo()
             
             elif QApplication.keyboardModifiers() in [
-                    Qt.NoModifier, Qt.KeypadModifier]:
+                Qt.KeyboardModifier.NoModifier,
+                Qt.KeyboardModifier.KeypadModifier
+            ]:
                 # some hex input
                 key = evt.text()
                 if key and key in "0123456789abcdef":
@@ -1337,7 +1339,7 @@
         self.viewport().update()
         cPos = self.cursorPositionFromPoint(evt.pos())
         if cPos >= 0:
-            if evt.modifiers() == Qt.ShiftModifier:
+            if evt.modifiers() == Qt.KeyboardModifier.ShiftModifier:
                 self.__setSelection(cPos)
             else:
                 self.__resetSelection(cPos)
@@ -1361,7 +1363,8 @@
             
             # draw some patterns if needed
             painter.fillRect(
-                evt.rect(), self.viewport().palette().color(QPalette.Base))
+                evt.rect(),
+                self.viewport().palette().color(QPalette.ColorRole.Base))
             if self.__addressArea:
                 painter.fillRect(
                     QRect(-pxOfsX, evt.rect().top(),
@@ -1370,12 +1373,12 @@
                     self.__addressAreaBrush)
             if self.__asciiArea:
                 linePos = self.__pxPosAsciiX - (self.__pxGapHexAscii // 2)
-                painter.setPen(Qt.gray)
+                painter.setPen(Qt.GlobalColor.gray)
                 painter.drawLine(linePos - pxOfsX, evt.rect().top(),
                                  linePos - pxOfsX, self.height())
             
             painter.setPen(
-                self.viewport().palette().color(QPalette.WindowText))
+                self.viewport().palette().color(QPalette.ColorRole.WindowText))
             
             # paint the address area
             if self.__addressArea:
@@ -1396,9 +1399,9 @@
             
             # paint hex and ascii area
             colStandard = QPen(
-                self.viewport().palette().color(QPalette.WindowText))
+                self.viewport().palette().color(QPalette.ColorRole.WindowText))
             
-            painter.setBackgroundMode(Qt.TransparentMode)
+            painter.setBackgroundMode(Qt.BGMode.TransparentMode)
             
             row = 0
             pxPosY = pxPosStartY
@@ -1412,7 +1415,8 @@
                     bPosLine + colIdx < len(self.__dataShown) and
                     colIdx < self.BYTES_PER_LINE
                 ):
-                    c = self.viewport().palette().color(QPalette.Base)
+                    c = self.viewport().palette().color(
+                        QPalette.ColorRole.Base)
                     painter.setPen(colStandard)
                     
                     posBa = self.__bPosFirst + bPosLine + colIdx
@@ -1476,14 +1480,15 @@
                 row += 1
                 pxPosY += self.__pxCharHeight
         
-        painter.setBackgroundMode(Qt.TransparentMode)
+        painter.setBackgroundMode(Qt.BGMode.TransparentMode)
         painter.setPen(
-            self.viewport().palette().color(QPalette.WindowText))
+            self.viewport().palette().color(QPalette.ColorRole.WindowText))
             
         # paint cursor
         if self.__blink and not self.__readOnly and self.isActiveWindow():
             painter.fillRect(
-                self.__cursorRect, self.palette().color(QPalette.WindowText))
+                self.__cursorRect,
+                self.palette().color(QPalette.ColorRole.WindowText))
         else:
             if self.__hexDataShown:
                 try:

eric ide

mercurial