--- a/eric6/Plugins/ViewManagerPlugins/Tabview/Tabview.py Mon Sep 09 18:52:08 2019 +0200 +++ b/eric6/Plugins/ViewManagerPlugins/Tabview/Tabview.py Thu Oct 03 11:12:10 2019 +0200 @@ -7,15 +7,18 @@ Module implementing a tabbed viewmanager class. """ -from __future__ import unicode_literals import os -from PyQt5.QtCore import pyqtSlot, QPoint, QFileInfo, pyqtSignal, QEvent, \ - QByteArray, QMimeData, Qt, QSize +from PyQt5.QtCore import ( + pyqtSlot, QPoint, QFileInfo, pyqtSignal, QEvent, QByteArray, QMimeData, + Qt, QSize +) from PyQt5.QtGui import QColor, QDrag, QPixmap -from PyQt5.QtWidgets import QWidget, QHBoxLayout, QSplitter, QTabBar, \ - QApplication, QToolButton, QMenu, QLabel +from PyQt5.QtWidgets import ( + QWidget, QHBoxLayout, QSplitter, QTabBar, QApplication, QToolButton, + QMenu, QLabel +) from E5Gui.E5Application import e5App @@ -85,9 +88,11 @@ @param event reference to the mouse move event @type QMouseEvent """ - if event.buttons() == Qt.MouseButtons(Qt.LeftButton) and \ - (event.pos() - self.__dragStartPos).manhattanLength() > \ - QApplication.startDragDistance(): + if ( + event.buttons() == Qt.MouseButtons(Qt.LeftButton) and + (event.pos() - self.__dragStartPos).manhattanLength() > + QApplication.startDragDistance() + ): drag = QDrag(self) mimeData = QMimeData() index = self.tabAt(event.pos()) @@ -116,11 +121,13 @@ """ mimeData = event.mimeData() formats = mimeData.formats() - if "action" in formats and \ - mimeData.data("action") == b"tab-reordering" and \ - "tabbar-id" in formats and \ - "source-index" in formats and \ - "tabwidget-id" in formats: + if ( + "action" in formats and + mimeData.data("action") == b"tab-reordering" and + "tabbar-id" in formats and + "source-index" in formats and + "tabwidget-id" in formats + ): event.acceptProposedAction() super(TabBar, self).dragEnterEvent(event) @@ -607,8 +614,10 @@ Private method to close the other tabs. """ index = self.contextMenuIndex - for i in list(range(self.count() - 1, index, -1)) + \ - list(range(index - 1, -1, -1)): + for i in ( + list(range(self.count() - 1, index, -1)) + + list(range(index - 1, -1, -1)) + ): editor = self.widget(i).getEditor() self.vm.closeEditorWindow(editor) @@ -879,9 +888,11 @@ # if this was the last editor in this view, switch to the next, that # still has open editors - for i in list(range(self.tabWidgets.index(tw), -1, -1)) + \ + for i in ( + list(range(self.tabWidgets.index(tw), -1, -1)) + list(range(self.tabWidgets.index(tw) + 1, - len(self.tabWidgets))): + len(self.tabWidgets))) + ): if self.tabWidgets[i].hasEditors(): self.currentTabWidget.showIndicator(False) self.currentTabWidget = self.tabWidgets[i] @@ -1322,8 +1333,10 @@ @return always False @rtype bool """ - if event.type() == QEvent.MouseButtonPress and \ - not event.button() == Qt.RightButton: + if ( + event.type() == QEvent.MouseButtonPress and + not event.button() == Qt.RightButton + ): switched = True self.currentTabWidget.showIndicator(False) if isinstance(watched, E5TabWidget): @@ -1334,8 +1347,10 @@ self.currentTabWidget = watched.parent() if switched: index = self.currentTabWidget.selectTab(event.pos()) - switched = self.currentTabWidget.widget(index) is \ + switched = ( + self.currentTabWidget.widget(index) is self.activeWindow() + ) elif isinstance(watched, QScintilla.Editor.Editor): for tw in self.tabWidgets: if tw.hasEditor(watched): @@ -1380,8 +1395,8 @@ if self.filenameOnly: txt = os.path.basename(fn) else: - txt = e5App().getObject("Project")\ - .getRelativePath(fn) + txt = e5App().getObject( + "Project").getRelativePath(fn) if len(txt) > self.maxFileNameChars: txt = "...{0}".format(txt[-self.maxFileNameChars:]) if not QFileInfo(fn).isWritable():