eric6/E5Gui/E5ToolBarDialog.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8207
d359172d11be
diff -r 27f636beebad -r 2c730d5fd177 eric6/E5Gui/E5ToolBarDialog.py
--- a/eric6/E5Gui/E5ToolBarDialog.py	Mon Mar 01 17:48:43 2021 +0100
+++ b/eric6/E5Gui/E5ToolBarDialog.py	Tue Mar 02 17:17:09 2021 +0100
@@ -45,8 +45,8 @@
     """
     Class implementing a toolbar configuration dialog.
     """
-    ActionIdRole = Qt.UserRole
-    WidgetActionRole = Qt.UserRole + 1
+    ActionIdRole = Qt.ItemDataRole.UserRole
+    WidgetActionRole = Qt.ItemDataRole.UserRole + 1
     
     def __init__(self, toolBarManager, parent=None):
         """
@@ -77,8 +77,9 @@
         self.rightButton.setIcon(UI.PixmapCache.getIcon("1rightarrow"))
         
         self.__restoreDefaultsButton = self.buttonBox.button(
-            QDialogButtonBox.RestoreDefaults)
-        self.__resetButton = self.buttonBox.button(QDialogButtonBox.Reset)
+            QDialogButtonBox.StandardButton.RestoreDefaults)
+        self.__resetButton = self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Reset)
         
         self.actionsTree.header().hide()
         self.__separatorText = self.tr("--Separator--")
@@ -91,12 +92,16 @@
                 item = QTreeWidgetItem(categoryItem)
                 item.setText(0, action.text())
                 item.setIcon(0, action.icon())
-                item.setTextAlignment(0, Qt.AlignLeft | Qt.AlignVCenter)
+                item.setTextAlignment(
+                    0,
+                    Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter
+                )
                 item.setData(0, E5ToolBarDialog.ActionIdRole, int(id(action)))
                 item.setData(0, E5ToolBarDialog.WidgetActionRole, False)
                 if self.__manager.isWidgetAction(action):
                     item.setData(0, E5ToolBarDialog.WidgetActionRole, True)
-                    item.setData(0, Qt.TextColorRole, QColor(Qt.blue))
+                    item.setData(0, Qt.ItemDataRole.TextColorRole,
+                                 QColor(Qt.GlobalColor.blue))
                     self.__widgetActionToToolBarItemID[id(action)] = None
             categoryItem.setExpanded(True)
         
@@ -122,7 +127,8 @@
             if default:
                 self.toolbarComboBox.setItemData(
                     self.toolbarComboBox.count() - 1,
-                    QColor(Qt.darkGreen), Qt.ForegroundRole)
+                    QColor(Qt.GlobalColor.darkGreen),
+                    Qt.ItemDataRole.ForegroundRole)
         self.toolbarComboBox.model().sort(0)
         
         self.toolbarComboBox.currentIndexChanged[int].connect(
@@ -138,7 +144,7 @@
             self,
             self.tr("New Toolbar"),
             self.tr("Toolbar Name:"),
-            QLineEdit.Normal)
+            QLineEdit.EchoMode.Normal)
         if ok and name:
             if self.toolbarComboBox.findText(name) != -1:
                 # toolbar with this name already exists
@@ -198,7 +204,7 @@
             self,
             self.tr("Rename Toolbar"),
             self.tr("New Toolbar Name:"),
-            QLineEdit.Normal,
+            QLineEdit.EchoMode.Normal,
             oldName)
         if ok and newName:
             if oldName == newName:
@@ -264,12 +270,14 @@
                 action = self.__manager.actionById(actionID)
                 item.setText(action.text())
                 item.setIcon(action.icon())
-                item.setTextAlignment(Qt.AlignLeft | Qt.AlignVCenter)
+                item.setTextAlignment(Qt.AlignmentFlag.AlignLeft |
+                                      Qt.AlignmentFlag.AlignVCenter)
                 item.setData(E5ToolBarDialog.ActionIdRole, int(id(action)))
                 item.setData(E5ToolBarDialog.WidgetActionRole, False)
                 if self.__manager.isWidgetAction(action):
                     item.setData(E5ToolBarDialog.WidgetActionRole, True)
-                    item.setData(Qt.TextColorRole, QColor(Qt.blue))
+                    item.setData(Qt.ItemDataRole.TextColorRole,
+                                 QColor(Qt.GlobalColor.blue))
         self.toolbarActionsList.setCurrentRow(0)
         
         self.__setupButtons()
@@ -366,12 +374,14 @@
             action = self.__manager.actionById(actionID)
             item.setText(action.text())
             item.setIcon(action.icon())
-            item.setTextAlignment(Qt.AlignLeft | Qt.AlignVCenter)
+            item.setTextAlignment(Qt.AlignmentFlag.AlignLeft |
+                                  Qt.AlignmentFlag.AlignVCenter)
             item.setData(E5ToolBarDialog.ActionIdRole, int(id(action)))
             item.setData(E5ToolBarDialog.WidgetActionRole, False)
             if self.__manager.isWidgetAction(action):
                 item.setData(E5ToolBarDialog.WidgetActionRole, True)
-                item.setData(Qt.TextColorRole, QColor(Qt.blue))
+                item.setData(Qt.ItemDataRole.TextColorRole,
+                             QColor(Qt.GlobalColor.blue))
                 oldTbItemID = self.__widgetActionToToolBarItemID[actionID]
                 if oldTbItemID is not None:
                     self.__toolbarItems[oldTbItemID].actionIDs.remove(actionID)
@@ -395,18 +405,28 @@
         
         @param button reference to the button clicked (QAbstractButton)
         """
-        if button == self.buttonBox.button(QDialogButtonBox.Cancel):
+        if button == self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Cancel
+        ):
             self.reject()
-        elif button == self.buttonBox.button(QDialogButtonBox.Apply):
+        elif button == self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Apply
+        ):
             self.__saveToolBars()
             self.__setupButtons()
-        elif button == self.buttonBox.button(QDialogButtonBox.Ok):
+        elif button == self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Ok
+        ):
             self.__saveToolBars()
             self.accept()
-        elif button == self.buttonBox.button(QDialogButtonBox.Reset):
+        elif button == self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Reset
+        ):
             self.__resetCurrentToolbar()
             self.__setupButtons()
-        elif button == self.buttonBox.button(QDialogButtonBox.RestoreDefaults):
+        elif button == self.buttonBox.button(
+            QDialogButtonBox.StandardButton.RestoreDefaults
+        ):
             self.__restoreCurrentToolbarToDefault()
             self.__setupButtons()
     

eric ide

mercurial