diff options
Diffstat (limited to 'src/main/python/utils')
-rw-r--r-- | src/main/python/utils/app.py | 12 | ||||
-rw-r--r-- | src/main/python/utils/dialogs.py | 1 | ||||
-rw-r--r-- | src/main/python/utils/fileWindow.py | 14 | ||||
-rw-r--r-- | src/main/python/utils/tabs.py | 22 | ||||
-rw-r--r-- | src/main/python/utils/toolbar.py | 40 |
5 files changed, 32 insertions, 57 deletions
diff --git a/src/main/python/utils/app.py b/src/main/python/utils/app.py index 4cc8228..96a45b0 100644 --- a/src/main/python/utils/app.py +++ b/src/main/python/utils/app.py @@ -3,7 +3,9 @@ Declare fbs application so that it can be imported in other modules. """ from fbs_runtime.application_context.PyQt5 import ApplicationContext -from PyQt5.QtCore import QSettings +from PyQt5.QtCore import QSettings, pyqtProperty +from PyQt5.QtGui import QIcon +from PyQt5.QtWidgets import QWidget from json import JSONEncoder, dumps, loads, dump, load from os.path import join @@ -15,6 +17,9 @@ def fileImporter(*file): # Helper function to fetch files from src/main/resources return app.get_resource(join(*file)) +with open(fileImporter("app.qss"), "r") as stylesheet: + app.app.setStyleSheet(stylesheet.read()) + class JSON_Encoder: def _encode(obj): @@ -52,6 +57,9 @@ class JSON_Typer(JSONEncoder): def encode(self, obj): return super(JSON_Typer, self).encode(self._encode(obj)) - + + +importer = pyqtProperty(str, fileImporter) + shapeGrips = {} lines = {}
\ No newline at end of file diff --git a/src/main/python/utils/dialogs.py b/src/main/python/utils/dialogs.py index 79685c5..f2c4eb9 100644 --- a/src/main/python/utils/dialogs.py +++ b/src/main/python/utils/dialogs.py @@ -58,7 +58,6 @@ class paperDims(QDialog): super(paperDims, self).exec_() self.deleteLater() #remove from memory #if ok was pressed return value else return None - print(self.landscapeCheckBox.isChecked()) return (self.returnCanvasSize, self.returnCanvasPPI, self.landscapeCheckBox.isChecked()) if self.result() else None class sideViewSwitchDialog(QDialog): diff --git a/src/main/python/utils/fileWindow.py b/src/main/python/utils/fileWindow.py index e0f5652..ba0b6e9 100644 --- a/src/main/python/utils/fileWindow.py +++ b/src/main/python/utils/fileWindow.py @@ -61,20 +61,6 @@ class fileWindow(QMdiSubWindow): self.sideView.setInteractive(False) self.sideViewCloseButton = QPushButton('×', self.sideView) self.sideViewCloseButton.setFlat(True) - self.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%); - } - """) self.sideViewCloseButton.setFixedSize(20, 20) self.moveSideViewCloseButton() self.sideViewCloseButton.clicked.connect(lambda: setattr(self, 'sideViewTab', None)) diff --git a/src/main/python/utils/tabs.py b/src/main/python/utils/tabs.py index 5196557..1431db2 100644 --- a/src/main/python/utils/tabs.py +++ b/src/main/python/utils/tabs.py @@ -41,19 +41,9 @@ class customTabWidget(QTabWidget): self.plusButton = QPushButton('+', self) #create the new tab button #style the new tab button self.plusButton.setFlat(True) - self.plusButton.setStyleSheet(""" - QPushButton{ - background: rgba(230, 230, 227, 0%); - padding: 1px; - border: 0px solid #E6E6E3; - - } - QPushButton:hover{ - background: rgba(230, 230, 227, 60%); - }""") #and parent it to the widget to add it at 0, 0 - self.plusButton.setFixedSize(35, 25) #set dimensions + self.plusButton.setFixedSize(25, 25) #set dimensions self.plusButton.clicked.connect(self.plusClicked.emit) #emit signal on click #set flags self.setMovable(True) @@ -64,23 +54,17 @@ class customTabWidget(QTabWidget): self.tab.nameChanged.connect(self.changeWidgetName) #set custom stylesheet for the widget area - self.setStyleSheet("""QTabWidget::pane { - margin: 0px,1px,1px,1px; - border: 2px solid #E6E6E3; - border-radius: 7px; - padding: 1px; - background-color: #E6E6E3;}""") def movePlusButton(self): #move the new tab button to correct location size = sum([self.tab.tabRect(i).width() for i in range(self.tab.count())]) # calculate width of all tabs - h = max(self.tab.geometry().bottom() - self.plusButton.height(), 0) #align with bottom of tabbar + h = max(self.tab.geometry().bottom() - self.plusButton.height()-10, -5) #align with bottom of tabbar w = self.tab.width() if size > w: #if all the tabs do not overflow the tab bar, add at the end self.plusButton.move(w-self.plusButton.width(), h) else: - self.plusButton.move(size-3, h) + self.plusButton.move(size+5, h) def changeWidgetName(self, index, newName): self.widget(index).setObjectName(newName)
\ No newline at end of file diff --git a/src/main/python/utils/toolbar.py b/src/main/python/utils/toolbar.py index 90b46fb..beac867 100644 --- a/src/main/python/utils/toolbar.py +++ b/src/main/python/utils/toolbar.py @@ -2,11 +2,11 @@ from fbs_runtime.application_context.PyQt5 import ApplicationContext from PyQt5.QtCore import QSize, Qt, pyqtSignal, QMimeData from PyQt5.QtGui import QIcon, QDrag from PyQt5.QtWidgets import (QBoxLayout, QDockWidget, QGridLayout, QLineEdit, - QScrollArea, QToolButton, QWidget, QApplication, QStyle, QLabel) + QScrollArea, QToolButton, QWidget, QStyle, QLabel) from re import search, IGNORECASE from .data import toolbarItems -from .app import fileImporter +from .app import fileImporter, app from .layout import flowLayout # resourceManager = ApplicationContext() #Used to load images, mainly toolbar icons @@ -39,14 +39,14 @@ class toolbar(QDockWidget): #create a scrollable area to house all buttons self.diagArea = QScrollArea(self) - self.diagArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + self.diagArea.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.diagArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.diagArea.setWidgetResizable(True) self.layout.addWidget(self.diagArea, stretch=1) self.diagAreaWidget = QWidget(self.diagArea) #inner widget for scroll area #custom layout for inner widget self.diagAreaLayout = flowLayout(self.diagAreaWidget) - + self.diagAreaLayout.setSizeConstraint(flowLayout.SetMinimumSize) self.setWidget(self.widget) #set main widget to dockwidget def clearLayout(self): @@ -81,18 +81,25 @@ class toolbar(QDockWidget): parent = self.parentWidget() #used to get parent dimensions self.layout.setDirection(QBoxLayout.TopToBottom) # here so that a horizontal toolbar can be implemented later # self.setFixedHeight(self.height()) #span available height - width = self.width() - QApplication.style().pixelMetric(QStyle.PM_ScrollBarExtent) + self.searchBox.setMinimumWidth(.15*parent.width()) + width = self.width() + scrollBar = self.diagArea.verticalScrollBar() + height = self.diagAreaLayout.heightForWidth(width) + if scrollBar.isVisible(): + width -= app.app.style().pixelMetric(QStyle.PM_ScrollBarExtent) # the following line, sets the required height for the current width, so that blank space doesnt occur - self.diagAreaWidget.setMinimumHeight(self.diagAreaLayout.heightForWidth(width)) - self.setMinimumWidth(.17*parent.width()) #12% of parent width + self.diagAreaWidget.setMinimumHeight(height) + self.setMinimumWidth(.18*parent.width()) #12% of parent width # self.setMinimumWidth(self.diagAreaLayout.minimumSize().width()) #12% of parent width self.diagAreaWidget.setLayout(self.diagAreaLayout) self.diagArea.setWidget(self.diagAreaWidget) for _, label in self.toolbarLabelDict.items(): - label.setFixedSize(width, 20) - + label.setFixedWidth(width) + + def resizeEvent(self, event): + self.resize() def toolbarItems(self, itemClasses): #helper functions to create required buttons @@ -139,7 +146,7 @@ class toolbarButton(QToolButton): #handles drag if not (event.buttons() and Qt.LeftButton): return #ignore if left click is not held - if (event.pos() - self.dragStartPosition).manhattanLength() < QApplication.startDragDistance(): + if (event.pos() - self.dragStartPosition).manhattanLength() < app.app.startDragDistance(): return #check if mouse was dragged enough, manhattan length is a rough and quick method in qt drag = QDrag(self) #create drag object @@ -155,17 +162,8 @@ class toolbarButton(QToolButton): def minimumSizeHint(self): #defines button size return QSize(40, 40) - + class sectionLabel(QLabel): def __init__(self, *args): - super(sectionLabel, self).__init__(*args) - self.setAlignment(Qt.AlignHCenter) - self.setStyleSheet(""" - QLabel{ - background-color: #E6E6E3; - border: 2px solid gray; - border-left: 0px; - background-clip: padding; - } - """)
\ No newline at end of file + super(sectionLabel, self).__init__(*args)
\ No newline at end of file |