diff --git a/BoatIcon.qml b/BoatIcon.qml index 2de1d3f..14b237b 100644 --- a/BoatIcon.qml +++ b/BoatIcon.qml @@ -1,12 +1,13 @@ import QtQuick import qs.Commons +import qs.Commons as Commons // A compact side-profile ship for the bar, separate from radar contact markers. Canvas { id: root implicitWidth: 16 implicitHeight: 16 - property color ink: Color.foreground + property color ink: Commons.Color.foreground onInkChanged: requestPaint() onWidthChanged: requestPaint() onHeightChanged: requestPaint() diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d1b0ef..1f25c1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,23 @@ version commit. From 0.7.1 onward, version headings link to release tags. ## Unreleased +## [0.9.1](https://github.com/simoz/omarchy-vessel/releases/tag/v0.9.1) — 2026-11-28 + +### Changed + +- Check in `tests/run` that `qmldir` declares every QML component and that + palette references are qualified, since neither `qmllint` nor + `omarchy plugin validate` reports these. + +### Fixed + +- Load the widget on Qt 6.12, where it failed with "Type Radar unavailable" and, + once loaded, lost its colors. `qmldir` now declares every component, because + the shell resolves only declared types, and palette colors are read through + `Commons.Color`, which QtQuick's new `Color` type cannot shadow. Restart the + shell after updating (`omarchy-restart-shell`): a plugin reload can keep the + previous `qmldir`. + ## [0.9.0](https://github.com/simoz/omarchy-vessel/releases/tag/v0.9.0) — 2026-09-27 ### Added diff --git a/ContactList.qml b/ContactList.qml index cf53377..fc35000 100644 --- a/ContactList.qml +++ b/ContactList.qml @@ -1,5 +1,6 @@ import QtQuick import qs.Commons +import qs.Commons as Commons import "Model.js" as Model // Contacts in receiver order, nearest first. The widget owns selection and @@ -18,7 +19,7 @@ ListView { signal activated() component Label: Text { - color: Color.foreground; font.family: root.family; font.pixelSize: root.textSize + color: Commons.Color.foreground; font.family: root.family; font.pixelSize: root.textSize textFormat: Text.PlainText } @@ -36,19 +37,19 @@ ListView { spacing: 4 // Keep delegates stable across snapshots; MMSI, not position, is identity. model: ShipModel { ships: root.ships } - Rectangle { anchors.fill: parent; color: "transparent"; border.color: Color.accent; visible: root.activeFocus; z: 2 } + Rectangle { anchors.fill: parent; color: "transparent"; border.color: Commons.Color.accent; visible: root.activeFocus; z: 2 } delegate: Rectangle { required property var ship readonly property var modelData: ship objectName: "vessel-" + modelData.mmsi width: ListView.view.width; height: 38 - color: Color.background + color: Commons.Color.background border.width: root.selectedMmsi === modelData.mmsi ? 1 : 0 - border.color: Color.accent + border.color: Commons.Color.accent opacity: modelData.stale ? 0.5 : 1 - Rectangle { anchors.left: parent.left; anchors.leftMargin: 8; anchors.verticalCenter: parent.verticalCenter; width: 8; height: 8; radius: 4; color: root.typeColors[Model.typeGroup(modelData.type)] || Color.accent } + Rectangle { anchors.left: parent.left; anchors.leftMargin: 8; anchors.verticalCenter: parent.verticalCenter; width: 8; height: 8; radius: 4; color: root.typeColors[Model.typeGroup(modelData.type)] || Commons.Color.accent } Label { anchors.left: parent.left; anchors.leftMargin: 24; anchors.verticalCenter: parent.verticalCenter; width: parent.width * 0.65 - 16; elide: Text.ElideRight; text: modelData.name || modelData.mmsi } - Label { anchors.right: parent.right; anchors.rightMargin: 8; anchors.verticalCenter: parent.verticalCenter; text: Model.distance(modelData.distance, root.unit); color: Color.accent } + Label { anchors.right: parent.right; anchors.rightMargin: 8; anchors.verticalCenter: parent.verticalCenter; text: Model.distance(modelData.distance, root.unit); color: Commons.Color.accent } MouseArea { anchors.fill: parent; cursorShape: Qt.PointingHandCursor; onClicked: root.revealRequested(modelData) } } } diff --git a/DetailMap.qml b/DetailMap.qml index 7b281c8..2c2077b 100644 --- a/DetailMap.qml +++ b/DetailMap.qml @@ -1,5 +1,6 @@ import QtQuick import qs.Commons +import qs.Commons as Commons import "Model.js" as Model // Projected vectors share the AIS coordinate system; zoom never stretches a bitmap. @@ -11,10 +12,10 @@ Canvas { // One coordinate unit is the observer's loaded range; offset is already pixels. property real viewScale: 1 property point offset: Qt.point(0, 0) - property color land: Color.foreground - property color sea: Color.background - property color roads: Color.muted - property color waterway: Color.accent + property color land: Commons.Color.foreground + property color sea: Commons.Color.background + property color roads: Commons.Color.muted + property color waterway: Commons.Color.accent onGeographyChanged: requestPaint() onViewScaleChanged: requestPaint() onOffsetChanged: requestPaint() diff --git a/KeyboardHelp.qml b/KeyboardHelp.qml index 7486087..0a6e1fa 100644 --- a/KeyboardHelp.qml +++ b/KeyboardHelp.qml @@ -1,5 +1,6 @@ import QtQuick import qs.Commons +import qs.Commons as Commons import "Keyboard.js" as Keyboard // Modal within the current surface; never opens another receiver or window. @@ -20,15 +21,15 @@ FocusScope { else if (event.key === Qt.Key_Up || event.key === Qt.Key_PageUp) scroll.contentY = Math.max(0, scroll.contentY - (event.key === Qt.Key_Up ? 32 : scroll.height * 0.8)); } - Rectangle { anchors.fill: parent; color: Color.background; opacity: 0.8 } + Rectangle { anchors.fill: parent; color: Commons.Color.background; opacity: 0.8 } MouseArea { anchors.fill: parent; onClicked: root.closed() } Rectangle { x: root.centered ? Math.round((parent.width - width) / 2) : 0 y: root.centered ? Math.round((parent.height - height) / 2) : 0 width: Math.min(parent.width, 760) height: Math.min(parent.height, contents.implicitHeight + 74) - color: Color.background - border.color: Color.muted + color: Commons.Color.background + border.color: Commons.Color.muted MouseArea { anchors.fill: parent } // Keep the close control outside the clipped, scrolling content. Row { @@ -36,17 +37,17 @@ FocusScope { anchors.top: parent.top; anchors.left: parent.left; anchors.right: parent.right anchors.margins: 16 height: 26 - Text { width: parent.width - 70; text: "K E Y S"; color: Color.accent; font.family: root.family; font.bold: true; font.pixelSize: 12; anchors.verticalCenter: parent.verticalCenter } + Text { width: parent.width - 70; text: "K E Y S"; color: Commons.Color.accent; font.family: root.family; font.bold: true; font.pixelSize: 12; anchors.verticalCenter: parent.verticalCenter } Rectangle { id: closeButton objectName: "closeKeyboardHelp" width: 70; height: 26 - color: "transparent"; border.color: activeFocus ? Color.accent : Color.muted + color: "transparent"; border.color: activeFocus ? Commons.Color.accent : Commons.Color.muted activeFocusOnTab: true Accessible.role: Accessible.Button Accessible.name: "Close keyboard shortcuts" Accessible.onPressAction: root.closed() - Text { anchors.centerIn: parent; text: "ESC ×"; color: Color.foreground; font.family: root.family; font.pixelSize: 11 } + Text { anchors.centerIn: parent; text: "ESC ×"; color: Commons.Color.foreground; font.family: root.family; font.pixelSize: 11 } MouseArea { anchors.fill: parent; cursorShape: Qt.PointingHandCursor; onClicked: root.closed() } } } @@ -78,11 +79,11 @@ FocusScope { Rectangle { required property string modelData width: Math.max(18, keyLabel.implicitWidth + 8); height: 18 - color: "transparent"; border.color: Color.muted + color: "transparent"; border.color: Commons.Color.muted Text { id: keyLabel anchors.centerIn: parent - text: modelData; color: Color.foreground + text: modelData; color: Commons.Color.foreground font.family: root.family; font.pixelSize: 10 } } @@ -91,16 +92,16 @@ FocusScope { Text { width: parent.width - 140 text: modelData[1]; wrapMode: Text.WordWrap - color: Color.foreground; font.family: root.family; font.pixelSize: 11 + color: Commons.Color.foreground; font.family: root.family; font.pixelSize: 11 } } } } - Rectangle { width: parent.width; height: 1; color: Color.muted; opacity: 0.5 } + Rectangle { width: parent.width; height: 1; color: Commons.Color.muted; opacity: 0.5 } Text { width: parent.width; wrapMode: Text.WordWrap text: "Click the status beside the location to pause / resume. Zoom in to pan.\nIn Settings, type normally and use Tab to move between controls.\nWith nothing else open, Esc closes the view." - color: Color.muted; font.family: root.family; font.pixelSize: 10 + color: Commons.Color.muted; font.family: root.family; font.pixelSize: 10 } } } diff --git a/KeyboardIcon.qml b/KeyboardIcon.qml index b0dbed4..ee105ec 100644 --- a/KeyboardIcon.qml +++ b/KeyboardIcon.qml @@ -1,9 +1,10 @@ import QtQuick import qs.Commons +import qs.Commons as Commons // Geometric keys stay legible even when the selected font lacks a keyboard glyph. Rectangle { - property color ink: Color.foreground + property color ink: Commons.Color.foreground implicitWidth: 20 implicitHeight: 13 color: "transparent" diff --git a/OfflineMap.qml b/OfflineMap.qml index ac0fb4b..d85622a 100644 --- a/OfflineMap.qml +++ b/OfflineMap.qml @@ -1,5 +1,6 @@ import QtQuick import qs.Commons +import qs.Commons as Commons import "Model.js" as Model // Draw only the bundled geography. Both map layers accept the same normalized @@ -15,8 +16,8 @@ Canvas { onOffsetChanged: requestPaint() property real viewScale: 1 onViewScaleChanged: requestPaint() - property color coastColor: Color.accent - property color landColor: Color.foreground + property color coastColor: Commons.Color.accent + property color landColor: Commons.Color.foreground onGeographyChanged: requestPaint() onCoastColorChanged: requestPaint() onLandColorChanged: requestPaint() diff --git a/Radar.qml b/Radar.qml index 2f717ae..9efdfe5 100644 --- a/Radar.qml +++ b/Radar.qml @@ -1,5 +1,6 @@ import QtQuick import qs.Commons +import qs.Commons as Commons import "Model.js" as Model // Positions are relative to the observer; vessel course controls the symbol orientation. @@ -113,7 +114,7 @@ Item { // Theme colors by type group; the accent covers themes without named hues. property var typeColors: ({}) function inkFor(ship) { - return (ship && typeColors[Model.typeGroup(ship.type)]) || Color.accent; + return (ship && typeColors[Model.typeGroup(ship.type)]) || Commons.Color.accent; } signal selected(string mmsi) implicitHeight: width @@ -142,7 +143,7 @@ Item { objectName: "radarSweep" anchors.fill: parent visible: root.scanning - property color ink: Color.accent + property color ink: Commons.Color.accent onInkChanged: requestPaint() onWidthChanged: requestPaint() onHeightChanged: requestPaint() @@ -171,8 +172,8 @@ Item { Canvas { id: grid anchors.fill: parent - property color ink: Color.accent - property color muted: Color.muted + property color ink: Commons.Color.accent + property color muted: Commons.Color.muted onInkChanged: requestPaint() onMutedChanged: requestPaint() onWidthChanged: requestPaint() @@ -210,11 +211,11 @@ Item { required property string modelData x: index === 1 ? root.width - width : index === 3 ? 0 : (root.width - width) / 2 y: index === 0 ? 0 : index === 2 ? root.height - height : (root.height - height) / 2 - text: modelData; color: Color.muted; font.pixelSize: 12; font.family: "monospace" + text: modelData; color: Commons.Color.muted; font.pixelSize: 12; font.family: "monospace" } } - Rectangle { anchors.centerIn: parent; anchors.horizontalCenterOffset: -root.centerPixels.x; anchors.verticalCenterOffset: -root.centerPixels.y; visible: Math.hypot(root.centerPixels.x, root.centerPixels.y) < root.chartRadius - 4; width: 7; height: 7; radius: 4; color: Color.foreground } - Text { anchors.centerIn: parent; anchors.horizontalCenterOffset: -root.centerPixels.x; anchors.verticalCenterOffset: 17 - root.centerPixels.y; visible: Math.hypot(root.centerPixels.x, 17 - root.centerPixels.y) < root.chartRadius - 16; text: "YOU"; font.pixelSize: 11; color: Color.muted } + Rectangle { anchors.centerIn: parent; anchors.horizontalCenterOffset: -root.centerPixels.x; anchors.verticalCenterOffset: -root.centerPixels.y; visible: Math.hypot(root.centerPixels.x, root.centerPixels.y) < root.chartRadius - 4; width: 7; height: 7; radius: 4; color: Commons.Color.foreground } + Text { anchors.centerIn: parent; anchors.horizontalCenterOffset: -root.centerPixels.x; anchors.verticalCenterOffset: 17 - root.centerPixels.y; visible: Math.hypot(root.centerPixels.x, 17 - root.centerPixels.y) < root.chartRadius - 16; text: "YOU"; font.pixelSize: 11; color: Commons.Color.muted } // The selected vessel's recent wake, beneath the contacts. Older segments // fade out; the line ends at the current position and is clipped to the chart. readonly property var selectedShip: { @@ -263,7 +264,7 @@ Item { opacity: modelData.stale ? 0.4 : 1 Rectangle { anchors.centerIn: parent; width: root.markerSize + 10; height: width; radius: width / 2 - color: "transparent"; border.width: 1.5; border.color: Color.foreground + color: "transparent"; border.width: 1.5; border.color: Commons.Color.foreground visible: target.chosen } Canvas { @@ -271,7 +272,7 @@ Item { visible: target.motion === "moving" rotation: target.orientation !== null ? target.orientation : 0 property color ink: target.ink - property color outline: Color.background + property color outline: Commons.Color.background onWidthChanged: requestPaint() onHeightChanged: requestPaint() onInkChanged: requestPaint() @@ -287,9 +288,9 @@ Item { Rectangle { anchors.centerIn: parent; width: root.markerSize * 0.75; height: width; radius: width / 2 visible: target.motion !== "moving" - color: target.motion === "stationary" ? target.ink : Color.background + color: target.motion === "stationary" ? target.ink : Commons.Color.background border.width: target.motion === "stationary" ? 0.6 : 1 - border.color: target.motion === "stationary" ? Color.background : target.ink + border.color: target.motion === "stationary" ? Commons.Color.background : target.ink } } } @@ -356,7 +357,7 @@ Item { property bool available: true signal activated() width: 32; height: 32; radius: 3 - color: Color.background; border.color: activeFocus ? Color.accent : Color.muted + color: Commons.Color.background; border.color: activeFocus ? Commons.Color.accent : Commons.Color.muted opacity: available ? 0.9 : 0.3 activeFocusOnTab: available Accessible.role: Accessible.Button @@ -365,8 +366,8 @@ Item { Item { anchors.centerIn: parent; width: 12; height: 12 visible: !parent.centerIcon - Rectangle { anchors.centerIn: parent; width: 12; height: 2; color: Color.foreground } - Rectangle { anchors.centerIn: parent; width: 2; height: 12; color: Color.foreground; visible: parent.parent.label === "+" } + Rectangle { anchors.centerIn: parent; width: 12; height: 2; color: Commons.Color.foreground } + Rectangle { anchors.centerIn: parent; width: 2; height: 12; color: Commons.Color.foreground; visible: parent.parent.label === "+" } } // Draw the reticle geometrically so font metrics cannot shift its center. Item { @@ -374,10 +375,10 @@ Item { visible: parent.centerIcon Rectangle { anchors.centerIn: parent; width: 10; height: 10; radius: 5 - color: "transparent"; border.width: 1; border.color: Color.foreground + color: "transparent"; border.width: 1; border.color: Commons.Color.foreground } - Rectangle { anchors.centerIn: parent; width: 14; height: 1; color: Color.foreground } - Rectangle { anchors.centerIn: parent; width: 1; height: 14; color: Color.foreground } + Rectangle { anchors.centerIn: parent; width: 14; height: 1; color: Commons.Color.foreground } + Rectangle { anchors.centerIn: parent; width: 1; height: 14; color: Commons.Color.foreground } } Keys.onReturnPressed: if (available) activated() Keys.onEnterPressed: if (available) activated() diff --git a/RadarLabels.qml b/RadarLabels.qml index 3dca638..aaa4f7a 100644 --- a/RadarLabels.qml +++ b/RadarLabels.qml @@ -1,5 +1,6 @@ import QtQuick import qs.Commons +import qs.Commons as Commons import "Model.js" as Model // Lay out names after reserving space for the observer and visible contacts. @@ -18,8 +19,8 @@ Canvas { property point viewCenter: Qt.point(0, 0) property real viewRadiusNm: 25 property real markerSize: 12 - property color ink: Color.muted - property color halo: Color.background + property color ink: Commons.Color.muted + property color halo: Commons.Color.background onGeographyChanged: requestPaint() onContactsChanged: requestPaint() onViewScaleChanged: requestPaint() diff --git a/Robot.qml b/Robot.qml index 7ea8bb8..1afc8de 100644 --- a/Robot.qml +++ b/Robot.qml @@ -1,5 +1,6 @@ import QtQuick import qs.Commons +import qs.Commons as Commons // Render the sprite with theme-bound rectangles so palette changes apply immediately. Item { @@ -37,7 +38,7 @@ Item { width: Math.ceil(root.width / 16) height: pixel === "b" && (!root.awake) ? 1 : Math.ceil(root.height / 16) visible: pixel !== "." - color: pixel === "a" ? Color.accent : pixel === "b" ? (!root.awake ? Color.muted : root.eyesLit ? Color.accent : Color.background) : Color.foreground + color: pixel === "a" ? Commons.Color.accent : pixel === "b" ? (!root.awake ? Commons.Color.muted : root.eyesLit ? Commons.Color.accent : Commons.Color.background) : Commons.Color.foreground } } // A gentle bob makes activity visible without distracting from the chart. diff --git a/SettingsForm.qml b/SettingsForm.qml index f4b66ca..92bed5f 100644 --- a/SettingsForm.qml +++ b/SettingsForm.qml @@ -2,6 +2,7 @@ import QtQuick import Quickshell import QtQuick.Controls.Basic import qs.Commons +import qs.Commons as Commons // The password lives in this editor only until Save/Cancel. Python never sends a // saved credential back to QML; an empty field preserves the existing key. @@ -77,7 +78,7 @@ Column { } onVisibleChanged: { if (visible) populate(); else { apiKey.text = ""; VesselService.clearCitySearch(); } } component Caption: Text { - color: Color.foreground; font.family: root.family; font.pixelSize: 12 + color: Commons.Color.foreground; font.family: root.family; font.pixelSize: 12 textFormat: Text.PlainText; wrapMode: Text.WordWrap; width: parent.width } component Field: TextField { @@ -90,18 +91,18 @@ Column { if (selectOnFocus) Qt.callLater(() => { if (editor.activeFocus) editor.selectAll(); }); } width: parent.width; height: 38 - color: Color.foreground; placeholderTextColor: Color.muted + color: Commons.Color.foreground; placeholderTextColor: Commons.Color.muted font.family: root.family; font.pixelSize: 13 - selectionColor: Color.accent; selectedTextColor: Color.background + selectionColor: Commons.Color.accent; selectedTextColor: Commons.Color.background selectByMouse: true - background: Rectangle { color: Color.background; border.color: parent.activeFocus ? Color.accent : Color.muted; radius: 3 } + background: Rectangle { color: Commons.Color.background; border.color: parent.activeFocus ? Commons.Color.accent : Commons.Color.muted; radius: 3 } } component Action: Button { focusPolicy: Qt.StrongFocus onActiveFocusChanged: if (activeFocus) root.focusRequested(this) font.family: root.family - contentItem: Text { textFormat: Text.PlainText; text: parent.text; color: Color.accent; font: parent.font; horizontalAlignment: Text.AlignHCenter; verticalAlignment: Text.AlignVCenter } - background: Rectangle { color: Color.background; border.color: parent.activeFocus ? Color.foreground : Color.accent; border.width: parent.activeFocus ? 2 : 1; radius: 3; opacity: parent.enabled ? 1 : 0.4 } + contentItem: Text { textFormat: Text.PlainText; text: parent.text; color: Commons.Color.accent; font: parent.font; horizontalAlignment: Text.AlignHCenter; verticalAlignment: Text.AlignVCenter } + background: Rectangle { color: Commons.Color.background; border.color: parent.activeFocus ? Commons.Color.foreground : Commons.Color.accent; border.width: parent.activeFocus ? 2 : 1; radius: 3; opacity: parent.enabled ? 1 : 0.4 } } // Sibling radio buttons keep the three unit choices mutually exclusive. component UnitOption: RadioButton { @@ -109,20 +110,20 @@ Column { onActiveFocusChanged: if (activeFocus) root.focusRequested(this) font.family: root.family contentItem: Text { - text: parent.text; textFormat: Text.PlainText; color: Color.foreground + text: parent.text; textFormat: Text.PlainText; color: Commons.Color.foreground font: parent.font; leftPadding: 30; verticalAlignment: Text.AlignVCenter } indicator: Rectangle { width: 18; height: 18; radius: 9; y: (parent.height - height) / 2 - color: Color.background; border.color: parent.activeFocus ? Color.foreground : Color.accent + color: Commons.Color.background; border.color: parent.activeFocus ? Commons.Color.foreground : Commons.Color.accent Rectangle { anchors.centerIn: parent; width: 8; height: 8; radius: 4 - color: Color.accent; visible: parent.parent.checked + color: Commons.Color.accent; visible: parent.parent.checked } } } - Caption { text: "VESSEL / SETTINGS"; color: Color.accent; font.bold: true } - Caption { text: "LOCATION"; color: Color.muted; font.pixelSize: 10 } + Caption { text: "VESSEL / SETTINGS"; color: Commons.Color.accent; font.bold: true } + Caption { text: "LOCATION"; color: Commons.Color.muted; font.pixelSize: 10 } Row { width: parent.width; spacing: 6 component Mode: Action { @@ -130,8 +131,8 @@ Column { width: (parent.width - 12) / 3 checked: root.locationMode === mode background: Rectangle { - color: parent.checked ? Qt.alpha(Color.accent, 0.15) : Color.background - border.color: parent.activeFocus ? Color.foreground : parent.checked ? Color.accent : Color.muted + color: parent.checked ? Qt.alpha(Commons.Color.accent, 0.15) : Commons.Color.background + border.color: parent.activeFocus ? Commons.Color.foreground : parent.checked ? Commons.Color.accent : Commons.Color.muted radius: 3 } onClicked: root.chooseMode(mode) @@ -173,7 +174,7 @@ Column { text: modelData.label + (modelData.detail ? " · " + modelData.detail : "") contentItem: Text { text: parent.text; textFormat: Text.PlainText - color: Color.foreground; font.family: root.family; font.pixelSize: 12 + color: Commons.Color.foreground; font.family: root.family; font.pixelSize: 12 wrapMode: Text.WordWrap } onClicked: { @@ -185,8 +186,8 @@ Column { } } } - Caption { text: root.cityName ? "Selected: " + root.cityName : "Search, then choose a city from the results."; color: Color.muted } - Caption { text: VesselService.cityError; visible: text.length > 0; color: Color.accent } + Caption { text: root.cityName ? "Selected: " + root.cityName : "Search, then choose a city from the results."; color: Commons.Color.muted } + Caption { text: VesselService.cityError; visible: text.length > 0; color: Commons.Color.accent } Action { text: "City search: Photon / © OpenStreetMap contributors ↗" font.pixelSize: 10 @@ -196,15 +197,15 @@ Column { Caption { visible: root.locationMode === "ip" text: "Uses your public IP to estimate your location. A VPN may place you elsewhere." - color: Color.muted + color: Commons.Color.muted } Row { width: parent.width; spacing: 8; visible: root.locationMode === "coordinates" Field { id: latitude; width: (parent.width - 8) / 2; placeholderText: "Latitude"; onTextEdited: root.cityName = "" } Field { id: longitude; width: (parent.width - 8) / 2; placeholderText: "Longitude"; onTextEdited: root.cityName = "" } } - Rectangle { width: parent.width; height: 1; color: Color.muted; opacity: 0.3 } - Caption { text: "COVERAGE"; color: Color.muted; font.pixelSize: 10 } + Rectangle { width: parent.width; height: 1; color: Commons.Color.muted; opacity: 0.3 } + Caption { text: "COVERAGE"; color: Commons.Color.muted; font.pixelSize: 10 } Caption { text: "Radius in nautical miles (1–200)" } Field { id: radius; placeholderText: "25" } Caption { text: "Distance units" } @@ -214,9 +215,9 @@ Column { UnitOption { id: kilometres; objectName: "unitKm"; text: "km" } UnitOption { id: miles; objectName: "unitMi"; text: "mi" } } - Caption { text: "Speed is shown in knots (kn)."; color: Color.muted } - Rectangle { width: parent.width; height: 1; color: Color.muted; opacity: 0.3 } - Caption { text: "AIS CONNECTION"; color: Color.muted; font.pixelSize: 10 } + Caption { text: "Speed is shown in knots (kn)."; color: Commons.Color.muted } + Rectangle { width: parent.width; height: 1; color: Commons.Color.muted; opacity: 0.3 } + Caption { text: "AIS CONNECTION"; color: Commons.Color.muted; font.pixelSize: 10 } Row { width: parent.width; spacing: 12 UnitOption { @@ -232,7 +233,7 @@ Column { text: root.provider === "openwaters" ? "Ready without an account. An optional personal token raises the limits." : "Sign in with GitHub to create a free AISStream key." - color: Color.muted + color: Commons.Color.muted } Row { width: parent.width; spacing: 12 @@ -256,5 +257,5 @@ Column { text: root.provider === "openwaters" ? "OPENWATERS / TOKEN ↗" : "GET AN API KEY ↗" onClicked: root.openBrowser(root.provider === "openwaters" ? "https://openwaters.io/ais/" : "https://aisstream.io/account") } - Caption { text: VesselService.settingsError; visible: text.length > 0; color: Color.accent } + Caption { text: VesselService.settingsError; visible: text.length > 0; color: Commons.Color.accent } } diff --git a/TypeFilters.qml b/TypeFilters.qml index 5c02735..bb8e31c 100644 --- a/TypeFilters.qml +++ b/TypeFilters.qml @@ -1,5 +1,6 @@ import QtQuick import qs.Commons +import qs.Commons as Commons import "Model.js" as Model // Type filters double as the color legend; keys 1–6 toggle them too. Equal @@ -17,7 +18,7 @@ Grid { signal closeRequested() component Label: Text { - color: Color.foreground; font.family: root.family; font.pixelSize: root.smallTextSize + color: Commons.Color.foreground; font.family: root.family; font.pixelSize: root.smallTextSize textFormat: Text.PlainText } @@ -32,12 +33,12 @@ Grid { required property var modelData required property int index readonly property bool shown: !root.hiddenTypes[modelData.key] - readonly property color ink: root.typeColors[modelData.key] || Color.accent + readonly property color ink: root.typeColors[modelData.key] || Commons.Color.accent objectName: "typeFilter-" + modelData.key width: root.cellWidth; height: 26; radius: 3 color: shown ? Qt.alpha(ink, 0.12) : "transparent" border.width: 1 - border.color: activeFocus ? Color.foreground : shown ? Qt.alpha(ink, 0.7) : Qt.alpha(Color.muted, 0.5) + border.color: activeFocus ? Commons.Color.foreground : shown ? Qt.alpha(ink, 0.7) : Qt.alpha(Commons.Color.muted, 0.5) activeFocusOnTab: true Accessible.role: Accessible.CheckBox Accessible.name: "Show " + modelData.label.toLowerCase() + " vessels, key " + (index + 1) @@ -55,7 +56,7 @@ Grid { anchors.verticalCenter: parent.verticalCenter width: 8; height: 8; radius: 4 color: chip.shown ? chip.ink : "transparent" - border.width: 1; border.color: chip.shown ? chip.ink : Color.muted + border.width: 1; border.color: chip.shown ? chip.ink : Commons.Color.muted } Label { anchors.left: chipDot.right; anchors.leftMargin: 6 @@ -64,14 +65,14 @@ Grid { text: chip.modelData.label elide: Text.ElideRight font.strikeout: !chip.shown - color: chip.shown ? Color.foreground : Color.muted + color: chip.shown ? Commons.Color.foreground : Commons.Color.muted } Label { id: chipCount anchors.right: parent.right; anchors.rightMargin: 8 anchors.verticalCenter: parent.verticalCenter text: root.typeCounts[chip.modelData.key] || 0 - color: chip.shown ? chip.ink : Color.muted + color: chip.shown ? chip.ink : Commons.Color.muted } MouseArea { anchors.fill: parent diff --git a/VesselDetails.qml b/VesselDetails.qml index 1c8ba23..67202f2 100644 --- a/VesselDetails.qml +++ b/VesselDetails.qml @@ -1,6 +1,7 @@ import QtQuick import QtQuick.Controls.Basic as Controls import qs.Commons +import qs.Commons as Commons import "Model.js" as Model // Details of the selected vessel. The widget supplies the selection, units and @@ -19,7 +20,7 @@ Column { visible: ship !== null component Label: Text { - color: Color.foreground; font.family: root.family; font.pixelSize: root.textSize + color: Commons.Color.foreground; font.family: root.family; font.pixelSize: root.textSize textFormat: Text.PlainText } // Three equal columns of caption and value. @@ -35,7 +36,7 @@ Column { width: (parent.width - 16) / 3; spacing: 4 Label { text: modelData.label - font.pixelSize: root.smallTextSize; color: Color.muted + font.pixelSize: root.smallTextSize; color: Commons.Color.muted } Label { // Wrap breaks long unspaced values, such as port codes, when needed. @@ -71,7 +72,7 @@ Column { width: 30; height: 30; radius: 3 color: "transparent" border.width: 1 - border.color: activeFocus ? Color.accent : "transparent" + border.color: activeFocus ? Commons.Color.accent : "transparent" enabled: vesselUrl.length > 0 activeFocusOnTab: true Accessible.role: Accessible.Button @@ -87,7 +88,7 @@ Column { Controls.ToolTip.text: text Label { anchors.centerIn: parent - text: "↗"; font.pixelSize: 22; color: Color.accent + text: "↗"; font.pixelSize: 22; color: Commons.Color.accent } MouseArea { id: pointer @@ -101,7 +102,7 @@ Column { Label { width: parent.width; wrapMode: Text.WordWrap; font.pixelSize: root.smallTextSize text: root.ship ? root.ship.type + " · " + root.ship.timeSource + " · " + Model.age(root.ship.lastSeen, root.now) + (root.ship.stale ? " · OLD POSITION" : "") : "" - color: root.ship && root.ship.stale ? Color.accent : Color.muted + color: root.ship && root.ship.stale ? Commons.Color.accent : Commons.Color.muted } } DetailRow { @@ -139,5 +140,5 @@ Column { {label: "DRAUGHT", value: root.ship && root.ship.draught ? root.ship.draught.toFixed(1) + " m" : ""} ] } - Rectangle { width: parent.width; height: 1; color: Color.muted; opacity: 0.2 } + Rectangle { width: parent.width; height: 1; color: Commons.Color.muted; opacity: 0.2 } } diff --git a/Widget.qml b/Widget.qml index 477511a..bf81b83 100644 --- a/Widget.qml +++ b/Widget.qml @@ -4,6 +4,7 @@ import QtQuick.Controls.Basic as Controls import Quickshell import Quickshell.Io import qs.Commons +import qs.Commons as Commons import qs.Ui import "." import "Model.js" as Model @@ -54,13 +55,13 @@ BarWidget { readonly property var typeColors: { var colors = {}; Model.typeGroups.forEach(function(group) { - colors[group.key] = !group.hue ? Color.foreground : (themeHues[group.hue] || Color.accent); + colors[group.key] = !group.hue ? Commons.Color.foreground : (themeHues[group.hue] || Commons.Color.accent); }); return colors; } FileView { id: themeColors - path: Color.currentThemePath + "/colors.toml" + path: Commons.Color.currentThemePath + "/colors.toml" watchChanges: true printErrors: false onLoaded: root.themeHues = Model.themeHues(text()) @@ -69,7 +70,7 @@ BarWidget { } // A theme switch replaces the theme directory; the shell palette changes with it. Connections { - target: Color + target: Commons.Color function onAccentChanged() { themeColors.reload(); } function onBackgroundChanged() { themeColors.reload(); } } @@ -201,7 +202,7 @@ BarWidget { Timer { interval: 1000; running: root.viewing; repeat: true; onTriggered: root.now = Date.now() } component Label: Text { - color: Color.foreground; font.family: root.family; font.pixelSize: root.textSize + color: Commons.Color.foreground; font.family: root.family; font.pixelSize: root.textSize textFormat: Text.PlainText } // Consistent hit-area heights and shared styling keep all panel @@ -218,12 +219,12 @@ BarWidget { implicitWidth: actionLabel.implicitWidth + 16 implicitHeight: 30 radius: 3 - color: checked && !hoverOnly ? Qt.alpha(Color.accent, 0.15) : "transparent" + color: checked && !hoverOnly ? Qt.alpha(Commons.Color.accent, 0.15) : "transparent" border.width: 1 // Expansion keeps its accessible state without a persistent visual selection. - border.color: hoverOnly ? (hovered ? Color.accent : "transparent") - : checked ? Color.accent : activeFocus ? Color.foreground - : hovered ? Color.muted : "transparent" + border.color: hoverOnly ? (hovered ? Commons.Color.accent : "transparent") + : checked ? Commons.Color.accent : activeFocus ? Commons.Color.foreground + : hovered ? Commons.Color.muted : "transparent" activeFocusOnTab: true Accessible.role: Accessible.Button Accessible.name: text @@ -234,7 +235,7 @@ BarWidget { id: actionLabel anchors.centerIn: parent visible: !action.iconOnly - text: action.text; color: Color.accent + text: action.text; color: Commons.Color.accent } Keys.onReturnPressed: triggered() Keys.onEnterPressed: triggered() @@ -295,7 +296,7 @@ BarWidget { implicitWidth: 1100 implicitHeight: 760 minimumSize: Qt.size(440, 420) - color: Color.background + color: Commons.Color.background onVisibleChanged: if (!visible && root.expanded) root.close() Item { id: windowSlot; anchors.fill: parent; anchors.margins: 20 } } @@ -347,7 +348,7 @@ BarWidget { anchors.left: parent.left; anchors.right: headerActions.left anchors.verticalCenter: parent.verticalCenter text: "VESSEL / MARINE RADAR"; elide: Text.ElideRight - color: Color.accent; font.bold: true; font.pixelSize: root.smallTextSize + 1 + color: Commons.Color.accent; font.bold: true; font.pixelSize: root.smallTextSize + 1 } Row { id: headerActions @@ -367,7 +368,7 @@ BarWidget { Canvas { anchors.centerIn: parent width: 18; height: 18 - property color ink: Color.accent + property color ink: Commons.Color.accent onInkChanged: requestPaint() onPaint: { var c = getContext("2d"); c.reset(); @@ -388,7 +389,7 @@ BarWidget { implicitWidth: 30; implicitHeight: 30 iconOnly: true onTriggered: root.showHelp() - KeyboardIcon { anchors.centerIn: parent; ink: Color.accent } + KeyboardIcon { anchors.centerIn: parent; ink: Commons.Color.accent } } } } @@ -399,7 +400,7 @@ BarWidget { anchors.left: parent.left; anchors.right: statusBadge.left; anchors.rightMargin: 16 anchors.verticalCenter: parent.verticalCenter text: root.report.location || "Finding your lookout…" - elide: Text.ElideRight; color: Color.muted + elide: Text.ElideRight; color: Commons.Color.muted } Action { id: statusBadge @@ -412,7 +413,7 @@ BarWidget { checked: !VesselService.paused text: VesselService.paused ? "Resume reception (P)" : "Pause reception (P)" color: "transparent" - border.color: activeFocus ? Color.foreground : hovered ? Color.muted : "transparent" + border.color: activeFocus ? Commons.Color.foreground : hovered ? Commons.Color.muted : "transparent" onTriggered: VesselService.togglePaused() Controls.ToolTip.visible: hovered Controls.ToolTip.delay: 500 @@ -425,17 +426,17 @@ BarWidget { Rectangle { anchors.verticalCenter: parent.verticalCenter width: 6; height: 6; radius: 3 - color: statusBadge.live ? Color.accent : Color.muted + color: statusBadge.live ? Commons.Color.accent : Commons.Color.muted } Label { text: VesselService.paused ? "PAUSED" : root.report.status - color: statusBadge.live ? Color.accent : Color.muted + color: statusBadge.live ? Commons.Color.accent : Commons.Color.muted font.bold: true; font.pixelSize: root.smallTextSize + 1 } } } } - Rectangle { width: parent.width; height: 1; color: Color.accent; opacity: 0.4 } + Rectangle { width: parent.width; height: 1; color: Commons.Color.accent; opacity: 0.4 } // The chart and vessel details share a row only when both fit. Grid { width: parent.width @@ -474,8 +475,8 @@ BarWidget { } Row { width: parent.width - Label { width: parent.width / 2; text: "VIEW / " + Model.distance(radar.viewRadiusNm, root.unit); color: Color.muted } - Label { visible: !root.expanded; width: parent.width / 2; text: radar.visibleShips.length + " / " + (root.report.total || 0) + " CONTACTS"; horizontalAlignment: Text.AlignRight; color: Color.accent } + Label { width: parent.width / 2; text: "VIEW / " + Model.distance(radar.viewRadiusNm, root.unit); color: Commons.Color.muted } + Label { visible: !root.expanded; width: parent.width / 2; text: radar.visibleShips.length + " / " + (root.report.total || 0) + " CONTACTS"; horizontalAlignment: Text.AlignRight; color: Commons.Color.accent } } TypeFilters { id: typeFilters @@ -492,7 +493,7 @@ BarWidget { Label { visible: !radar.detailed text: radar.mapLoading ? "LOADING MAP…" : (VesselService.basemap.available ? "OFFLINE MAP" : "BASEMAP UNAVAILABLE") - font.pixelSize: root.smallTextSize; color: Color.muted + font.pixelSize: root.smallTextSize; color: Commons.Color.muted } Item { id: chartFooter @@ -506,7 +507,7 @@ BarWidget { Label { width: parent.width; wrapMode: Text.WordWrap text: "● STATIONARY · ▲ MOVING · ○ SPEED UNKNOWN" - font.pixelSize: root.smallTextSize; color: Color.muted + font.pixelSize: root.smallTextSize; color: Commons.Color.muted } Column { id: credits @@ -520,7 +521,7 @@ BarWidget { textFormat: Text.StyledText font.pixelSize: credits.textSize font.family: root.family - color: Color.muted; linkColor: Color.muted + color: Commons.Color.muted; linkColor: Commons.Color.muted wrapMode: Text.Wrap onLinkActivated: link => Qt.openUrlExternally(link) } @@ -528,7 +529,7 @@ BarWidget { visible: !radar.detailed && VesselService.basemap.available width: parent.width; wrapMode: Text.WordWrap text: "Natural Earth · © GeoNames" - font.pixelSize: credits.textSize; color: Color.muted + font.pixelSize: credits.textSize; color: Commons.Color.muted } } } @@ -544,7 +545,7 @@ BarWidget { id: contactCount objectName: "contactCount" text: radar.visibleShips.length + " / " + (root.report.total || 0) + " CONTACTS" - color: Color.accent + color: Commons.Color.accent } } Robot { @@ -562,7 +563,7 @@ BarWidget { Column { width: keys.wide ? 320 : parent.width spacing: 12 - Rectangle { visible: !keys.wide; width: parent.width; height: 1; color: Color.muted; opacity: 0.3 } + Rectangle { visible: !keys.wide; width: parent.width; height: 1; color: Commons.Color.muted; opacity: 0.3 } VesselDetails { id: details objectName: "vesselDetails" @@ -579,11 +580,11 @@ BarWidget { Label { width: parent.width; wrapMode: Text.WordWrap; visible: root.ships.length === 0 text: root.allShips.length > 0 ? "No vessels of the selected types. Click a type below the radar, or press T to show all." : VesselService.paused ? "Reception paused. Click PAUSED next to the location, or press P, to resume." : root.report.status === "SETUP" ? "Your lookout is ready for setup." : "Listening for vessels. New contacts appear as AIS reports arrive." - color: Color.muted + color: Commons.Color.muted } Label { width: parent.width; wrapMode: Text.WordWrap; visible: !!root.report.error - text: root.report.error || ""; color: Color.accent + text: root.report.error || ""; color: Commons.Color.accent } // Bound the contact list height; the receiver already sorts by distance. ContactList { @@ -613,7 +614,7 @@ BarWidget { anchors.right: parent.right anchors.bottom: parent.bottom height: 43 - Rectangle { width: parent.width; height: 1; color: Color.muted; opacity: 0.3 } + Rectangle { width: parent.width; height: 1; color: Commons.Color.muted; opacity: 0.3 } Row { anchors.bottom: parent.bottom spacing: 4 diff --git a/docs/development.md b/docs/development.md index ace42fe..760c3d6 100644 --- a/docs/development.md +++ b/docs/development.md @@ -64,6 +64,12 @@ still require testing on Omarchy. The host API targets the `quattro` branch. ## Code layout +Declare every QML component in `qmldir`. The shell loads the plugin through +`qs://` URLs, where undeclared sibling types do not resolve, although `file://` +loads, `qmllint` and `omarchy plugin validate` accept them. Read the palette as +`Commons.Color`, with `import qs.Commons as Commons`: from Qt 6.12, QtQuick's own +`Color` type shadows an unqualified `Color`. `tests/qml.test.cjs` checks both. + Code comments are in English. Python formatting and import checks use `ruff.toml`; Ruff is an optional development tool, not a plugin dependency: diff --git a/manifest.json b/manifest.json index 7a84004..ce4a8ff 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "schemaVersion": 1, "id": "simoz.vessel", "name": "Vessel", - "version": "0.9.0", + "version": "0.9.1", "author": "simoz", "license": "MIT", "description": "A marine radar for Omarchy. Discover nearby ships, see where they’re heading, and explore the traffic along your coast.", diff --git a/qmldir b/qmldir index 5ad9f97..1016ef7 100644 --- a/qmldir +++ b/qmldir @@ -1 +1,14 @@ singleton VesselService 1.0 VesselService.qml +BoatIcon 1.0 BoatIcon.qml +ContactList 1.0 ContactList.qml +DetailMap 1.0 DetailMap.qml +KeyboardHelp 1.0 KeyboardHelp.qml +KeyboardIcon 1.0 KeyboardIcon.qml +OfflineMap 1.0 OfflineMap.qml +Radar 1.0 Radar.qml +RadarLabels 1.0 RadarLabels.qml +Robot 1.0 Robot.qml +SettingsForm 1.0 SettingsForm.qml +ShipModel 1.0 ShipModel.qml +TypeFilters 1.0 TypeFilters.qml +VesselDetails 1.0 VesselDetails.qml diff --git a/tests/qml.test.cjs b/tests/qml.test.cjs new file mode 100644 index 0000000..d7a787f --- /dev/null +++ b/tests/qml.test.cjs @@ -0,0 +1,51 @@ +const {test} = require('node:test'); +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const path = require('node:path'); + +// The shell loads plugins through qs:// URLs, where a directory with a qmldir +// exposes only the types it declares. file:// loads, qmllint and +// `omarchy plugin validate` resolve undeclared siblings anyway, so a missing +// entry otherwise surfaces only in the running shell. +const root = path.join(__dirname, '..'); +const manifest = JSON.parse(fs.readFileSync(path.join(root, 'manifest.json'), 'utf8')); +const entryPoints = new Set(Object.values(manifest.entryPoints)); +const qmlFiles = fs.readdirSync(root).filter(name => name.endsWith('.qml')).sort(); +const read = file => fs.readFileSync(path.join(root, file), 'utf8'); + +function declarations() { + const entries = new Map(); + for (const line of read('qmldir').split('\n')) { + const words = line.trim().split(/\s+/); + const singleton = words[0] === 'singleton'; + const [type, version, file] = singleton ? words.slice(1) : words; + if (file && file.endsWith('.qml')) entries.set(file, {type, version, singleton}); + } + return entries; +} + +test('qmldir declares every component under its file name', () => { + const entries = declarations(); + for (const file of qmlFiles) { + if (entryPoints.has(file)) continue; + const entry = entries.get(file); + assert.ok(entry, `${file} is missing from qmldir; the shell cannot resolve undeclared types`); + assert.equal(entry.type, path.basename(file, '.qml'), `${file} is declared under another name`); + assert.equal(entry.singleton, /^\s*pragma Singleton\b/m.test(read(file)), `${file} singleton declaration`); + } + for (const file of entries.keys()) assert.ok(qmlFiles.includes(file), `qmldir lists a missing file: ${file}`); +}); + +// From Qt 6.12, QtQuick exports its own Color singleton, which shadows the +// shell's palette for an unqualified name: Color.accent becomes undefined. +test('palette references are qualified as Commons.Color', () => { + for (const file of qmlFiles) { + const source = read(file); + source.split('\n').forEach((line, index) => { + const code = line.replace(/(^|\s)\/\/.*$/, ''); + assert.doesNotMatch(code, /(?