8 """ |
8 """ |
9 |
9 |
10 import os |
10 import os |
11 |
11 |
12 from PyQt6.QtCore import ( |
12 from PyQt6.QtCore import ( |
13 pyqtSlot, QPoint, QFileInfo, pyqtSignal, QEvent, QByteArray, QMimeData, |
13 pyqtSlot, QPoint, pyqtSignal, QEvent, QByteArray, QMimeData, Qt, QSize |
14 Qt, QSize |
|
15 ) |
14 ) |
16 from PyQt6.QtGui import QColor, QDrag, QPixmap, QMouseEvent |
15 from PyQt6.QtGui import QColor, QDrag, QPixmap, QMouseEvent |
17 from PyQt6.QtWidgets import ( |
16 from PyQt6.QtWidgets import ( |
18 QWidget, QHBoxLayout, QSplitter, QTabBar, QApplication, QToolButton, |
17 QWidget, QHBoxLayout, QSplitter, QTabBar, QApplication, QToolButton, |
19 QMenu, QLabel |
18 QMenu, QLabel |
1027 txt = os.path.basename(fn) |
1026 txt = os.path.basename(fn) |
1028 else: |
1027 else: |
1029 txt = ericApp().getObject("Project").getRelativePath(fn) |
1028 txt = ericApp().getObject("Project").getRelativePath(fn) |
1030 if len(txt) > self.maxFileNameChars: |
1029 if len(txt) > self.maxFileNameChars: |
1031 txt = "...{0}".format(txt[-self.maxFileNameChars:]) |
1030 txt = "...{0}".format(txt[-self.maxFileNameChars:]) |
1032 if not QFileInfo(fn).isWritable(): |
1031 if not os.access(fn, os.W_OK): |
1033 txt = self.tr("{0} (ro)").format(txt) |
1032 txt = self.tr("{0} (ro)").format(txt) |
1034 if addNext: |
1033 if addNext: |
1035 index = self.currentTabWidget.currentIndex() + 1 |
1034 index = self.currentTabWidget.currentIndex() + 1 |
1036 self.currentTabWidget.insertWidget(index, win, txt) |
1035 self.currentTabWidget.insertWidget(index, win, txt) |
1037 elif indexes: |
1036 elif indexes: |
1082 txt = os.path.basename(fn) |
1081 txt = os.path.basename(fn) |
1083 else: |
1082 else: |
1084 txt = ericApp().getObject("Project").getRelativePath(fn) |
1083 txt = ericApp().getObject("Project").getRelativePath(fn) |
1085 if len(txt) > self.maxFileNameChars: |
1084 if len(txt) > self.maxFileNameChars: |
1086 txt = "...{0}".format(txt[-self.maxFileNameChars:]) |
1085 txt = "...{0}".format(txt[-self.maxFileNameChars:]) |
1087 if not QFileInfo(fn).isWritable(): |
1086 if not os.access(fn, os.W_OK): |
1088 txt = self.tr("{0} (ro)").format(txt) |
1087 txt = self.tr("{0} (ro)").format(txt) |
1089 nindex = tabWidget.insertWidget(index, win, txt) |
1088 nindex = tabWidget.insertWidget(index, win, txt) |
1090 tabWidget.setTabToolTip(nindex, fn) |
1089 tabWidget.setTabToolTip(nindex, fn) |
1091 tabWidget.setCurrentWidget(win) |
1090 tabWidget.setCurrentWidget(win) |
1092 win.show() |
1091 win.show() |
1479 else: |
1478 else: |
1480 txt = ericApp().getObject( |
1479 txt = ericApp().getObject( |
1481 "Project").getRelativePath(fn) |
1480 "Project").getRelativePath(fn) |
1482 if len(txt) > self.maxFileNameChars: |
1481 if len(txt) > self.maxFileNameChars: |
1483 txt = "...{0}".format(txt[-self.maxFileNameChars:]) |
1482 txt = "...{0}".format(txt[-self.maxFileNameChars:]) |
1484 if not QFileInfo(fn).isWritable(): |
1483 if not os.access(fn, os.W_OK): |
1485 txt = self.tr("{0} (ro)").format(txt) |
1484 txt = self.tr("{0} (ro)").format(txt) |
1486 tabWidget.setTabText(index, txt) |
1485 tabWidget.setTabText(index, txt) |
1487 |
1486 |
1488 def getTabWidgetById(self, id_): |
1487 def getTabWidgetById(self, id_): |
1489 """ |
1488 """ |