7 Module implementing a tabbed viewmanager class. |
7 Module implementing a tabbed viewmanager class. |
8 """ |
8 """ |
9 |
9 |
10 import os |
10 import os |
11 |
11 |
12 from PyQt5.QtCore import ( |
12 from PyQt6.QtCore import ( |
13 pyqtSlot, QPoint, QFileInfo, pyqtSignal, QEvent, QByteArray, QMimeData, |
13 pyqtSlot, QPoint, QFileInfo, pyqtSignal, QEvent, QByteArray, QMimeData, |
14 Qt, QSize |
14 Qt, QSize |
15 ) |
15 ) |
16 from PyQt5.QtGui import QColor, QDrag, QPixmap, QMouseEvent |
16 from PyQt6.QtGui import QColor, QDrag, QPixmap, QMouseEvent |
17 from PyQt5.QtWidgets import ( |
17 from PyQt6.QtWidgets import ( |
18 QWidget, QHBoxLayout, QSplitter, QTabBar, QApplication, QToolButton, |
18 QWidget, QHBoxLayout, QSplitter, QTabBar, QApplication, QToolButton, |
19 QMenu, QLabel |
19 QMenu, QLabel |
20 ) |
20 ) |
21 |
21 |
22 from E5Gui.E5Application import e5App |
22 from E5Gui.E5Application import e5App |
75 |
75 |
76 @param event reference to the mouse press event |
76 @param event reference to the mouse press event |
77 @type QMouseEvent |
77 @type QMouseEvent |
78 """ |
78 """ |
79 if event.button() == Qt.MouseButton.LeftButton: |
79 if event.button() == Qt.MouseButton.LeftButton: |
80 self.__dragStartPos = QPoint(event.pos()) |
80 self.__dragStartPos = QPoint(event.position().toPoint()) |
81 super().mousePressEvent(event) |
81 super().mousePressEvent(event) |
82 |
82 |
83 def mouseMoveEvent(self, event): |
83 def mouseMoveEvent(self, event): |
84 """ |
84 """ |
85 Protected method to handle mouse move events. |
85 Protected method to handle mouse move events. |
87 @param event reference to the mouse move event |
87 @param event reference to the mouse move event |
88 @type QMouseEvent |
88 @type QMouseEvent |
89 """ |
89 """ |
90 if ( |
90 if ( |
91 event.buttons() == Qt.MouseButtons(Qt.MouseButton.LeftButton) and |
91 event.buttons() == Qt.MouseButtons(Qt.MouseButton.LeftButton) and |
92 (event.pos() - self.__dragStartPos).manhattanLength() > |
92 (event.position().toPoint() - self.__dragStartPos).manhattanLength() > |
93 QApplication.startDragDistance() |
93 QApplication.startDragDistance() |
94 ): |
94 ): |
95 drag = QDrag(self) |
95 drag = QDrag(self) |
96 mimeData = QMimeData() |
96 mimeData = QMimeData() |
97 index = self.tabAt(event.pos()) |
97 index = self.tabAt(event.position().toPoint()) |
98 mimeData.setText(self.tabText(index)) |
98 mimeData.setText(self.tabText(index)) |
99 mimeData.setData("action", b"tab-reordering") |
99 mimeData.setData("action", b"tab-reordering") |
100 mimeData.setData("tabbar-id", str(id(self)).encode("utf-8")) |
100 mimeData.setData("tabbar-id", str(id(self)).encode("utf-8")) |
101 mimeData.setData( |
101 mimeData.setData( |
102 "source-index", |
102 "source-index", |
142 @type QDropEvent |
142 @type QDropEvent |
143 """ |
143 """ |
144 mimeData = event.mimeData() |
144 mimeData = event.mimeData() |
145 oldID = int(mimeData.data("tabbar-id")) |
145 oldID = int(mimeData.data("tabbar-id")) |
146 fromIndex = int(mimeData.data("source-index")) |
146 fromIndex = int(mimeData.data("source-index")) |
147 toIndex = self.tabAt(event.pos()) |
147 toIndex = self.tabAt(event.position().toPoint()) |
148 if oldID != id(self): |
148 if oldID != id(self): |
149 parentID = int(mimeData.data("tabwidget-id")) |
149 parentID = int(mimeData.data("tabwidget-id")) |
150 if event.proposedAction() == Qt.DropAction.MoveAction: |
150 if event.proposedAction() == Qt.DropAction.MoveAction: |
151 self.tabRelocateRequested.emit( |
151 self.tabRelocateRequested.emit( |
152 str(parentID), fromIndex, toIndex) |
152 str(parentID), fromIndex, toIndex) |
1355 self.currentTabWidget = watched |
1355 self.currentTabWidget = watched |
1356 elif isinstance(watched, QTabBar): |
1356 elif isinstance(watched, QTabBar): |
1357 switched = watched.parent() is not self.currentTabWidget |
1357 switched = watched.parent() is not self.currentTabWidget |
1358 self.currentTabWidget = watched.parent() |
1358 self.currentTabWidget = watched.parent() |
1359 if switched: |
1359 if switched: |
1360 index = self.currentTabWidget.selectTab(event.pos()) |
1360 index = self.currentTabWidget.selectTab(event.position().toPoint()) |
1361 switched = ( |
1361 switched = ( |
1362 self.currentTabWidget.widget(index) is |
1362 self.currentTabWidget.widget(index) is |
1363 self.activeWindow() |
1363 self.activeWindow() |
1364 ) |
1364 ) |
1365 elif isinstance(watched, QScintilla.Editor.Editor): |
1365 elif isinstance(watched, QScintilla.Editor.Editor): |