Commit 94c54a8e authored by Benjamin Mummery's avatar Benjamin Mummery 💻

Updated colour controls

parent 3c5cda89
Pipeline #955 failed
......@@ -10,7 +10,7 @@ repos:
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 19.10b0
rev: 19.3b0
hooks:
- id: black
language_version: python3.7
......
......@@ -47,6 +47,7 @@ class NativeUI(HEVClient, QMainWindow):
self.colors = {
"background": QColor.fromRgb(30, 30, 30),
"foreground": QColor.fromRgb(200, 200, 200),
"background-enabled": QColor.fromRgb(30, 30, 30),
"background-disabled": QColor.fromRgb(15, 15, 15),
"foreground-disabled": QColor.fromRgb(100, 100, 100),
}
......@@ -54,7 +55,7 @@ class NativeUI(HEVClient, QMainWindow):
# bars
self.topBar = TabTopBar(self)
self.leftBar = TabLeftBar(self, colors=self.colors)
self.leftBar = TabLeftBar(self)
# Views
self.stack = QStackedWidget(self)
......
from PySide2 import QtWidgets, QtGui, QtCore
import os
class okButton(
QtWidgets.QPushButton
): # chose QWidget over QDialog family because easier to modify
def __init__(self, NativeUI, *args, **kwargs):
super().__init__(*args, **kwargs)
iconpath_check = os.path.join(NativeUI.iconpath, "check-solid.png")
self.setIcon(QtGui.QIcon(iconpath_check))
self.setStyleSheet(
"background-color: " + NativeUI.colors["background-enabled"].name() + ";"
"border-radius:4px "
)
class cancelButton(
QtWidgets.QPushButton
): # chose QWidget over QDialog family because easier to modify
def __init__(self, NativeUI, *args, **kwargs):
super().__init__(*args, **kwargs)
iconpath_cross = os.path.join(NativeUI.iconpath, "times-solid.png")
self.setIcon(QtGui.QIcon(iconpath_cross))
self.setStyleSheet(
"background-color: " + NativeUI.colors["background-enabled"].name() + ";"
"border-radius:4px "
)
......@@ -2,21 +2,24 @@ from PySide2 import QtWidgets, QtGui, QtCore
class selectorButton(QtWidgets.QPushButton):
def __init__(self, *args, **kwargs):
def __init__(self, NativeUI, *args, **kwargs):
super(selectorButton, self).__init__(*args, **kwargs)
style = """QPushButton{
font:20pt;
}
QPushButton[selected="0"]{
font:black;
background-color:white ;
border:none;
}
QPushButton[selected="1"]{
font:white;
background-color:black;
border:none;
}""" # border:none is necessary to enact bg colour change
fontsize = 20
style = (
"QPushButton{"
"font: " + str(fontsize) + "pt;"
"}"
"QPushButton[selected='0']{"
"font: " + str(fontsize) + "pt;"
"color: " + NativeUI.colors["foreground"].name() + ";"
"background-color: " + NativeUI.colors["background-enabled"].name() + ";"
"}"
"QPushButton[selected='1']{"
"font: " + str(fontsize) + "pt;"
"color: " + NativeUI.colors["foreground"].name() + ";"
"background-color: " + NativeUI.colors["background-disabled"].name() + ";"
"}"
)
self.setStyleSheet(style)
self.setProperty("selected", "0")
......@@ -18,18 +18,20 @@ class TypeValuePopup(
self.lineEdit = QtWidgets.QLineEdit()
self.lineEdit.setText("4")
self.lineEdit.setStyleSheet(
"""QLineEdit{font: 16pt;
background-color:white;
border-radius:4px }
QLineEdit[colour = "0"]{
color:green
}
QLineEdit[colour = "1"]{
color:rgb(144,231,211);
}
QLineEdit[colour = "2"]{
color:red
}"""
"QLineEdit{"
"font: 16pt;"
"background-color: white;"
"border-radius: 4px;"
"}"
"QLineEdit[colour = '0']{"
"color: green;"
"}"
"QLineEdit[colour = '1']{"
"color: rgb(144, 231, 211);"
"}"
"QLineEdit[colour = '2']{"
"color: red;"
"}"
)
self.lineEdit.setProperty("colour", "1")
self.lineEdit.setAlignment(QtCore.Qt.AlignCenter)
......
......@@ -13,7 +13,7 @@ class TabLeftBar(QtWidgets.QWidget):
TODO
"""
def __init__(self, NativeUI, *args, colors: dict = None, **kwargs):
def __init__(self, NativeUI, *args, **kwargs):
super().__init__(*args, **kwargs)
layout = QtWidgets.QVBoxLayout(self)
......@@ -21,10 +21,10 @@ class TabLeftBar(QtWidgets.QWidget):
button_width = 150
self.tab_page_buttons = TabPageButtons(
NativeUI, colors=colors, size=QSize(button_width, button_width)
NativeUI, size=QSize(button_width, button_width)
)
self.tab_start_stop_buttons = TabStartStopStandbyButtons(
NativeUI, colors=colors, size=QSize(button_width, int(button_width / 3))
NativeUI, size=QSize(button_width, int(button_width / 3))
)
self.widgets = [self.tab_page_buttons, self.tab_start_stop_buttons]
......
......@@ -14,14 +14,10 @@ class TabPageButtons(QtWidgets.QWidget):
colors are not set they default to red.
"""
def __init__(
self, NativeUI, *args, size: QSize = None, colors: dict = None, **kwargs
):
def __init__(self, NativeUI, *args, size: QSize = None, **kwargs):
super(TabPageButtons, self).__init__(*args, **kwargs)
self.NativeUI = NativeUI
# self.__iconpath = self.__find_icons()
self.__colors = self.__interpret_colors(colors)
if size is not None:
self.__button_size = size
......@@ -55,17 +51,21 @@ class TabPageButtons(QtWidgets.QWidget):
# set icon color
mask = pixmap.mask() # mask from alpha
pixmap.fill(self.__colors["foreground"]) # fill with color
pixmap.fill(NativeUI.colors["foreground"]) # fill with color
pixmap.setMask(mask) # reapply mask
# set button appearance
button.setStyleSheet(
"QPushButton{"
"background-color: " + self.__colors["background"].name() + ";"
"border-color: " + self.__colors["background"].name() + ";"
"background-color: "
+ NativeUI.colors["background-enabled"].name()
+ ";"
"border-color: " + NativeUI.colors["background"].name() + ";"
"}"
"QPushButton:disabled{"
"background-color: " + self.__colors["background-disabled"].name() + ";"
"background-color: "
+ NativeUI.colors["background-disabled"].name()
+ ";"
"}"
)
button.setFixedSize(self.__button_size)
......@@ -104,36 +104,3 @@ class TabPageButtons(QtWidgets.QWidget):
for button in self.__buttons:
button.setEnabled(True)
self.button_fancon.setEnabled(False)
def __find_icons(self):
initial_path = "hev-display/assets/png/"
# assume we're in the root directory
temp_path = os.path.join(os.getcwd(), initial_path)
if os.path.isdir(temp_path):
return temp_path
# assume we're one folder deep in the root directory
temp_path = os.path.join("..", temp_path)
if os.path.isdir(temp_path):
return temp_path
walk = os.walk(os.path.join(os.getcwd(), ".."))
for w in walk:
if "png" in w[1]:
temp_path = os.path.join(os.path.normpath(w[0]), "png")
return temp_path
raise Exception(FileNotFoundError, "could not locate png icon files")
def __interpret_colors(self, colors):
try:
_, _ = colors["foreground"], colors["background"]
return colors
except TypeError:
logging.warning("Color dict not set")
except KeyError:
logging.warning("missing key in color dict: %s" % str(colors))
return {
"foreground": QtGui.QColor.fromRgb(255, 0, 0),
"background": QtGui.QColor.fromRgb(0, 255, 0),
}
......@@ -11,14 +11,11 @@ class TabStartStopStandbyButtons(QtWidgets.QWidget):
TODO
"""
def __init__(
self, NativeUI, *args, size: QSize = None, colors: dict = None, **kwargs
):
def __init__(self, NativeUI, *args, size: QSize = None, **kwargs):
super(TabStartStopStandbyButtons, self).__init__(*args, **kwargs)
self.NativeUI = NativeUI
self.__colors = self.__interpret_colors(colors)
if size is not None:
self.__button_size = size
else:
......@@ -37,24 +34,26 @@ class TabStartStopStandbyButtons(QtWidgets.QWidget):
button.setText(text)
layout.addWidget(button)
button.setStyleSheet(
"background-color: " + self.__colors["background"].name() + ";"
"border-color: " + self.__colors["foreground"].name() + ";"
"background-color: "
+ NativeUI.colors["background-enabled"].name()
+ ";"
"border-color: " + NativeUI.colors["foreground"].name() + ";"
"font-size: 20pt;"
"color: " + self.__colors["foreground"].name() + ";"
"color: " + NativeUI.colors["foreground"].name() + ";"
)
button.setFixedSize(self.__button_size)
self.setLayout(layout)
def __interpret_colors(self, colors):
try:
_, _ = colors["foreground"], colors["background"]
return colors
except TypeError:
logging.warning("Color dict not set")
except KeyError:
logging.warning("missing key in color dict: %" % colors)
return {
"foreground": QtGui.QColor.fromRgb(255, 0, 0),
"background": QtGui.QColor.fromRgb(0, 255, 0),
}
# def __interpret_colors(self, colors):
# try:
# _, _ = colors["foreground"], colors["background"]
# return colors
# except TypeError:
# logging.warning("Color dict not set")
# except KeyError:
# logging.warning("missing key in color dict: %" % colors)
# return {
# "foreground": QtGui.QColor.fromRgb(255, 0, 0),
# "background": QtGui.QColor.fromRgb(0, 255, 0),
# }
......@@ -26,9 +26,9 @@ class AlarmView(TemplateMainPages):
def __init__(self, NativeUI, *args, **kwargs):
super(AlarmView, self).__init__(*args, **kwargs)
self.alarmButton = selectorButton("List of Alarms")
self.clinicalButton = selectorButton("Clinical Limits")
self.techButton = selectorButton("Technical Limits")
self.alarmButton = selectorButton(NativeUI, "List of Alarms")
self.clinicalButton = selectorButton(NativeUI, "Clinical Limits")
self.techButton = selectorButton(NativeUI, "Technical Limits")
self.buttonWidgets = [self.alarmButton, self.clinicalButton, self.techButton]
......
......@@ -103,10 +103,7 @@ class TabNormalExpertButtons(QWidget):
layout = QHBoxLayout()
self.normal_button = QPushButton("Normal")
self.expert_button = QPushButton("Detailed")
self.buttons = [
self.normal_button,
self.expert_button,
]
self.buttons = [self.normal_button, self.expert_button]
layout.addWidget(self.normal_button)
layout.addWidget(self.expert_button)
# layout.setAlignment(self.normal_button, QtCore.Qt.AlignLeft)
......@@ -118,7 +115,9 @@ class TabNormalExpertButtons(QWidget):
"QPushButton{"
"color: " + NativeUI.colors["foreground"].name() + ";"
"font-size: " + str(font_size) + "pt;"
"background-color: " + NativeUI.colors["background"].name() + ";"
"background-color: "
+ NativeUI.colors["background-enabled"].name()
+ ";"
"border-color: " + NativeUI.colors["background"].name() + ";"
"}"
"QPushButton:disabled{"
......
......@@ -9,8 +9,8 @@ class ModeView(TemplateMainPages):
def __init__(self, NativeUI, *args, **kwargs):
super(ModeView, self).__init__(*args, **kwargs)
self.modeButton = selectorButton("Mode Settings")
self.personalButton = selectorButton("Personal Settings")
self.modeButton = selectorButton(NativeUI, "Mode Settings")
self.personalButton = selectorButton(NativeUI, "Personal Settings")
self.buttonWidgets = [self.modeButton, self.personalButton]
self.modeTab = TabModes(NativeUI)
......
......@@ -17,8 +17,8 @@ class SettingsView(TemplateMainPages):
def __init__(self, NativeUI, *args, **kwargs):
super(SettingsView, self).__init__(*args, **kwargs)
self.expertButton = selectorButton("Expert")
self.chartButton = selectorButton("Charts")
self.expertButton = selectorButton(NativeUI, "Expert")
self.chartButton = selectorButton(NativeUI, "Charts")
self.buttonWidgets = [self.expertButton, self.chartButton]
self.expertTab = TabExpert(NativeUI)
......
......@@ -23,24 +23,24 @@ class TabModes(
hlayout = QtWidgets.QHBoxLayout()
hlayout.setSpacing(0)
self.pcacButton = selectorButton("PC/AC")
self.pcacButton = selectorButton(NativeUI, "PC/AC")
self.pcacButton.setProperty("selected", "1")
self.pcacButton.style().polish(self.pcacButton)
self.pcacEnable = [1, 0, 1, 1, 0, 1, 0, 1]
self.pcacVals = [1, 2, 3, 4, 5, 6, 7, 8]
self.pcacPage = TemplateSetValues(NativeUI)
self.prvcButton = selectorButton("PC/AC-PRVC")
self.prvcButton = selectorButton(NativeUI, "PC/AC-PRVC")
self.prvcEnable = [1, 1, 0, 1, 0, 1, 1, 1]
self.prvcVals = [2, 3, 4, 5, 6, 7, 8, 9]
self.prvcPage = TemplateSetValues(NativeUI)
self.psvButton = selectorButton("PC-PSV")
self.psvButton = selectorButton(NativeUI, "PC-PSV")
self.psvEnable = [1, 1, 0, 1, 0, 1, 0, 1]
self.psvVals = [3, 4, 5, 6, 7, 8, 9, 1]
self.psvPage = TemplateSetValues(NativeUI)
self.cpapButton = selectorButton("CPAP")
self.cpapButton = selectorButton(NativeUI, "CPAP")
self.cpapEnable = [1, 0, 1, 1, 0, 1, 0, 1]
self.cpapVals = [4, 5, 6, 7, 8, 9, 1, 2]
self.cpapPage = TemplateSetValues(NativeUI)
......
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