eric6/Plugins/ViewManagerPlugins/Tabview/Tabview.py

branch
maintenance
changeset 8176
31965986ecd1
parent 8043
0acf98cd089a
parent 8143
2c730d5fd177
child 8273
698ae46f40a4
diff -r e01ae92db699 -r 31965986ecd1 eric6/Plugins/ViewManagerPlugins/Tabview/Tabview.py
--- a/eric6/Plugins/ViewManagerPlugins/Tabview/Tabview.py	Sat Mar 06 10:00:52 2021 +0100
+++ b/eric6/Plugins/ViewManagerPlugins/Tabview/Tabview.py	Sun Mar 28 15:00:11 2021 +0200
@@ -76,7 +76,7 @@
         @param event reference to the mouse press event
         @type QMouseEvent
         """
-        if event.button() == Qt.LeftButton:
+        if event.button() == Qt.MouseButton.LeftButton:
             self.__dragStartPos = QPoint(event.pos())
         super(TabBar, self).mousePressEvent(event)
     
@@ -88,7 +88,7 @@
         @type QMouseEvent
         """
         if (
-            event.buttons() == Qt.MouseButtons(Qt.LeftButton) and
+            event.buttons() == Qt.MouseButtons(Qt.MouseButton.LeftButton) and
             (event.pos() - self.__dragStartPos).manhattanLength() >
                 QApplication.startDragDistance()
         ):
@@ -105,10 +105,14 @@
                 "tabwidget-id",
                 str(id(self.parentWidget())).encode("utf-8"))
             drag.setMimeData(mimeData)
-            if event.modifiers() == Qt.KeyboardModifiers(Qt.ShiftModifier):
-                drag.exec(Qt.DropActions(Qt.CopyAction))
-            elif event.modifiers() == Qt.KeyboardModifiers(Qt.NoModifier):
-                drag.exec(Qt.DropActions(Qt.MoveAction))
+            if event.modifiers() == Qt.KeyboardModifiers(
+                Qt.KeyboardModifier.ShiftModifier
+            ):
+                drag.exec(Qt.DropActions(Qt.DropAction.CopyAction))
+            elif event.modifiers() == Qt.KeyboardModifiers(
+                Qt.KeyboardModifier.NoModifier
+            ):
+                drag.exec(Qt.DropActions(Qt.DropAction.MoveAction))
         super(TabBar, self).mouseMoveEvent(event)
     
     def dragEnterEvent(self, event):
@@ -143,20 +147,20 @@
         toIndex = self.tabAt(event.pos())
         if oldID != id(self):
             parentID = int(mimeData.data("tabwidget-id"))
-            if event.proposedAction() == Qt.MoveAction:
+            if event.proposedAction() == Qt.DropAction.MoveAction:
                 self.tabRelocateRequested.emit(
                     str(parentID), fromIndex, toIndex)
                 event.acceptProposedAction()
-            elif event.proposedAction() == Qt.CopyAction:
+            elif event.proposedAction() == Qt.DropAction.CopyAction:
                 self.tabCopyRequested[str, int, int].emit(
                     str(parentID), fromIndex, toIndex)
                 event.acceptProposedAction()
         else:
             if fromIndex != toIndex:
-                if event.proposedAction() == Qt.MoveAction:
+                if event.proposedAction() == Qt.DropAction.MoveAction:
                     self.tabMoveRequested.emit(fromIndex, toIndex)
                     event.acceptProposedAction()
-                elif event.proposedAction() == Qt.CopyAction:
+                elif event.proposedAction() == Qt.DropAction.CopyAction:
                     self.tabCopyRequested[int, int].emit(fromIndex, toIndex)
                     event.acceptProposedAction()
         super(TabBar, self).dropEvent(event)
@@ -182,7 +186,7 @@
             QSize(2 * iconSize.width(), iconSize.height()))
         
         self.setUsesScrollButtons(True)
-        self.setElideMode(Qt.ElideNone)
+        self.setElideMode(Qt.TextElideMode.ElideNone)
         if isMacPlatform():
             self.setDocumentMode(True)
         
@@ -196,7 +200,7 @@
         self.editors = []
         
         self.indicator = E5Led(self)
-        self.setCornerWidget(self.indicator, Qt.TopLeftCorner)
+        self.setCornerWidget(self.indicator, Qt.Corner.TopLeftCorner)
         
         self.rightCornerWidget = QWidget(self)
         self.rightCornerWidgetLayout = QHBoxLayout(self.rightCornerWidget)
@@ -210,27 +214,29 @@
         self.navigationButton = QToolButton(self)
         self.navigationButton.setIcon(UI.PixmapCache.getIcon("1downarrow"))
         self.navigationButton.setToolTip(self.tr("Show a navigation menu"))
-        self.navigationButton.setPopupMode(QToolButton.InstantPopup)
+        self.navigationButton.setPopupMode(
+            QToolButton.ToolButtonPopupMode.InstantPopup)
         self.navigationButton.setMenu(self.__navigationMenu)
         self.navigationButton.setEnabled(False)
         self.rightCornerWidgetLayout.addWidget(self.navigationButton)
         
         self.tabCloseRequested.connect(self.__closeRequested)
         
-        self.setCornerWidget(self.rightCornerWidget, Qt.TopRightCorner)
+        self.setCornerWidget(self.rightCornerWidget, Qt.Corner.TopRightCorner)
         
         self.__initMenu()
         self.contextMenuEditor = None
         self.contextMenuIndex = -1
         
-        self.setTabContextMenuPolicy(Qt.CustomContextMenu)
+        self.setTabContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
         self.customTabContextMenuRequested.connect(self.__showContextMenu)
         
         ericPic = QPixmap(
             os.path.join(getConfig('ericPixDir'), 'eric_small.png'))
         self.emptyLabel = QLabel()
         self.emptyLabel.setPixmap(ericPic)
-        self.emptyLabel.setAlignment(Qt.AlignVCenter | Qt.AlignHCenter)
+        self.emptyLabel.setAlignment(
+            Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignHCenter)
         super(TabWidget, self).addTab(
             self.emptyLabel,
             UI.PixmapCache.getIcon("empty"), "")
@@ -811,7 +817,7 @@
         tw.currentChanged.connect(self.__currentChanged)
         tw.installEventFilter(self)
         tw.tabBar().installEventFilter(self)
-        self.__splitter.setOrientation(Qt.Vertical)
+        self.__splitter.setOrientation(Qt.Orientation.Vertical)
         self.__inRemoveView = False
         
         self.maxFileNameChars = Preferences.getUI(
@@ -1160,7 +1166,7 @@
         tw.currentChanged.connect(self.__currentChanged)
         tw.installEventFilter(self)
         tw.tabBar().installEventFilter(self)
-        if self.__splitter.orientation() == Qt.Horizontal:
+        if self.__splitter.orientation() == Qt.Orientation.Horizontal:
             size = self.width()
         else:
             size = self.height()
@@ -1211,7 +1217,7 @@
                     if assembly is not None:
                         editor = assembly.getEditor()
                         if editor is not None:
-                            editor.setFocus(Qt.OtherFocusReason)
+                            editor.setFocus(Qt.FocusReason.OtherFocusReason)
                 if len(self.tabWidgets) == 1:
                     self.splitRemoveAct.setEnabled(False)
                     self.nextSplitAct.setEnabled(False)
@@ -1249,7 +1255,7 @@
         Public method to get the orientation of the split view.
         
         @return orientation of the split
-        @rtype Qt.Horizontal or Qt.Vertical
+        @rtype Qt.Orientation.Horizontal or Qt.Orientation.Vertical
         """
         return self.__splitter.orientation()
         
@@ -1258,7 +1264,7 @@
         Public method used to set the orientation of the split view.
         
         @param orientation orientation of the split
-        @type Qt.Horizontal or Qt.Vertical
+        @type Qt.Orientation.Horizontal or Qt.Orientation.Vertical
         """
         self.__splitter.setOrientation(orientation)
         
@@ -1337,8 +1343,8 @@
         @rtype bool
         """
         if (
-            event.type() == QEvent.MouseButtonPress and
-            not event.button() == Qt.RightButton
+            event.type() == QEvent.Type.MouseButtonPress and
+            not event.button() == Qt.MouseButton.RightButton
         ):
             switched = True
             self.currentTabWidget.showIndicator(False)

eric ide

mercurial