diff options
author | Blaine | 2020-06-09 13:21:19 +0530 |
---|---|---|
committer | Blaine | 2020-06-10 11:29:49 +0530 |
commit | 3ee9a4e5f976182e0193b640ad68012f6f97dba4 (patch) | |
tree | 5c820b289a1d84e2dc72f267e5daca688b43cc33 /src/main | |
parent | 6da3f0038037ad3553370eb264912bfe380f2089 (diff) | |
download | Chemical-PFD-3ee9a4e5f976182e0193b640ad68012f6f97dba4.tar.gz Chemical-PFD-3ee9a4e5f976182e0193b640ad68012f6f97dba4.tar.bz2 Chemical-PFD-3ee9a4e5f976182e0193b640ad68012f6f97dba4.zip |
diagram name
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/python/utils/fileWindow.py | 4 | ||||
-rw-r--r-- | src/main/python/utils/tabs.py | 23 |
2 files changed, 21 insertions, 6 deletions
diff --git a/src/main/python/utils/fileWindow.py b/src/main/python/utils/fileWindow.py index 8edd38e..a0b4024 100644 --- a/src/main/python/utils/fileWindow.py +++ b/src/main/python/utils/fileWindow.py @@ -248,8 +248,8 @@ class fileWindow(QMdiSubWindow): } def __setstate__(self, dict): - self.setObjectName = dict['ObjectName'] - self.setWindowTitle = dict['ObjectName'] + self.setObjectName(dict['ObjectName']) + self.setWindowTitle(dict['ObjectName']) for i in dict['tabs']: diagram = self.newDiagram(i['ObjectName']) diagram.__setstate__(i) diff --git a/src/main/python/utils/tabs.py b/src/main/python/utils/tabs.py index eab056a..5196557 100644 --- a/src/main/python/utils/tabs.py +++ b/src/main/python/utils/tabs.py @@ -1,11 +1,12 @@ -from PyQt5.QtWidgets import QTabBar, QPushButton, QTabWidget -from PyQt5.QtCore import pyqtSignal, QSize +from PyQt5.QtWidgets import QTabBar, QPushButton, QTabWidget, QInputDialog +from PyQt5.QtCore import pyqtSignal, QSize, Qt class tabBarPlus(QTabBar): """ Just implemented to overload resize and layout change to emit a signal """ layoutChanged = pyqtSignal() + nameChanged = pyqtSignal(int, str) def resizeEvent(self, event): super().resizeEvent(event) self.layoutChanged.emit() @@ -14,7 +15,17 @@ class tabBarPlus(QTabBar): super().tabLayoutChange() self.layoutChanged.emit() - + def mouseDoubleClickEvent(self, event): + if event.button() != Qt.LeftButton: + return super().mouseDoubleClickEvent() + index = self.currentIndex() + newName, bool = QInputDialog.getText(self, "Change Diagram Name", "Enter new name", + text = self.tabText(index)) + if bool: + self.setTabText(index, newName) + self.nameChanged.emit(index, newName) + + class customTabWidget(QTabWidget): """ QTabWidget with a new tab button, also catches layoutChange signal by @@ -50,6 +61,7 @@ class customTabWidget(QTabWidget): self.tab.layoutChanged.connect(self.movePlusButton) #connect layout change # to dynamically move the button. + self.tab.nameChanged.connect(self.changeWidgetName) #set custom stylesheet for the widget area self.setStyleSheet("""QTabWidget::pane { @@ -68,4 +80,7 @@ class customTabWidget(QTabWidget): if size > w: #if all the tabs do not overflow the tab bar, add at the end self.plusButton.move(w-self.plusButton.width(), h) else: - self.plusButton.move(size-3, h)
\ No newline at end of file + self.plusButton.move(size-3, h) + + def changeWidgetName(self, index, newName): + self.widget(index).setObjectName(newName)
\ No newline at end of file |