summaryrefslogtreecommitdiff
path: root/src/main/python/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/python/utils')
-rw-r--r--src/main/python/utils/canvas.py7
-rw-r--r--src/main/python/utils/tabs.py50
2 files changed, 24 insertions, 33 deletions
diff --git a/src/main/python/utils/canvas.py b/src/main/python/utils/canvas.py
index 9578b1a..fe5b527 100644
--- a/src/main/python/utils/canvas.py
+++ b/src/main/python/utils/canvas.py
@@ -73,6 +73,7 @@ class canvas(QWidget):
def adjustCanvasDialog(self):
dialogBox = QDialog(self)
+ dialogBox.setWindowTitle(self.objectName()+":Canvas Size")
dialogBoxLayout = QFormLayout(dialogBox)
sizeComboBox = QComboBox()
sizeComboBox.addItems(sheetDimensionList)
@@ -94,7 +95,7 @@ class canvas(QWidget):
dialogBoxLayout.setWidget(1, QFormLayout.FieldRole, ppiComboBox)
dialogBox.setLayout(dialogBoxLayout)
- dialogBox.show()
+ dialogBox.exec_()
def __getstate__(self) -> dict:
return {
@@ -126,7 +127,7 @@ class fileWindow(QMdiSubWindow):
self.tabber.setObjectName(title)
self.tabber.tabCloseRequested.connect(self.closeTab)
self.tabber.currentChanged.connect(self.changeTab)
- self.tabber.tab.plusClicked.connect(self.newDiagram)
+ self.tabber.plusClicked.connect(self.newDiagram)
self.setWidget(self.tabber)
self.setWindowTitle(title)
@@ -208,7 +209,7 @@ class fileWindow(QMdiSubWindow):
return False
def closeEvent(self, event):
- if self.saveEvent():
+ if self.tabCount or self.saveEvent():
event.accept()
else:
event.ignore()
diff --git a/src/main/python/utils/tabs.py b/src/main/python/utils/tabs.py
index 695a7fc..634a4ff 100644
--- a/src/main/python/utils/tabs.py
+++ b/src/main/python/utils/tabs.py
@@ -2,50 +2,40 @@ from PyQt5.QtWidgets import QTabBar, QPushButton, QTabWidget
from PyQt5.QtCore import pyqtSignal, QSize
class tabBarPlus(QTabBar):
- plusClicked = pyqtSignal()
- def __init__(self):
- super().__init__()
-
- self.plusButton = QPushButton("+", self)
- self.plusButton.setParent(self)
- self.setTabButton(0, QTabBar.RightSide, self.plusButton)
- self.plusButton.setFixedSize(20, 20)
- self.plusButton.clicked.connect(self.plusClicked.emit)
- # self.movePlusButton()
-
- def sizeHint(self):
- sizeHint = QTabBar.sizeHint(self)
- width = sizeHint.width()
- height = sizeHint.height()
- return QSize(width+25, height)
-
+ layoutChanged = pyqtSignal()
def resizeEvent(self, event):
super().resizeEvent(event)
- # self.movePlusButton()
+ self.layoutChanged.emit()
def tabLayoutChange(self):
super().tabLayoutChange()
- # self.movePlusButton()
+ self.layoutChanged.emit()
- def movePlusButton(self):
- size = sum([self.tabRect(i).width() for i in range(self.count())])
- h = self.geometry().top()
- w = self.width()
- if size > w:
- self.plusButton.move(w-54, h)
- else:
- self.plusButton.move(size, h)
class customTabWidget(QTabWidget):
-
+ plusClicked = pyqtSignal()
def __init__(self, parent=None):
super(customTabWidget, self).__init__(parent)
self.tab = tabBarPlus()
self.setTabBar(self.tab)
-
+
+ self.plusButton = QPushButton('+', self)
+ self.plusButton.setFixedSize(20, 20)
+ self.plusButton.clicked.connect(self.plusClicked.emit)
self.setMovable(True)
self.setTabsClosable(True)
+ self.tab.layoutChanged.connect(self.movePlusButton)
# self.tab.tabMoved.connect(self.moveTab)
- # self.tabCloseRequested.connect(self.removeTab) \ No newline at end of file
+ # self.tabCloseRequested.connect(self.removeTab)
+
+ def movePlusButton(self):
+ size = sum([self.tab.tabRect(i).width() for i in range(self.tab.count())])
+ h = max(self.tab.geometry().bottom() - 20, 0)
+ w = self.tab.width()
+ print(size, w, h)
+ if size > w:
+ self.plusButton.move(w-self.plusButton.width(), h)
+ else:
+ self.plusButton.move(size, h) \ No newline at end of file