Move Qt/Tauri/full Web SPA under archive/, ship hermit as CLI/TUI plus libcstcore and cst-webui/1 HTTP+SSE (turn lifecycle hooks, capabilities). Co-authored-by: Cursor <cursoragent@cursor.com>
51 lines
1.6 KiB
QML
51 lines
1.6 KiB
QML
import QtQuick
|
|
|
|
// One icon, from the desktop's icon theme (image://csttheme/, see
|
|
// app/src/ui/ThemeIcons.cpp), tinted with a color of the window's own.
|
|
//
|
|
// `glyph` is the last resort: a machine with no icon theme at all gets the
|
|
// unicode character the app used before, rather than an empty hole. Every
|
|
// place that shows an icon names its glyph, so nothing can go blank.
|
|
Item {
|
|
id: root
|
|
property string name: ""
|
|
property string glyph: ""
|
|
property color color: Theme.textDim
|
|
property int size: 16
|
|
implicitWidth: size
|
|
implicitHeight: size
|
|
|
|
/* "#rrggbb": a color typed to a string in QML carries alpha and a
|
|
* leading '#', which the provider's query would choke on. */
|
|
function hex(c) {
|
|
function two(v) {
|
|
const s = Math.round(Math.max(0, Math.min(1, v)) * 255).toString(16)
|
|
return s.length < 2 ? "0" + s : s
|
|
}
|
|
return "#" + two(c.r) + two(c.g) + two(c.b)
|
|
}
|
|
|
|
Image {
|
|
id: img
|
|
anchors.fill: parent
|
|
source: root.name.length
|
|
? "image://csttheme/" + root.name + "?color=" + encodeURIComponent(root.hex(root.color))
|
|
: ""
|
|
sourceSize.width: root.size
|
|
sourceSize.height: root.size
|
|
fillMode: Image.PreserveAspectFit
|
|
smooth: true
|
|
visible: status === Image.Ready
|
|
}
|
|
|
|
Text {
|
|
anchors.fill: parent
|
|
visible: img.status === Image.Error && root.glyph.length > 0
|
|
text: root.glyph
|
|
color: root.color
|
|
font.pixelSize: Math.round(root.size * 0.85)
|
|
horizontalAlignment: Text.AlignHCenter
|
|
verticalAlignment: Text.AlignVCenter
|
|
}
|
|
}
|