Skip to content

Commit abf9b49

Browse files
Merge branch 'main' into update-setup-readme
2 parents 0f2b2b1 + f50fba8 commit abf9b49

File tree

9 files changed

+140
-204
lines changed

9 files changed

+140
-204
lines changed

src/surface/gui/gui/app.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import atexit
22
import signal
3+
from pathlib import Path
34
from threading import Thread
45

56
import rclpy.utilities
7+
from ament_index_python import get_package_share_directory
68
from PyQt6.QtWidgets import QApplication, QWidget
9+
from qt_material import apply_stylesheet
710
from rclpy.executors import MultiThreadedExecutor
811

912
from gui.gui_node import GUINode
@@ -29,18 +32,27 @@ def run_gui(self) -> None:
2932
# Kills with Control + C
3033
signal.signal(signal.SIGINT, signal.SIG_DFL)
3134

32-
# TODO: New method of dark mode
35+
extra_blue = {'success': '#040444', 'danger': '#040444', 'warning': '#040444'}
36+
extra_watermelon = {'success': '#341616', 'danger': '#341616', 'warning': '#341616'}
3337
# Apply theme
34-
# theme_param = self.theme_param.get_parameter_value().string_value
35-
# theme_path = Path(get_package_share_directory('gui')) / 'styles' / (theme_param + '.qss')
36-
37-
# base_theme = 'dark' if theme_param == 'dark' else 'light'
38-
# custom_styles = '\n'
39-
# if theme_path.exists():
40-
# with theme_path.open(encoding='utf-8') as theme_file:
41-
# custom_styles += theme_file.read()
42-
43-
# qdarktheme.setup_theme(base_theme, additional_qss=custom_styles)
38+
theme_param = self.theme_param.get_parameter_value().string_value
39+
40+
match theme_param:
41+
case 'dark':
42+
base_theme = 'dark_blue.xml'
43+
case 'light':
44+
base_theme = 'light_blue.xml'
45+
case 'watermelon':
46+
base_path = Path(get_package_share_directory('gui')) / 'styles' / ('watermelon.xml')
47+
base_theme = base_path.as_posix()
48+
case _:
49+
base_theme = 'dark_blue.xml'
50+
self.node.get_logger().info(
51+
'Theme ' + theme_param + ' not found, defaulting to dark.'
52+
)
53+
54+
extra = extra_watermelon if theme_param == 'watermelon' else extra_blue
55+
apply_stylesheet(self, theme=base_theme, style='', extra=extra)
4456

4557
executor = MultiThreadedExecutor()
4658
executor.add_node(self.node)

src/surface/gui/gui/operator_app.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from gui.widgets.heartbeat import HeartbeatWidget
88
from gui.widgets.ip_widget import IPWidget
99
from gui.widgets.logger import Logger
10-
from gui.widgets.tabs.carp_model_tab import CarpModelTab
1110
from gui.widgets.tabs.dna_tab import DNATab
1211
from gui.widgets.tabs.general_debug_tab import GeneralDebugTab
1312
from gui.widgets.tabs.photosphere_tab import PhotosphereTab
@@ -58,7 +57,6 @@ def __init__(self) -> None:
5857
self.tabs.addTab(main_tab, 'Main')
5958
self.tabs.addTab(GeneralDebugTab(), 'General Debug')
6059
self.tabs.addTab(PhotosphereTab(), 'Photosphere')
61-
self.tabs.addTab(CarpModelTab(), 'Carp Model')
6260
self.shipwreck_tab = ShipwreckTab()
6361
self.tabs.addTab(DNATab(), 'DNA Sample')
6462
self.tabs.addTab(self.shipwreck_tab, SHIPWRECK_TEXT)

src/surface/gui/gui/styles/custom_styles.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,16 @@ class IndicatorMixin(QWidget):
1515
# The stylesheets that correspond to each widget state
1616
_STYLESHEETS: Final[dict[WidgetState, str]] = {
1717
# Stylesheet for when a component is running, enabled, or armed
18-
WidgetState.ON: 'QWidget { background-color: limegreen; }',
18+
WidgetState.ON: """
19+
QWidget { background-color: limegreen; }
20+
QWidget:hover { background-color: #5bd75b; }
21+
""",
1922
# Stylesheet for when a component is disabled, not running, or disarmed, but could be
2023
# enabled through this widget
21-
WidgetState.OFF: 'QWidget { background-color: red; }',
24+
WidgetState.OFF: """
25+
QWidget { background-color: red; }
26+
QWidget:hover { background-color: #ff3333; }
27+
""",
2228
# Stylesheet for when a component is disabled, not expected to have any effect or perform
2329
# its function because of some external factor, either another widget or something
2430
# external to the gui. For example, a the arm button when the pi is not connected
@@ -48,6 +54,13 @@ def set_state(self, new_state: WidgetState) -> None:
4854
The new state for the widget
4955
"""
5056
self.current_state = new_state
57+
match self.current_state:
58+
case WidgetState.OFF:
59+
self.setProperty('class', 'danger')
60+
case WidgetState.ON:
61+
self.setProperty('class', 'success')
62+
case _:
63+
self.setProperty('class', 'warning')
5164
self.setStyleSheet(self._original_stylesheet + self._STYLESHEETS[self.current_state])
5265

5366

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!--?xml version="1.0" encoding="UTF-8"?-->
2+
<resources>
3+
<color name="primaryColor">#ff4d4e</color>
4+
<color name="primaryLightColor">#bf0002</color>
5+
<color name="secondaryColor">#6f0001</color>
6+
<color name="secondaryLightColor">#31363b</color>
7+
<color name="secondaryDarkColor">#1b5e1a</color>
8+
<color name="primaryTextColor">#ffffff</color>
9+
<color name="secondaryTextColor">#ffffff</color>
10+
</resources>

src/surface/gui/gui/widgets/carp_animation.py

Lines changed: 0 additions & 105 deletions
This file was deleted.

src/surface/gui/gui/widgets/tabs/carp_model_tab.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/surface/gui/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
<exec_depend>python3-numpy</exec_depend>
1515
<exec_depend>cv_bridge</exec_depend>
16+
<exec_depend>python3-qt-material-pip</exec_depend>
1617
<exec_depend>python3-pyqtgraph</exec_depend>
1718
<exec_depend>pyqt6-dev-tools</exec_depend>
1819
<exec_depend>python3-pyqt6.qtmultimedia</exec_depend>

src/surface/gui/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# Include all style files.
2828
(
2929
str(Path('share') / PACKAGE_NAME / 'styles'),
30-
[str(path) for path in (Path('gui') / 'styles').glob('*.qss')],
30+
[str(path) for path in (Path('gui') / 'styles').glob('*.xml')],
3131
),
3232
# Include all images.
3333
(

0 commit comments

Comments
 (0)