summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBlaine2020-04-30 16:07:33 +0530
committerBlaine2020-04-30 16:07:33 +0530
commit8d479352c448247be8b7e080048dd588094d98b0 (patch)
treee24f6c346fe9962c00d9ef3e41cfb9b3356783a8 /src
parent3d75d12cb5f90b3af03e7408cbdb805426485a1c (diff)
downloadChemical-PFD-8d479352c448247be8b7e080048dd588094d98b0.tar.gz
Chemical-PFD-8d479352c448247be8b7e080048dd588094d98b0.tar.bz2
Chemical-PFD-8d479352c448247be8b7e080048dd588094d98b0.zip
rebase
Diffstat (limited to 'src')
-rw-r--r--src/main/python/main.py7
-rw-r--r--src/main/python/utils/canvas.py16
-rw-r--r--src/main/python/utils/fileWindow.py35
-rw-r--r--src/main/python/utils/tabs.py1
4 files changed, 30 insertions, 29 deletions
diff --git a/src/main/python/main.py b/src/main/python/main.py
index 059bb63..5971403 100644
--- a/src/main/python/main.py
+++ b/src/main/python/main.py
@@ -74,6 +74,7 @@ class appWindow(QMainWindow):
project.newDiagram() #create a new tab in the new file
project.resizeHandler()
project.fileCloseEvent.connect(self.fileClosed) #closed file signal to switch to sub window view
+ project.fileMinimized.connect(self.fileMinimized)
if self.count > 1: #switch to tab view if needed
self.mdi.setViewMode(QMdiArea.TabbedView)
project.show()
@@ -127,7 +128,11 @@ class appWindow(QMainWindow):
def fileClosed(self, index):
if self.count <= 2 :
self.mdi.setViewMode(QMdiArea.SubWindowView)
-
+
+ def fileMinimized(self, file):
+ if self.count > 1:
+ self.mdi.activateNextSubWindow()
+
@property
def activeFiles(self):
return [i for i in self.mdi.subWindowList() if i.tabCount]
diff --git a/src/main/python/utils/canvas.py b/src/main/python/utils/canvas.py
index 8bbe99b..2c99ff2 100644
--- a/src/main/python/utils/canvas.py
+++ b/src/main/python/utils/canvas.py
@@ -32,11 +32,7 @@ class canvas(QWidget):
self.layout = QHBoxLayout(self) #create the layout of the canvas, the canvas could just subclass QGView instead
self.layout.addWidget(self.view, alignment=Qt.AlignCenter)
- # 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)
+ self.layout.setContentsMargins(0, 0, 0, 0)
#set layout and background color
self.setLayout(self.layout)
@@ -54,20 +50,20 @@ class canvas(QWidget):
def adjustView(self):
#update view size
width, height = self.dimensions
- frameWidth = self.view.frameWidth()
+ frameWidth = self.view.frameWidth()
self.view.setSceneRect(0, 0, width - frameWidth*2, height)
# give the view some time to adjust itself
prect = self.parent().parentWidget().parentWidget().parentWidget().rect()
- width = width + 50
- height = height + 100
+ width = width + 20
+ height = height + 60
if self.view.verticalScrollBar().isVisible():
width += self.style().pixelMetric(QStyle.PM_ScrollBarExtent)
if self.view.horizontalScrollBar().isVisible():
height += self.style().pixelMetric(QStyle.PM_ScrollBarExtent)
- self.view.setFixedWidth(min(prect.width() - 50, width))
- self.view.setFixedHeight(min(prect.height() - 100, height))
+ self.view.setFixedWidth(min(prect.width() - 20, width))
+ self.view.setFixedHeight(min(prect.height() - 60, height))
# self.resize(width + frameWidth * 2, height + frameWidth * 2)
def resizeEvent(self, event):
diff --git a/src/main/python/utils/fileWindow.py b/src/main/python/utils/fileWindow.py
index d5ad19f..fd2bc11 100644
--- a/src/main/python/utils/fileWindow.py
+++ b/src/main/python/utils/fileWindow.py
@@ -13,6 +13,7 @@ class fileWindow(QMdiSubWindow):
canvases. Pre-Defined so that a file can be instantly created without defining the structure again.
"""
fileCloseEvent = pyqtSignal(int)
+ fileMinimized = pyqtSignal(QMdiSubWindow)
def __init__(self, parent = None, title = 'New Project', size = 'A4', ppi = '72'):
super(fileWindow, self).__init__(parent)
@@ -57,7 +58,7 @@ class fileWindow(QMdiSubWindow):
def resizeHandler(self):
# experimental resize Handler to handle resize on parent resize.
- parentRect = self.mdiArea().sizeHint()
+ parentRect = self.mdiArea().size()
current = self.tabber.currentWidget()
width, height = current.dimensions
width = min(parentRect.width(), width + 100)
@@ -82,23 +83,21 @@ class fileWindow(QMdiSubWindow):
else:
return None
- def resizeEvent(self, event):
- # self.resizeHandler()
- super(fileWindow, self).resizeEvent(event)
- # pass
-
- def stateChange(self, oldState, newState):
- if newState == Qt.WindowMinimized:
- self.hide()
- else:
- if not self.isVisible():
- self.show()
- if newState == Qt.WindowMaximized:
- self.setFixedSize(self.mdiArea().size())
-
- def showShaded(self):
- self.hide()
-
+ # def stateChange(self, oldState, newState):
+ # if newState == Qt.WindowMinimized:
+ # print("a")
+ # self.setVisible(False)
+ # elif newState == Qt.WindowMaximized:
+ # print("b")
+ # parentRect = self.mdiArea().size()
+ # self.setFixedSize(parentRect.width(), parentRect.height())
+ # self.tabber.resize(parentRect.width(), parentRect.height())
+ # self.tabber.currentWidget().adjustView()
+ # else:
+ # if oldState == Qt.WindowMinimized or oldState == Qt.WindowMaximized:
+ # print("c")
+ # self.resizeHandler()
+
@property
def tabList(self):
#returns a list of tabs in the given window
diff --git a/src/main/python/utils/tabs.py b/src/main/python/utils/tabs.py
index 7c6319c..037710c 100644
--- a/src/main/python/utils/tabs.py
+++ b/src/main/python/utils/tabs.py
@@ -43,6 +43,7 @@ class customTabWidget(QTabWidget):
border-radius: 7px;
padding: 1px;
background-color: #E6E6E3;}""")
+ self.setContentsMargins(0, 0, 0, 0)
def movePlusButton(self):
#move the new tab button to correct location