RefactoringRope/HistoryDialog.py

branch
eric7
changeset 365
f740b50380df
parent 347
b5048b5ff454
child 374
958f34e97952
diff -r a92b3272f4c1 -r f740b50380df RefactoringRope/HistoryDialog.py
--- a/RefactoringRope/HistoryDialog.py	Wed May 26 17:53:08 2021 +0200
+++ b/RefactoringRope/HistoryDialog.py	Wed May 26 19:07:42 2021 +0200
@@ -7,26 +7,27 @@
 Module implementing the History dialog.
 """
 
-from PyQt5.QtCore import pyqtSlot, Qt, QItemSelectionModel
-from PyQt5.QtGui import QBrush, QColor, QTextCursor
-from PyQt5.QtWidgets import (
+from PyQt6.QtCore import pyqtSlot, Qt, QItemSelectionModel
+from PyQt6.QtGui import QBrush, QTextCursor
+from PyQt6.QtWidgets import (
     QDialog, QDialogButtonBox, QListWidgetItem, QAbstractButton
 )
 
-from E5Gui.E5Application import e5App
-from E5Gui import E5MessageBox
+from EricWidgets.EricApplication import ericApp
+from EricWidgets import EricMessageBox
 
 from .Ui_HistoryDialog import Ui_HistoryDialog
 
 import Globals
 import Utilities
+import Preferences
 
 
 class HistoryDialog(QDialog, Ui_HistoryDialog):
     """
     Class implementing the History dialog.
     """
-    ChangeIDRole = Qt.UserRole
+    ChangeIDRole = Qt.ItemDataRole.UserRole
     
     def __init__(self, refactoring, filename="", parent=None):
         """
@@ -41,7 +42,7 @@
         """
         QDialog.__init__(self, parent)
         self.setupUi(self)
-        self.setWindowFlags(Qt.Window)
+        self.setWindowFlags(Qt.WindowType.Window)
         
         if Globals.isWindowsPlatform():
             self.previewEdit.setFontFamily("Lucida Console")
@@ -50,20 +51,30 @@
         
         self.formats = {}
         self.formats[' '] = self.previewEdit.currentCharFormat()
+        
         charFormat = self.previewEdit.currentCharFormat()
-        charFormat.setBackground(QBrush(QColor(190, 237, 190)))
+        charFormat.setBackground(
+            QBrush(Preferences.getDiffColour("AddedColor")))
         self.formats['+'] = charFormat
+        
         charFormat = self.previewEdit.currentCharFormat()
-        charFormat.setBackground(QBrush(QColor(237, 190, 190)))
+        charFormat.setBackground(
+            QBrush(Preferences.getDiffColour("RemovedColor")))
         self.formats['-'] = charFormat
+        
         charFormat = self.previewEdit.currentCharFormat()
-        charFormat.setBackground(QBrush(QColor(190, 190, 237)))
+        charFormat.setBackground(
+            QBrush(Preferences.getDiffColour("ReplacedColor")))
         self.formats['@'] = charFormat
+        
         charFormat = self.previewEdit.currentCharFormat()
-        charFormat.setBackground(QBrush(QColor(124, 124, 124)))
+        charFormat.setBackground(
+            QBrush(Preferences.getDiffColour("ContextColor")))
         self.formats['?'] = charFormat
+        
         charFormat = self.previewEdit.currentCharFormat()
-        charFormat.setBackground(QBrush(QColor(190, 190, 190)))
+        charFormat.setBackground(
+            QBrush(Preferences.getDiffColour("HeaderColor")))
         self.formats['='] = charFormat
         
         self.__refactoring = refactoring
@@ -76,13 +87,13 @@
                 filename))
         
         self.__undoButton = self.buttonBox.addButton(
-            self.tr("&Undo"), QDialogButtonBox.ActionRole)
+            self.tr("&Undo"), QDialogButtonBox.ButtonRole.ActionRole)
         self.__redoButton = self.buttonBox.addButton(
-            self.tr("&Redo"), QDialogButtonBox.ActionRole)
+            self.tr("&Redo"), QDialogButtonBox.ButtonRole.ActionRole)
         self.__refreshButton = self.buttonBox.addButton(
-            self.tr("Re&fresh"), QDialogButtonBox.ActionRole)
+            self.tr("Re&fresh"), QDialogButtonBox.ButtonRole.ActionRole)
         self.__clearButton = self.buttonBox.addButton(
-            self.tr("&Clear History"), QDialogButtonBox.ActionRole)
+            self.tr("&Clear History"), QDialogButtonBox.ButtonRole.ActionRole)
         
         # populate the list
         self.__refreshHistories()
@@ -97,7 +108,7 @@
         @type QTextCharFormat
         """
         tc = self.previewEdit.textCursor()
-        tc.movePosition(QTextCursor.End)
+        tc.movePosition(QTextCursor.MoveOperation.End)
         self.previewEdit.setTextCursor(tc)
         self.previewEdit.setCurrentCharFormat(charFormat)
         self.previewEdit.insertPlainText(txt)
@@ -110,7 +121,7 @@
         @param button reference to the button clicked
         @type QAbstractButton
         """
-        if button == QDialogButtonBox.Close:
+        if button == QDialogButtonBox.StandardButton.Close:
             self.close()
         elif button == self.__undoButton:
             self.__undoChanges()
@@ -191,9 +202,9 @@
         currentUndoItem = self.undoChangesList.currentItem()
         change = currentUndoItem.text()
         changeId = currentUndoItem.data(HistoryDialog.ChangeIDRole)
-        res = E5MessageBox.yesNo(
+        res = EricMessageBox.yesNo(
             None,
-            self.tr("Undo refactorings"),
+            self.tr("Undo Refactorings"),
             self.tr("""Shall all refactorings up to <b>{0}</b>"""
                     """ be undone?""")
             .format(Utilities.html_encode(change)))
@@ -213,9 +224,9 @@
         currentRedoItem = self.redoChangesList.currentItem()
         change = currentRedoItem.text()
         changeId = currentRedoItem.data(HistoryDialog.ChangeIDRole)
-        res = E5MessageBox.yesNo(
+        res = EricMessageBox.yesNo(
             None,
-            self.tr("Redo refactorings"),
+            self.tr("Redo Refactorings"),
             self.tr("""Shall all refactorings up to <b>{0}</b>"""
                     """ be redone?""")
             .format(Utilities.html_encode(change)))
@@ -250,7 +261,7 @@
         """
         Private method to clear the refactoring history.
         """
-        res = E5MessageBox.yesNo(
+        res = EricMessageBox.yesNo(
             None,
             self.tr("Clear History"),
             self.tr("Do you really want to clear the refactoring history?"))
@@ -286,11 +297,11 @@
             if self.undoChangesList.count() > 0:
                 self.undoChangesList.setCurrentItem(
                     self.undoChangesList.item(0),
-                    QItemSelectionModel.Select)
+                    QItemSelectionModel.SelectionFlag.Select)
             elif self.redoChangesList.count() > 0:
                 self.redoChangesList.setCurrentItem(
                     self.redoChangesList.item(0),
-                    QItemSelectionModel.Select)
+                    QItemSelectionModel.SelectionFlag.Select)
             
             self.__refreshButton.setEnabled(True)
             if (
@@ -309,7 +320,7 @@
         
         elif subcommand in ["Undo", "Redo"]:
             self.__refactoring.refreshEditors(data["ChangedFiles"])
-            p = e5App().getObject("Project")
+            p = ericApp().getObject("Project")
             if p.isDirty():
                 p.saveProject()
             

eric ide

mercurial