mirror of
https://github.com/bec-project/bec_widgets.git
synced 2026-10-28 16:11:27 +01:00
refactor(bec_queue,bec_status_box): host the QML views through the unified UI kit
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019EaukntuyeZn7cPqVqDTBE
This commit is contained in:
9 files changed
+23
-21
No files matched your search
@@ -13,7 +13,7 @@ from bec_widgets.utils.bec_connector import ConnectionConfig
|
||||
from bec_widgets.utils.bec_widget import BECWidget
|
||||
from bec_widgets.utils.compact_popup import CompactPopupWidget
|
||||
from bec_widgets.utils.error_popups import SafeSlot
|
||||
from bec_widgets.widgets.services.bec_queue.qml_host import create_quick_widget
|
||||
from bec_widgets.utils.quick import create_quick_widget
|
||||
from bec_widgets.widgets.services.bec_queue.queue_model import IDLE_STATUSES, QueueController
|
||||
|
||||
logger = bec_logger.logger
|
||||
@@ -79,7 +79,7 @@ class BECQueue(BECWidget, CompactPopupWidget):
|
||||
|
||||
def _create_view(self) -> QWidget:
|
||||
"""Create the widget that renders the queue: here the QML view."""
|
||||
return create_quick_widget(self, QML_FILE, {"queue": self.controller})
|
||||
return create_quick_widget(self, QML_FILE, context={"queue": self.controller})
|
||||
|
||||
def _release_view(self):
|
||||
"""Unload the QML tree before the controller it binds to is deleted."""
|
||||
|
||||
@@ -166,7 +166,7 @@ Rectangle {
|
||||
contentItem: Text {
|
||||
leftPadding: mi.checkable ? 22 : 4
|
||||
text: mi.text
|
||||
color: !mi.enabled ? theme.faint : mi.text.indexOf("Halt") === 0 || mi.text.indexOf("Clear") === 0 ? theme.errText : theme.fg
|
||||
color: !mi.enabled ? theme.faint : mi.text.indexOf("Halt") === 0 || mi.text.indexOf("Clear") === 0 ? theme.dangerText : theme.fg
|
||||
font.pixelSize: 13
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
@@ -212,7 +212,7 @@ Rectangle {
|
||||
Layout.bottomMargin: 8
|
||||
implicitHeight: bannerRow.implicitHeight + 16
|
||||
radius: 7
|
||||
color: root.locked ? theme.errTint : theme.warnTint
|
||||
color: root.locked ? theme.dangerTint : theme.warningTint
|
||||
RowLayout {
|
||||
id: bannerRow
|
||||
anchors { fill: parent; margins: 8; leftMargin: 10 }
|
||||
@@ -220,7 +220,7 @@ Rectangle {
|
||||
Icon {
|
||||
name: root.locked ? "lock" : "pause_circle"
|
||||
size: 20
|
||||
color: root.locked ? theme.errText : theme.warnText
|
||||
color: root.locked ? theme.dangerText : theme.warningText
|
||||
Layout.alignment: Qt.AlignTop
|
||||
}
|
||||
ColumnLayout {
|
||||
|
||||
@@ -31,7 +31,7 @@ AbstractButton {
|
||||
anchors.centerIn: parent
|
||||
name: root.iconName
|
||||
size: root.iconSize
|
||||
color: !root.enabled ? theme.faint : root.danger ? theme.errText : theme.muted
|
||||
color: !root.enabled ? theme.faint : root.danger ? theme.dangerText : theme.muted
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,7 +137,7 @@ Rectangle {
|
||||
height: parent.height
|
||||
radius: 2.5
|
||||
width: parent.width * Math.max(0, row.progress)
|
||||
color: row.tone === "warn" ? theme.warn : theme.busy
|
||||
color: row.tone === "warn" ? theme.warning : theme.busy
|
||||
Behavior on width { NumberAnimation { duration: 250; easing.type: Easing.OutCubic } }
|
||||
}
|
||||
Rectangle { // indeterminate: no progress reported yet
|
||||
|
||||
@@ -9,14 +9,14 @@ Rectangle {
|
||||
property string iconName
|
||||
property string tone: "neutral"
|
||||
|
||||
readonly property color textColor: tone === "busy" ? theme.busyText
|
||||
: tone === "ok" ? theme.okText
|
||||
: tone === "warn" ? theme.warnText
|
||||
: tone === "err" ? theme.errText
|
||||
readonly property color textColor: tone === "busy" ? theme.infoText
|
||||
: tone === "ok" ? theme.successText
|
||||
: tone === "warn" ? theme.warningText
|
||||
: tone === "err" ? theme.dangerText
|
||||
: tone === "stale" ? theme.faint : theme.muted
|
||||
readonly property color fillColor: tone === "busy" ? theme.busyTint
|
||||
: tone === "warn" ? theme.warnTint
|
||||
: tone === "err" ? theme.errTint : "transparent"
|
||||
readonly property color fillColor: tone === "busy" ? theme.infoTint
|
||||
: tone === "warn" ? theme.warningTint
|
||||
: tone === "err" ? theme.dangerTint : "transparent"
|
||||
|
||||
implicitHeight: 22
|
||||
implicitWidth: row.implicitWidth + 14
|
||||
|
||||
@@ -23,16 +23,16 @@ Button {
|
||||
|
||||
readonly property color fgColor: !enabled ? theme.faint
|
||||
: kind === "dangerSolid" ? "white"
|
||||
: kind === "danger" ? theme.errText : theme.fg
|
||||
: kind === "danger" ? theme.dangerText : theme.fg
|
||||
|
||||
background: Rectangle {
|
||||
radius: 6
|
||||
color: root.kind === "dangerSolid"
|
||||
? (root.down ? Qt.darker(theme.err, 1.2) : root.hovered ? Qt.lighter(theme.err, 1.1) : theme.err)
|
||||
? (root.down ? Qt.darker(theme.danger, 1.2) : root.hovered ? Qt.lighter(theme.danger, 1.1) : theme.danger)
|
||||
: root.down ? theme.pressed : root.hovered ? theme.hover : "transparent"
|
||||
border.width: root.visualFocus ? 2 : 1
|
||||
border.color: root.visualFocus ? theme.primary
|
||||
: root.kind === "danger" && root.enabled ? Qt.alpha(theme.err, 0.55)
|
||||
: root.kind === "danger" && root.enabled ? Qt.alpha(theme.danger, 0.55)
|
||||
: root.kind === "dangerSolid" ? "transparent" : theme.border
|
||||
Behavior on color { ColorAnimation { duration: 90 } }
|
||||
}
|
||||
|
||||
@@ -134,9 +134,11 @@ class BECStatusBox(BECWidget, CompactPopupWidget):
|
||||
if self.view_kind == "qml":
|
||||
try:
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from bec_widgets.utils.qml_host import create_quick_widget
|
||||
from bec_widgets.utils.quick import create_quick_widget
|
||||
|
||||
quick = create_quick_widget(self, QML_FILE, context={"statusModel": self.model})
|
||||
quick = create_quick_widget(
|
||||
self, QML_FILE, context={"statusModel": self.model}, raise_on_error=True
|
||||
)
|
||||
quick.setMinimumSize(280, 220)
|
||||
return quick
|
||||
except Exception as exc: # pylint: disable=broad-except
|
||||
|
||||
@@ -15,7 +15,7 @@ Rectangle {
|
||||
function toneColor(tone) {
|
||||
if (tone === "success") return theme.success
|
||||
if (tone === "warning") return theme.warning
|
||||
if (tone === "emergency") return theme.emergency
|
||||
if (tone === "emergency") return theme.danger
|
||||
return theme.muted
|
||||
}
|
||||
function iconUrl(name, color, filled) {
|
||||
|
||||
@@ -214,7 +214,7 @@ def test_qml_view_loads(qtbot, mocked_client):
|
||||
|
||||
def test_qml_falls_back_to_widgets(qtbot, mocked_client):
|
||||
with mock.patch(
|
||||
"bec_widgets.utils.qml_host.create_quick_widget", side_effect=RuntimeError("no GL")
|
||||
"bec_widgets.utils.quick.create_quick_widget", side_effect=RuntimeError("no GL")
|
||||
):
|
||||
box = create_widget(
|
||||
qtbot,
|
||||
|
||||
Reference in new issue
Block a user