-
Notifications
You must be signed in to change notification settings - Fork 1
Qt-material theming #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 4 commits
765f363
1884e4d
4946296
901dbb5
5a6f21e
e37fe4f
bcbc44c
2348625
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,12 @@ | ||
| import atexit | ||
| import signal | ||
| from pathlib import Path | ||
| from threading import Thread | ||
|
|
||
| import rclpy.utilities | ||
| from ament_index_python import get_package_share_directory | ||
| from PyQt6.QtWidgets import QApplication, QWidget | ||
| from qt_material import apply_stylesheet | ||
| from rclpy.executors import MultiThreadedExecutor | ||
|
|
||
| from gui.gui_node import GUINode | ||
|
|
@@ -29,18 +32,24 @@ def run_gui(self) -> None: | |
| # Kills with Control + C | ||
| signal.signal(signal.SIGINT, signal.SIG_DFL) | ||
|
|
||
| # TODO: New method of dark mode | ||
| extra_blue = {'success': '#040444', 'danger': '#040444', 'warning': '#040444'} | ||
| extra_watermelon = {'success': '#341616', 'danger': '#341616', 'warning': '#341616'} | ||
| # Apply theme | ||
| # theme_param = self.theme_param.get_parameter_value().string_value | ||
| # theme_path = Path(get_package_share_directory('gui')) / 'styles' / (theme_param + '.qss') | ||
|
|
||
| # base_theme = 'dark' if theme_param == 'dark' else 'light' | ||
| # custom_styles = '\n' | ||
| # if theme_path.exists(): | ||
| # with theme_path.open(encoding='utf-8') as theme_file: | ||
| # custom_styles += theme_file.read() | ||
|
|
||
| # qdarktheme.setup_theme(base_theme, additional_qss=custom_styles) | ||
| theme_param = self.theme_param.get_parameter_value().string_value | ||
|
|
||
| base_theme = ( | ||
| 'dark_blue.xml' | ||
| if theme_param == 'dark' | ||
| else 'light_blue.xml' | ||
| if theme_param == 'light' | ||
| else 'watermelon.xml' | ||
| ) | ||
| if base_theme == 'watermelon.xml': | ||
| base_theme = Path(get_package_share_directory('gui')) / 'styles' / ('watermelon.xml') | ||
|
||
| base_theme = base_theme.as_posix() | ||
|
|
||
| extra = extra_watermelon if theme_param == 'watermelon' else extra_blue | ||
| apply_stylesheet(self, theme=base_theme, extra=extra) | ||
|
|
||
| executor = MultiThreadedExecutor() | ||
| executor.add_node(self.node) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <!--?xml version="1.0" encoding="UTF-8"?--> | ||
| <resources> | ||
| <color name="primaryColor">#ff4d4e</color> | ||
| <color name="primaryLightColor">#bf0002</color> | ||
| <color name="secondaryColor">#6f0001</color> | ||
| <color name="secondaryLightColor">#31363b</color> | ||
| <color name="secondaryDarkColor">#1b5e1a</color> | ||
| <color name="primaryTextColor">#ffffff</color> | ||
| <color name="secondaryTextColor">#ffffff</color> | ||
| </resources> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is confusing on what conditions set the value of base_theme to each possible value. Could you please refactor this into an easier to read format such as if and elif, switch cases, or some easier to read format. Also, because we default to dark theme when there is no parameter, I think it would be good to default to dark theme when anyone enters a value for the parameter that we don't have a theme for instead of using watermelon for that situation.