Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
HEV - High Energy Ventilator
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
HEV - High Energy Ventilator
Commits
6bbf2d58
Commit
6bbf2d58
authored
May 17, 2021
by
Benjamin Mummery
💻
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ui_dev' into feature/ui_full_screen_popups
parents
32528507
8bf9bf16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
357 additions
and
68 deletions
+357
-68
NativeUI.py
NativeUI/NativeUI.py
+9
-0
ui_layout.py
NativeUI/ui_layout.py
+52
-23
ui_widgets.py
NativeUI/ui_widgets.py
+86
-45
info_display_widgets.py
NativeUI/widget_library/info_display_widgets.py
+210
-0
No files found.
NativeUI/NativeUI.py
View file @
6bbf2d58
...
...
@@ -194,6 +194,8 @@ class NativeUI(HEVClient, QMainWindow):
self
.
setWindowTitle
(
self
.
text
[
"ui_window_title"
]
.
format
(
version
=
__version__
))
self
.
setPalette
(
palette
)
self
.
setAutoFillBackground
(
True
)
self
.
widgets
.
version_display_widget
.
update_UI_version
(
__version__
)
self
.
widgets
.
version_display_widget
.
update_UI_hash
(
self
.
__get_hash
())
# Connect widgets
self
.
__define_connections
()
...
...
@@ -216,6 +218,13 @@ class NativeUI(HEVClient, QMainWindow):
return
files_list
def
__get_hash
(
self
)
->
str
:
"""
Get the hash of the current commit.
"""
repo
=
git
.
Repo
(
search_parent_directories
=
True
)
return
repo
.
head
.
object
.
hexsha
def
__define_connections
(
self
)
->
int
:
"""
Connect the signals and slots necessary for the UI to function.
...
...
NativeUI/ui_layout.py
View file @
6bbf2d58
...
...
@@ -15,7 +15,8 @@ __email__ = "benjamin.mummery@stfc.ac.uk"
__status__
=
"Prototype"
from
PySide2
import
QtWidgets
,
QtCore
,
QtGui
#from PySide2.QtGui import QFont, QSizePolicy
# from PySide2.QtGui import QFont, QSizePolicy
from
widget_library.switchable_stack_widget
import
SwitchableStackWidget
import
json
...
...
@@ -86,7 +87,7 @@ class Layout:
self
.
layout_startup_main
(),
self
.
layout_mode_startup
(),
# self, settings, mode:str, enableList:list, buttons: bool)
self
.
layout_mode_personal
(
"startup_"
,
False
),
self
.
layout_startup_confirmation
()
self
.
layout_startup_confirmation
()
,
]
),
"startup_stack"
,
...
...
@@ -309,11 +310,21 @@ class Layout:
self
.
left_bar_width
,
None
,
spacing
=
self
.
widget_spacing
)
# Create the system info tab
sysinfo_widgets
=
[
self
.
widgets
.
version_display_widget
,
self
.
widgets
.
maintenance_time_display_widget
,
self
.
widgets
.
update_time_display_widget
,
]
tab_info
=
self
.
layout_tab_info
(
sysinfo_widgets
)
for
widget
in
sysinfo_widgets
:
widget
.
setFont
(
self
.
NativeUI
.
text_font
)
# Create the stack
page_settings
=
SwitchableStackWidget
(
self
.
NativeUI
,
[
self
.
layout_settings_expert
(),
tab_charts
],
[
"Expert"
,
"Charts"
],
[
self
.
layout_settings_expert
(),
tab_charts
,
tab_info
],
[
"Expert"
,
"Charts"
,
"Info"
],
)
page_settings
.
setFont
(
self
.
NativeUI
.
text_font
)
self
.
widgets
.
add_widget
(
page_settings
,
"setting_stack"
)
...
...
@@ -393,6 +404,9 @@ class Layout:
return
tab_main_detailed
def
layout_tab_charts
(
self
,
widgets
:
list
)
->
QtWidgets
.
QWidget
:
"""
Construct the layout for the charts page.
"""
tab_charts
=
QtWidgets
.
QWidget
()
tab_charts_layout
=
QtWidgets
.
QHBoxLayout
(
tab_charts
)
for
widget
in
widgets
:
...
...
@@ -400,6 +414,17 @@ class Layout:
tab_charts
.
setLayout
(
tab_charts_layout
)
return
tab_charts
def
layout_tab_info
(
self
,
widgets
:
list
)
->
QtWidgets
.
QWidget
:
"""
Construct the layout for the info page.
"""
tab_info
=
QtWidgets
.
QWidget
()
tab_info_layout
=
QtWidgets
.
QVBoxLayout
(
tab_info
)
for
widget
in
widgets
:
tab_info_layout
.
addWidget
(
widget
)
tab_info
.
setLayout
(
tab_info_layout
)
return
tab_info
def
__make_stack
(
self
,
widgets
):
"""
Make a stack of widgets
...
...
@@ -533,7 +558,9 @@ class Layout:
hRadioLayout
=
QtWidgets
.
QHBoxLayout
()
for
mode
in
self
.
NativeUI
.
modeList
:
hRadioLayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
'startup_radio_'
+
mode
))
hRadioLayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
"startup_radio_"
+
mode
)
)
vlayout
=
QtWidgets
.
QVBoxLayout
()
vlayout
.
addWidget
(
mode_stack
)
...
...
@@ -658,23 +685,23 @@ class Layout:
modeDict
=
json
.
load
(
json_file
)
stack
=
self
.
NativeUI
.
widgets
.
main_mode_stack
for
setting
in
modeDict
[
'settings'
]:
if
setting
[
0
]
in
modeDict
[
'mainPageSettings'
]:
attrName
=
'CURRENT_'
+
setting
[
2
]
for
setting
in
modeDict
[
"settings"
]:
if
setting
[
0
]
in
modeDict
[
"mainPageSettings"
]:
attrName
=
"CURRENT_"
+
setting
[
2
]
widg
=
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
)
if
setting
[
0
]
in
modeDict
[
'radioSettings'
]:
if
setting
[
0
]
in
modeDict
[
"radioSettings"
]:
stack
.
addWidget
(
widg
)
else
:
hlayout
.
addWidget
(
widg
)
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
main_mode_stack
)
vbuttonLayout
=
QtWidgets
.
QVBoxLayout
()
okButton
=
self
.
NativeUI
.
widgets
.
get_widget
(
'CURRENT_ok_button'
)
okButton
.
setSizePolicy
(
QtGui
.
QSizePolicy
.
Expanding
,
QtGui
.
QSizePolicy
.
Fixed
)
vbuttonLayout
=
QtWidgets
.
QVBoxLayout
()
okButton
=
self
.
NativeUI
.
widgets
.
get_widget
(
"CURRENT_ok_button"
)
okButton
.
setSizePolicy
(
QtGui
.
QSizePolicy
.
Expanding
,
QtGui
.
QSizePolicy
.
Fixed
)
vbuttonLayout
.
addWidget
(
okButton
)
cancelButton
=
self
.
NativeUI
.
widgets
.
get_widget
(
'CURRENT_cancel_button'
)
cancelButton
.
setSizePolicy
(
QtGui
.
QSizePolicy
.
Expanding
,
QtGui
.
QSizePolicy
.
Fixed
)
cancelButton
=
self
.
NativeUI
.
widgets
.
get_widget
(
"CURRENT_cancel_button"
)
cancelButton
.
setSizePolicy
(
QtGui
.
QSizePolicy
.
Expanding
,
QtGui
.
QSizePolicy
.
Fixed
)
vbuttonLayout
.
addWidget
(
cancelButton
)
hlayout
.
addLayout
(
vbuttonLayout
)
...
...
@@ -687,16 +714,18 @@ class Layout:
clinicalDict
=
json
.
load
(
json_file
)
vlayout
=
QtWidgets
.
QVBoxLayout
()
for
setting
in
clinicalDict
[
'settings'
]:
attrName
=
'clinical_spin_'
+
setting
[
0
][
2
]
for
setting
in
clinicalDict
[
"settings"
]:
attrName
=
"clinical_spin_"
+
setting
[
0
][
2
]
hlayout
=
QtWidgets
.
QHBoxLayout
()
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
'_min'
))
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
'_max'
))
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_min"
))
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_max"
))
vlayout
.
addLayout
(
hlayout
)
hbuttonlayout
=
QtWidgets
.
QHBoxLayout
()
hbuttonlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
'clinical_ok_button'
))
hbuttonlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
'clinical_cancel_button'
))
hbuttonlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
"clinical_ok_button"
))
hbuttonlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
"clinical_cancel_button"
)
)
vlayout
.
addLayout
(
hbuttonlayout
)
# hlayoutMeta.addLayout(vlayout)
# hlayoutMeta.addLayout(vlayout2)
...
...
@@ -740,7 +769,9 @@ class Layout:
def
layout_startup_confirmation
(
self
):
vlayout
=
QtWidgets
.
QVBoxLayout
()
i
=
0
for
key
,
spinBox
in
self
.
NativeUI
.
widgets
.
get_widget
(
'startup_handler'
)
.
spinDict
.
items
():
for
key
,
spinBox
in
self
.
NativeUI
.
widgets
.
get_widget
(
"startup_handler"
)
.
spinDict
.
items
():
i
=
i
+
1
hlayout
=
QtWidgets
.
QHBoxLayout
()
nameLabel
=
QtWidgets
.
QLabel
(
key
)
...
...
@@ -751,8 +782,6 @@ class Layout:
if
i
==
10
:
break
widg
=
QtWidgets
.
QWidget
()
widg
.
setLayout
(
vlayout
)
return
widg
NativeUI/ui_widgets.py
View file @
6bbf2d58
This diff is collapsed.
Click to expand it.
NativeUI/widget_library/info_display_widgets.py
0 → 100644
View file @
6bbf2d58
#!/usr/bin/env python3
"""
info_display_widgets.py
Simple widgets to display various system information parameters including version
number(s), time since last maintenance, and time since last update.
"""
__author__
=
[
"Benjamin Mummery"
,
"Tiago Sarmento"
]
__credits__
=
[
"Benjamin Mummery"
,
"Dónal Murray"
,
"Tim Powell"
,
"Tiago Sarmento"
]
__license__
=
"GPL"
__version__
=
"0.1.0"
__maintainer__
=
"Benjamin Mummery"
__email__
=
"benjamin.mummery@stfc.ac.uk"
__status__
=
"Development"
import
logging
from
PySide2
import
QtCore
,
QtWidgets
class
VersionDisplayWidget
(
QtWidgets
.
QLabel
):
"""
Widget that displays the current version number.
We don't need to override setFont as long as we're just subclassing the QLabel
widget. If we later expand this class to include more complexity, we'll have to add
setFont as a method to propogate the font to any subwidgets.
"""
def
__init__
(
self
,
colors
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
self
.
__mcu_version
:
str
=
"???"
self
.
__mcu_hash
:
str
=
None
self
.
__ui_version
:
str
=
"???"
self
.
__ui_hash
:
str
=
None
self
.
setStyleSheet
(
"background-color:"
+
colors
[
"page_background"
]
.
name
()
+
";"
"border: none;"
"color:"
+
colors
[
"page_foreground"
]
.
name
()
+
";"
)
self
.
__refresh_display
()
def
__refresh_display
(
self
)
->
int
:
"""
Update the display to show the current values of __ui_version and __mcu_version.
"""
display_text
=
""
display_text
+=
"MCU Software Version:
%
s"
%
self
.
__mcu_version
if
self
.
__mcu_hash
is
not
None
:
display_text
+=
" (
%
s)"
%
self
.
__mcu_hash
display_text
+=
"<br>UI Software Version:
%
s"
%
self
.
__ui_version
if
self
.
__ui_hash
is
not
None
:
display_text
+=
" (
%
s)"
%
self
.
__ui_hash
self
.
setText
(
display_text
)
return
0
@
QtCore
.
Slot
(
str
)
def
update_UI_version
(
self
,
version
:
str
)
->
int
:
"""
Update the value shown for the UI version
"""
self
.
__ui_version
=
version
self
.
__refresh_display
()
return
0
@
QtCore
.
Slot
(
str
)
def
update_UI_hash
(
self
,
hash
:
str
)
->
int
:
"""
Update the value shown for the UI hash
"""
self
.
__ui_hash
=
hash
self
.
__refresh_display
()
return
0
@
QtCore
.
Slot
(
str
)
def
update_mcu_version
(
self
,
version
:
str
)
->
int
:
"""
Update the value shown for the MCU version
"""
self
.
__mcu_version
=
version
self
.
__refresh_display
()
return
0
@
QtCore
.
Slot
(
str
)
def
update_mcu_version
(
self
,
hash
:
str
)
->
int
:
"""
Update the value shown for the MCU hash
"""
self
.
__mcu_hash
=
hash
self
.
__refresh_display
()
return
0
def
set_size
(
self
,
x
:
int
,
y
:
int
)
->
int
:
"""
Set the size of the widget.
"""
self
.
setFixedSize
(
x
,
y
)
return
0
class
MaintenanceTimeDisplayWidget
(
QtWidgets
.
QLabel
):
"""
Widget that displays the time since the last maintenance.
"""
def
__init__
(
self
,
colors
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
self
.
__time_since_maintenance
:
str
=
"???"
self
.
__time_to_maintenance
:
str
=
"???"
self
.
__maintenance_needed
:
bool
=
True
self
.
__normal_color
=
colors
[
"page_foreground"
]
.
name
()
self
.
__alert_color
=
colors
[
"red"
]
.
name
()
self
.
setStyleSheet
(
"background-color:"
+
colors
[
"page_background"
]
.
name
()
+
";"
"border: none;"
"color:"
+
self
.
__normal_color
+
";"
)
self
.
__refresh_display
()
def
__refresh_display
(
self
)
->
int
:
"""
Update the display to show the current values of time to, and since,
maintenance.
"""
self
.
setText
(
"
%
s since last maintenance. Maintenance due in
%
s."
%
(
self
.
__time_since_maintenance
,
self
.
__time_to_maintenance
)
)
if
self
.
__maintenance_needed
:
self
.
setStyleSheet
(
"color:
%
s"
%
self
.
__alert_color
)
else
:
self
.
setStyleSheet
(
"color:
%
s"
%
self
.
__normal_color
)
return
0
@
QtCore
.
Slot
(
str
,
str
,
bool
)
def
set_time_values
(
self
,
time_since_maintenance
:
str
,
time_to_maintenance
:
str
,
maintenance_needed
:
bool
,
)
->
int
:
"""
set the time since and to maintenance, and whether maintenance is needed.
"""
self
.
__time_since_maintenance
=
time_since_maintenance
self
.
__time_to_maintenance
=
time_to_maintenance
self
.
__maintenance_needed
=
maintenance_needed
return
self
.
__refresh_display
()
class
UpdateTimeDisplayWidget
(
QtWidgets
.
QLabel
):
"""
Widget that displays the time since the last update.
"""
def
__init__
(
self
,
colors
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
self
.
__time_since_update
:
str
=
"???"
self
.
__time_to_update_check
:
str
=
"???"
self
.
__update_check_needed
:
bool
=
True
self
.
__normal_color
=
colors
[
"page_foreground"
]
.
name
()
self
.
__alert_color
=
colors
[
"red"
]
.
name
()
self
.
setStyleSheet
(
"background-color:"
+
colors
[
"page_background"
]
.
name
()
+
";"
"border: none;"
"color:"
+
self
.
__normal_color
+
";"
)
self
.
__refresh_display
()
def
__refresh_display
(
self
)
->
int
:
"""
Update the display to show the current values of time to, and since,
update.
"""
self
.
setText
(
"
%
s since last update. Check for updates due in
%
s."
%
(
self
.
__time_since_update
,
self
.
__time_to_update_check
)
)
if
self
.
__update_check_needed
:
self
.
setStyleSheet
(
"color:
%
s"
%
self
.
__alert_color
)
else
:
self
.
setStyleSheet
(
"color:
%
s"
%
self
.
__normal_color
)
return
0
@
QtCore
.
Slot
(
str
,
str
,
bool
)
def
set_time_values
(
self
,
time_since_update
:
str
,
time_to_update_check
:
str
,
update_check_needed
:
bool
,
)
->
int
:
"""
set the time since and to maintenance, and whether maintenance is needed.
"""
self
.
__time_since_update
=
time_since_update
self
.
__time_to_update_check
=
time_to_update_check
self
.
__update_check_needed
=
update_check_needed
return
self
.
__refresh_display
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment