summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBlaine2020-05-04 15:26:27 +0530
committerBlaine2020-05-04 15:26:27 +0530
commite7ca3971e9412d41076a6c36b7fb829447ef0b3b (patch)
tree07cab6c799cb532b7ff2898b9f9a979364e20dc4 /src
parent61725f4a541ad956295c3fa425d26bf9bd0aa008 (diff)
downloadChemical-PFD-e7ca3971e9412d41076a6c36b7fb829447ef0b3b.tar.gz
Chemical-PFD-e7ca3971e9412d41076a6c36b7fb829447ef0b3b.tar.bz2
Chemical-PFD-e7ca3971e9412d41076a6c36b7fb829447ef0b3b.zip
mino fixes and floating close button
Diffstat (limited to 'src')
-rw-r--r--src/main/python/main.py16
-rw-r--r--src/main/python/utils/fileWindow.py38
2 files changed, 45 insertions, 9 deletions
diff --git a/src/main/python/main.py b/src/main/python/main.py
index a61d230..647792b 100644
--- a/src/main/python/main.py
+++ b/src/main/python/main.py
@@ -51,13 +51,14 @@ class appWindow(QMainWindow):
self.mdi.setOption(QMdiArea.DontMaximizeSubWindowOnActivation, True)
self.mdi.setTabsClosable(True)
self.mdi.setTabsMovable(True)
- self.mdi.setDocumentMode(True)
+ self.mdi.setDocumentMode(False)
#declare main window layout
self.mainWidget.setLayout(mainLayout)
self.setCentralWidget(self.mainWidget)
self.resize(1280, 720) #set collapse dim
-
+ self.mdi.subWindowActivated.connect(self.tabSwitched)
+
def createToolbar(self):
#place holder for toolbar with fixed width, layout may change
self.toolbar = QWidget(self.mainWidget)
@@ -96,7 +97,7 @@ class appWindow(QMainWindow):
def saveProject(self):
#pickle all files in mdi area
- for j, i in enumerate(self.mdi.activeFiles): #get list of all windows with atleast one tab
+ for j, i in enumerate(self.activeFiles): #get list of all windows with atleast one tab
if i.tabCount:
name = QFileDialog.getSaveFileName(self, 'Save File', f'New Diagram {j}', 'Process Flow Diagram (*.pfd)')
i.saveProject(name)
@@ -112,10 +113,15 @@ class appWindow(QMainWindow):
#place holder for future implementaion
pass
+ def tabSwitched(self, window):
+ #handle window switched edge case
+ if window:
+ window.resizeHandler()
+
def resizeEvent(self, event):
#overload resize to also handle resize on file windows inside
- if self.mdi.activeSubWindow():
- self.mdi.activeSubWindow().resizeHandler()
+ for i in self.mdi.subWindowList():
+ i.resizeHandler()
super(appWindow, self).resizeEvent(event)
def closeEvent(self, event):
diff --git a/src/main/python/utils/fileWindow.py b/src/main/python/utils/fileWindow.py
index 22bbc68..fdf1c11 100644
--- a/src/main/python/utils/fileWindow.py
+++ b/src/main/python/utils/fileWindow.py
@@ -1,12 +1,16 @@
import pickle
from PyQt5.QtCore import Qt, pyqtSignal
-from PyQt5.QtWidgets import QMdiSubWindow, QFileDialog, QMenu, QSizePolicy, QWidget, QHBoxLayout, QSplitter, QGraphicsView
+from PyQt5.QtGui import QIcon
+from PyQt5.QtWidgets import (QFileDialog, QGraphicsView, QHBoxLayout,
+ QMdiSubWindow, QMenu, QPushButton, QSizePolicy,
+ QSplitter, QWidget)
from . import dialogs
from .canvas import canvas
from .tabs import customTabWidget
+
class fileWindow(QMdiSubWindow):
"""
This defines a single file, inside the application, consisting of multiple tabs that contain
@@ -31,12 +35,10 @@ class fileWindow(QMdiSubWindow):
#assign layout to widget
self.mainWidget = QWidget(self)
layout = QHBoxLayout(self.mainWidget)
+ self.createSideViewArea() #create the side view objects
layout.addWidget(self.tabber)
- self.splitter = QSplitter(Qt.Vertical ,self)
layout.addWidget(self.splitter)
- self.sideView = QGraphicsView(self)
layout.addWidget(self.sideView)
-
self.mainWidget.setLayout(layout)
self.setWidget(self.mainWidget)
self.setWindowTitle(title)
@@ -50,6 +52,30 @@ class fileWindow(QMdiSubWindow):
self.setWindowFlag(Qt.WindowMinimizeButtonHint, False)
self.setWindowFlag(Qt.WindowMaximizeButtonHint, False)
+ def createSideViewArea(self):
+ #creates the side view widgets and sets them to invisible
+ self.splitter = QSplitter(Qt.Vertical ,self)
+ self.sideView = QGraphicsView(self)
+ self.sideView.setInteractive(False)
+ sideViewCloseButton = QPushButton('×', self.sideView)
+ sideViewCloseButton.setFlat(True)
+ sideViewCloseButton.setStyleSheet("""QPushButton{
+ background: rgba(214, 54, 40, 50%);
+ border: 1px groove white;
+ border-radius: 2px;
+ font-size: 18px;
+ font-weight: Bold;
+ padding: 1px 2px 3px 3px;
+ color: rgba(255, 255, 255, 50%);
+ }
+ QPushButton:Hover{
+ background: rgba(214, 54, 40, 90%);
+ color: rgba(255, 255, 255, 90%);
+ }
+ """)
+ sideViewCloseButton.setFixedSize(20, 20)
+ sideViewCloseButton.move(5, 5)
+ sideViewCloseButton.clicked.connect(lambda: setattr(self, 'sideViewTab', None))
self.splitter.setVisible(False)
self.sideView.setVisible(False)
@@ -67,10 +93,14 @@ class fileWindow(QMdiSubWindow):
width = min(parentRect.width(), width + 100)
height = min(parentRect.height(), height + 200)
+ if len(self.parent().parent().subWindowList()) > 1:
+ height -= 20
+
# set element dimensions
self.setFixedSize(width, height)
self.tabber.resize(width, height)
self.tabber.currentWidget().adjustView()
+
def contextMenu(self, point):
#function to display the right click menu at point of right click