Commit ebdaa681 authored by Benjamin Mummery's avatar Benjamin Mummery 💻

Fixed alignment of radiobuttons

parent 6e5f9ee8
Pipeline #1819 canceled with stages
......@@ -153,13 +153,15 @@ class labelledSpin(QtWidgets.QWidget):
# self.simpleSpin.setValue(self.initVal)
self.simpleSpin.setStyleSheet(
"QDoubleSpinBox{"
" width:100px;" # TODO: unhardcode
"border:none;"
"}"
"QDoubleSpinBox[bgColour='1']{"
" background-color:" + NativeUI.colors["page_foreground"].name() + ";"
"}"
"QDoubleSpinBox[bgColour='0']{"
" background-color:" + NativeUI.colors["page_background"].name() + ";"
" background-color:"
+ NativeUI.colors["button_background_disabled"].name()
+ ";"
"}"
"QDoubleSpinBox[textColour='0']{"
" color:" + NativeUI.colors["page_background"].name() + ";"
......@@ -171,11 +173,11 @@ class labelledSpin(QtWidgets.QWidget):
" color:" + NativeUI.colors["page_foreground"].name() + ";"
"}"
"QDoubleSpinBox::up-button{"
"width:20; "
# "width:20; "
"}"
"QDoubleSpinBox::down-button{"
"width:20px;"
"height:20px; "
# "width:20px;"
# "height:20px; "
"}"
)
self.simpleSpin.setFont(NativeUI.text_font)
......@@ -264,15 +266,14 @@ class labelledSpin(QtWidgets.QWidget):
def insertWidget(self, widget):
"""Insert a widget with the nameLabel. Used to put a radio button in specific spin boxes"""
self.insertedWidget = widget
self.insertedWidget.setFixedWidth(30)
mini_hlayout = (
QtWidgets.QHBoxLayout()
) # create new layout to ensure label and new widget aligned as one
mini_hlayout.addWidget(self.nameLabel)
mini_hlayout.addWidget(self.insertedWidget)
self.layout.addLayout(mini_hlayout)
self.layout.addWidget(self.simpleSpin)
self.layout.addWidget(self.unitLabel)
temp_widgets = [self.layout.takeAt(0) for i in range(self.layout.count())]
temp_widgets = [temp_widgets[0], self.insertedWidget] + temp_widgets[1:]
for w in temp_widgets:
try:
self.layout.addWidget(w)
except TypeError:
self.layout.addItem(w)
self.setLayout(self.layout)
return 0
......@@ -309,18 +310,26 @@ class labelledSpin(QtWidgets.QWidget):
Set the size of the widget.
Also rescale the elements within it to equally distribute the width
"""
if x is not None:
self.setFixedWidth(x)
x_widget = int(x / 8)
self.nameLabel.setFixedWidth(3 * x_widget - spacing)
self.simpleSpin.setFixedWidth(3 * x_widget - spacing)
self.unitLabel.setFixedWidth(2 * x_widget - spacing)
x_widget = int(0.9 * x / 8)
if hasattr(self, "insertedWidget"):
self.nameLabel.setFixedWidth(2 * x_widget)
self.insertedWidget.setFixedWidth(x_widget)
else:
self.nameLabel.setFixedWidth(3 * x_widget)
self.simpleSpin.setFixedWidth(4 * x_widget)
self.unitLabel.setFixedWidth(1 * x_widget)
if y is not None:
self.setFixedHeight(y)
for widget in self.widgetList:
widget.setFixedHeight(y)
# self.layout.setSpacing(spacing)
self.nameLabel.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.simpleSpin.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
self.unitLabel.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
self.layout.setSpacing(0)
return 0
def localise_text(self, text: dict) -> int:
......
......@@ -102,7 +102,7 @@ class Layout:
[
self.layout_mode_startup(),
self.layout_mode_personal(
"startup_", False, int(self.screen_width / 2)
"startup_", False, int(0.9 * self.screen_width / 2)
),
# self.layout_startup_confirmation(),
],
......@@ -138,7 +138,7 @@ class Layout:
"""
Layout for the startup / calibration page.
"""
panel_width = int(self.screen_width / 2)
panel_width = int(0.9 * self.screen_width / 2)
top_bar_layout = QtWidgets.QHBoxLayout()
top_bar_widgets = [
......@@ -159,10 +159,7 @@ class Layout:
vlayout = QtWidgets.QVBoxLayout()
vlayout.addLayout(top_bar_layout)
vlayout.addStretch()
for widget in [
self.widgets.calibration,
self.widgets.leak_test,
]:
for widget in [self.widgets.calibration, self.widgets.leak_test]:
vlayout.addWidget(widget)
widget.setFont(self.NativeUI.text_font)
widget.set_size(
......@@ -619,6 +616,8 @@ class Layout:
radioWidgets = ["Inhale Time", "IE Ratio"]
vLayout = QtWidgets.QVBoxLayout()
vLayout.addStretch()
for widget, enableBool in zip(spinList, enableList):
vLayout.addWidget(widget)
......@@ -645,6 +644,7 @@ class Layout:
widget.set_size(
panel_width, self.min_button_height, spacing=self.widget_spacing
)
vLayout.addStretch()
if buttons == True:
hButtonLayout = QtWidgets.QHBoxLayout()
......@@ -731,11 +731,13 @@ class Layout:
)
vLayout = QtWidgets.QVBoxLayout()
vLayout.addStretch()
for widget in personalList:
vLayout.addWidget(widget)
widget.set_size(
panel_width, self.min_button_height, spacing=self.widget_spacing
)
vLayout.addStretch()
if buttons:
hButtonLayout = QtWidgets.QHBoxLayout()
......
......@@ -61,7 +61,7 @@ class LabelledLineEditWidget(QtWidgets.QWidget):
elif len(infoArray) == 3:
self.label, self.units, self.tag = infoArray
self.manuallyUpdated = False
layout = QtWidgets.QHBoxLayout()
self.layout = QtWidgets.QHBoxLayout()
self.widgetList = []
# if self.label != "":
......@@ -70,20 +70,22 @@ class LabelledLineEditWidget(QtWidgets.QWidget):
self.nameLabel.setStyleSheet(
"color:" + NativeUI.colors["page_foreground"].name() + ";"
)
self.nameLabel.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.widgetList.append(self.nameLabel)
self.simpleSpin = SignallingLineEditWidget(NativeUI, popup, self.label)
self.simpleSpin.setText(self.initText)
self.simpleSpin.setStyleSheet(
"QLineEdit{"
" border: none;"
" color:" + NativeUI.colors["page_foreground"].name() + ";"
"}"
"QLineEdit[bgColour='1']{"
" background-color:" + NativeUI.colors["page_foreground"].name() + ";"
"}"
"QLineEdit[bgColour='0']{"
" background-color:" + NativeUI.colors["page_background"].name() + ";"
" background-color:"
+ NativeUI.colors["button_background_disabled"].name()
+ ";"
"}"
"QLineEdit[textColour='1']{"
" color:" + NativeUI.colors["page_background"].name() + ";"
......@@ -95,11 +97,11 @@ class LabelledLineEditWidget(QtWidgets.QWidget):
" color:" + NativeUI.colors["red"].name() + ";"
"}"
)
self.simpleSpin.setFixedWidth(600)
self.simpleSpin.setFont(NativeUI.text_font)
self.simpleSpin.setProperty("textColour", "1")
self.simpleSpin.setProperty("bgColour", "1")
self.simpleSpin.setAlignment(QtCore.Qt.AlignCenter)
self.simpleSpin.textChanged.connect(self.textUpdate)
if self.cmd_type == "":
self.simpleSpin.setReadOnly(True)
......@@ -112,13 +114,12 @@ class LabelledLineEditWidget(QtWidgets.QWidget):
self.unitLabel.setStyleSheet(
"color:" + NativeUI.colors["page_foreground"].name() + ""
)
self.unitLabel.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
self.widgetList.append(self.unitLabel)
for widget in self.widgetList:
layout.addWidget(widget)
self.layout.addWidget(widget)
self.setLayout(layout)
self.setLayout(self.layout)
self.localise_text(NativeUI.text)
def textUpdate(self):
......@@ -144,17 +145,23 @@ class LabelledLineEditWidget(QtWidgets.QWidget):
Set the size of the widget.
Also rescale the elements within it to equally distribute the width
"""
print("line_edit", self.label)
if x is not None:
self.setFixedWidth(x)
x_widget = int(x / 8)
self.nameLabel.setFixedWidth(3 * x_widget - spacing)
self.simpleSpin.setFixedWidth(3 * x_widget - spacing)
self.unitLabel.setFixedWidth(2 * x_widget - spacing)
x_widget = int(0.9 * x / 8)
self.nameLabel.setFixedWidth(3 * x_widget)
self.simpleSpin.setFixedWidth(4 * x_widget)
self.unitLabel.setFixedWidth(1 * x_widget)
if y is not None:
self.setFixedHeight(y)
for widget in self.widgetList:
widget.setFixedHeight(y)
self.nameLabel.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.simpleSpin.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
self.unitLabel.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
self.layout.setSpacing(0)
# self.layout.setSpacing(spacing)
return 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment