Commit 4ba39441 authored by Benjamin Mummery's avatar Benjamin Mummery 💻

Merge branch 'feature/ui_localisation' into ui_dev

parents 9d2f7775 c8c105c2
Pipeline #1809 canceled with stages
...@@ -41,13 +41,12 @@ from PySide2.QtCore import Slot, QTimer, Qt ...@@ -41,13 +41,12 @@ from PySide2.QtCore import Slot, QTimer, Qt
from PySide2.QtGui import QColor, QFont, QPalette from PySide2.QtGui import QColor, QFont, QPalette
from ui_layout import Layout from ui_layout import Layout
from ui_widgets import Widgets from ui_widgets import Widgets
from PySide2.QtWidgets import ( from widget_library.localised_base_widgets import (
QApplication, LocalisedQStackedWidget,
QMainWindow, LocalisedQWidget,
QWidget, LocalisedQDialog,
QDialog,
QStackedWidget,
) )
from PySide2.QtWidgets import QApplication, QMainWindow
# from handler_library.alarm_handler import AlarmHandler # from handler_library.alarm_handler import AlarmHandler
from handler_library.battery_handler import BatteryHandler from handler_library.battery_handler import BatteryHandler
...@@ -224,14 +223,14 @@ class NativeUI(HEVClient, QMainWindow): ...@@ -224,14 +223,14 @@ class NativeUI(HEVClient, QMainWindow):
self.messageCommandPopup = SetConfirmPopup(self) self.messageCommandPopup = SetConfirmPopup(self)
self.confirmPopup = confirmPopup(self, self) self.confirmPopup = confirmPopup(self, self)
self.confirmPopup.show() self.confirmPopup.show()
self.main_display = QWidget(self) self.main_display = LocalisedQWidget(self)
self.main_display.setLayout(self.layouts.global_layout()) self.main_display.setLayout(self.layouts.global_layout())
self.startupWidget = QDialog(self) self.startupWidget = LocalisedQDialog(self)
self.startupWidget.setLayout(self.layouts.startup_layout()) self.startupWidget.setLayout(self.layouts.startup_layout())
self.startupWidget.setPalette(palette) self.startupWidget.setPalette(palette)
self.startupWidget.setAutoFillBackground(True) self.startupWidget.setAutoFillBackground(True)
self.display_stack = QStackedWidget(self) self.display_stack = LocalisedQStackedWidget(self)
for widget in [ for widget in [
self.typeValPopupNum, self.typeValPopupNum,
self.typeValPopupAlpha, self.typeValPopupAlpha,
...@@ -383,7 +382,7 @@ class NativeUI(HEVClient, QMainWindow): ...@@ -383,7 +382,7 @@ class NativeUI(HEVClient, QMainWindow):
self.widgets.normal_plots.update_plot_data, self.widgets.normal_plots.update_plot_data,
self.widgets.detailed_plots.update_plot_data, self.widgets.detailed_plots.update_plot_data,
self.widgets.circle_plots.update_plot_data, self.widgets.circle_plots.update_plot_data,
self.widgets.charts_widget.update_plot_data, # self.widgets.charts_widget.update_plot_data,
]: ]:
self.data_handler.UpdatePlots.connect(plot_widget) self.data_handler.UpdatePlots.connect(plot_widget)
...@@ -639,44 +638,44 @@ class NativeUI(HEVClient, QMainWindow): ...@@ -639,44 +638,44 @@ class NativeUI(HEVClient, QMainWindow):
self.timer.start() self.timer.start()
# Localisation needs to update widgets # Localisation needs to update widgets
localised_widgets = [ # localised_widgets = [
self.widgets.normal_measurements, # self.widgets.normal_measurements,
self.widgets.detailed_measurements, # self.widgets.detailed_measurements,
self.widgets.normal_plots, # self.widgets.normal_plots,
self.widgets.detailed_plots, # self.widgets.detailed_plots,
self.widgets.circle_plots, # self.widgets.circle_plots,
self.widgets.ventilator_start_stop_buttons_widget, # self.widgets.ventilator_start_stop_buttons_widget,
# self.widgets.charts_widget, # # self.widgets.charts_widget,
self.widgets.plot_stack, # self.widgets.plot_stack,
self.widgets.alarms_page, # self.widgets.alarms_page,
self.widgets.settings_page, # self.widgets.settings_page,
self.widgets.modes_page, # self.widgets.modes_page,
self.widgets.modes_stack, # self.widgets.modes_stack,
self.widgets.startup_stack, # self.widgets.startup_stack,
self.widgets.mode_settings_stack, # self.widgets.mode_settings_stack,
self.widgets.mode_settings_stack_startup, # self.widgets.mode_settings_stack_startup,
self.widgets.normal_measurements, # self.widgets.normal_measurements,
self.widgets.standby_timer, # self.widgets.standby_timer,
self.widgets.stop_timer, # self.widgets.stop_timer,
self.widgets.acknowledge_button, # self.widgets.acknowledge_button,
self.widgets.calibration, # self.widgets.calibration,
self.widgets.leak_test, # self.widgets.leak_test,
self.widgets.maintenance, # self.widgets.maintenance,
self.widgets.alarm_table, # self.widgets.alarm_table,
self.widgets.localisation_startup_button, # self.widgets.localisation_startup_button,
# self.widgets.spin_buttons, # # self.widgets.spin_buttons,
# self.widgets.mode_personal_tab, # # self.widgets.mode_personal_tab,
] # ]
with open("NativeUI/configs/mode_config.json") as json_file: # with open("NativeUI/configs/mode_config.json") as json_file:
modeDict = json.load(json_file) # modeDict = json.load(json_file)
for setting in modeDict["settings"]: # for setting in modeDict["settings"]:
try: # try:
localised_widgets.append( # localised_widgets.append(
self.widgets.get_widget("CURRENT_" + setting[2]) # self.widgets.get_widget("CURRENT_" + setting[2])
) # )
except AttributeError: # except AttributeError:
continue # continue
for widget in localised_widgets: for widget in self.widgets.widget_list:
self.widgets.localisation_button.SetLocalisation.connect( self.widgets.localisation_button.SetLocalisation.connect(
widget.localise_text widget.localise_text
) )
...@@ -775,7 +774,7 @@ class NativeUI(HEVClient, QMainWindow): ...@@ -775,7 +774,7 @@ class NativeUI(HEVClient, QMainWindow):
if self.enableState == False: if self.enableState == False:
for attribute in dir(self.widgets): for attribute in dir(self.widgets):
widg = self.widgets.get_widget(attribute) widg = self.widgets.get_widget(attribute)
if isinstance(widg, QWidget): if isinstance(widg, LocalisedQWidget):
try: try:
self.saveStateDict[attribute] = widg.isEnabled() self.saveStateDict[attribute] = widg.isEnabled()
except KeyError as e: except KeyError as e:
...@@ -790,7 +789,7 @@ class NativeUI(HEVClient, QMainWindow): ...@@ -790,7 +789,7 @@ class NativeUI(HEVClient, QMainWindow):
self.setPalette(self.alt_palette) self.setPalette(self.alt_palette)
for attribute in dir(self.widgets): for attribute in dir(self.widgets):
widg = self.widgets.get_widget(attribute) widg = self.widgets.get_widget(attribute)
if isinstance(widg, QWidget): if isinstance(widg, LocalisedQWidget):
if self.enableState: if self.enableState:
try: try:
widg.setEnabled(self.saveStateDict[attribute]) widg.setEnabled(self.saveStateDict[attribute])
......
...@@ -40,8 +40,7 @@ class AlarmList(QtWidgets.QListWidget): ...@@ -40,8 +40,7 @@ class AlarmList(QtWidgets.QListWidget):
self.addItem(newItem) self.addItem(newItem)
def acknowledge_all(self): def acknowledge_all(self):
self.NativeUI.q_send_cmd('RESET_ALARM', 'TRUE') self.NativeUI.q_send_cmd("RESET_ALARM", "TRUE")
def addAlarm(self, abstractAlarm): def addAlarm(self, abstractAlarm):
"""Use abstractAlarm object to create a new alarm in the list.""" """Use abstractAlarm object to create a new alarm in the list."""
...@@ -62,3 +61,8 @@ class AlarmList(QtWidgets.QListWidget): ...@@ -62,3 +61,8 @@ class AlarmList(QtWidgets.QListWidget):
if abstractAlarm.alarmPayload["alarm_code"] in self.item(x).text(): if abstractAlarm.alarmPayload["alarm_code"] in self.item(x).text():
self.takeItem(x) self.takeItem(x)
def localise_text(self, text: dict) -> int:
"""
Change the language of text elements.
"""
pass
...@@ -54,9 +54,13 @@ class AlarmWidget(QtWidgets.QWidget): ...@@ -54,9 +54,13 @@ class AlarmWidget(QtWidgets.QWidget):
self.setFixedHeight(popup_height) self.setFixedHeight(popup_height)
self.setLayout(self.layout) self.setLayout(self.layout)
if self.alarmPayload["alarm_type"] == "PRIORITY_HIGH": if self.alarmPayload["alarm_type"] == "PRIORITY_HIGH":
self.setStyleSheet("background-color:" + NativeUI.colors["red"].name() + ";") self.setStyleSheet(
"background-color:" + NativeUI.colors["red"].name() + ";"
)
elif self.alarmPayload["alarm_type"] == "PRIORITY_MEDIUM": elif self.alarmPayload["alarm_type"] == "PRIORITY_MEDIUM":
self.setStyleSheet("background-color" + NativeUI.colors["orange"].name() + ";") self.setStyleSheet(
"background-color" + NativeUI.colors["orange"].name() + ";"
)
self.setFixedSize(NativeUI.alarm_popup_width + popup_height, popup_height) self.setFixedSize(NativeUI.alarm_popup_width + popup_height, popup_height)
self.installEventFilter(self) # install response to press self.installEventFilter(self) # install response to press
...@@ -65,7 +69,9 @@ class AlarmWidget(QtWidgets.QWidget): ...@@ -65,7 +69,9 @@ class AlarmWidget(QtWidgets.QWidget):
"""Repsond to button press by opening alarm page""" """Repsond to button press by opening alarm page"""
if event.type() == QtCore.QEvent.MouseButtonPress: if event.type() == QtCore.QEvent.MouseButtonPress:
self.NativeUI.widgets.page_buttons.alarms_button.click() self.NativeUI.widgets.page_buttons.alarms_button.click()
self.NativeUI.widgets.alarms_page.setTab(self.NativeUI.widgets.alarms_page.button_list[0]) self.NativeUI.widgets.alarms_page.setTab(
self.NativeUI.widgets.alarms_page.button_list[0]
)
return False return False
def get_priority(self): def get_priority(self):
...@@ -81,7 +87,6 @@ class AlarmWidget(QtWidgets.QWidget): ...@@ -81,7 +87,6 @@ class AlarmWidget(QtWidgets.QWidget):
class AlarmPopup(QtWidgets.QDialog): class AlarmPopup(QtWidgets.QDialog):
def __init__(self, NativeUI, *args, **kwargs): def __init__(self, NativeUI, *args, **kwargs):
super(AlarmPopup, self).__init__(*args, **kwargs) super(AlarmPopup, self).__init__(*args, **kwargs)
"""Container class for alarm widgets. Handles ordering and positioning of alarms. """Container class for alarm widgets. Handles ordering and positioning of alarms.
...@@ -176,6 +181,12 @@ class AlarmPopup(QtWidgets.QDialog): ...@@ -176,6 +181,12 @@ class AlarmPopup(QtWidgets.QDialog):
self.move(x, y) self.move(x, y)
return 0 return 0
def localise_text(self, text: dict) -> int:
"""
Change the language of text elements.
"""
pass
class AlarmExtrasWidget(QtWidgets.QWidget): class AlarmExtrasWidget(QtWidgets.QWidget):
"""Widget created to indicate there are many alarms not listed.""" """Widget created to indicate there are many alarms not listed."""
......
{ {
"settings":[ "settings":[
[["APNEA", "ms", "APNEA", "SET_THRESHOLD_MIN", "APNEA", 5, 20, 10, 1, 0]], [
[["Check Pressure Patient", "ms", "CHECK_P_PATIENT", "SET_THRESHOLD_MIN", "CHECK_P_PATIENT"],["Check Pressure Patient", "ms", "CHECK_P_PATIENT", "SET_THRESHOLD_MAX", "CHECK_P_PATIENT"]], ["APNEA", "unit_ms", "APNEA", "SET_THRESHOLD_MIN", "APNEA", 5, 20, 10, 1, 0]
[["FIO2", "%", "HIGH_FIO2", "SET_THRESHOLD_MIN", "HIGH_FIO2", -10, 0, -5, 1, 0],["Percentage O2", "%", "fiO2_percent", "SET_TARGET_CURRENT", "FIO2_PERCENT", 21, 100, 51, 1, 0],["FIO2", "%", "HIGH_FIO2", "SET_THRESHOLD_MAX", "HIGH_FIO2", 0, 10, 5, 1, 0]], ],
[["Pressure", "cm H2O", "HIGH_PRESSURE", "SET_THRESHOLD_MIN", "HIGH_PRESSURE", -10, 0, -5, 1, 0],["Inhale Pressure","cm H2O","inspiratory_pressure","SET_TARGET_CURRENT","INSPIRATORY_PRESSURE", 10, 50, 17, 1, 0],["Pressure", "cm H2O", "HIGH_PRESSURE", "SET_THRESHOLD_MAX", "HIGH_PRESSURE", 0,10,5,1,1]], [
[["Respiratory Rate", "%", "HIGH_RR", "SET_THRESHOLD_MIN", "HIGH_RR", -10, 0, -5, 0.1, 1],["Respiratory Rate","/min","respiratory_rate","SET_TARGET_CURRENT","RESPIRATORY_RATE", 10, 20, 15, 0.1, 1],["Respiratory Rate", "%", "HIGH_RR", "SET_THRESHOLD_MAX", "HIGH_RR", 0, 10, 5, 0.1, 1]], ["Check Pressure Patient", "unit_ms", "CHECK_P_PATIENT", "SET_THRESHOLD_MIN", "CHECK_P_PATIENT"],
[["VTE", "%", "HIGH_VTE", "SET_THRESHOLD_MIN", "HIGH_VTE", -10, 0, -5, 1, 0],["Inhale Volume", "mL", "volume", "SET_TARGET_CURRENT", "VOLUME", 200, 800, 400, 20, 0],["VTE", "%", "HIGH_VTE", "SET_THRESHOLD_MAX", "HIGH_VTE",0, 10, 5, 1, 0]], ["Check Pressure Patient", "unit_ms", "CHECK_P_PATIENT", "SET_THRESHOLD_MAX", "CHECK_P_PATIENT"]
[["VTI", "%", "HIGH_VTI", "SET_THRESHOLD_MIN", "HIGH_VTI", -10, 0, -5, 1, 0],["VTI", "%", "HIGH_VTI", "SET_THRESHOLD_MAX", "HIGH_VTI",0, 10, 5, 1, 0]], ],
[["Occlusion", " ", "OCCLUSION","SET_THRESHOLD_MIN", "OCCLUSION", 5, 20, 15, 1, 0]], [
[["PEEP", "cm H2O", "HIGH_PEEP","SET_THRESHOLD_MIN", "HIGH_PEEP", -2, 0, -2, 1, 0],["PEEP","cm H2O","peep","SET_TARGET_CURRENT","PEEP", 0, 100, 15, 0.1, 1],["PEEP", "cm H2O", "HIGH_PEEP","SET_THRESHOLD_MAX", "HIGH_PEEP",0, 2, 2, 1, 0]] ["FIO2", "unit_percent", "HIGH_FIO2", "SET_THRESHOLD_MIN", "HIGH_FIO2", -10, 0, -5, 1, 0],
["Percentage O2", "", "fiO2_percent", "SET_TARGET_CURRENT", "FIO2_PERCENT", 21, 100, 51, 1, 0],
["FIO2", "unit_percent", "HIGH_FIO2", "SET_THRESHOLD_MAX", "HIGH_FIO2", 0, 10, 5, 1, 0]
],
[
["Pressure", "", "HIGH_PRESSURE", "SET_THRESHOLD_MIN", "HIGH_PRESSURE"],
["Inhale Pressure","","inspiratory_pressure","SET_TARGET_CURRENT","INSPIRATORY_PRESSURE", 10, 50, 17, 1, 0],
["Pressure", "", "HIGH_PRESSURE", "SET_THRESHOLD_MAX", "HIGH_PRESSURE"],
["Pressure", "", "HIGH_PRESSURE", "SET_THRESHOLD_MAX", "HIGH_PRESSURE"]],
[
["Respiratory Rate", "", "HIGH_RR", "SET_THRESHOLD_MIN", "HIGH_RR", -10, 0, -5, 0.1, 1],
["Respiratory Rate","unit_min","respiratory_rate","SET_TARGET_CURRENT","RESPIRATORY_RATE", 10, 20, 15, 0.1, 1],
["Respiratory Rate", "", "HIGH_RR", "SET_THRESHOLD_MAX", "HIGH_RR", 0, 10, 5, 0.1, 1]
],
[
["VTE", "", "HIGH_VTE", "SET_THRESHOLD_MIN", "HIGH_VTE", -10, 0, -5, 1, 0],
["Inhale Volume", "", "volume", "SET_TARGET_CURRENT", "VOLUME", 200, 800, 400, 20, 0],
["VTE", "", "HIGH_VTE", "SET_THRESHOLD_MAX", "HIGH_VTE",0, 10, 5, 1, 0]
],
[
["VTI", "", "HIGH_VTI", "SET_THRESHOLD_MIN", "HIGH_VTI", -10, 0, -5, 1, 0],
["VTI", "", "HIGH_VTI", "SET_THRESHOLD_MAX", "HIGH_VTI",0, 10, 5, 1, 0]
],
[
["Occlusion", "", "OCCLUSION","SET_THRESHOLD_MIN", "OCCLUSION", 5, 20, 15, 1, 0]
],
[
["PEEP", "", "HIGH_PEEP","SET_THRESHOLD_MIN", "HIGH_PEEP", -2, 0, -2, 1, 0],
["PEEP","unit_cm_h2o","peep","SET_TARGET_CURRENT","PEEP", 0, 100, 15, 0.1, 1],
["PEEP", "", "HIGH_PEEP","SET_THRESHOLD_MAX", "HIGH_PEEP",0, 2, 2, 1, 0]
]
], ],
"SingleThresholds": ["APNEA", "Occlusion"], "SingleThresholds": ["APNEA", "Occlusion"],
"AbsoluteLimits": ["Percentage O2", "FIO2", "PEEP"] "AbsoluteLimits": ["Percentage O2", "FIO2", "PEEP"]
......
{ {
"settings":[ "settings":[
["APNEA", "ms", "APNEA", "SET_THRESHOLD_MIN", "APNEA"], ["APNEA", "unit_ms", "APNEA", "SET_THRESHOLD_MIN", "APNEA"],
["Check Pressure Patient", "ms", "CHECK_P_PATIENT", "SET_THRESHOLD_MIN", "CHECK_P_PATIENT"], ["Check Pressure Patient", "unit_ms", "CHECK_P_PATIENT", "SET_THRESHOLD_MIN", "CHECK_P_PATIENT"],
["FIO2", "ms", "HIGH_FIO2", "SET_THRESHOLD_MIN", "HIGH_FIO2"], ["FIO2", "unit_ms", "HIGH_FIO2", "SET_THRESHOLD_MIN", "HIGH_FIO2"],
["High Pressure", " ", "HIGH_PRESSURE", "SET_THRESHOLD_MIN", "HIGH_PRESSURE"], ["High Pressure", " ", "HIGH_PRESSURE", "SET_THRESHOLD_MIN", "HIGH_PRESSURE"],
["High Respiratory Rate", " ", "HIGH_RR", "SET_THRESHOLD_MIN", "HIGH_RR"], ["High Respiratory Rate", " ", "HIGH_RR", "SET_THRESHOLD_MIN", "HIGH_RR"],
["High VTE", " ", "HIGH_VTE", "SET_THRESHOLD_MAX", "HIGH_VTE"], ["High VTE", " ", "HIGH_VTE", "SET_THRESHOLD_MAX", "HIGH_VTE"],
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"Buffers": [ "Buffers": [
[ [
"Calibration", "Calibration",
"ms", "unit_ms",
"duration_calibration", "duration_calibration",
"SET_DURATION", "SET_DURATION",
"CALIBRATION", "CALIBRATION",
...@@ -11,19 +11,19 @@ ...@@ -11,19 +11,19 @@
50, 50,
0 0
], ],
["Purge", "ms", "duration_buff_purge", "SET_DURATION", "BUFF_PURGE"], ["Purge", "unit_ms", "duration_buff_purge", "SET_DURATION", "BUFF_PURGE"],
["Flush", "ms", "duration_buff_flush", "SET_DURATION", "BUFF_FLUSH"], ["Flush", "unit_ms", "duration_buff_flush", "SET_DURATION", "BUFF_FLUSH"],
[ [
"Pre-fill", "Pre-fill",
"ms", "unit_ms",
"duration_buff_prefill", "duration_buff_prefill",
"SET_DURATION", "SET_DURATION",
"BUFF_PREFILL" "BUFF_PREFILL"
], ],
["Fill", "ms", "duration_buff_prefill", "SET_DURATION", "BUFF_FILL"], ["Fill", "unit_ms", "duration_buff_prefill", "SET_DURATION", "BUFF_FILL"],
[ [
"Pre-inhale", "Pre-inhale",
"ms", "unit_ms",
"duration_buff_pre_inhale", "duration_buff_pre_inhale",
"SET_DURATION", "SET_DURATION",
"BUFF_PRE_INHALE" "BUFF_PRE_INHALE"
...@@ -48,14 +48,14 @@ ...@@ -48,14 +48,14 @@
["Inhale", "", "valve_inhale"], ["Inhale", "", "valve_inhale"],
["Exhale", "", "valve_exhale"], ["Exhale", "", "valve_exhale"],
["Purge valve", "", "valve_purge"], ["Purge valve", "", "valve_purge"],
["Inhale Opening", "%", "valve_inhale_percent"], ["Inhale Opening", "unit_percent", "valve_inhale_percent"],
["Exhale Opening", "%", "valve_exhale_percent"] ["Exhale Opening", "unit_percent", "valve_exhale_percent"]
], ],
"Breathing": [ "Breathing": [
["Inhale", "ms", "duration_inhale", "SET_DURATION", "INHALE"], ["Inhale", "unit_ms", "duration_inhale", "SET_DURATION", "INHALE"],
["Pause", "ms", "duration_pause", "SET_DURATION", "PAUSE"], ["Pause", "unit_ms", "duration_pause", "SET_DURATION", "PAUSE"],
["Exhale fill", "ms", "duration_exhale", "SET_DURATION", "EXHALE_FILL"], ["Exhale fill", "unit_ms", "duration_exhale", "SET_DURATION", "EXHALE_FILL"],
["Exhale", "ms", "duration_exhale", "SET_DURATION", "EXHALE"], ["Exhale", "unit_ms", "duration_exhale", "SET_DURATION", "EXHALE"],
["I:E Ratio", "", "inhale_exhale_ratio"] ["I:E Ratio", "", "inhale_exhale_ratio"]
] ]
} }
{"settings":[ {"settings":[
["Respiratory Rate","/min","respiratory_rate","SET_TARGET_","RESPIRATORY_RATE", 0, 20, 15, 0.1, 1], ["Respiratory Rate","unit_min","respiratory_rate","SET_TARGET_","RESPIRATORY_RATE", 0, 20, 15, 0.1, 1],
["PEEP","cm h2o","peep","SET_TARGET_","PEEP", 0, 100, 15, 0.1, 1], ["PEEP","unit_cm_h2o","peep","SET_TARGET_","PEEP", 0, 100, 15, 0.1, 1],
["Inhale Time", "s", "inhale_time", "SET_TARGET_", "INHALE_TIME", 0, 20, 1, 0.1, 1], ["Inhale Time", "unit_s", "inhale_time", "SET_TARGET_", "INHALE_TIME", 0, 20, 1, 0.1, 1],
["IE Ratio", "", "ie_ratio", "SET_TARGET_", "IE_RATIO", 0, 1, 0.338, 0.001, 3], ["IE Ratio", "", "ie_ratio", "SET_TARGET_", "IE_RATIO", 0, 1, 0.338, 0.001, 3],
["Inhale Trigger Sensitivity","","inhale_trigger_threshold","SET_TARGET_","INHALE_TRIGGER_THRESHOLD", 0, 20, 5, 0.2, 1], ["Inhale Trigger Sensitivity","","inhale_trigger_threshold","SET_TARGET_","INHALE_TRIGGER_THRESHOLD", 0, 20, 5, 0.2, 1],
["Exhale Trigger Sensitivity","","exhale_trigger_threshold","SET_TARGET_","EXHALE_TRIGGER_THRESHOLD", 0, 50, 25, 0.2, 1], ["Exhale Trigger Sensitivity","","exhale_trigger_threshold","SET_TARGET_","EXHALE_TRIGGER_THRESHOLD", 0, 50, 25, 0.2, 1],
......
{"settings":[ {"settings":[
["Name", "/min", "name", "SET_PERSONAL", "NAME", "Goedkoop Van Tilator"], ["Name", "", "name", "SET_PERSONAL", "NAME", "Goedkoop Van Tilator"],
["Patient ID", "s", "patient_id", "SET_PERSONAL", "PATIENT_ID", "11235813FIB"], ["Patient ID", "", "patient_id", "SET_PERSONAL", "PATIENT_ID", "11235813FIB"],
["Age", "years", "age", "SET_PERSONAL", "AGE", 0, 130, 25, 1, 0], ["Age", "unit_years", "age", "SET_PERSONAL", "AGE", 0, 130, 25, 1, 0],
["Sex", "", "sex", "SET_PERSONAL", "SEX", "X"], ["Sex", "", "sex", "SET_PERSONAL", "SEX", "X"],
["Weight", "kg", "weight", "SET_PERSONAL", "WEIGHT", 20, 250, 60, 1, 0], ["Weight", "unit_kg", "weight", "SET_PERSONAL", "WEIGHT", 20, 250, 60, 1, 0],
["Height", "cms", "height", "SET_PERSONAL", "HEIGHT",20, 250, 160, 1, 0] ["Height", "unit_cm", "height", "SET_PERSONAL", "HEIGHT",20, 250, 160, 1, 0]
], ],
"textBoxes": ["Name", "Patient ID", "Sex"] "textBoxes": ["Name", "Patient ID", "Sex"]
......
...@@ -51,12 +51,12 @@ ...@@ -51,12 +51,12 @@
"spin_box_label_Inhale_Time": "Inhale Time", "spin_box_label_Inhale_Time": "Inhale Time",
"spin_box_label_IE_Ratio": "IE Ratio", "spin_box_label_IE_Ratio": "IE Ratio",
"spin_box_label_Percentage_O2": "Percentage O2", "spin_box_label_Percentage_O2": "Percentage O2",
"personal_tab_name": "Name", "name": "Name",
"personal_tab_patientid": "Patient ID", "patient_id": "Patient ID",
"personal_tab_age": "Age", "age": "Age",
"personal_tab_sex": "Sex", "sex": "Sex",
"personal_tab_weight": "Weight", "weight": "Weight",
"personal_tab_height": "Height", "height": "Height",
"popup_hold_standby": "HOLD FOR VENTILATOR STANDBY", "popup_hold_standby": "HOLD FOR VENTILATOR STANDBY",
"popup_hold_stop": "HOLD FOR VENTILATOR STOP", "popup_hold_stop": "HOLD FOR VENTILATOR STOP",
"label_modeswitch": "", "label_modeswitch": "",
...@@ -68,5 +68,52 @@ ...@@ -68,5 +68,52 @@
"Percentage O2": "Percentage O2", "Percentage O2": "Percentage O2",
"calibration": "Calibration", "calibration": "Calibration",
"Leak Test": "Leak Test", "Leak Test": "Leak Test",
"maintenance": "Maintenance" "maintenance": "Maintenance",
"APNEA": "APNEA",
"duration_buff_prefill": "Fill",
"duration_buff_pre_inhale": "Pre-inhale",
"kp": "KP",
"ki": "KI",
"kd": "KD",
"pid_gain": "PID Gain",
"max_patient_pressure": "Max. PP",
"valve_air_in": "Air in",
"valve_o2_in": "O<sub>2</sub> in",
"valve_inhale": "Inhale",
"valve_exhale": "Exhale",
"valve_purge": "Purge valve",
"valve_inhale_percent": "Inhale Opening",
"valve_exhale_percent": "Exhale Opening",
"CHECK_P_PATIENT":"Check Pressure Patient",
"HIGH_FIO2":"FIO2",
"HIGH_PRESSURE":"Pressure",
"HIGH_RR":"Respiratory Rate",
"HIGH_VTE":"VTE",
"HIGH_VTI":"VTI",
"OCCLUSION":"Occlusion",
"HIGH_PEEP":"PEEP",
"unit_ms": "ms",
"unit_percent": "%",
"unit_min":"/min",
"unit_cm_h2o": "cm H<sub>2</sub>O",
"unit_s": "s",
"unit_years": "Years",
"unit_kg": "kg",
"unit_cm": "cm",
"peep": "PEEP",
"respiratory_rate":"Respiratory Rate",
"inhale_time":"Inhale Time",
"ie_ratio":"IE Ratio",
"inhale_trigger_threshold":"Inhale Trigger Sensitivity",
"exhale_trigger_threshold":"Exhale Trigger Sensitivity",
"inspiratory_pressure":"Inhale Pressure",
"volume":"Inhale Volume",
"fiO2_percent":"Percentage O2",
"duration_calibration":"Calibration",
"duration_buff_purge":"Purge",
"duration_buff_flush":"Flush",
"duration_inhale":"Inhale",
"duration_pause":"Pause",
"duration_exhale":"Exhale fill",
"inhale_exhale_ratio":"I:E Ratio"
} }
...@@ -7,10 +7,10 @@ ...@@ -7,10 +7,10 @@
"PC/AC-PRVC": "PC/AC-PRVC", "PC/AC-PRVC": "PC/AC-PRVC",
"PC-PSV": "PC-PSV", "PC-PSV": "PC-PSV",
"CPAP": "CPAP", "CPAP": "CPAP",
"alarm_table_header_timestamp": "-", "alarm_table_header_timestamp": "Data-Hora",
"alarm_table_header_priority_level": "-", "alarm_table_header_priority_level": "Nivel de Prioridade",
"alarm_table_header_alarm_code": "-", "alarm_table_header_alarm_code": "Cod. Alarme",
"alarm_table_header_duration": "-", "alarm_table_header_duration": "Duracao do Alarme",
"plot_axis_label_pressure": "Pressao [cmH<sub>2</sub>O]", "plot_axis_label_pressure": "Pressao [cmH<sub>2</sub>O]",
"plot_axis_label_flow": "Fluxo [L/min]", "plot_axis_label_flow": "Fluxo [L/min]",
"plot_axis_label_volume": "Volume [mL]", "plot_axis_label_volume": "Volume [mL]",
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
"button_label_main_normal": "Normal", "button_label_main_normal": "Normal",
"button_label_main_detailed": "Detalhado", "button_label_main_detailed": "Detalhado",
"button_label_alarms_list": "Lista de Alarmes", "button_label_alarms_list": "Lista de Alarmes",
"button_label_alarms_list_reset_alarms": "-", "button_label_alarms_list_reset_alarms": "Reiniciar Alarmes",
"button_label_alarms_table": "Tabela de Alarmes", "button_label_alarms_table": "Tabela de Alarmes",
"button_label_alarms_clinical": "Limites Clinicos", "button_label_alarms_clinical": "Limites Clinicos",
"button_label_settings_expert": "Config. Especialista", "button_label_settings_expert": "Config. Especialista",
...@@ -51,22 +51,69 @@ ...@@ -51,22 +51,69 @@
"spin_box_label_Inhale_Time": "Tempo Inspiracao", "spin_box_label_Inhale_Time": "Tempo Inspiracao",
"spin_box_label_IE_Ratio": "Razao I/E", "spin_box_label_IE_Ratio": "Razao I/E",
"spin_box_label_Percentage_O2": "Porcetagem O<sub>2</sub>", "spin_box_label_Percentage_O2": "Porcetagem O<sub>2</sub>",
"personal_tab_name": "Nome", "name": "Nome",
"personal_tab_patientid": "ID do paciente", "patient_id": "ID do paciente",
"personal_tab_age": "Idade", "age": "Idade",
"personal_tab_sex": "Sexo", "sex": "Sexo",
"personal_tab_weight": "Peso", "weight": "Peso",
"personal_tab_height": "Altura", "height": "Altura",
"personal_tab_height": "Height", "popup_hold_standby": "Segure para modo Espera",
"popup_hold_standby": "-", "popup_hold_stop": "Segure para Parar",
"popup_hold_stop": "-", "label_modeswitch": "",
"Respiratory Rate": "Freq. Respiratoria", "Respiratory Rate": "Freq. Respiratoria",
"PEEP": "PEEP", "PEEP": "PEEP",
"Inhale Time": "Tempo Inspiratorio", "Inhale Time": "Tempo Inspiratorio",
"IE Ratio": "Razao IE", "IE Ratio": "Razao IE",
"Inhale Pressure": "Pressao Inspiratoria", "Inhale Pressure": "Pressao Inspiratoria",
"Percentage O2": "Porcentagem O<sub>2</sub>", "Percentage O2": "Porcentagem O<sub>2</sub>",
"calibration": "-", "calibration": "Calibracao",
"Leak Test": "-", "Leak Test": "Teste de Vazamento",
"maintenance": "-" "maintenance": "Manutencao",
"APNEA": "-",
"duration_buff_prefill": "-",
"duration_buff_pre_inhale": "-",
"kp": "-",
"ki": "-",
"kd": "-",
"pid_gain": "-",
"max_patient_pressure": "-",
"valve_air_in": "-",
"valve_o2_in": "-",
"valve_inhale": "-",
"valve_exhale": "-",
"valve_purge": "-",
"valve_inhale_percent": "-",
"valve_exhale_percent": "-",
"CHECK_P_PATIENT":"-",
"HIGH_FIO2":"-",
"HIGH_PRESSURE":"-",
"HIGH_RR":"-",
"HIGH_VTE":"-",
"HIGH_VTI":"-",
"OCCLUSION":"-",
"HIGH_PEEP":"-",
"unit_ms": "-",
"unit_percent": "-",
"unit_min":"-",
"unit_cm_h2o": "-",
"unit_s": "-",
"unit_years": "-",
"unit_kg": "-",
"unit_cm": "-",
"peep": "-",
"respiratory_rate":"-",
"inhale_time":"-",
"ie_ratio":"-",
"inhale_trigger_threshold":"-",
"exhale_trigger_threshold":"-",
"inspiratory_pressure":"-",
"volume":"-",
"fiO2_percent":"-",
"duration_calibration":"-",
"duration_buff_purge":"-",
"duration_buff_flush":"-",
"duration_inhale":"-",
"duration_pause":"-",
"duration_exhale":"-",
"inhale_exhale_ratio":"-"
} }
...@@ -62,7 +62,6 @@ class SetConfirmPopup(QtWidgets.QDialog): ...@@ -62,7 +62,6 @@ class SetConfirmPopup(QtWidgets.QDialog):
self.setLayout(vlayout) self.setLayout(vlayout)
def populatePopup(self, handlerWidget, messageList): def populatePopup(self, handlerWidget, messageList):
"""One popup is used for all the handlers. It is populated when called by a particular handler""" """One popup is used for all the handlers. It is populated when called by a particular handler"""
self.handler = handlerWidget self.handler = handlerWidget
...@@ -103,6 +102,9 @@ class SetConfirmPopup(QtWidgets.QDialog): ...@@ -103,6 +102,9 @@ class SetConfirmPopup(QtWidgets.QDialog):
logging.warning("Unrecognised handler type: %s", type(self.handler)) logging.warning("Unrecognised handler type: %s", type(self.handler))
return 0 return 0
def localise_text(self, text: dict) -> int:
pass
class confirmWidget(QtWidgets.QWidget): class confirmWidget(QtWidgets.QWidget):
"""A widget displaying an individual command confirmation from the MCU. Is contained in confirmPopup""" """A widget displaying an individual command confirmation from the MCU. Is contained in confirmPopup"""
...@@ -169,10 +171,11 @@ class confirmPopup(QtWidgets.QDialog): ...@@ -169,10 +171,11 @@ class confirmPopup(QtWidgets.QDialog):
self.timer = QtCore.QTimer() self.timer = QtCore.QTimer()
self.timer.setInterval(500) self.timer.setInterval(500)
self.timer.timeout.connect(self.adjustSize) # container needs to adjust to a new number of confirmWidgets self.timer.timeout.connect(
self.adjustSize
) # container needs to adjust to a new number of confirmWidgets
self.timer.start() self.timer.start()
def addConfirmation(self, confirmMessage): def addConfirmation(self, confirmMessage):
"""Add a confirmation to the popup. Triggered when UI receives a confirmation from the microcontroller""" """Add a confirmation to the popup. Triggered when UI receives a confirmation from the microcontroller"""
self.confirmDict[confirmMessage] = confirmWidget( self.confirmDict[confirmMessage] = confirmWidget(
......
...@@ -132,7 +132,7 @@ class labelledSpin(QtWidgets.QWidget): ...@@ -132,7 +132,7 @@ class labelledSpin(QtWidgets.QWidget):
textStyle = "color:" + NativeUI.colors["page_foreground"].name() + ";" textStyle = "color:" + NativeUI.colors["page_foreground"].name() + ";"
# if self.label != "": # if self.label != "":
self.nameLabel = QtWidgets.QLabel(self.label) self.nameLabel = QtWidgets.QLabel()
self.nameLabel.setStyleSheet(textStyle) self.nameLabel.setStyleSheet(textStyle)
self.nameLabel.setFont(NativeUI.text_font) self.nameLabel.setFont(NativeUI.text_font)
self.nameLabel.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.nameLabel.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
...@@ -187,7 +187,7 @@ class labelledSpin(QtWidgets.QWidget): ...@@ -187,7 +187,7 @@ class labelledSpin(QtWidgets.QWidget):
self.simpleSpin.setEditability(False) self.simpleSpin.setEditability(False)
self.simpleSpin.style().polish(self.simpleSpin) self.simpleSpin.style().polish(self.simpleSpin)
self.unitLabel = QtWidgets.QLabel(self.units) self.unitLabel = QtWidgets.QLabel()
self.unitLabel.setFont(NativeUI.text_font) self.unitLabel.setFont(NativeUI.text_font)
self.unitLabel.setStyleSheet(textStyle) self.unitLabel.setStyleSheet(textStyle)
self.unitLabel.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.unitLabel.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
...@@ -202,6 +202,8 @@ class labelledSpin(QtWidgets.QWidget): ...@@ -202,6 +202,8 @@ class labelledSpin(QtWidgets.QWidget):
self.setEnabled(True) self.setEnabled(True)
# self.simpleSpin.valueChanged.connect(self.valChange) # self.simpleSpin.valueChanged.connect(self.valChange)
self.localise_text(NativeUI.text)
def manualStep(self): def manualStep(self):
"""Handle changes in value. Change colour if different to set value, set updating values.""" """Handle changes in value. Change colour if different to set value, set updating values."""
if self.manuallyUpdated: if self.manuallyUpdated:
...@@ -301,3 +303,38 @@ class labelledSpin(QtWidgets.QWidget): ...@@ -301,3 +303,38 @@ class labelledSpin(QtWidgets.QWidget):
self.simpleSpin.stepBy(self.min - self.simpleSpin.value()) self.simpleSpin.stepBy(self.min - self.simpleSpin.value())
self.simpleSpin.setRange(self.min, self.max) self.simpleSpin.setRange(self.min, self.max)
return 0 return 0
def set_size(self, x: int, y: int, spacing: int = 5) -> int:
"""
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 / 4 - spacing)
self.nameLabel.setFixedWidth(x_widget)
self.simpleSpin.setFixedWidth(2 * x_widget)
self.unitLabel.setFixedWidth(x_widget)
if y is not None:
self.setFixedHeight(y)
for widget in self.widgetList:
widget.setFixedHeight(y)
# self.layout.setSpacing(spacing)
return 0
def localise_text(self, text: dict) -> int:
"""
Source the text for the labels from the specified dictionary.
"""
if self.label == "":
self.nameLabel.setText("")
else:
self.nameLabel.setText(text[self.tag])
if self.units == "":
self.unitLabel.setText("")
else:
self.unitLabel.setText(text[self.units])
return 0
...@@ -256,6 +256,12 @@ class AbstractTypeValPopup(QtWidgets.QDialog): ...@@ -256,6 +256,12 @@ class AbstractTypeValPopup(QtWidgets.QDialog):
def get_value(self): def get_value(self):
return self.lineEdit.text() return self.lineEdit.text()
def localise_text(self, text: dict) -> int:
"""
Change the language of text elements.
"""
pass
# #
# class TypeValuePopup(): # class TypeValuePopup():
......
...@@ -15,6 +15,7 @@ __status__ = "Prototype" ...@@ -15,6 +15,7 @@ __status__ = "Prototype"
import logging import logging
from PySide2 import QtCore, QtGui, QtWidgets from PySide2 import QtCore, QtGui, QtWidgets
from widget_library.ok_cancel_buttons_widget import OkButtonWidget, CancelButtonWidget from widget_library.ok_cancel_buttons_widget import OkButtonWidget, CancelButtonWidget
from widget_library.localised_base_widgets import LocalisedQStackedWidget
# from global_widgets.global_ok_cancel_buttons import okButton, cancelButton # from global_widgets.global_ok_cancel_buttons import okButton, cancelButton
import time import time
...@@ -42,7 +43,7 @@ class timerConfirmPopup(QtWidgets.QWidget): ...@@ -42,7 +43,7 @@ class timerConfirmPopup(QtWidgets.QWidget):
"border:none" "border:none"
) )
self.stack = QtWidgets.QStackedWidget() self.stack = LocalisedQStackedWidget()
# Define progress bar # Define progress bar
vlayout = QtWidgets.QVBoxLayout() vlayout = QtWidgets.QVBoxLayout()
......
...@@ -4,11 +4,16 @@ handler.py ...@@ -4,11 +4,16 @@ handler.py
from threading import Lock from threading import Lock
from global_widgets.global_spinbox import labelledSpin from global_widgets.global_spinbox import labelledSpin
from widget_library.ok_cancel_buttons_widget import OkButtonWidget, CancelButtonWidget, OkSendButtonWidget from widget_library.ok_cancel_buttons_widget import (
OkButtonWidget,
CancelButtonWidget,
OkSendButtonWidget,
)
from PySide2.QtCore import QObject from PySide2.QtCore import QObject
from PySide2.QtWidgets import QRadioButton from PySide2.QtWidgets import QRadioButton
class GenericDataHandler(QObject): class GenericDataHandler(QObject):
""" """
Base class for non-payload data handlers. Base class for non-payload data handlers.
...@@ -43,6 +48,9 @@ class GenericDataHandler(QObject): ...@@ -43,6 +48,9 @@ class GenericDataHandler(QObject):
""" """
pass pass
def localise_text(self, text: dict) -> int:
pass
class PayloadHandler(GenericDataHandler): class PayloadHandler(GenericDataHandler):
""" """
......
This diff is collapsed.
...@@ -13,14 +13,14 @@ __maintainer__ = "Benjamin Mummery" ...@@ -13,14 +13,14 @@ __maintainer__ = "Benjamin Mummery"
__email__ = "benjamin.mummery@stfc.ac.uk" __email__ = "benjamin.mummery@stfc.ac.uk"
__status__ = "Prototype" __status__ = "Prototype"
from widget_library.LocalisedPushButton import LocalisedPushButton from widget_library.localised_base_widgets import (
from PySide2.QtWidgets import ( LocalisedQStackedWidget,
QWidget, LocalisedQRadioButton,
QRadioButton, LocalisedQPushButton,
QButtonGroup, LocalisedQWidget,
QLabel, LocalisedQLabel,
QStackedWidget,
) )
from PySide2.QtWidgets import QWidget, QButtonGroup
from global_widgets.tab_hold_buttons import timerConfirmPopup from global_widgets.tab_hold_buttons import timerConfirmPopup
from global_widgets.tab_modeswitch_button import TabModeswitchButton from global_widgets.tab_modeswitch_button import TabModeswitchButton
from global_widgets.global_spinbox import labelledSpin from global_widgets.global_spinbox import labelledSpin
...@@ -45,10 +45,7 @@ from widget_library.info_display_widgets import ( ...@@ -45,10 +45,7 @@ from widget_library.info_display_widgets import (
UpdateTimeDisplayWidget, UpdateTimeDisplayWidget,
) )
from widget_library.alarm_control_widget import AlarmControlWidget from widget_library.alarm_control_widget import AlarmControlWidget
# from widget_library.tab_charts import TabChart
from widget_library.chart_buttons_widget import ChartButtonsWidget from widget_library.chart_buttons_widget import ChartButtonsWidget
from widget_library.page_buttons_widget import PageButtonsWidget, PageButton from widget_library.page_buttons_widget import PageButtonsWidget, PageButton
from widget_library.personal_display_widget import PersonalDisplayWidget from widget_library.personal_display_widget import PersonalDisplayWidget
from widget_library.plot_widget import ( from widget_library.plot_widget import (
...@@ -57,28 +54,15 @@ from widget_library.plot_widget import ( ...@@ -57,28 +54,15 @@ from widget_library.plot_widget import (
TimePlotsWidget, TimePlotsWidget,
) )
from widget_library.spin_buttons_widget import SpinButton from widget_library.spin_buttons_widget import SpinButton
# from widget_library.tab_expert import TabExpert
from widget_library.ventilator_start_stop_buttons_widget import ( from widget_library.ventilator_start_stop_buttons_widget import (
VentilatorStartStopButtonsWidget, VentilatorStartStopButtonsWidget,
) )
from widget_library.line_edit_widget import LabelledLineEditWidget from widget_library.line_edit_widget import LabelledLineEditWidget
from global_widgets.global_typeval_popup import AbstractTypeValPopup from global_widgets.global_typeval_popup import AbstractTypeValPopup
# from widget_library.NativeUI.expert_handler import ExpertHandler
# from mode_widgets.NativeUI.personal_handler import PersonalHandler
# from widget_library.tab_expert import TabExpert
# from widget_library.tab_charts import TabChart
from alarm_widgets.alarm_handler import AlarmHandler from alarm_widgets.alarm_handler import AlarmHandler
from alarm_widgets.alarm_list import AlarmList from alarm_widgets.alarm_list import AlarmList
from alarm_widgets.alarm_popup import AlarmPopup from alarm_widgets.alarm_popup import AlarmPopup
from alarm_widgets.alarm_table import AlarmTable from alarm_widgets.alarm_table import AlarmTable
# from alarm_widgets.tab_alarm_table import TabAlarmTable
# from alarm_widgets.tab_clinical import TabClinical
import json import json
import os import os
import shutil import shutil
...@@ -95,12 +79,19 @@ class Widgets: ...@@ -95,12 +79,19 @@ class Widgets:
""" """
# NativeUI = NativeUI # NativeUI = NativeUI
self.widget_list = []
# Start up procedure # Start up procedure
self.startup_confirm_popup = SetConfirmPopup(NativeUI) self.startup_confirm_popup = SetConfirmPopup(NativeUI)
self.startup_handler = StartupHandler(NativeUI, self.startup_confirm_popup) self.startup_handler = StartupHandler(NativeUI, self.startup_confirm_popup)
self.localisation_startup_button = LocalisedPushButton( self.localisation_startup_button = LocalisedQPushButton(
NativeUI, "language_name" NativeUI, "language_name"
) )
self.widget_list = self.widget_list + [
self.startup_confirm_popup,
self.startup_handler,
self.localisation_startup_button,
]
if not os.path.isfile("NativeUI/configs/startup_config.json"): if not os.path.isfile("NativeUI/configs/startup_config.json"):
logging.warning( logging.warning(
...@@ -122,7 +113,9 @@ class Widgets: ...@@ -122,7 +113,9 @@ class Widgets:
for mode in NativeUI.modeList: for mode in NativeUI.modeList:
self.add_handled_widget( self.add_handled_widget(
QRadioButton(mode), "startup_radio_" + mode, self.startup_handler LocalisedQRadioButton(mode),
"startup_radio_" + mode,
self.startup_handler,
) )
self.add_handled_widget( self.add_handled_widget(
...@@ -146,6 +139,14 @@ class Widgets: ...@@ -146,6 +139,14 @@ class Widgets:
) )
self.alarm_control = AlarmControlWidget(NativeUI) self.alarm_control = AlarmControlWidget(NativeUI)
self.alarm_control_startup = AlarmControlWidget(NativeUI, test=True) self.alarm_control_startup = AlarmControlWidget(NativeUI, test=True)
self.widget_list = self.widget_list + [
self.tab_modeswitch,
self.battery_display,
self.personal_display,
self.localisation_button,
self.alarm_control,
self.alarm_control_startup,
]
# Left Bar widgets # Left Bar widgets
self.standby_timer = timerConfirmPopup(NativeUI, "popup_hold_standby") self.standby_timer = timerConfirmPopup(NativeUI, "popup_hold_standby")
...@@ -157,6 +158,13 @@ class Widgets: ...@@ -157,6 +158,13 @@ class Widgets:
self.lock_button = PageButton( self.lock_button = PageButton(
NativeUI, "", signal_value="lock_screen", icon=NativeUI.icons["lock_screen"] NativeUI, "", signal_value="lock_screen", icon=NativeUI.icons["lock_screen"]
) )
self.widget_list = self.widget_list + [
self.standby_timer,
self.stop_timer,
self.page_buttons,
self.ventilator_start_stop_buttons_widget,
self.lock_button,
]
# Main Page Widgets # Main Page Widgets
self.history_buttons = HistoryButtonsWidget(NativeUI) self.history_buttons = HistoryButtonsWidget(NativeUI)
...@@ -165,16 +173,31 @@ class Widgets: ...@@ -165,16 +173,31 @@ class Widgets:
self.normal_measurements = NormalMeasurementsBlockWidget(NativeUI) self.normal_measurements = NormalMeasurementsBlockWidget(NativeUI)
self.circle_plots = CirclePlotsWidget(NativeUI) self.circle_plots = CirclePlotsWidget(NativeUI)
self.detailed_measurements = ExpertMeasurementsBloackWidget(NativeUI) self.detailed_measurements = ExpertMeasurementsBloackWidget(NativeUI)
self.widget_list = self.widget_list + [
self.history_buttons,
self.normal_plots,
self.normal_measurements,
self.circle_plots,
self.detailed_measurements,
]
# Alarm Page Widgets # Alarm Page Widgets
self.alarm_handler = AlarmHandler(NativeUI) self.alarm_handler = AlarmHandler(NativeUI)
self.alarm_popup = AlarmPopup(NativeUI) self.alarm_popup = AlarmPopup(NativeUI)
self.alarm_list = AlarmList(NativeUI) self.alarm_list = AlarmList(NativeUI)
self.acknowledge_button = LocalisedPushButton( self.acknowledge_button = LocalisedQPushButton(
NativeUI, "button_label_alarms_list_reset_alarms" NativeUI, "button_label_alarms_list_reset_alarms"
) )
self.alarm_table = AlarmTable(NativeUI) self.alarm_table = AlarmTable(NativeUI)
self.clinical_tab = QWidget() # TabClinical(NativeUI) self.clinical_tab = LocalisedQWidget() # TabClinical(NativeUI)
self.widget_list = self.widget_list + [
self.alarm_handler,
self.alarm_popup,
self.alarm_list,
self.acknowledge_button,
self.alarm_table,
self.clinical_tab,
]
### Alarm limits ### Alarm limits
with open("NativeUI/configs/clinical_config.json") as json_file: with open("NativeUI/configs/clinical_config.json") as json_file:
...@@ -227,7 +250,7 @@ class Widgets: ...@@ -227,7 +250,7 @@ class Widgets:
modes = NativeUI.modeList modes = NativeUI.modeList
self.add_handled_widget( self.add_handled_widget(
QStackedWidget(), "main_mode_stack", NativeUI.mode_handler LocalisedQStackedWidget(), "main_mode_stack", NativeUI.mode_handler
) )
for setting in modeDict["settings"]: for setting in modeDict["settings"]:
if setting[0] in modeDict["mainPageSettings"]: if setting[0] in modeDict["mainPageSettings"]:
...@@ -278,7 +301,7 @@ class Widgets: ...@@ -278,7 +301,7 @@ class Widgets:
) )
if setting[0] in radioSettings: if setting[0] in radioSettings:
radioButton = QRadioButton() radioButton = LocalisedQRadioButton()
self.groupDict[mode + startup].addButton(radioButton) self.groupDict[mode + startup].addButton(radioButton)
if startup == "_startup": if startup == "_startup":
self.add_handled_widget( self.add_handled_widget(
...@@ -362,7 +385,7 @@ class Widgets: ...@@ -362,7 +385,7 @@ class Widgets:
) )
##### Settings Tab: Expert and Charts tabs ##### Settings Tab: Expert and Charts tabs
self.add_widget(QStackedWidget(), "expert_passlock_stack") self.add_widget(LocalisedQStackedWidget(), "expert_passlock_stack")
self.add_handled_widget( self.add_handled_widget(
AbstractTypeValPopup(NativeUI, "alpha"), AbstractTypeValPopup(NativeUI, "alpha"),
"expert_password_widget", "expert_password_widget",
...@@ -375,7 +398,7 @@ class Widgets: ...@@ -375,7 +398,7 @@ class Widgets:
for key in controlDict: for key in controlDict:
self.add_widget(QLabel(key), "expert_label_" + key) self.add_widget(LocalisedQLabel(key), "expert_label_" + key)
for setting in controlDict[key]: for setting in controlDict[key]:
attrName = "expert_spin_" + setting[2] attrName = "expert_spin_" + setting[2]
self.add_handled_widget( self.add_handled_widget(
...@@ -399,8 +422,12 @@ class Widgets: ...@@ -399,8 +422,12 @@ class Widgets:
) )
# Chart Tab # Chart Tab
self.charts_widget = ChartsPlotWidget(colors=NativeUI.colors) # self.charts_widget = ChartsPlotWidget(colors=NativeUI.colors)
self.chart_buttons_widget = ChartButtonsWidget(colors=NativeUI.colors) # self.chart_buttons_widget = ChartButtonsWidget(colors=NativeUI.colors)
# self.widget_list = self.widget_list + [
# self.charts_widget,
# self.chart_buttons_widget,
# ]
# Info Tab # Info Tab
self.version_display_widget = VersionDisplayWidget(NativeUI.colors) self.version_display_widget = VersionDisplayWidget(NativeUI.colors)
...@@ -408,15 +435,22 @@ class Widgets: ...@@ -408,15 +435,22 @@ class Widgets:
NativeUI.colors NativeUI.colors
) )
self.update_time_display_widget = UpdateTimeDisplayWidget(NativeUI.colors) self.update_time_display_widget = UpdateTimeDisplayWidget(NativeUI.colors)
self.widget_list = self.widget_list + [
self.version_display_widget,
self.maintenance_time_display_widget,
self.update_time_display_widget,
]
def add_widget(self, widget, name) -> int: def add_widget(self, widget, name) -> int:
setattr(self, name, widget) setattr(self, name, widget)
self.widget_list.append(getattr(self, name))
return 0 return 0
def add_handled_widget(self, widget, name, handler) -> int: def add_handled_widget(self, widget, name, handler) -> int:
"""Add a widget to Widgets and pass it into a handler""" """Add a widget to Widgets and pass it into a handler"""
setattr(self, name, widget) setattr(self, name, widget)
handler.add_widget(widget, name) handler.add_widget(widget, name)
self.widget_list.append(getattr(self, name))
return 0 return 0
def get_widget(self, name) -> QWidget: def get_widget(self, name) -> QWidget:
......
...@@ -15,8 +15,8 @@ __status__ = "Prototype" ...@@ -15,8 +15,8 @@ __status__ = "Prototype"
from PySide2 import QtWidgets, QtGui, QtCore from PySide2 import QtWidgets, QtGui, QtCore
import os import os
class AlarmControlWidget(QtWidgets.QWidget):
class AlarmControlWidget(QtWidgets.QWidget):
def __init__(self, NativeUI, test=False, *args, **kwargs): def __init__(self, NativeUI, test=False, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
"""Button controlling alarm volume and mute. There are 3 volume options and a mute button """ """Button controlling alarm volume and mute. There are 3 volume options and a mute button """
...@@ -24,39 +24,52 @@ class AlarmControlWidget(QtWidgets.QWidget): ...@@ -24,39 +24,52 @@ class AlarmControlWidget(QtWidgets.QWidget):
self.volState = 2 self.volState = 2
nVolSteps = 3 nVolSteps = 3
self.volButtonsList = [] self.volButtonsList = []
self.volTruth = [0]*nVolSteps self.volTruth = [0] * nVolSteps
hlayout = QtWidgets.QHBoxLayout() hlayout = QtWidgets.QHBoxLayout()
for i in range(0,nVolSteps): for i in range(0, nVolSteps):
self.volButtonsList.append(QtWidgets.QPushButton()) self.volButtonsList.append(QtWidgets.QPushButton())
self.volButtonsList[-1].setStyleSheet( self.volButtonsList[-1].setStyleSheet(
"QPushButton{" "QPushButton{"
" background-color:"+ NativeUI.colors["page_foreground"].name() + "; border:none;" " background-color:"
+ NativeUI.colors["page_foreground"].name()
+ "; border:none;"
"}" "}"
"QPushButton[bgColour='1']{" "QPushButton[bgColour='1']{"
" background-color:" + NativeUI.colors["button_background_highlight"].name() + ";border: none;" " background-color:"
+ NativeUI.colors["button_background_highlight"].name()
+ ";border: none;"
"}" "}"
"QPushButton[bgColour='0']{" "QPushButton[bgColour='0']{"
" background-color:" + NativeUI.colors["page_foreground"].name() + "; border:none;" " background-color:"
"}") + NativeUI.colors["page_foreground"].name()
self.volButtonsList[-1].pressed.connect(lambda k = i: self.buttonPushed(k)) + "; border:none;"
"}"
)
self.volButtonsList[-1].pressed.connect(lambda k=i: self.buttonPushed(k))
hlayout.addWidget(self.volButtonsList[-1]) hlayout.addWidget(self.volButtonsList[-1])
self.buttonPushed(self.volState) self.buttonPushed(self.volState)
self.iconStack = QtWidgets.QStackedWidget() self.iconStack = QtWidgets.QStackedWidget()
self.onSpeakers = QtWidgets.QPushButton() self.onSpeakers = QtWidgets.QPushButton()
self.onSpeakers.pressed.connect(self.mute_pressed) self.onSpeakers.pressed.connect(self.mute_pressed)
self.onSpeakers.setStyleSheet('background-color: ' + NativeUI.colors['button_background_enabled'].name() + '; border:none;') self.onSpeakers.setStyleSheet(
"background-color: "
+ NativeUI.colors["button_background_enabled"].name()
+ "; border:none;"
)
self.iconStack.addWidget(self.onSpeakers) self.iconStack.addWidget(self.onSpeakers)
self.offSpeakers = QtWidgets.QPushButton() self.offSpeakers = QtWidgets.QPushButton()
self.offSpeakers.pressed.connect(self.unmute_pressed) self.offSpeakers.pressed.connect(self.unmute_pressed)
self.offSpeakers.setStyleSheet( self.offSpeakers.setStyleSheet(
'background-color: ' + NativeUI.colors['button_background_enabled'].name() + '; border:none;') "background-color: "
+ NativeUI.colors["button_background_enabled"].name()
+ "; border:none;"
)
self.iconStack.addWidget(self.offSpeakers) self.iconStack.addWidget(self.offSpeakers)
hlayout.addWidget(self.iconStack) hlayout.addWidget(self.iconStack)
if test: if test:
self.testSpeakers = QtWidgets.QPushButton('Test Alarm') self.testSpeakers = QtWidgets.QPushButton("Test Alarm")
self.setMaximumHeight(100) self.setMaximumHeight(100)
self.iconStack.addWidget(self.testSpeakers) self.iconStack.addWidget(self.testSpeakers)
self.iconStack.setCurrentWidget(self.testSpeakers) self.iconStack.setCurrentWidget(self.testSpeakers)
...@@ -76,16 +89,18 @@ class AlarmControlWidget(QtWidgets.QWidget): ...@@ -76,16 +89,18 @@ class AlarmControlWidget(QtWidgets.QWidget):
pixmap.setMask(mask) pixmap.setMask(mask)
self.offSpeakers.setIcon(QtGui.QIcon(pixmap)) self.offSpeakers.setIcon(QtGui.QIcon(pixmap))
self.timeLabel = QtWidgets.QLabel('') self.timeLabel = QtWidgets.QLabel("")
self.timeLabel.setFont(NativeUI.value_font) self.timeLabel.setFont(NativeUI.value_font)
self.timeLabel.setStyleSheet("color:" + NativeUI.colors["page_foreground"].name() + ";") self.timeLabel.setStyleSheet(
"color:" + NativeUI.colors["page_foreground"].name() + ";"
)
hlayout.addWidget(self.timeLabel) hlayout.addWidget(self.timeLabel)
self.setLayout(hlayout) self.setLayout(hlayout)
self.timer = QtCore.QTimer() self.timer = QtCore.QTimer()
self.timer.setInterval(1000) # just faster than 60Hz self.timer.setInterval(1000) # just faster than 60Hz
self.timer.timeout.connect(self.mute_timer) self.timer.timeout.connect(self.mute_timer)
#self.timer.start() # self.timer.start()
def mute_timer(self): def mute_timer(self):
self.remaining_mute_time += -1 self.remaining_mute_time += -1
...@@ -104,47 +119,53 @@ class AlarmControlWidget(QtWidgets.QWidget): ...@@ -104,47 +119,53 @@ class AlarmControlWidget(QtWidgets.QWidget):
def unmute_pressed(self): def unmute_pressed(self):
self.timer.stop() self.timer.stop()
self.remaining_mute_time = 120 self.remaining_mute_time = 120
self.timeLabel.setText('') self.timeLabel.setText("")
self.buttonPushed(self.volState) self.buttonPushed(self.volState)
self.iconStack.setCurrentWidget(self.onSpeakers) self.iconStack.setCurrentWidget(self.onSpeakers)
self.NativeUI.q_send_cmd("MUTE_ALARM", "FALSE") self.NativeUI.q_send_cmd("MUTE_ALARM", "FALSE")
def test_speakers(self): def test_speakers(self):
print('testin!') print("testin!")
print(self.volState) print(self.volState)
self.NativeUI.q_send_cmd("TEST_AUDIO_ALARM") self.NativeUI.q_send_cmd("TEST_AUDIO_ALARM")
def buttonPushed(self, index): def buttonPushed(self, index):
if index != -1: if index != -1:
self.volState = index self.volState = index
for i in range(0,index+1): for i in range(0, index + 1):
#self.volTruth[i] = int(not self.volTruth[i] # self.volTruth[i] = int(not self.volTruth[i]
self.volButtonsList[i].setProperty("bgColour", str(1)) self.volButtonsList[i].setProperty("bgColour", str(1))
self.volButtonsList[i].style().polish(self.volButtonsList[i]) self.volButtonsList[i].style().polish(self.volButtonsList[i])
for i in range(index+1, len(self.volButtonsList)): for i in range(index + 1, len(self.volButtonsList)):
self.volButtonsList[i].setProperty("bgColour", str(0)) self.volButtonsList[i].setProperty("bgColour", str(0))
self.volButtonsList[i].style().polish(self.volButtonsList[i]) self.volButtonsList[i].style().polish(self.volButtonsList[i])
#self.volButtonsList[i].style().polish(self.volButtonsList[index]) # self.volButtonsList[i].style().polish(self.volButtonsList[index])
self.style().polish(self) self.style().polish(self)
if index == -1: if index == -1:
for i in range(0, len(self.volButtonsList)): for i in range(0, len(self.volButtonsList)):
self.volButtonsList[i].setProperty("bgColour", str(0)) self.volButtonsList[i].setProperty("bgColour", str(0))
self.volButtonsList[i].style().polish(self.volButtonsList[i]) self.volButtonsList[i].style().polish(self.volButtonsList[i])
elif index >=0: elif index >= 0:
self.NativeUI.q_send_cmd("SET_VOLUME", index) self.NativeUI.q_send_cmd("SET_VOLUME", index)
def set_size(self, x: int, y: int, spacing=10) -> int: def set_size(self, x: int, y: int, spacing=10) -> int:
self.setFixedSize(x, y) self.setFixedSize(x, y)
return 0 return 0
def localise_text(self, text: dict) -> int:
"""
Change the language of text elements.
"""
pass
if __name__ == "__main__": if __name__ == "__main__":
import sys import sys
app = QtWidgets.QApplication(sys.argv) app = QtWidgets.QApplication(sys.argv)
widg = AlarmControlButton('a') widg = AlarmControlButton("a")
widg.show() widg.show()
sys.exit(app.exec_()) sys.exit(app.exec_())
...@@ -93,6 +93,12 @@ class BatteryDisplayWidget(QtWidgets.QWidget): ...@@ -93,6 +93,12 @@ class BatteryDisplayWidget(QtWidgets.QWidget):
self.text_display.setFont(font) self.text_display.setFont(font)
return 0 return 0
def localise_text(self, text: dict) -> int:
"""
Change the language of text elements.
"""
pass
class BatteryText(QtWidgets.QLabel): class BatteryText(QtWidgets.QLabel):
"""""" """"""
......
...@@ -131,6 +131,12 @@ class HistoryButtonsWidget(QtWidgets.QWidget): ...@@ -131,6 +131,12 @@ class HistoryButtonsWidget(QtWidgets.QWidget):
button.setFont(font) button.setFont(font)
return 0 return 0
def localise_text(self, text: dict) -> int:
"""
Change the language of text elements.
"""
pass
class HistoryButton(QtWidgets.QPushButton): class HistoryButton(QtWidgets.QPushButton):
""" """
......
...@@ -101,6 +101,12 @@ class VersionDisplayWidget(QtWidgets.QLabel): ...@@ -101,6 +101,12 @@ class VersionDisplayWidget(QtWidgets.QLabel):
self.setFixedSize(x, y) self.setFixedSize(x, y)
return 0 return 0
def localise_text(self, text: dict) -> int:
"""
Change the language of text elements.
"""
pass
class MaintenanceTimeDisplayWidget(QtWidgets.QLabel): class MaintenanceTimeDisplayWidget(QtWidgets.QLabel):
""" """
...@@ -155,6 +161,12 @@ class MaintenanceTimeDisplayWidget(QtWidgets.QLabel): ...@@ -155,6 +161,12 @@ class MaintenanceTimeDisplayWidget(QtWidgets.QLabel):
self.__maintenance_needed = maintenance_needed self.__maintenance_needed = maintenance_needed
return self.__refresh_display() return self.__refresh_display()
def localise_text(self, text: dict) -> int:
"""
Change the language of text elements.
"""
pass
class UpdateTimeDisplayWidget(QtWidgets.QLabel): class UpdateTimeDisplayWidget(QtWidgets.QLabel):
""" """
...@@ -208,3 +220,9 @@ class UpdateTimeDisplayWidget(QtWidgets.QLabel): ...@@ -208,3 +220,9 @@ class UpdateTimeDisplayWidget(QtWidgets.QLabel):
self.__time_to_update_check = time_to_update_check self.__time_to_update_check = time_to_update_check
self.__update_check_needed = update_check_needed self.__update_check_needed = update_check_needed
return self.__refresh_display() return self.__refresh_display()
def localise_text(self, text: dict) -> int:
"""
Change the language of text elements.
"""
pass
from PySide2 import QtWidgets, QtGui, QtCore from PySide2 import QtWidgets, QtGui, QtCore
#from global_widgets.global_typeval_popup import TypeValuePopup
# from global_widgets.global_typeval_popup import TypeValuePopup
class SignallingLineEditWidget(QtWidgets.QLineEdit): class SignallingLineEditWidget(QtWidgets.QLineEdit):
...@@ -10,11 +11,11 @@ class SignallingLineEditWidget(QtWidgets.QLineEdit): ...@@ -10,11 +11,11 @@ class SignallingLineEditWidget(QtWidgets.QLineEdit):
self.installEventFilter(self) self.installEventFilter(self)
self.label_text = label self.label_text = label
self.NativeUI = NativeUI self.NativeUI = NativeUI
self.popUp = popup#NativeUI.typeValPopupAlpha self.popUp = popup # NativeUI.typeValPopupAlpha
#self.popUp = TypeValuePopup(NativeUI)#,'text edit',0,1,2,3,4) # self.popUp = TypeValuePopup(NativeUI)#,'text edit',0,1,2,3,4)
#self.popUp.lineEdit.setValidator(None) # nsure it accepts text # self.popUp.lineEdit.setValidator(None) # nsure it accepts text
#self.popUp.okButton.clicked.connect(self.okButtonPressed) # self.popUp.okButton.clicked.connect(self.okButtonPressed)
#self.popUp.cancelButton.clicked.connect(self.cancelButtonPressed) # self.popUp.cancelButton.clicked.connect(self.cancelButtonPressed)
def okButtonPressed(self): def okButtonPressed(self):
val = self.popUp.lineEdit.text() val = self.popUp.lineEdit.text()
...@@ -53,21 +54,23 @@ class LabelledLineEditWidget(QtWidgets.QWidget): ...@@ -53,21 +54,23 @@ class LabelledLineEditWidget(QtWidgets.QWidget):
infoArray infoArray
) )
elif len(infoArray) == 6: elif len(infoArray) == 6:
self.label, self.units, self.tag, self.cmd_type, self.cmd_code, self.initText = infoArray self.label, self.units, self.tag, self.cmd_type, self.cmd_code, self.initText = (
infoArray
)
elif len(infoArray) == 3: elif len(infoArray) == 3:
self.label, self.units, self.tag = infoArray self.label, self.units, self.tag = infoArray
self.manuallyUpdated = False self.manuallyUpdated = False
layout = QtWidgets.QHBoxLayout() layout = QtWidgets.QHBoxLayout()
widgetList = [] self.widgetList = []
if self.label != "": # if self.label != "":
self.label == "etst" self.nameLabel = QtWidgets.QLabel()
self.nameLabel = QtWidgets.QLabel(self.label)
self.nameLabel.setFont(NativeUI.text_font) self.nameLabel.setFont(NativeUI.text_font)
self.nameLabel.setStyleSheet("color:" + NativeUI.colors["page_foreground"].name() + ";") self.nameLabel.setStyleSheet(
"color:" + NativeUI.colors["page_foreground"].name() + ";"
)
self.nameLabel.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.nameLabel.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
widgetList.append(self.nameLabel) self.widgetList.append(self.nameLabel)
self.simpleSpin = SignallingLineEditWidget(NativeUI, popup, self.label) self.simpleSpin = SignallingLineEditWidget(NativeUI, popup, self.label)
self.simpleSpin.setText(self.initText) self.simpleSpin.setText(self.initText)
...@@ -100,35 +103,72 @@ class LabelledLineEditWidget(QtWidgets.QWidget): ...@@ -100,35 +103,72 @@ class LabelledLineEditWidget(QtWidgets.QWidget):
if self.cmd_type == "": if self.cmd_type == "":
self.simpleSpin.setReadOnly(True) self.simpleSpin.setReadOnly(True)
self.simpleSpin.setProperty("bgColour", "1") self.simpleSpin.setProperty("bgColour", "1")
widgetList.append(self.simpleSpin) self.widgetList.append(self.simpleSpin)
#if self.units != "": # if self.units != "":
self.unitLabel = QtWidgets.QLabel(self.units) self.unitLabel = QtWidgets.QLabel()
self.unitLabel.setFont(NativeUI.text_font) self.unitLabel.setFont(NativeUI.text_font)
self.unitLabel.setStyleSheet("color:" + NativeUI.colors["page_foreground"].name() + "") self.unitLabel.setStyleSheet(
self.unitLabel.setAlignment(QtCore.Qt.AlignLeft| QtCore.Qt.AlignVCenter) "color:" + NativeUI.colors["page_foreground"].name() + ""
widgetList.append(self.unitLabel) )
self.unitLabel.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
self.widgetList.append(self.unitLabel)
for widget in widgetList: for widget in self.widgetList:
layout.addWidget(widget) layout.addWidget(widget)
self.setLayout(layout) self.setLayout(layout)
self.localise_text(NativeUI.text)
def textUpdate(self): def textUpdate(self):
self.manuallyUpdated = True self.manuallyUpdated = True
self.simpleSpin.setProperty("textColour", "2") self.simpleSpin.setProperty("textColour", "2")
self.simpleSpin.style().polish(self.simpleSpin) self.simpleSpin.style().polish(self.simpleSpin)
def update_value(self, db):
def update_value(self,db):
newVal = db[self.tag] newVal = db[self.tag]
if newVal == {}: if newVal == {}:
a = 1 # do nothing a = 1 # do nothing
else: else:
print('got a personal db') print("got a personal db")
self.simpleSpin.setText(newVal) self.simpleSpin.setText(newVal)
self.simpleSpin.setProperty("textColour", "1") self.simpleSpin.setProperty("textColour", "1")
self.simpleSpin.style().polish(self.simpleSpin) self.simpleSpin.style().polish(self.simpleSpin)
def get_value(self): def get_value(self):
return self.simpleSpin.text() return self.simpleSpin.text()
def set_size(self, x: int, y: int, spacing: int = 5) -> int:
"""
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 / 4 - spacing)
self.nameLabel.setFixedWidth(x_widget)
self.simpleSpin.setFixedWidth(2 * x_widget)
self.unitLabel.setFixedWidth(x_widget)
if y is not None:
self.setFixedHeight(y)
for widget in self.widgetList:
widget.setFixedHeight(y)
# self.layout.setSpacing(spacing)
return 0
def localise_text(self, text: dict) -> int:
"""
Source the text for the labels from the specified dictionary.
"""
if self.label == "":
self.nameLabel.setText("")
else:
self.nameLabel.setText(text[self.tag])
if self.units == "":
self.unitLabel.setText("")
else:
self.unitLabel.setText(text[self.units])
return 0
...@@ -114,3 +114,9 @@ class LocalisationButtonWidget(QtWidgets.QWidget): ...@@ -114,3 +114,9 @@ class LocalisationButtonWidget(QtWidgets.QWidget):
self.localisation_button.click() self.localisation_button.click()
return 0 return 0
def localise_text(self, text: dict) -> int:
"""
Change the language of text elements.
"""
pass
from PySide2 import QtWidgets from PySide2 import QtWidgets
class LocalisedPushButton(QtWidgets.QPushButton): class LocalisedQPushButton(QtWidgets.QPushButton):
def __init__(self, NativeUI, text_key, *args, **kwargs): def __init__(self, NativeUI, text_key, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.text_key = text_key self.text_key = text_key
...@@ -33,3 +33,58 @@ class LocalisedPushButton(QtWidgets.QPushButton): ...@@ -33,3 +33,58 @@ class LocalisedPushButton(QtWidgets.QPushButton):
if y is not None: if y is not None:
self.setFixedHeight(y) self.setFixedHeight(y)
return 0 return 0
class LocalisedQRadioButton(QtWidgets.QRadioButton):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def localise_text(self, text: dict) -> int:
"""
Change the language of text elements.
"""
pass
class LocalisedQWidget(QtWidgets.QWidget):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def localise_text(self, text: dict) -> int:
"""
Change the language of text elements.
"""
pass
class LocalisedQStackedWidget(QtWidgets.QStackedWidget):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def localise_text(self, text: dict) -> int:
"""
Change the language of text elements.
"""
pass
class LocalisedQLabel(QtWidgets.QLabel):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def localise_text(self, text: dict) -> int:
"""
Change the language of text elements.
"""
pass
class LocalisedQDialog(QtWidgets.QDialog):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def localise_text(self, text: dict) -> int:
"""
Change the language of text elements.
"""
pass
...@@ -52,6 +52,12 @@ class styledButton(QtWidgets.QPushButton): ...@@ -52,6 +52,12 @@ class styledButton(QtWidgets.QPushButton):
self.setProperty("bgColour", str(option)) self.setProperty("bgColour", str(option))
self.style().polish(self) self.style().polish(self)
def localise_text(self, text: dict) -> int:
"""
Change the language of text elements.
"""
pass
class OkButtonWidget(styledButton): class OkButtonWidget(styledButton):
def __init__(self, NativeUI, *args, **kwargs): def __init__(self, NativeUI, *args, **kwargs):
......
...@@ -156,6 +156,12 @@ class PageButtonsWidget(QtWidgets.QWidget): ...@@ -156,6 +156,12 @@ class PageButtonsWidget(QtWidgets.QWidget):
return 0 return 0
def localise_text(self, text: dict) -> int:
"""
Change the language of text elements.
"""
pass
class PageButton(QtWidgets.QPushButton): class PageButton(QtWidgets.QPushButton):
PageButtonPressed = Signal(str) PageButtonPressed = Signal(str)
......
...@@ -74,3 +74,9 @@ class PersonalDisplayWidget(QtWidgets.QWidget): ...@@ -74,3 +74,9 @@ class PersonalDisplayWidget(QtWidgets.QWidget):
outtxt = "{name}, {height}m".format(**new_info) outtxt = "{name}, {height}m".format(**new_info)
self.info_label.set_text(outtxt) self.info_label.set_text(outtxt)
return 0 return 0
def localise_text(self, text: dict) -> int:
"""
Source the text for the labels from the specified dictionary.
"""
pass
...@@ -15,7 +15,7 @@ __status__ = "Prototype" ...@@ -15,7 +15,7 @@ __status__ = "Prototype"
from PySide2 import QtWidgets, QtGui, QtCore from PySide2 import QtWidgets, QtGui, QtCore
from datetime import datetime from datetime import datetime
import os import os
from widget_library.LocalisedPushButton import LocalisedPushButton from widget_library.localised_base_widgets import LocalisedQPushButton
import logging import logging
...@@ -27,7 +27,7 @@ class calibrationWidget(QtWidgets.QWidget): ...@@ -27,7 +27,7 @@ class calibrationWidget(QtWidgets.QWidget):
self.infoDict = infoDict self.infoDict = infoDict
hlayout = QtWidgets.QHBoxLayout() hlayout = QtWidgets.QHBoxLayout()
self.button = LocalisedPushButton(NativeUI, infoDict["label"]) self.button = LocalisedQPushButton(NativeUI, infoDict["label"])
hlayout.addWidget(self.button) hlayout.addWidget(self.button)
self.progBar = QtWidgets.QProgressBar() self.progBar = QtWidgets.QProgressBar()
......
...@@ -144,3 +144,9 @@ class StartupHandler( ...@@ -144,3 +144,9 @@ class StartupHandler(
for mode in self.NativeUI.modeList: for mode in self.NativeUI.modeList:
if mode in key: if mode in key:
return mode return mode
def localise_text(self, text: dict) -> int:
"""
Change the language of text elements.
"""
pass
...@@ -3,6 +3,8 @@ New version of what was template_main_pages. ...@@ -3,6 +3,8 @@ New version of what was template_main_pages.
""" """
from PySide2 import QtWidgets from PySide2 import QtWidgets
from PySide2.QtGui import QFont from PySide2.QtGui import QFont
from ui_widgets import LocalisedQStackedWidget
from widget_library.localised_base_widgets import LocalisedQStackedWidget
class SwitchableStackWidget(QtWidgets.QWidget): class SwitchableStackWidget(QtWidgets.QWidget):
...@@ -41,7 +43,7 @@ class SwitchableStackWidget(QtWidgets.QWidget): ...@@ -41,7 +43,7 @@ class SwitchableStackWidget(QtWidgets.QWidget):
""" """
vlayout = QtWidgets.QVBoxLayout() vlayout = QtWidgets.QVBoxLayout()
hButtonLayout = QtWidgets.QHBoxLayout() hButtonLayout = QtWidgets.QHBoxLayout()
self.stack = QtWidgets.QStackedWidget() self.stack = LocalisedQStackedWidget()
assert len(self.widget_list) == len(self.button_list) assert len(self.widget_list) == len(self.button_list)
...@@ -109,6 +111,8 @@ class SwitchableStackWidget(QtWidgets.QWidget): ...@@ -109,6 +111,8 @@ class SwitchableStackWidget(QtWidgets.QWidget):
def localise_text(self, text: dict) -> int: def localise_text(self, text: dict) -> int:
for button in self.button_list: for button in self.button_list:
button.localise_text(text) button.localise_text(text)
for widget in self.widget_list:
widget.localise_text(text)
return 0 return 0
......
...@@ -29,7 +29,7 @@ class TabExpert(TemplateSetValues): ...@@ -29,7 +29,7 @@ class TabExpert(TemplateSetValues):
"Buffers": [ "Buffers": [
[ [
"Calibration", "Calibration",
"ms", "unit_ms",
"duration_calibration", "duration_calibration",
"SET_DURATION", "SET_DURATION",
"CALIBRATION", "CALIBRATION",
...@@ -38,19 +38,37 @@ class TabExpert(TemplateSetValues): ...@@ -38,19 +38,37 @@ class TabExpert(TemplateSetValues):
50, 50,
0, 0,
], ],
["Purge", "ms", "duration_buff_purge", "SET_DURATION", "BUFF_PURGE"], [
["Flush", "ms", "duration_buff_flush", "SET_DURATION", "BUFF_FLUSH"], "Purge",
"unit_ms",
"duration_buff_purge",
"SET_DURATION",
"BUFF_PURGE",
],
[
"Flush",
"unit_ms",
"duration_buff_flush",
"SET_DURATION",
"BUFF_FLUSH",
],
[ [
"Pre-fill", "Pre-fill",
"ms", "unit_ms",
"duration_buff_prefill", "duration_buff_prefill",
"SET_DURATION", "SET_DURATION",
"BUFF_PREFILL", "BUFF_PREFILL",
], ],
["Fill", "ms", "duration_buff_prefill", "SET_DURATION", "BUFF_FILL"], [
"Fill",
"unit_ms",
"duration_buff_prefill",
"SET_DURATION",
"BUFF_FILL",
],
[ [
"Pre-inhale", "Pre-inhale",
"ms", "unit_ms",
"duration_buff_pre_inhale", "duration_buff_pre_inhale",
"SET_DURATION", "SET_DURATION",
"BUFF_PRE_INHALE", "BUFF_PRE_INHALE",
...@@ -79,10 +97,16 @@ class TabExpert(TemplateSetValues): ...@@ -79,10 +97,16 @@ class TabExpert(TemplateSetValues):
["Exhale Opening", "%", "valve_exhale_percent"], ["Exhale Opening", "%", "valve_exhale_percent"],
], ],
"Breathing": [ "Breathing": [
["Inhale", "ms", "duration_inhale", "SET_DURATION", "INHALE"], ["Inhale", "unit_ms", "duration_inhale", "SET_DURATION", "INHALE"],
["Pause", "ms", "duration_pause", "SET_DURATION", "PAUSE"], ["Pause", "unit_ms", "duration_pause", "SET_DURATION", "PAUSE"],
["Exhale fill", "ms", "duration_exhale", "SET_DURATION", "EXHALE_FILL"], [
["Exhale", "ms", "duration_exhale", "SET_DURATION", "EXHALE"], "Exhale fill",
"unit_ms",
"duration_exhale",
"SET_DURATION",
"EXHALE_FILL",
],
["Exhale", "unit_ms", "duration_exhale", "SET_DURATION", "EXHALE"],
["I:E Ratio", "", "inhale_exhale_ratio"], ["I:E Ratio", "", "inhale_exhale_ratio"],
], ],
} }
......
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