summaryrefslogtreecommitdiff
path: root/src/main/python/utils/fileWindow.py
diff options
context:
space:
mode:
authorpravindalve2020-06-12 12:49:53 +0530
committerGitHub2020-06-12 12:49:53 +0530
commit7d2d686209e3c0cf7e869088f14678ce309fe7dd (patch)
treefeb418bd92e1da5f6caf0dbe8a1fe93439813e70 /src/main/python/utils/fileWindow.py
parentb70d765b41d9de58cbe9411b8420a44a7e1f10e2 (diff)
parentd3bb58bc5d77b02d2102c6a59151cff6beee662f (diff)
downloadChemical-PFD-7d2d686209e3c0cf7e869088f14678ce309fe7dd.tar.gz
Chemical-PFD-7d2d686209e3c0cf7e869088f14678ce309fe7dd.tar.bz2
Chemical-PFD-7d2d686209e3c0cf7e869088f14678ce309fe7dd.zip
Merge pull request #18 from Blakeinstein/master
side view + canvas overhaul
Diffstat (limited to 'src/main/python/utils/fileWindow.py')
-rw-r--r--src/main/python/utils/fileWindow.py42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/main/python/utils/fileWindow.py b/src/main/python/utils/fileWindow.py
index 28a576e..6d35437 100644
--- a/src/main/python/utils/fileWindow.py
+++ b/src/main/python/utils/fileWindow.py
@@ -2,7 +2,7 @@ from PyQt5.QtCore import Qt, pyqtSignal, QPoint
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import (QFileDialog, QHBoxLayout,
QMdiSubWindow, QMenu, QPushButton, QSizePolicy,
- QSplitter, QWidget, QStyle)
+ QSplitter, QWidget, QStyle, QSizePolicy)
from os import path
from . import dialogs
from .graphics import customView
@@ -38,8 +38,17 @@ class fileWindow(QMdiSubWindow):
self.mainWidget = QWidget(self)
layout = QHBoxLayout(self.mainWidget)
self.createSideViewArea() #create the side view objects
+
+ left = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
+ left.setHorizontalStretch(1)
+ self.tabber.setSizePolicy(left)
+
+ right = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
+ right.setHorizontalStretch(1)
+ self.sideView.setSizePolicy(right)
+
layout.addWidget(self.tabber)
- layout.addWidget(self.splitter)
+ # layout.addWidget(self.splitter)
layout.addWidget(self.sideView)
self.mainWidget.setLayout(layout)
self.setWidget(self.mainWidget)
@@ -57,7 +66,7 @@ class fileWindow(QMdiSubWindow):
def createSideViewArea(self):
#creates the side view widgets and sets them to invisible
- self.splitter = QSplitter(Qt.Vertical ,self)
+ # self.splitter = QSplitter(Qt.Vertical ,self)
self.sideView = customView(parent = self)
self.sideView.setInteractive(False)
self.sideViewCloseButton = QPushButton('×', self.sideView)
@@ -66,10 +75,11 @@ class fileWindow(QMdiSubWindow):
self.sideViewCloseButton.setFixedSize(20, 20)
self.moveSideViewCloseButton()
self.sideViewCloseButton.clicked.connect(lambda: setattr(self, 'sideViewTab', None))
- self.splitter.setVisible(False)
+ # self.splitter.setVisible(False)
self.sideView.setVisible(False)
self.sideView.setContextMenuPolicy(Qt.CustomContextMenu)
self.sideView.customContextMenuRequested.connect(self.sideViewContextMenu)
+ self.sideView.resize(self.width()//2 - self.sideView.frameWidth(), self.height())
def resizeHandler(self):
# resize Handler to handle resize cases.
@@ -77,23 +87,20 @@ class fileWindow(QMdiSubWindow):
current = self.tabber.currentWidget()
width, height = current.dimensions
- # if side view is visible, set width to maximum possible, else use minimum requirement
if self.sideViewTab:
- width = parentRect.width()
- height = parentRect.height()
- self.moveSideViewCloseButton()
-
+ width2, height2 = self.sideViewTab.dimensions
+ width = min(parentRect.width(), width + width2)
+ height = min(parentRect.height(), height + height2)
else:
width = min(parentRect.width(), width + 100)
- height = min(parentRect.height(), height + 200)
+ height = min(parentRect.height(), height + 150)
if len(self.parent().parent().subWindowList()) > 1:
height -= 20
- # set element dimensions
+ # set element dimensions
self.setFixedSize(width, height)
- self.tabber.resize(width, height)
- self.tabber.currentWidget().adjustView()
+ current.adjustView()
def contextMenu(self, point):
#function to display the right click menu at point of right click
@@ -118,16 +125,15 @@ class fileWindow(QMdiSubWindow):
def sideViewToggle(self):
#Function checks if current side view tab is set, and toggles view as required
if self.sideViewTab:
- self.splitter.setVisible(True)
+ # self.splitter.setVisible(True)
self.sideView.setVisible(True)
self.sideView.setScene(self.tabber.currentWidget().painter)
- self.moveSideViewCloseButton()
self.resizeHandler()
return True
else:
- self.splitter.setVisible(False)
- self.sideView.setVisible(False)
- self.resizeHandler()
+ # self.splitter.setVisible(False)
+ self.sideView.setVisible(False)
+ self.resizeHandler()
return False
def moveSideViewCloseButton(self):