refactor: use accent colors for bec_status_box icons; closes #338
@ -1,3 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" height="48px" viewBox="0 -960 960 960" width="48px" fill="#EA3323">
|
|
||||||
<path d="M479.85-265.87q19.8 0 32.69-12.46 12.9-12.46 12.9-32.26 0-19.8-12.75-32.98-12.74-13.17-32.54-13.17-19.8 0-32.69 13.16-12.9 13.15-12.9 32.95 0 19.8 12.75 32.28 12.74 12.48 32.54 12.48Zm-36.46-166.56h79.22v-262.61h-79.22v262.61Zm36.95 366.56q-86.2 0-161.5-32.39-75.3-32.4-131.74-88.84-56.44-56.44-88.84-131.73-32.39-75.3-32.39-161.59t32.39-161.67q32.4-75.37 88.75-131.34t131.69-88.62q75.34-32.65 161.67-32.65 86.34 0 161.78 32.61 75.45 32.6 131.37 88.5 55.93 55.89 88.55 131.45 32.63 75.56 32.63 161.87 0 86.29-32.65 161.58t-88.62 131.48q-55.97 56.18-131.42 88.76-75.46 32.58-161.67 32.58Z"/>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 718 B |
@ -1,3 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" height="48px" viewBox="0 -960 960 960" width="48px" fill="#EA3323">
|
|
||||||
<path d="m759.04-283.09-63.13-62q49.31-9.43 84.44-46.02 35.13-36.59 35.13-86.14 0-55.49-39.42-95.08-39.43-39.58-94.93-39.58h-153.3v-79.79h152.74q89.28 0 151.7 62.71Q894.7-566.28 894.7-477q0 63.7-38.26 115.96-38.27 52.26-97.4 77.95ZM596.83-443.61l-65.66-66.78h110.05v66.78h-44.39ZM804.96-56 58.48-802.48 106-850l746.48 746.48L804.96-56ZM443.22-265.87H279.43q-89.28 0-151.7-62.42Q65.3-390.72 65.3-480q0-72.57 43.09-129.54 43.09-56.98 112.09-76.07l70.13 70.7h-11.18q-55.73 0-95.32 39.3-39.59 39.31-39.59 95.61t39.66 95.61q39.66 39.3 95.5 39.3h163.54v79.22ZM319.35-446.61v-66.78h77.3l66.78 66.78H319.35Z"/>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 721 B |
@ -1,3 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" height="48px" viewBox="0 -960 960 960" width="48px" fill="#FFFF55">
|
|
||||||
<path d="M478.3-145.87q-138.65 0-236.39-97.74-97.74-97.74-97.74-236.25t97.74-236.68q97.74-98.16 236.39-98.16 88.4 0 155.45 35.76 67.04 35.76 115.86 98.9V-814.7h66.78v274.92H540.91V-606h165.74q-38.56-57.74-95.3-93.33-56.74-35.58-133.05-35.58-106.88 0-180.89 73.98-74.02 73.99-74.02 180.83 0 106.84 74.02 180.93 74.02 74.08 180.91 74.08 80.16 0 147.74-46.08 67.59-46.09 95.16-121.83H803q-29.56 110.65-119.67 178.89-90.1 68.24-205.03 68.24Z"/>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 559 B |
@ -1,3 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" height="48px" viewBox="0 -960 960 960" width="48px" fill="#75FB4C">
|
|
||||||
<path d="m419.87-289.52 289.22-289.22-57.31-56.87L419.87-403.7 304.96-518.61l-56.31 56.87 171.22 172.22Zm60.21 223.65q-85.47 0-161.01-32.39-75.53-32.4-131.97-88.84-56.44-56.44-88.84-131.89-32.39-75.46-32.39-160.93 0-86.47 32.39-162.01 32.4-75.53 88.75-131.5t131.85-88.62q75.5-32.65 161.01-32.65 86.52 0 162.12 32.61 75.61 32.6 131.53 88.5 55.93 55.89 88.55 131.45Q894.7-566.58 894.7-480q0 85.55-32.65 161.07-32.65 75.53-88.62 131.9-55.97 56.37-131.42 88.77-75.46 32.39-161.93 32.39Z"/>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 604 B |
@ -1,3 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" height="48px" viewBox="0 -960 960 960" width="48px" fill="#F19E39">
|
|
||||||
<path d="M27.56-112.65 480-894.7l452.44 782.05H27.56Zm456.62-125.48q13.15 0 22.61-9.64 9.47-9.65 9.47-22.8t-9.64-22.33q-9.65-9.19-22.8-9.19t-22.61 9.36q-9.47 9.36-9.47 22.51 0 13.15 9.64 22.62 9.65 9.47 22.8 9.47ZM454-348h60v-219.48h-60V-348Z"/>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 364 B |
@ -14,7 +14,7 @@ from qtpy.QtCore import QObject, QTimer, Signal, Slot
|
|||||||
from qtpy.QtWidgets import QHBoxLayout, QTreeWidget, QTreeWidgetItem, QWidget
|
from qtpy.QtWidgets import QHBoxLayout, QTreeWidget, QTreeWidgetItem, QWidget
|
||||||
|
|
||||||
from bec_widgets.utils.bec_widget import BECWidget
|
from bec_widgets.utils.bec_widget import BECWidget
|
||||||
from bec_widgets.utils.colors import apply_theme
|
from bec_widgets.utils.colors import set_theme
|
||||||
from bec_widgets.widgets.bec_status_box.status_item import StatusItem
|
from bec_widgets.widgets.bec_status_box.status_item import StatusItem
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
@ -303,17 +303,13 @@ class BECStatusBox(BECWidget, QWidget):
|
|||||||
return super().cleanup()
|
return super().cleanup()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
if __name__ == "__main__": # pragma: no cover
|
||||||
"""Main method to run the BECStatusBox widget."""
|
import sys
|
||||||
# pylint: disable=import-outside-toplevel
|
|
||||||
from qtpy.QtWidgets import QApplication
|
from qtpy.QtWidgets import QApplication
|
||||||
|
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
apply_theme("dark")
|
set_theme("dark")
|
||||||
main_window = BECStatusBox()
|
main_window = BECStatusBox()
|
||||||
main_window.show()
|
main_window.show()
|
||||||
sys.exit(app.exec())
|
sys.exit(app.exec())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
|
@ -6,11 +6,13 @@ import os
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from bec_lib.utils.import_utils import lazy_import_from
|
from bec_lib.utils.import_utils import lazy_import_from
|
||||||
|
from bec_qthemes import material_icon
|
||||||
from qtpy.QtCore import Qt, Slot
|
from qtpy.QtCore import Qt, Slot
|
||||||
from qtpy.QtGui import QIcon
|
from qtpy.QtGui import QIcon, QPainter
|
||||||
from qtpy.QtWidgets import QDialog, QHBoxLayout, QLabel, QVBoxLayout, QWidget
|
from qtpy.QtWidgets import QDialog, QHBoxLayout, QLabel, QVBoxLayout, QWidget
|
||||||
|
|
||||||
import bec_widgets
|
import bec_widgets
|
||||||
|
from bec_widgets.utils.colors import get_accent_colors
|
||||||
|
|
||||||
# TODO : Put normal imports back when Pydantic gets faster
|
# TODO : Put normal imports back when Pydantic gets faster
|
||||||
BECStatus = lazy_import_from("bec_lib.messages", ("BECStatus",))
|
BECStatus = lazy_import_from("bec_lib.messages", ("BECStatus",))
|
||||||
@ -21,11 +23,11 @@ MODULE_PATH = os.path.dirname(bec_widgets.__file__)
|
|||||||
class IconsEnum(enum.Enum):
|
class IconsEnum(enum.Enum):
|
||||||
"""Enum class for icons in the status item widget."""
|
"""Enum class for icons in the status item widget."""
|
||||||
|
|
||||||
RUNNING = os.path.join(MODULE_PATH, "assets", "status_icons", "running.svg")
|
RUNNING = "done_outline"
|
||||||
BUSY = os.path.join(MODULE_PATH, "assets", "status_icons", "refresh.svg")
|
BUSY = "progress_activity"
|
||||||
IDLE = os.path.join(MODULE_PATH, "assets", "status_icons", "warning.svg")
|
IDLE = "progress_activity"
|
||||||
ERROR = os.path.join(MODULE_PATH, "assets", "status_icons", "error.svg")
|
ERROR = "emergency_home"
|
||||||
NOTCONNECTED = os.path.join(MODULE_PATH, "assets", "status_icons", "not_connected.svg")
|
NOTCONNECTED = "signal_disconnected"
|
||||||
|
|
||||||
|
|
||||||
class StatusItem(QWidget):
|
class StatusItem(QWidget):
|
||||||
@ -43,13 +45,13 @@ class StatusItem(QWidget):
|
|||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Please initialize the StatusItem with a BECServiceInfoContainer for config, received None."
|
"Please initialize the StatusItem with a BECServiceInfoContainer for config, received None."
|
||||||
)
|
)
|
||||||
|
self.accent_colors = get_accent_colors()
|
||||||
self.config = config
|
self.config = config
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.layout = None
|
self.layout = None
|
||||||
self._label = None
|
self._label = None
|
||||||
self._icon = None
|
self._icon = None
|
||||||
self.icon_size = (24, 24)
|
self.icon_size = (24, 24)
|
||||||
|
|
||||||
self._popup_label_ref = {}
|
self._popup_label_ref = {}
|
||||||
self.init_ui()
|
self.init_ui()
|
||||||
|
|
||||||
@ -97,8 +99,15 @@ class StatusItem(QWidget):
|
|||||||
|
|
||||||
def set_status(self) -> None:
|
def set_status(self) -> None:
|
||||||
"""Set the status icon for the status item widget."""
|
"""Set the status icon for the status item widget."""
|
||||||
icon_path = IconsEnum[self.config.status].value
|
status = self.config.status
|
||||||
icon = QIcon(icon_path)
|
if status in ["RUNNING", "BUSY"]:
|
||||||
|
color = self.accent_colors.success
|
||||||
|
elif status == "IDLE":
|
||||||
|
color = self.accent_colors.warning
|
||||||
|
elif status in ["ERROR", "NOTCONNECTED"]:
|
||||||
|
color = self.accent_colors.emergency
|
||||||
|
icon = QIcon(material_icon(IconsEnum[status].value, filled=True, color=color))
|
||||||
|
|
||||||
self._icon.setPixmap(icon.pixmap(*self.icon_size))
|
self._icon.setPixmap(icon.pixmap(*self.icon_size))
|
||||||
self._icon.setAlignment(Qt.AlignmentFlag.AlignRight)
|
self._icon.setAlignment(Qt.AlignmentFlag.AlignRight)
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 115 KiB After Width: | Height: | Size: 109 KiB |