diff options
author | Blaine | 2020-04-30 14:18:45 +0530 |
---|---|---|
committer | Blaine | 2020-04-30 14:18:45 +0530 |
commit | c6c699b2c231616b17625d355ec269b1a51809a5 (patch) | |
tree | 2eccaf02903b0b1c27c750495a497f9934a54439 /src/main | |
parent | 8024803c29b85e87a0e65eedfd1c8c1975be074c (diff) | |
download | Chemical-PFD-c6c699b2c231616b17625d355ec269b1a51809a5.tar.gz Chemical-PFD-c6c699b2c231616b17625d355ec269b1a51809a5.tar.bz2 Chemical-PFD-c6c699b2c231616b17625d355ec269b1a51809a5.zip |
implement ok and cancel on adjust canvas dialog
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/python/utils/canvas.py | 2 | ||||
-rw-r--r-- | src/main/python/utils/dialogs.py | 11 | ||||
-rw-r--r-- | src/main/python/utils/fileWindow.py | 13 |
3 files changed, 19 insertions, 7 deletions
diff --git a/src/main/python/utils/canvas.py b/src/main/python/utils/canvas.py index 8bac15f..8bbe99b 100644 --- a/src/main/python/utils/canvas.py +++ b/src/main/python/utils/canvas.py @@ -35,6 +35,8 @@ class canvas(QWidget): # self.spacer = QSpacerItem(1, self.height()) #Horizonatal spacer to force view to not expand to fill widget # self.layout.addSpacerItem(self.spacer) # self.layout.addSpacing(0) + self.layout.setContentsMargins(0, 0, 0 ,0) + self.layout.setSpacing(0) #set layout and background color self.setLayout(self.layout) diff --git a/src/main/python/utils/dialogs.py b/src/main/python/utils/dialogs.py index 1cd3e0c..83a5f90 100644 --- a/src/main/python/utils/dialogs.py +++ b/src/main/python/utils/dialogs.py @@ -1,4 +1,4 @@ -from PyQt5.QtWidgets import QDialog, QPushButton, QFormLayout, QComboBox, QLabel, QMessageBox +from PyQt5.QtWidgets import QDialog, QPushButton, QFormLayout, QComboBox, QLabel, QMessageBox, QDialogButtonBox from .sizes import sheetDimensionList, ppiList class paperDims(QDialog): @@ -35,6 +35,12 @@ class paperDims(QDialog): ppiComboBox.setCurrentIndex(ppiList.index(self._ppi)) #set index to current value of canvas dialogBoxLayout.setWidget(1, QFormLayout.LabelRole, ppiLabel) dialogBoxLayout.setWidget(1, QFormLayout.FieldRole, ppiComboBox) + + buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self) + buttonBox.accepted.connect(self.accept) + buttonBox.rejected.connect(self.reject) + + dialogBoxLayout.addWidget(buttonBox) self.setLayout(dialogBoxLayout) self.resize(300,100) #resize to a certain size @@ -51,8 +57,7 @@ class paperDims(QDialog): def exec_(self): #overload exec_ to add return values and delete itself(currently being tested) super(paperDims, self).exec_() - # self.deleteLater() - return self._canvasSize, self._ppi + return self._canvasSize, self._ppi if self.result==1 else None def saveEvent(parent = None): #utility function to generate a Qt alert window requesting the user to save the file, returns user intention on window close diff --git a/src/main/python/utils/fileWindow.py b/src/main/python/utils/fileWindow.py index 1e8258d..bab9004 100644 --- a/src/main/python/utils/fileWindow.py +++ b/src/main/python/utils/fileWindow.py @@ -13,7 +13,6 @@ class fileWindow(QMdiSubWindow): canvases. Pre-Defined so that a file can be instantly created without defining the structure again. """ fileCloseEvent = pyqtSignal(int) - fileMinimized = pyqtSignal(int) def __init__(self, parent = None, title = 'New Project', size = 'A4', ppi = '72'): super(fileWindow, self).__init__(parent) @@ -37,6 +36,8 @@ class fileWindow(QMdiSubWindow): self.windowStateChanged.connect(self.stateChange) + self.setAttribute(Qt.WA_DeleteOnClose, True) + def changeTab(self, currentIndex): #placeholder function to detect tab change self.resizeHandler() @@ -56,7 +57,7 @@ class fileWindow(QMdiSubWindow): def resizeHandler(self): # experimental resize Handler to handle resize on parent resize. - parentRect = self.mdiArea().rect() + parentRect = self.mdiArea().sizeHint() current = self.tabber.currentWidget() width, height = current.dimensions width = min(parentRect.width(), width + 100) @@ -74,8 +75,12 @@ class fileWindow(QMdiSubWindow): def adjustCanvasDialog(self): #helper function to the context menu dialog box currentTab = self.tabber.currentWidget() - currentTab.canvasSize, currentTab.ppi = dialogs.paperDims(self, currentTab._canvasSize, currentTab._ppi, currentTab.objectName()).exec_() - self.resizeHandler() + result = dialogs.paperDims(self, currentTab._canvasSize, currentTab._ppi, currentTab.objectName()).exec_() + if result: + currentTab.canvasSize, currentTab.ppi = result + return self.resizeHandler() + else: + return None def resizeEvent(self, event): # self.resizeHandler() |