Rework GUI.

Work-in-progress state of the new gui.

Change-Id: Ib5e9ad2178b372fbd2914077096a9c73f025ecb7
This commit is contained in:
Alexander Zaft
2023-01-24 11:13:26 +01:00
parent 12f21996e4
commit a36d875fae
37 changed files with 4967 additions and 1403 deletions

50
frappy/gui/collapsible.py Normal file
View File

@@ -0,0 +1,50 @@
from frappy.gui.qt import QToolButton, QFrame, QWidget, QGridLayout, QSizePolicy, QVBoxLayout, Qt
class CollapsibleWidget(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.button = QToolButton()
self.widget = QWidget()
self.widgetContainer = QWidget()
self.button.setArrowType(Qt.RightArrow)
self.button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
self.button.setStyleSheet("QToolButton { border: none; }")
self.button.setCheckable(True)
self.button.toggled.connect(self._collapse)
line = QFrame()
line.setFrameShape(QFrame.HLine)
line.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
l = QVBoxLayout()
l.addWidget(self.widget)
self.widgetContainer.setLayout(l)
self.widgetContainer.setMaximumHeight(0)
layout = QGridLayout()
layout.addWidget(self.button, 0, 0, Qt.AlignLeft)
layout.addWidget(line, 0, 1, 1, 1)
layout.addWidget(self.widgetContainer, 1, 0, -1, -1)
self.setLayout(layout)
def _collapse(self, expand):
if expand:
self.button.setArrowType(Qt.DownArrow)
self.widgetContainer.setMaximumHeight(self.widget.maximumHeight())
else:
self.button.setArrowType(Qt.RightArrow)
self.widgetContainer.setMaximumHeight(0)
self.setMaximumHeight(self.button.maximumHeight())
def replaceWidget(self, widget):
layout = self.widgetContainer.layout()
layout.removeWidget(self.widget)
self.widget = widget
layout.addWidget(self.widget)
def setTitle(self, title):
self.button.setText(title)
def getWidget(self):
return self.widget