Add glassMxrph shell sources

Initial commit of the Quickshell desktop suite: bar, dock, launcher,
settings, Control Center, dashboard, OSD, lock screen, desktop widgets,
plugin host with the vendored Noctalia/Omarchy compatibility layer,
helpers, packaging, tests and phase documentation.

Includes the optimization work so far: usage widgets and dashboard
gauges no longer animate continuously, desktop widgets pause while
covered, system controls stop flickering on background polls, dock app
matching uses an indexed catalog, and workspace ghosts are created only
for occupied slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mxandClaude Opus 5.5 committed 2026-10-07 22:36:17 +02:00
commit 99e64a7713
433 files changed
+57792

No files matched your search

@@ -0,0 +1,242 @@
pragma Singleton
import QtQuick
import "BorderGeometry.js" as Geometry
// Central border-spec factory for shell surfaces and controls. A spec carries
// color, optional gradient, and top/right/bottom/left widths so renderers can
// choose the cheap Rectangle path or the Shape-ring path without duplicating
// theme parsing logic.
QtObject {
id: root
function none() {
return flat("transparent", 0)
}
function flat(color, width) {
return {
color: color || "transparent",
widths: Geometry.parseWidthSpec(width, 0),
gradient: { colors: [], angle: 0, enabled: false },
}
}
function value(section, key) {
var v = Color.shellValues[section + "." + key]
return (v === undefined || v === null) ? "" : v
}
function valueOr(section, keys) {
for (var i = 0; i < keys.length; i++) {
var v = value(section, keys[i])
if (String(v).length > 0) return v
}
return ""
}
function resolveValueRef(raw) {
var s = String(raw || "").replace(/^\s+|\s+$/g, "")
var seen = {}
while (s.match(/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/) && !seen[s]) {
seen[s] = true
var next = Color.shellValues[s]
if (next === undefined || next === null || String(next).length === 0) break
s = String(next).replace(/^\s+|\s+$/g, "")
}
return s
}
function alpha(section, key, fallback) {
var raw = value(section, key)
if (String(raw).length === 0) return fallback
var n = Number(raw)
return isFinite(n) ? Geometry.clampAlpha(n) : fallback
}
function cssColor(color, opacity) {
var a = opacity === undefined || opacity === null ? 1 : Geometry.clampAlpha(opacity)
if (color && typeof color === "object" && color.r !== undefined) {
if (typeof Qt !== "undefined" && Qt.rgba) {
return Qt.rgba(color.r, color.g, color.b, (color.a === undefined ? 1 : color.a) * a)
}
return "#"
+ Geometry.padHex(color.r * 255)
+ Geometry.padHex(color.g * 255)
+ Geometry.padHex(color.b * 255)
+ Geometry.padHex((color.a === undefined ? 1 : color.a) * a * 255)
}
var s = String(color || "").replace(/^\s+|\s+$/g, "")
var role = s.toLowerCase()
if (role === "foreground" || role === "text") return cssColor(Color.foreground, a)
if (role === "accent") return cssColor(Color.accent, a)
if (role === "urgent") return cssColor(Color.urgent, a)
if (role === "background") return cssColor(Color.background, a)
if (role === "transparent") return "transparent"
return Geometry.canonicalColor(s, a)
}
function resolvedGradient(raw, fallbackColor, opacity) {
var s = String(raw || "").replace(/^\s+|\s+$/g, "")
if (s.length === 0) return { colors: [], angle: 0, enabled: false }
var parts = s.split(/\s+/)
var colors = []
var angle = 0
for (var i = 0; i < parts.length; i++) {
if (parts[i].match(/^-?\d+(?:\.\d+)?deg$/)) angle = Number(parts[i].replace(/deg$/, ""))
else colors.push(cssColor(parts[i], opacity))
}
if (colors.length === 0) colors.push(cssColor(fallbackColor, opacity))
return { colors: colors, angle: angle, enabled: colors.length > 1 }
}
function sameColor(a, b) {
if (typeof Qt === "undefined" || !Qt.color) return String(a) === String(b)
var ca = typeof a === "string" ? Qt.color(a) : a
var cb = typeof b === "string" ? Qt.color(b) : b
if (!ca || !cb || ca.r === undefined || cb.r === undefined) return String(a) === String(b)
return Math.round(ca.r * 255) === Math.round(cb.r * 255)
&& Math.round(ca.g * 255) === Math.round(cb.g * 255)
&& Math.round(ca.b * 255) === Math.round(cb.b * 255)
&& Math.round((ca.a === undefined ? 1 : ca.a) * 255) === Math.round((cb.a === undefined ? 1 : cb.a) * 255)
}
function localOrSurfaceSpec(section, token, localColor, defaultColor, fallbackWidth, alphaKey) {
if (!sameColor(localColor, defaultColor)) return flat(localColor, fallbackWidth)
return surfaceSpec(section, token, localColor, fallbackWidth, alphaKey)
}
function surfaceWidths(section, token, fallbackWidth) {
var base = valueOr(section, token === "border" ? ["border-width"] : [token + "-width", "border-width"])
var widths = Geometry.parseWidthSpec(base, fallbackWidth)
return Geometry.withSideOverrides(
widths,
valueOr(section, token === "border" ? ["border-width-top"] : [token + "-width-top", "border-width-top"]),
valueOr(section, token === "border" ? ["border-width-right"] : [token + "-width-right", "border-width-right"]),
valueOr(section, token === "border" ? ["border-width-bottom"] : [token + "-width-bottom", "border-width-bottom"]),
valueOr(section, token === "border" ? ["border-width-left"] : [token + "-width-left", "border-width-left"])
)
}
function borderValue(raw, fallbackColor, opacity, legacyGradientRaw) {
var fallback = cssColor(fallbackColor, opacity)
var primaryRaw = String(raw || "").replace(/^\s+|\s+$/g, "")
var primary = resolvedGradient(primaryRaw.length > 0 ? primaryRaw : fallbackColor, fallbackColor, opacity)
var color = primary.colors.length > 0 ? primary.colors[0] : fallback
var gradient = primary.enabled ? primary : { colors: [], angle: 0, enabled: false }
// Backward compatibility for existing configs written during the separate
// border-gradient experiment. New configs put solid colors and gradients in
// the same border token.
if (!gradient.enabled && String(legacyGradientRaw || "").replace(/^\s+|\s+$/g, "").length > 0) {
var legacy = resolvedGradient(legacyGradientRaw, color, opacity)
if (legacy.enabled) gradient = legacy
}
return { color: color, gradient: gradient }
}
function surfaceSpec(section, token, fallbackColor, fallbackWidth, alphaKey) {
var opacity = alpha(section, alphaKey || token + "-alpha", 1.0)
var legacyGradientRaw = valueOr(section, token === "border" ? ["border-gradient"] : [token + "-gradient", "border-gradient"])
var resolved = borderValue(resolveValueRef(value(section, token)), fallbackColor, opacity, legacyGradientRaw)
return {
color: resolved.color,
widths: surfaceWidths(section, token, fallbackWidth),
gradient: resolved.gradient,
}
}
function hyprlandActiveSpec(fallbackColor, fallbackWidth) {
var raw = value("hyprland", "active-border")
var opacity = alpha("hyprland", "active-border-alpha", 1.0)
// Existing generated themes predate [hyprland] and already keep the active
// border under [notifications]. Use it as the compatibility source until
// the next theme refresh writes the shared token.
if (String(raw).length === 0) {
raw = value("notifications", "border")
opacity = alpha("notifications", "border-alpha", opacity)
}
var resolved = borderValue(resolveValueRef(raw), fallbackColor, opacity, "")
return {
color: resolved.color,
widths: Geometry.parseWidthSpec(value("hyprland", "active-border-width"), fallbackWidth),
gradient: resolved.gradient,
}
}
function controlPrefix(state) {
if (state === "hover" || state === "hot") return "hover-cursor"
return state || "normal"
}
function controlColor(prefix, foreground, accent, urgent) {
if (prefix === "focus") return Style.focusStateColor(foreground, accent, urgent)
if (prefix === "hover-cursor") return Style.hoverStateColor(foreground, accent, urgent)
if (prefix === "selected") return Style.selectedStateColor(foreground, accent, urgent)
return Style.normalStateColor(foreground, accent, urgent)
}
function controlAlpha(prefix) {
if (prefix === "focus") return Style.focusBorderAlpha
if (prefix === "hover-cursor") return Style.hoverBorderAlpha
if (prefix === "selected") return Style.selectedBorderAlpha
return Style.normalBorderAlpha
}
function controlFallbackWidth(prefix) {
if (prefix === "focus") return Style.focusBorderWidth
if (prefix === "hover-cursor") return Style.hoverBorderWidth
if (prefix === "selected") return Style.selectedBorderWidth
return Style.normalBorderWidth
}
function controlWidths(state) {
var prefix = controlPrefix(state)
var fallbackWidth = controlFallbackWidth(prefix)
var base = Style.styleOverrides[prefix + "-border-width"]
var widths = Geometry.parseWidthSpec(base, fallbackWidth)
return Geometry.withSideOverrides(
widths,
Style.styleOverrides[prefix + "-border-width-top"],
Style.styleOverrides[prefix + "-border-width-right"],
Style.styleOverrides[prefix + "-border-width-bottom"],
Style.styleOverrides[prefix + "-border-width-left"]
)
}
function controlHasWidth(state) {
return Geometry.maxWidth(controlWidths(state)) > 0
}
function controlSpec(state, foreground, accent, urgent) {
var prefix = controlPrefix(state)
var resolved = borderValue(
Style.styleOverrides[prefix + "-border"],
controlColor(prefix, foreground, accent, urgent),
controlAlpha(prefix),
Style.styleOverrides[prefix + "-border-gradient"]
)
return { color: resolved.color, widths: controlWidths(prefix), gradient: resolved.gradient }
}
function withWidth(spec, width) {
if (!spec) return flat("transparent", 0)
return { color: spec.color, gradient: spec.gradient, widths: Geometry.parseWidthSpec(width, 0) }
}
function isNone(spec) { return !spec || Geometry.maxWidth(spec.widths) <= 0 }
function needsOverlay(spec) { return Geometry.needsOverlay(spec) }
function canUseNative(spec) { return Geometry.canUseNative(spec) }
function top(spec) { return spec && spec.widths ? spec.widths.top : 0 }
function right(spec) { return spec && spec.widths ? spec.widths.right : 0 }
function bottom(spec) { return spec && spec.widths ? spec.widths.bottom : 0 }
function left(spec) { return spec && spec.widths ? spec.widths.left : 0 }
function uniformWidth(spec) { return spec && spec.widths ? spec.widths.top : 0 }
function color(spec) { return spec ? spec.color : "transparent" }
}
@@ -0,0 +1,373 @@
.pragma library
function clamp(value, min, max) {
var n = Number(value)
if (!isFinite(n)) return min
return Math.max(min, Math.min(max, n))
}
function clampAlpha(value) {
return clamp(value, 0, 1)
}
function padHex(value) {
var n = clamp(Math.round(Number(value)), 0, 255)
var h = n.toString(16)
return h.length < 2 ? "0" + h : h
}
function qmlHexColor(rgb, alphaByte) {
var rgbPart = String(rgb || "").replace(/^#/, "")
var a = clamp(Math.round(Number(alphaByte)), 0, 255)
if (typeof Qt !== "undefined" && Qt.rgba && rgbPart.length >= 6) {
return Qt.rgba(
parseInt(rgbPart.substring(0, 2), 16) / 255,
parseInt(rgbPart.substring(2, 4), 16) / 255,
parseInt(rgbPart.substring(4, 6), 16) / 255,
a / 255
)
}
var aHex = padHex(a)
return aHex.toLowerCase() === "ff" ? "#" + rgbPart : "#" + rgbPart + aHex
}
function canonicalColor(value, alpha) {
var a = alpha === undefined || alpha === null ? 1 : clampAlpha(alpha)
var s = String(value || "").replace(/^\s+|\s+$/g, "")
var m
m = s.match(/^#([0-9A-Fa-f]{3})$/)
if (m) {
var sh = m[1]
return qmlHexColor(
sh.charAt(0) + sh.charAt(0)
+ sh.charAt(1) + sh.charAt(1)
+ sh.charAt(2) + sh.charAt(2),
a * 255
)
}
m = s.match(/^#([0-9A-Fa-f]{6})([0-9A-Fa-f]{2})?$/)
if (m) {
var colorAlpha = m[2] ? parseInt(m[2], 16) / 255 : 1
return qmlHexColor(m[1], colorAlpha * a * 255)
}
m = s.match(/^[Rr][Gg][Bb]\(([0-9A-Fa-f]{6})\)$/)
if (m) return qmlHexColor(m[1], a * 255)
m = s.match(/^[Rr][Gg][Bb][Aa]\(([0-9A-Fa-f]{6})([0-9A-Fa-f]{2})\)$/)
if (m) return qmlHexColor(m[1], (parseInt(m[2], 16) / 255) * a * 255)
m = s.match(/^[Rr][Gg][Bb]\(([0-9]+),([0-9]+),([0-9]+)\)$/)
if (m) return qmlHexColor(padHex(m[1]) + padHex(m[2]) + padHex(m[3]), a * 255)
m = s.match(/^[Rr][Gg][Bb][Aa]\(([0-9]+),([0-9]+),([0-9]+),([0-9.]+)\)$/)
if (m) return qmlHexColor(padHex(m[1]) + padHex(m[2]) + padHex(m[3]), clampAlpha(m[4]) * a * 255)
m = s.match(/^0x([0-9A-Fa-f]{2})([0-9A-Fa-f]{6})$/)
if (m) return qmlHexColor(m[2], (parseInt(m[1], 16) / 255) * a * 255)
return s
}
function parseWidthSpec(value, fallback) {
var fb = Number(fallback)
if (!isFinite(fb) || fb < 0) fb = 0
if (value === undefined || value === null || value === "") {
return { top: fb, right: fb, bottom: fb, left: fb }
}
var parts = String(value).match(/-?\d+(?:\.\d+)?/g) || []
var nums = []
for (var i = 0; i < parts.length && i < 4; i++) {
var n = Number(parts[i])
nums.push(isFinite(n) && n > 0 ? n : 0)
}
if (nums.length === 0) nums = [fb]
if (nums.length === 1) return { top: nums[0], right: nums[0], bottom: nums[0], left: nums[0] }
if (nums.length === 2) return { top: nums[0], right: nums[1], bottom: nums[0], left: nums[1] }
if (nums.length === 3) return { top: nums[0], right: nums[1], bottom: nums[2], left: nums[1] }
return { top: nums[0], right: nums[1], bottom: nums[2], left: nums[3] }
}
function withSideOverrides(widths, top, right, bottom, left) {
var out = {
top: Number(widths && widths.top) || 0,
right: Number(widths && widths.right) || 0,
bottom: Number(widths && widths.bottom) || 0,
left: Number(widths && widths.left) || 0,
}
if (top !== undefined && top !== null && top !== "") out.top = Math.max(0, Number(top) || 0)
if (right !== undefined && right !== null && right !== "") out.right = Math.max(0, Number(right) || 0)
if (bottom !== undefined && bottom !== null && bottom !== "") out.bottom = Math.max(0, Number(bottom) || 0)
if (left !== undefined && left !== null && left !== "") out.left = Math.max(0, Number(left) || 0)
return out
}
function parseGradientSpec(value, fallbackColor, alpha) {
var s = String(value || "").replace(/^\s+|\s+$/g, "")
var colors = []
var angle = 0
var parts = s.length > 0 ? s.split(/\s+/) : []
for (var i = 0; i < parts.length; i++) {
var part = parts[i]
var angleMatch = part.match(/^(-?\d+(?:\.\d+)?)deg$/)
if (angleMatch) angle = Number(angleMatch[1])
else colors.push(canonicalColor(part, alpha))
}
if (colors.length === 0 && fallbackColor !== undefined && fallbackColor !== null)
colors.push(canonicalColor(fallbackColor, alpha))
return {
colors: colors,
angle: isFinite(angle) ? angle : 0,
enabled: colors.length > 1,
}
}
function isUniform(widths) {
if (!widths) return true
return widths.top === widths.right && widths.top === widths.bottom && widths.top === widths.left
}
function maxWidth(widths) {
if (!widths) return 0
return Math.max(widths.top || 0, widths.right || 0, widths.bottom || 0, widths.left || 0)
}
function needsOverlay(spec) {
if (!spec) return false
if (maxWidth(spec.widths) <= 0) return false
return !!(spec.gradient && spec.gradient.enabled) || !isUniform(spec.widths)
}
function canUseNative(spec) {
return !!spec && maxWidth(spec.widths) > 0 && !needsOverlay(spec)
}
function normalizeRadii(w, h, r) {
var tl = { rx: Math.max(0, Number(r.tlrx) || 0), ry: Math.max(0, Number(r.tlry) || 0) }
var tr = { rx: Math.max(0, Number(r.trrx) || 0), ry: Math.max(0, Number(r.trry) || 0) }
var br = { rx: Math.max(0, Number(r.brrx) || 0), ry: Math.max(0, Number(r.brry) || 0) }
var bl = { rx: Math.max(0, Number(r.blrx) || 0), ry: Math.max(0, Number(r.blry) || 0) }
var scale = 1
if (tl.rx + tr.rx > w && tl.rx + tr.rx > 0) scale = Math.min(scale, w / (tl.rx + tr.rx))
if (bl.rx + br.rx > w && bl.rx + br.rx > 0) scale = Math.min(scale, w / (bl.rx + br.rx))
if (tl.ry + bl.ry > h && tl.ry + bl.ry > 0) scale = Math.min(scale, h / (tl.ry + bl.ry))
if (tr.ry + br.ry > h && tr.ry + br.ry > 0) scale = Math.min(scale, h / (tr.ry + br.ry))
if (scale < 1) {
tl.rx *= scale; tr.rx *= scale; br.rx *= scale; bl.rx *= scale
tl.ry *= scale; tr.ry *= scale; br.ry *= scale; bl.ry *= scale
}
return { tl: tl, tr: tr, br: br, bl: bl }
}
function appendArc(path, rx, ry, sweep, point) {
if (rx > 0 && ry > 0) path.push("A", rx, ry, 0, 0, sweep, point.x, point.y)
else path.push("L", point.x, point.y)
}
function roundedRectPath(x, y, w, h, radii) {
if (w <= 0 || h <= 0) return ""
var r = normalizeRadii(w, h, radii)
var right = x + w
var bottom = y + h
var p = []
p.push("M", x + r.tl.rx, y)
p.push("H", right - r.tr.rx)
appendArc(p, r.tr.rx, r.tr.ry, 1, { x: right, y: y + r.tr.ry })
p.push("V", bottom - r.br.ry)
appendArc(p, r.br.rx, r.br.ry, 1, { x: right - r.br.rx, y: bottom })
p.push("H", x + r.bl.rx)
appendArc(p, r.bl.rx, r.bl.ry, 1, { x: x, y: bottom - r.bl.ry })
p.push("V", y + r.tl.ry)
appendArc(p, r.tl.rx, r.tl.ry, 1, { x: x + r.tl.rx, y: y })
p.push("Z")
return p.join(" ")
}
function borderBoundary(x, y, w, h, radii) {
var r = radii && radii.tl ? radii : normalizeRadii(w, h, radii)
var right = x + w
var bottom = y + h
return {
start: [
{ x: x + r.tl.rx, y: y },
{ x: right, y: y + r.tr.ry },
{ x: right - r.br.rx, y: bottom },
{ x: x, y: bottom - r.bl.ry },
],
end: [
{ x: right - r.tr.rx, y: y },
{ x: right, y: bottom - r.br.ry },
{ x: x + r.bl.rx, y: bottom },
{ x: x, y: y + r.tl.ry },
],
corner: [r.tr, r.br, r.bl, r.tl],
}
}
function appendForwardCorner(path, boundary, side) {
var corner = boundary.corner[side]
appendArc(path, corner.rx, corner.ry, 1, boundary.start[(side + 1) % 4])
}
function appendReverseCorner(path, boundary, side) {
var corner = boundary.corner[side]
appendArc(path, corner.rx, corner.ry, 0, boundary.end[side])
}
function reverseBoundaryPath(boundary) {
var p = ["M", boundary.start[0].x, boundary.start[0].y]
for (var side = 3; side >= 0; side--) {
appendReverseCorner(p, boundary, side)
p.push("L", boundary.start[side].x, boundary.start[side].y)
}
p.push("Z")
return p.join(" ")
}
function runPath(outer, inner, start, length) {
var previous = (start + 3) % 4
var next = (start + length) % 4
var p = ["M", outer.end[previous].x, outer.end[previous].y]
appendForwardCorner(p, outer, previous)
for (var offset = 0; offset < length; offset++) {
var side = (start + offset) % 4
p.push("L", outer.end[side].x, outer.end[side].y)
appendForwardCorner(p, outer, side)
}
p.push("L", inner.start[next].x, inner.start[next].y)
for (var reverseOffset = length - 1; reverseOffset >= 0; reverseOffset--) {
var reverseSide = (start + reverseOffset) % 4
appendReverseCorner(p, inner, reverseSide)
p.push("L", inner.start[reverseSide].x, inner.start[reverseSide].y)
}
appendReverseCorner(p, inner, previous)
p.push("Z")
return p.join(" ")
}
function radiiFit(w, h, r) {
return r.tlrx + r.trrx <= w
&& r.blrx + r.brrx <= w
&& r.tlry + r.blry <= h
&& r.trry + r.brry <= h
}
// Internal geometry output used by ringPath and focused topology tests.
// Connected enabled-side runs share one closed contour; opposite-only sides
// need two. The all-sides case is one compound winding path with a reversed
// inner loop. Disabled sides never require touching or epsilon-offset inner
// geometry, so a zero/zero rounded corner emits no border pixels.
function borderPaths(w, h, radius, widths) {
w = Math.max(0, Number(w) || 0)
h = Math.max(0, Number(h) || 0)
radius = Math.max(0, Number(radius) || 0)
widths = widths || { top: 0, right: 0, bottom: 0, left: 0 }
if (w <= 0 || h <= 0) return []
var top = Math.max(0, Number(widths.top) || 0)
var right = Math.max(0, Number(widths.right) || 0)
var bottom = Math.max(0, Number(widths.bottom) || 0)
var left = Math.max(0, Number(widths.left) || 0)
var enabled = [top > 0, right > 0, bottom > 0, left > 0]
if (!enabled[0] && !enabled[1] && !enabled[2] && !enabled[3]) return []
var outerRadii = normalizeRadii(w, h, {
tlrx: radius, tlry: radius,
trrx: radius, trry: radius,
brrx: radius, brry: radius,
blrx: radius, blry: radius,
})
var outerPath = roundedRectPath(0, 0, w, h, {
tlrx: outerRadii.tl.rx, tlry: outerRadii.tl.ry,
trrx: outerRadii.tr.rx, trry: outerRadii.tr.ry,
brrx: outerRadii.br.rx, brry: outerRadii.br.ry,
blrx: outerRadii.bl.rx, blry: outerRadii.bl.ry,
})
var iw = w - left - right
var ih = h - top - bottom
if (iw <= 0 || ih <= 0) return [outerPath]
var desiredInnerRadii = {
tlrx: Math.max(0, outerRadii.tl.rx - left),
tlry: Math.max(0, outerRadii.tl.ry - top),
trrx: Math.max(0, outerRadii.tr.rx - right),
trry: Math.max(0, outerRadii.tr.ry - top),
brrx: Math.max(0, outerRadii.br.rx - right),
brry: Math.max(0, outerRadii.br.ry - bottom),
blrx: Math.max(0, outerRadii.bl.rx - left),
blry: Math.max(0, outerRadii.bl.ry - bottom),
}
// Normalizing an inner radius that cannot fit can move its tangent beyond
// the outer rounded boundary. Winding fill may then paint outside the outer
// contour. Conservatively treat that rounded interior as consumed instead.
if (!radiiFit(iw, ih, desiredInnerRadii)) return [outerPath]
var innerRadii = normalizeRadii(iw, ih, desiredInnerRadii)
var outer = borderBoundary(0, 0, w, h, outerRadii)
var inner = borderBoundary(left, top, iw, ih, innerRadii)
if (enabled[0] && enabled[1] && enabled[2] && enabled[3])
return [outerPath + " " + reverseBoundaryPath(inner)]
var paths = []
for (var start = 0; start < 4; start++) {
if (!enabled[start] || enabled[(start + 3) % 4]) continue
var length = 1
while (length < 4 && enabled[(start + length) % 4]) length++
paths.push(runPath(outer, inner, start, length))
}
return paths
}
function ringPath(w, h, radius, widths) {
return borderPaths(w, h, radius, widths).join(" ")
}
function gradientEndpoints(w, h, angle) {
w = Math.max(1, Number(w) || 1)
h = Math.max(1, Number(h) || 1)
var rad = (Number(angle) || 0) * Math.PI / 180
var dx = Math.cos(rad)
var dy = Math.sin(rad)
var len = (Math.abs(w * dx) + Math.abs(h * dy)) / 2
var cx = w / 2
var cy = h / 2
return {
x1: cx - dx * len,
y1: cy - dy * len,
x2: cx + dx * len,
y2: cy + dy * len,
}
}
function stopColor(colors, index) {
if (!colors || colors.length === 0) return "transparent"
if (index < colors.length) return colors[index]
return colors[colors.length - 1]
}
function stopPosition(colors, index) {
var count = colors ? colors.length : 0
if (count <= 1) return index === 0 ? 0 : 1
if (index >= count) return 1
return index / (count - 1)
}
+109
View File
@@ -0,0 +1,109 @@
pragma Singleton
import QtQuick
import "../../../theme" as G
// glassMxrph replacement for Omarchy's Color singleton. Same API (palette,
// per-surface groups, helper functions), but every value comes from the
// glassMxrph theme so plugins render with our glass tint, accent and text.
// Omarchy's theme files (colors.toml / shell.toml) are not read.
QtObject {
id: root
property color foreground: G.Theme.text
property color background: G.Theme.surface
property color accent: G.Theme.accentVivid
property color urgent: G.Theme.urgent
property color muted: G.Theme.textSecondary
// Kept for API compatibility; always empty here.
property var shellValues: ({})
property var themeShellValues: ({})
property var userShellValues: ({})
// Surfaces: glass tint at the shell's glass opacity, hairline borders.
readonly property color glass: Qt.alpha(G.Theme.surface, G.Theme.glassOpacity)
readonly property color panel: Qt.alpha(G.Theme.surface, G.Theme.panelOpacity)
function pick(key, fallback) {
return fallback;
}
function pickAlpha(key, fallback) {
return Util.clampAlpha(fallback);
}
function firstColorToken(value) {
return value;
}
function flatColor(value, fallback) {
return fallback;
}
function composed(colorKey, alphaKey, colorFallback, alphaFallback) {
return Util.alpha(colorFallback, alphaFallback);
}
function loadColors(raw) {
}
function parseShell(raw) {
return {};
}
function mergeShell() {
}
function loadShell(raw) {
}
function loadUserShell(raw) {
}
readonly property QtObject bar: QtObject {
property color background: root.glass
property color text: root.foreground
property color active: root.accent
}
readonly property QtObject popups: QtObject {
property color background: root.glass
property color text: root.foreground
property color border: G.Theme.border
}
readonly property QtObject tooltip: QtObject {
property color background: root.panel
property color text: root.foreground
property color border: G.Theme.border
}
readonly property QtObject notifications: QtObject {
property color background: root.panel
property color text: root.foreground
property color border: G.Theme.border
property color countdown: root.accent
}
readonly property QtObject menu: QtObject {
property color background: root.panel
property color text: root.foreground
property color border: G.Theme.border
property color scrim: Qt.alpha(G.Theme.surface, 0.5)
property color selectedBackground: G.Theme.hover
property color selectedText: root.accent
property color selectedBorder: "transparent"
}
readonly property QtObject polkit: QtObject {
property color background: root.panel
property color text: root.foreground
property color textError: root.urgent
property color border: G.Theme.border
property color borderError: root.urgent
property color accent: root.accent
property color scrim: Qt.alpha(G.Theme.surface, 0.5)
}
readonly property QtObject lock: QtObject {
property color background: root.panel
property color text: root.foreground
property color placeholder: Qt.alpha(root.foreground, 0.66)
property color textError: root.urgent
property color border: G.Theme.border
property color borderActive: root.accent
property color borderError: root.urgent
property color selection: Qt.alpha(root.accent, 0.45)
}
readonly property QtObject imagePicker: QtObject {
property color scrim: Qt.alpha(G.Theme.surface, 0.5)
property color text: root.foreground
property color selectedBorder: root.accent
property color unselectedBorder: Qt.alpha(root.foreground, 0.28)
}
}
@@ -0,0 +1,77 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
// Every ShellIpc handler, so the shell can answer an omarchy-shell call over
// its own socket instead of through a qs ipc client started per call. It
// answers only what qs ipc would: the first live, enabled handler for a
// target, and only the functions that handler declares. Those are allowed by
// name, never inferred from what a function call happens to reach: QObject
// methods such as destroy() are callable but not enumerable.
Singleton {
id: root
property var handlers: []
// A bare handler's own functions (signals and hooks such as targetChanged),
// which qs ipc never exposes and neither may the socket.
readonly property var builtins: functionNames(bareHandler)
IpcHandler {
id: bareHandler
enabled: false
}
function functionNames(object) {
var names = []
for (var key in object) {
if (typeof object[key] === "function") names.push(key)
}
return names
}
function register(handler) {
if (handlers.indexOf(handler) === -1) handlers.push(handler)
}
function unregister(handler) {
var index = handlers.indexOf(handler)
if (index !== -1) handlers.splice(index, 1)
}
function handlerFor(target) {
for (var i = 0; i < handlers.length; i++) {
var handler = handlers[i]
if (handler && handler.enabled && handler.target === target) return handler
}
return null
}
// { ran: true, output } once the function ran; { ran: false } when it did
// not (unknown target or function, wrong argument count), so the caller
// can ask qs ipc for its exact answer without running anything twice.
// The functions a handler declares: what it enumerates beyond a bare
// handler, less property change signals.
function declaredFunctions(handler) {
return functionNames(handler).filter(function(name) {
return builtins.indexOf(name) === -1 && !/Changed$/.test(name)
})
}
function call(target, method, args) {
var handler = handlerFor(target)
if (!handler) return { ran: false }
if (declaredFunctions(handler).indexOf(method) === -1) return { ran: false }
if (handler[method].length !== args.length) return { ran: false }
var result
try {
result = handler[method].apply(handler, args)
} catch (error) {
console.warn("ipc " + target + " " + method + " failed: " + error)
return { ran: true, output: "" }
}
return { ran: true, output: result === undefined || result === null ? "" : String(result) }
}
}
@@ -0,0 +1,12 @@
import QtQuick
import Quickshell.Io
// An IpcHandler the shell can also answer over its own socket (see
// IpcRegistry), so omarchy-shell reaches it without a qs ipc client. qs ipc
// still reaches it as before.
IpcHandler {
id: handler
Component.onCompleted: IpcRegistry.register(handler)
Component.onDestruction: IpcRegistry.unregister(handler)
}
+466
View File
@@ -0,0 +1,466 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
import "../../../theme" as G
// Shared structural style tokens for the shell. Color is the palette
// singleton; Style holds everything else themes can influence — corner
// rounding, gap to screen edges, state affordances, spacing, typography
// scale, and bar dimensions.
//
// `cornerRadius` mirrors Hyprland's `decoration:rounding`. `gapsOut` is
// half of Hyprland's `general:gaps_out` — Hyprland's value works well as
// a window-to-window gap but feels too cavernous when used as the
// distance from a panel/notification to the screen edge, so the shell
// halves it. Themes and user Hyprland config own those values; the
// shell picks them up by re-running `hyprctl getoption` on startup and
// after theme IPC applies a theme.
//
// Typography, spacing, and bar size come from theme/shell.toml.
// `[font] base-size` is the rem root; every `Style.font.<token>` derives
// from it via the scale multipliers below unless the theme pins that
// specific token. `[spacing] scale` multiplies shared margins, gaps,
// padding, controls, and panel dimensions while preserving each component's
// proportions; by default it also tracks `base-size`. `[bar]
// size-horizontal` / `size-vertical` set the cross-axis dimension for
// top/bottom and left/right bars at the default 12px font size; by default
// those dimensions scale with `base-size` so larger fonts don't clip.
QtObject {
id: root
// glassMxrph: rounding and spacing follow the glassMxrph theme; panels
// attach to the bar as drawers, so there is no gap to the screen edge.
property int cornerRadius: Math.round(G.Theme.radius * 0.5)
property int gapsOut: 0
// ---------------------------------------------------------- state tokens
//
// Shared interactive-state tokens for every reusable surface in the kit.
// The vocabulary:
// normal — idle control chrome
// hover-cursor — mouse hover OR panel keyboard cursor (`hasCursor`)
// selected — persistent chosen/current state
// focus — actual Qt activeFocus, defaulting to hover-cursor
//
// Each state has a color token plus fill/border alphas. Color tokens
// may be palette roles (`foreground`, `accent`, `urgent`, `background`)
// or hex colors. Set a state's border width to 0 to drop that border.
// glassMxrph state look: hairline borders, soft hover/selected fills and an
// accent selection, matching glassMxrph's own controls.
property var styleOverrides: ({
"normal-border-alpha": 0.18,
"hover-cursor-border-alpha": 0.18,
"focus-border-alpha": 0.6,
"focus-color": "accent",
"normal-fill-alpha": 0.05,
"hover-cursor-fill-alpha": 0.09,
"selected-color": "accent",
"selected-fill-alpha": 0.28,
"selected-border-width": 0,
"pressed-fill-alpha": 0.16,
"selection-color": "accent"
})
function styleRawNum(key) {
var v = styleOverrides[key]
var n = Number(v)
return isFinite(n) ? n : null
}
function styleNum(key, fallback) {
var n = styleRawNum(key)
return n === null ? fallback : n
}
function styleAlpha(key, fallback) {
return Util.clampAlpha(styleNum(key, fallback))
}
function styleString(key, fallback) {
var v = styleOverrides[key]
if (typeof v !== "string") return fallback
v = v.replace(/^\s+|\s+$/g, "")
return v.length > 0 ? v : fallback
}
readonly property string normalColorToken: styleString("normal-color", "foreground")
readonly property string hoverColorToken: styleString("hover-cursor-color", "foreground")
readonly property string selectedColorToken: styleString("selected-color", "foreground")
readonly property string pressedColorToken: styleString("pressed-color", hoverColorToken)
readonly property string focusColorToken: styleString("focus-color", hoverColorToken)
readonly property string selectionColorToken: styleString("selection-color", "foreground")
readonly property int normalBorderWidth: Math.max(0, Math.round(styleNum("normal-border-width", 1)))
readonly property int hoverBorderWidth: Math.max(0, Math.round(styleNum("hover-cursor-border-width", normalBorderWidth)))
readonly property int selectedBorderWidth: Math.max(0, Math.round(styleNum("selected-border-width", 0)))
readonly property int focusBorderWidth: Math.max(0, Math.round(styleNum("focus-border-width", hoverBorderWidth)))
readonly property real normalFillAlpha: styleAlpha("normal-fill-alpha", 0.04)
readonly property real hoverFillAlpha: styleAlpha("hover-cursor-fill-alpha", 0.08)
readonly property real selectedFillAlpha: styleAlpha("selected-fill-alpha", 0.18)
readonly property real pressedFillAlpha: styleAlpha("pressed-fill-alpha", 0.22)
readonly property real focusFillAlpha: styleAlpha("focus-fill-alpha", hoverFillAlpha)
readonly property real selectionFillAlpha: styleAlpha("selection-fill-alpha", 0.35)
readonly property real normalBorderAlpha: styleAlpha("normal-border-alpha", 0.4)
readonly property real hoverBorderAlpha: styleAlpha("hover-cursor-border-alpha", 0.25)
readonly property real selectedBorderAlpha: styleAlpha("selected-border-alpha", 1.0)
readonly property real focusBorderAlpha: styleAlpha("focus-border-alpha", hoverBorderAlpha)
function colorFromHex(value, fallback) {
var s = String(value || "").replace(/^\s+|\s+$/g, "")
var shortHex = s.match(/^#([0-9A-Fa-f]{3})$/)
if (shortHex) {
var sh = shortHex[1]
return Qt.rgba(
parseInt(sh.charAt(0) + sh.charAt(0), 16) / 255,
parseInt(sh.charAt(1) + sh.charAt(1), 16) / 255,
parseInt(sh.charAt(2) + sh.charAt(2), 16) / 255,
1)
}
var hex = s.match(/^#([0-9A-Fa-f]{6})([0-9A-Fa-f]{2})?$/)
if (!hex) return fallback
var h = hex[1]
return Qt.rgba(
parseInt(h.substr(0, 2), 16) / 255,
parseInt(h.substr(2, 2), 16) / 255,
parseInt(h.substr(4, 2), 16) / 255,
hex[2] ? parseInt(hex[2], 16) / 255 : 1)
}
function resolveStateColor(token, foreground, accent, urgent, fallback) {
var fb = fallback || foreground || Color.foreground
var s = String(token || "").replace(/^\s+|\s+$/g, "")
var role = s.toLowerCase()
if (role === "foreground" || role === "text") return foreground || Color.foreground
if (role === "accent") return accent || Color.accent
if (role === "urgent") return urgent || Color.urgent
if (role === "background") return Color.background
if (role === "transparent") return Qt.rgba(0, 0, 0, 0)
return colorFromHex(s, fb)
}
function normalStateColor(foreground, accent, urgent) {
return resolveStateColor(normalColorToken, foreground, accent, urgent, foreground || Color.foreground)
}
function hoverStateColor(foreground, accent, urgent) {
return resolveStateColor(hoverColorToken, foreground, accent, urgent, foreground || Color.foreground)
}
function selectedStateColor(foreground, accent, urgent) {
return resolveStateColor(selectedColorToken, foreground, accent, urgent, foreground || Color.foreground)
}
function pressedStateColor(foreground, accent, urgent) {
return resolveStateColor(pressedColorToken, foreground, accent, urgent, hoverStateColor(foreground, accent, urgent))
}
function focusStateColor(foreground, accent, urgent) {
var role = String(focusColorToken || "").replace(/^\s+|\s+$/g, "").toLowerCase()
if (role === "hover" || role === "hover-cursor" || role === "inherit")
return hoverStateColor(foreground, accent, urgent)
return resolveStateColor(focusColorToken, foreground, accent, urgent, hoverStateColor(foreground, accent, urgent))
}
function selectionStateColor(foreground, accent, urgent) {
return resolveStateColor(selectionColorToken, foreground, accent, urgent, foreground || Color.foreground)
}
function normalFillFor(foreground, accent, urgent) { return Util.alpha(normalStateColor(foreground, accent, urgent), normalFillAlpha) }
function hoverFillFor(foreground, accent, urgent) { return Util.alpha(hoverStateColor(foreground, accent, urgent), hoverFillAlpha) }
function selectedFillFor(foreground, accent, urgent) { return Util.alpha(selectedStateColor(foreground, accent, urgent), selectedFillAlpha) }
function pressedFillFor(foreground, accent, urgent) { return Util.alpha(pressedStateColor(foreground, accent, urgent), pressedFillAlpha) }
function focusFillFor(foreground, accent, urgent) { return Util.alpha(focusStateColor(foreground, accent, urgent), focusFillAlpha) }
function selectionFillFor(foreground, accent, urgent) { return Util.alpha(selectionStateColor(foreground, accent, urgent), selectionFillAlpha) }
function normalBorderFor(foreground, accent, urgent) { return Util.alpha(normalStateColor(foreground, accent, urgent), normalBorderAlpha) }
function hoverBorderFor(foreground, accent, urgent) { return Util.alpha(hoverStateColor(foreground, accent, urgent), hoverBorderAlpha) }
function selectedBorderFor(foreground, accent, urgent) { return Util.alpha(selectedStateColor(foreground, accent, urgent), selectedBorderAlpha) }
function focusBorderFor(foreground, accent, urgent) { return Util.alpha(focusStateColor(foreground, accent, urgent), focusBorderAlpha) }
// Composite helpers for the focus > hover > normal priority chain used by
// every form control surface (TextField, NumberField, Dropdown, Toggle,
// etc.). Saves callers from re-writing the three-line ternary ladder for
// fill / border / border-width on every Rectangle background.
function controlFill(focused, hot, foreground, accent) {
if (focused) return focusFillFor(foreground, accent)
if (hot) return hoverFillFor(foreground, accent)
return normalFillFor(foreground, accent)
}
function controlBorder(focused, hot, foreground, accent) {
if (focused) return focusBorderFor(foreground, accent)
if (hot) return hoverBorderFor(foreground, accent)
return normalBorderFor(foreground, accent)
}
function controlBorderWidth(focused, hot) {
if (focused) return focusBorderWidth
if (hot) return hoverBorderWidth
return normalBorderWidth
}
// Convenience colors resolved against the foundational palette.
readonly property color normalFill: normalFillFor(Color.foreground, Color.accent, Color.urgent)
readonly property color hoverFill: hoverFillFor(Color.foreground, Color.accent, Color.urgent)
readonly property color selectedFill: selectedFillFor(Color.foreground, Color.accent, Color.urgent)
readonly property color pressedFill: pressedFillFor(Color.foreground, Color.accent, Color.urgent)
readonly property color focusFillColor: focusFillFor(Color.foreground, Color.accent, Color.urgent)
readonly property color normalBorderColor: normalBorderFor(Color.foreground, Color.accent, Color.urgent)
readonly property color hoverBorderColor: hoverBorderFor(Color.foreground, Color.accent, Color.urgent)
readonly property color selectedBorderColor: selectedBorderFor(Color.foreground, Color.accent, Color.urgent)
readonly property color focusBorderColor: focusBorderFor(Color.foreground, Color.accent, Color.urgent)
readonly property color selectedAccentFill: Util.alpha(Color.accent, selectedFillAlpha)
readonly property color selectionFill: selectionFillFor(Color.foreground, Color.accent, Color.urgent)
// ---------------------------------------------------------- spacing
//
// The spacing scale is the shell equivalent of rem for margins, gaps,
// and padding. Components keep their existing proportions by asking for
// the old pixel value through `Style.space(px)` (or `spaceReal(px)` for
// fractional geometry); themes can make the shell denser or roomier
// with `[spacing] scale`, or pin individual tokens.
property real spacingScale: 1.0
property bool spacingScaleWithFont: true
property var spacingOverrides: ({})
readonly property real effectiveSpacingScale: spacingScale * (spacingScaleWithFont ? fontScale : 1)
function spaceReal(px) {
var n = Number(px)
if (!isFinite(n) || n <= 0) return 0
return n * effectiveSpacingScale
}
function space(px) {
var n = spaceReal(px)
if (n <= 0) return 0
return Math.max(1, Math.round(n))
}
function spacingToken(key, fallback) {
var v = spacingOverrides[key]
var n = Number(v)
return (isFinite(n) && n >= 0) ? Math.round(n) : space(fallback)
}
readonly property QtObject spacing: QtObject {
readonly property real scale: root.effectiveSpacingScale
readonly property int hairline: root.space(1)
readonly property int xxs: root.spacingToken("xxs", 2)
readonly property int xs: root.spacingToken("xs", 3)
readonly property int sm: root.spacingToken("sm", 4)
readonly property int md: root.spacingToken("md", 6)
readonly property int lg: root.spacingToken("lg", 8)
readonly property int xl: root.spacingToken("xl", 10)
readonly property int xxl: root.spacingToken("xxl", 12)
readonly property int xxxl: root.spacingToken("xxxl", 14)
readonly property int huge: root.spacingToken("huge", 18)
readonly property int controlGap: root.spacingToken("control-gap", 8)
readonly property int controlPaddingX: root.spacingToken("control-padding-x", 10)
readonly property int controlPaddingY: root.spacingToken("control-padding-y", 6)
readonly property int inputPaddingY: root.spacingToken("input-padding-y", 7)
readonly property int controlHeight: root.spacingToken("control-height", 28)
readonly property int popupRowHeight: root.spacingToken("popup-row-height", 28)
readonly property int dropdownWidth: root.spacingToken("dropdown-width", 240)
readonly property int searchableDropdownWidth: root.spacingToken("searchable-dropdown-width", 260)
readonly property int numberFieldWidth: root.spacingToken("number-field-width", 120)
readonly property int searchablePopupMinHeight: root.spacingToken("searchable-popup-min-height", 220)
readonly property int rowGap: root.spacingToken("row-gap", 8)
readonly property int rowPaddingX: root.spacingToken("row-padding-x", 12)
readonly property int labelGap: root.spacingToken("label-gap", 4)
readonly property int panelGap: root.spacingToken("panel-gap", 14)
readonly property int panelPadding: root.spacingToken("panel-padding", 18)
readonly property int popupPadding: root.spacingToken("popup-padding", 14)
}
// ---------------------------------------------------------- typography
//
// `fontFamily` defaults to "monospace" so the bar and every qs.Ui
// component follows the fontconfig alias `omarchy-font-set` writes.
// Themes can override per-token via [font] in shell.toml, but the
// family stays system-wide.
property string fontFamily: Qt.application.font.family
// The concrete family `monospace` resolves to right now, e.g.
// "JetBrainsMono Nerd Font". Bind `font.family` to `fontFamily` (so the
// alias path keeps working when the user runs `omarchy font set`), but
// read `resolvedFontFamily` when you want to *display* what's drawing.
property string resolvedFontFamily: Qt.application.font.family
// The only sanity floor is 1px. Themes and users can make this as large
// as they like; if the shell gets ridiculous, that's their call.
property int fontBaseSize: 12
property var fontOverrides: ({})
property var barOverrides: ({})
property bool barScaleWithFont: true
readonly property real fontScale: Math.max(1 / 12, fontBaseSize / 12)
function fontPx(mult) {
return Math.max(1, Math.round(fontBaseSize * mult))
}
function fontToken(key, fallback) {
var v = fontOverrides[key]
var n = Number(v)
return (isFinite(n) && n > 0) ? Math.round(n) : fallback
}
function barToken(key, fallback) {
var v = barOverrides[key]
var n = Number(v)
var base = (isFinite(n) && n > 0) ? n : fallback
if (barScaleWithFont) base *= fontScale
return Math.max(1, Math.round(base))
}
function boolToken(value, fallback) {
if (value === undefined || value === null) return fallback
var s = String(value).replace(/^\s+|\s+$/g, "").toLowerCase()
if (s === "true" || s === "1" || s === "yes" || s === "on") return true
if (s === "false" || s === "0" || s === "no" || s === "off") return false
return fallback
}
// The menu, polkit, emojis, and clipboard surfaces honor an
// OMARCHY_MENU_FONT override for users who want a different family on the
// summoned popups than on the bar. Resolved once at startup; an empty env
// value falls back to the shared fontconfig alias.
readonly property string menuFontFamily: {
var override = Quickshell.env("OMARCHY_MENU_FONT")
return (override && override.length > 0) ? override : fontFamily
}
readonly property QtObject font: QtObject {
readonly property string family: root.fontFamily
readonly property string resolvedFamily: root.resolvedFontFamily
readonly property string menuFamily: root.menuFontFamily
readonly property int baseSize: root.fontBaseSize
readonly property int caption: root.fontToken("caption", root.fontPx(0.833)) // 10
readonly property int bodySmall: root.fontToken("body-small", root.fontPx(0.917)) // 11
readonly property int body: root.fontToken("body", root.fontPx(1.0)) // 12
readonly property int subtitle: root.fontToken("subtitle", root.fontPx(1.083)) // 13
readonly property int title: root.fontToken("title", root.fontPx(1.167)) // 14
readonly property int heading: root.fontToken("heading", root.fontPx(1.333)) // 16
readonly property int display: root.fontToken("display", root.fontPx(2.0)) // 24
readonly property int displayLarge: root.fontToken("display-large", root.fontPx(2.333)) // 28
readonly property int iconSmall: root.fontToken("icon-small", bodySmall)
readonly property int icon: root.fontToken("icon", title)
readonly property int iconLarge: root.fontToken("icon-large", root.fontPx(1.5)) // 18
}
readonly property QtObject bar: QtObject {
readonly property int sizeHorizontal: root.barToken("size-horizontal", 26)
readonly property int sizeVertical: root.barToken("size-vertical", 28)
readonly property int iconSlot: root.barToken("icon-slot", 27)
readonly property int iconCanvas: root.barToken("icon-canvas", 16)
readonly property int iconFont: root.barToken("icon-font", 13)
readonly property int statusSlot: root.barToken("status-slot", 21)
}
// Off with Hyprland's own animations, as `omarchy toggle animations` turns
// them off for machines that render on the CPU. Every shell animation runs
// for Style.duration(ms), which is then 0, so nothing is drawn in between.
property bool reduceMotion: G.Theme.duration === 0
function duration(ms) {
return reduceMotion ? 0 : ms
}
// Hyprland/fontconfig lookups are not used under glassMxrph.
function refresh() {
}
function scheduleRefresh() {
}
function applyRoundingJson(raw) {
try {
var json = JSON.parse(raw || "{}")
var n = Number(json.int)
if (isFinite(n) && n >= 0) cornerRadius = n
} catch (e) {
// hyprctl missing / Hyprland not running — leave the previous value.
}
}
function applyGapsOutJson(raw) {
try {
var json = JSON.parse(raw || "{}")
var css = String(json.css || "")
var parts = css.match(/-?\d+(?:\.\d+)?/g) || []
var n = parts.length > 0 ? Number(parts[0]) : Number(json.int)
if (isFinite(n) && n >= 0) gapsOut = Math.max(0, Math.round(n / 2))
} catch (e) {
// hyprctl missing / Hyprland not running — leave the previous value.
}
}
// Pull typography, bar dimensions, state tokens, and spacing out of the
// shell.toml dict that Color already parsed. Called by Color.loadShell so
// a single parse pass feeds both singletons.
function applyShellValues(values) {
var fontOut = {}
var barOut = {}
var styleOut = {}
var spacingOut = {}
var nextBase = 12
var nextSpacingScale = 1.0
var nextSpacingScaleWithFont = true
var nextBarScaleWithFont = true
var v = values || {}
for (var fullKey in v) {
var dot = fullKey.indexOf(".")
if (dot < 0) continue
var section = fullKey.substr(0, dot)
var key = fullKey.substr(dot + 1)
var raw = v[fullKey]
if (section === "font") {
var ival = parseInt(raw, 10)
if (!isFinite(ival)) continue
if (key === "base-size") nextBase = ival
else fontOut[key] = ival
} else if (section === "bar") {
if (key === "scale-with-font") {
nextBarScaleWithFont = boolToken(raw, nextBarScaleWithFont)
} else if (key === "size-horizontal" || key === "size-vertical") {
var b = parseInt(raw, 10)
if (isFinite(b)) barOut[key] = b
}
} else if (section === "spacing") {
if (key === "scale-with-font") {
nextSpacingScaleWithFont = boolToken(raw, nextSpacingScaleWithFont)
} else {
var fval = parseFloat(raw)
if (!isFinite(fval)) continue
if (key === "scale") nextSpacingScale = fval
else spacingOut[key] = fval
}
} else if (section === "controls" || section === "style") {
// Strings are passed through; styleRawNum/styleString coerce on read.
// [style] is the legacy name for [controls].
styleOut[key] = raw
}
}
// Keep only a 1px sanity floor. Per-token overrides aren't clamped
// either — a theme that wants display-large = 64 should be allowed to
// ship it.
if (!isFinite(nextBase) || nextBase < 1) nextBase = 1
if (!isFinite(nextSpacingScale) || nextSpacingScale < 0) nextSpacingScale = 1.0
spacingScale = nextSpacingScale
spacingScaleWithFont = nextSpacingScaleWithFont
fontBaseSize = nextBase
fontOverrides = fontOut
barOverrides = barOut
barScaleWithFont = nextBarScaleWithFont
spacingOverrides = spacingOut
styleOverrides = styleOut
}
}
+159
View File
@@ -0,0 +1,159 @@
pragma Singleton
import Quickshell
import QtQuick
// Shared utility helpers used across plugins. Pure functions only — no
// state. Anything stateful belongs on Color, Style, or a service.
QtObject {
id: root
function clamp(value, min, max) {
var n = Number(value)
if (!isFinite(n)) return min
return Math.max(min, Math.min(max, n))
}
function clampAlpha(value) {
return clamp(value, 0, 1)
}
function wheelSteps(accumulator, delta) {
// Some mouse/compositor combinations scale a single notch well beyond
// Qt's conventional 120 units. Keep one event to one step while still
// accumulating the smaller deltas emitted by touchpads.
delta = Math.max(-120, Math.min(120, delta))
if (accumulator * delta < 0) accumulator = 0
var total = accumulator + delta
var steps = total < 0 ? Math.ceil(total / 120) : Math.floor(total / 120)
return { steps: steps, remainder: total - steps * 120 }
}
// Compose a base color with an opacity. Accepts a color object or a hex
// string; null/undefined yields transparent black at the requested alpha.
function alpha(c, opacity) {
var a = clampAlpha(opacity)
if (!c) return Qt.rgba(0, 0, 0, a)
if (typeof c === "string") c = Qt.color(c)
return Qt.rgba(c.r, c.g, c.b, a)
}
// file:// URL with each path segment percent-encoded so spaces and
// special chars in user paths don't break Image.source.
function fileUrl(path) {
if (!path) return ""
return "file://" + String(path).split("/").map(encodeURIComponent).join("/")
}
function isVideoPath(path) {
return /\.(mp4|m4v|mov|webm|mkv|avi)$/i.test(String(path || ""))
}
// Single-quote a string for bash. The replace handles embedded single
// quotes by closing, escaping, and re-opening the literal.
function shellQuote(value) {
return "'" + String(value || "").replace(/'/g, "'\\''") + "'"
}
function execDetached(command) {
Quickshell.execDetached(["bash", "-lc", command])
}
// Run an argv vector without a shell interpreting it: the constant `exec "$@"`
// means the args only ever land in positional parameters, which bash expands
// without re-tokenizing — so untrusted data ($(id), a filename) stays literal.
// The login shell (-l) keeps the PATH/session env GUI targets (omasnap, mpv,
// xdg-open) need. Prefer this over execDetached for anything built from input.
function execArgv(argv) {
Quickshell.execDetached(["bash", "-lc", 'exec "$@"', "bash"].concat(argv))
}
function isPlainObject(value) {
return value !== null && typeof value === "object" && !Array.isArray(value)
}
function canonicalWidgetId(id) {
return String(id || "")
}
// Best-effort base64 decode. Returns "" on parse failure rather than
// surfacing garbage downstream.
function decodeBase64(value) {
var s = String(value || "")
if (!s) return ""
try { return Qt.atob(s) } catch (e) { return "" }
}
function cloneJson(value) {
return JSON.parse(JSON.stringify(value === undefined ? null : value))
}
// Parse the last line of a custom-module / indicator process output as
// waybar-style JSON ({text, class, tooltip, ...}). Falls back to {text: raw}
// when the output isn't JSON, and {} for empty output.
function parseModuleJson(raw) {
var text = String(raw || "").trim()
if (!text) return {}
var lines = text.split("\n")
try {
return JSON.parse(lines[lines.length - 1])
} catch (e) {
return { text: text }
}
}
// Standard Qt text-editing keys shared by every searchable panel's filter:
// Backspace delete previous character
// Ctrl+Backspace delete previous word (Qt DeleteStartOfWord)
// Ctrl+U clear the whole field
// True only when the event would actually change the text, so an empty
// filter never swallows the key — panels keep their own empty-filter
// fallbacks (e.g. menu back-navigation) in later branches.
function editsFilter(event, text) {
if (!text) return false
// Alt/Meta-modified sequences belong to other shortcuts — never edit here.
if (event.modifiers & (Qt.AltModifier | Qt.MetaModifier)) return false
if (event.key === Qt.Key_U) // Ctrl+U only (not Ctrl+Shift+U → Unicode input)
return event.modifiers === Qt.ControlModifier
return event.key === Qt.Key_Backspace // plain, Shift, or Ctrl Backspace
}
// New filter text after applying an edit key. Assumes editsFilter(event, text).
function editedFilter(event, text) {
if (event.key === Qt.Key_U) return "" // Ctrl+U: clear
if (event.modifiers & Qt.ControlModifier) // Ctrl+Backspace: word
return text.replace(/\s+$/, "").replace(/\S+$/, "")
return text.slice(0, -1) // Backspace: char
}
// Layout normalization shared by bar config consumers
// so the two never drift. Entries are deep-cloned to decouple from the
// input config; consumers can mutate without leaking back to shell.json.
function normalizeLayoutEntry(entry) {
if (typeof entry === "string") return { id: canonicalWidgetId(entry) }
if (isPlainObject(entry) && entry.id) {
var copy = cloneJson(entry)
copy.id = canonicalWidgetId(copy.id)
return copy
}
return null
}
function normalizeLayoutSection(list) {
if (!Array.isArray(list)) return []
var out = []
for (var i = 0; i < list.length; i++) {
var e = normalizeLayoutEntry(list[i])
if (e) out.push(e)
}
return out
}
function normalizeLayout(layout) {
var src = isPlainObject(layout) ? layout : {}
return {
left: normalizeLayoutSection(src.left),
center: normalizeLayoutSection(src.center),
right: normalizeLayoutSection(src.right)
}
}
}
+6
View File
@@ -0,0 +1,6 @@
singleton Border 1.0 Border.qml
singleton Color 1.0 Color.qml
singleton IpcRegistry 1.0 IpcRegistry.qml
singleton Style 1.0 Style.qml
singleton Util 1.0 Util.qml
ShellIpc 1.0 ShellIpc.qml
@@ -0,0 +1,70 @@
import QtQuick
// Capability-scoped shell surface for installed third-party plugins.
//
// The callbacks are closed over one plugin id by shell.qml. A plugin can call
// them directly, but it cannot widen their scope: ordinary plugins are limited
// to their own id, and full-bar callbacks independently enforce their explicit
// non-authentication UI scope. This object avoids directly injecting the host
// shell, but it is not a QML sandbox: visual plugins share the host object tree.
QtObject {
id: api
required property string pluginId
property var appLibrary: null
property var bar: null
property var barConfig: ({})
property var idleConfig: ({})
property var _serviceLookup: null
property var _firstPartyServiceLookup: null
property var _barEntryShellLookup: null
property var _summon: null
property var _hide: null
property var _toggle: null
property var _isOpen: null
property var _updateSettings: null
property var _mutateBarConfig: null
function serviceFor(id) {
return _serviceLookup ? _serviceLookup(String(id || "")) : null
}
// Only full-bar facades receive narrow proxies for the specific
// non-authentication services used by the built-in bar widgets.
function firstPartyServiceFor(id) {
return _firstPartyServiceLookup
? _firstPartyServiceLookup(String(id || "")) : null
}
function pluginShellForBarEntry(ownerId, moduleName) {
return _barEntryShellLookup
? _barEntryShellLookup(String(ownerId || ""), String(moduleName || "")) : null
}
function summon(id, payloadJson) {
return _summon ? _summon(String(id || ""), String(payloadJson || "")) : false
}
function hide(id) {
return _hide ? _hide(String(id || "")) : false
}
function toggle(id, payloadJson) {
return _toggle ? _toggle(String(id || ""), String(payloadJson || "")) : false
}
function isPluginOpen(id) {
return _isOpen ? _isOpen(String(id || "")) : false
}
function updateEntryInline(id, settings) {
return _updateSettings ? _updateSettings(String(id || ""), settings) : false
}
function mutateShellConfig(mutator) {
return _mutateBarConfig && typeof mutator === "function"
? _mutateBarConfig(mutator) : false
}
}
+1
View File
@@ -0,0 +1 @@
PluginShellApi 1.0 PluginShellApi.qml
+26
View File
@@ -0,0 +1,26 @@
Omarchy shell UI kit (qs.Ui, qs.Commons), vendored for running Omarchy shell
plugins inside glassMxrph. Source: https://github.com/omacom/omarchy (branch quattro, shell/).
glassMxrph replaces Color and the Style tokens and restyles WidgetButton, ToggleSwitch, PanelSlider,
PopupCard and KeyboardPanel so plugins match the glassMxrph look; imports point at qs.compat.omarchy.*.
bin/ holds portable Omarchy helper commands, with #!/usr/bin/env shebangs for NixOS.
Copyright (c) David Heinemeier Hansson
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,45 @@
import QtQuick
import qs.compat.omarchy.Commons
// The shell draws stills only. OWE owns video backgrounds on the desktop, and
// it feeds the lock screen through its own socket.
Item {
id: root
property string path: ""
property int version: 0
// Unversioned images cache by path. A caller whose version changes with every
// new file, as the lock's does, may cache too: the version is in the URL.
property bool cached: version === 0
// A caller that knows the size its screen needs, in physical pixels, sets
// constrainDecode and decodeSize. The image then waits for that size rather
// than decoding at the file's native size first.
property bool constrainDecode: false
property size decodeSize: Qt.size(0, 0)
readonly property var current: imageLoader.item
readonly property bool ready: current ? current.ready : false
readonly property bool video: Util.isVideoPath(path)
// Cache-bust images selected in a running lock session, so a theme switch
// that replaces the file behind an unchanged path shows the new pixels.
readonly property url imageUrl: path && !video ? Util.fileUrl(path) + (version ? "?v=" + version : "") : ""
Loader {
id: imageLoader
anchors.fill: parent
active: root.path !== "" && !root.video
sourceComponent: imageComponent
}
Component {
id: imageComponent
Image {
readonly property bool ready: status === Image.Ready
source: !root.constrainDecode || root.decodeSize.width > 0 ? root.imageUrl : ""
fillMode: Image.PreserveAspectCrop
asynchronous: true
cache: root.cached
sourceSize.width: root.constrainDecode ? root.decodeSize.width : (root.version > 0 ? width : 0)
sourceSize.height: root.constrainDecode ? root.decodeSize.height : (root.version > 0 ? height : 0)
}
}
}
@@ -0,0 +1,66 @@
import QtQuick
import Quickshell
import qs.compat.omarchy.Commons
WidgetButton {
id: root
property Component iconComponent: null
property real slotSize: Style.bar.iconSlot
property real opticalSize: Style.bar.iconCanvas
property bool debugOpticalBounds: Quickshell.env("OMARCHY_DEBUG_BAR_ICONS") === "1"
// Measured against the slot, which the open-panel underline centers on.
readonly property real opticalCenterErrorX: glyph.visible ? opticalCanvas.x + glyph.paintedCenterX - root.width / 2 : 0
readonly property real glyphPaintedWidth: glyph.visible ? glyph.tightWidth : 0
readonly property real glyphBaselineY: glyph.visible ? glyph.baselineY : 0
readonly property int glyphFontSize: glyph.visible ? glyph.renderedFontSize : 0
labelVisible: false
hasVisualContent: text !== "" || iconComponent !== null
fontSize: Style.bar.iconFont
fixedWidth: vertical ? -1 : slotSize
fixedHeight: vertical ? slotSize : -1
Item {
id: opticalCanvas
// Placed exactly, not anchored: centerIn snaps an even canvas in an odd slot
// to a whole pixel, pulling every glyph off the open-panel underline.
x: (root.width - width) / 2
y: (root.height - height) / 2
width: root.opticalSize
height: root.opticalSize
OpticalGlyph {
id: glyph
anchors.fill: parent
visible: root.iconComponent === null
text: root.text
fontFamily: root.fontFamily
fontSize: root.fontSize
color: root.active && root.useActiveColor ? root.activeColor : root.foreground
rotation: root.textRotation
debugBounds: root.debugOpticalBounds
}
Loader {
anchors.fill: parent
visible: root.iconComponent !== null
sourceComponent: root.iconComponent
}
Rectangle {
visible: root.debugOpticalBounds && root.iconComponent !== null
anchors.fill: parent
color: "transparent"
border.width: 1
border.color: "#4488ff"
}
}
Rectangle {
visible: root.debugOpticalBounds
anchors.fill: parent
color: "transparent"
border.width: 1
border.color: "#ff4455"
}
}
@@ -0,0 +1,50 @@
import QtQuick
import qs.compat.omarchy.Commons
BarIconButton {
id: root
property string moduleName: ""
property var settings: ({})
property string activeText: ""
property string inactiveText: activeText
property string activeTooltipText: ""
property string inactiveTooltipText: activeTooltipText
property string indicatorBlock: "single"
property var indicatorHost: null
property var activeOverride: null
readonly property bool effectiveActive: activeOverride === null || activeOverride === undefined ? active : activeOverride === true
readonly property bool belongsInBlock: indicatorBlock === "active" ? effectiveActive : (indicatorBlock === "inactive" ? !effectiveActive : true)
readonly property bool inactiveRevealed: !effectiveActive && !!indicatorHost && indicatorHost.revealInactiveIndicators
function extractData(raw) {
return Util.parseModuleJson(raw)
}
function syncIndicatorOpacity() {
root.opacity = !belongsInBlock ? 0 : (effectiveActive ? 1 : (inactiveRevealed ? 0.45 : 0))
}
Component.onCompleted: syncIndicatorOpacity()
onActiveChanged: syncIndicatorOpacity()
onEffectiveActiveChanged: syncIndicatorOpacity()
onBarChanged: syncIndicatorOpacity()
onBelongsInBlockChanged: syncIndicatorOpacity()
onInactiveRevealedChanged: syncIndicatorOpacity()
onIndicatorBlockChanged: syncIndicatorOpacity()
visible: belongsInBlock && (text !== "" || keepSpace)
text: effectiveActive ? activeText : inactiveText
tooltipText: effectiveActive ? activeTooltipText : inactiveTooltipText
keepSpace: true
dimmed: !effectiveActive
concealed: !effectiveActive && !inactiveRevealed
interactive: belongsInBlock && (effectiveActive || indicatorBlock === "inactive" || inactiveRevealed)
useActiveColor: false
maintainIndicatorReveal: indicatorBlock === "inactive"
revealHost: indicatorHost
fontSize: Style.font.caption
horizontalMargin: 5
verticalPadding: 5
fixedWidth: vertical ? -1 : Style.bar.statusSlot
fixedHeight: vertical ? Style.bar.statusSlot : -1
}
@@ -0,0 +1,44 @@
import QtQuick
import qs.compat.omarchy.Commons
// Base item every bar widget extends. Codifies the three properties the
// bar host injects into each widget slot:
// bar - the host Bar instance (foreground/background/run/etc).
// moduleName - widget's canonical id, used by the host registry to look
// up settings and to disambiguate inline IPC routes.
// settings - per-widget overrides read from shell.json's layout entry.
//
// Widgets are free to add their own properties, signals, and child items.
Item {
id: root
property QtObject bar: null
property string moduleName: ""
property var settings: ({})
// Bar geometry, lifted off the host. Widgets read these constantly to pick
// between horizontal/vertical layouts; defining them on the base keeps the
// `bar ? bar.x : fallback` ternary out of every widget body.
readonly property bool vertical: bar ? bar.vertical : false
readonly property int barSize: bar ? bar.barSize : Style.bar.sizeHorizontal
// Run `method` on every live instance of this widget. An IPC target only
// ever routes to one handler, but a bar surface exists per monitor, so the
// instance that owns the target relays the call to its peers — otherwise a
// refresh would land on a single screen and leave the others stale.
function broadcast(method) {
var items = bar && typeof bar.moduleWidgets === "function"
? bar.moduleWidgets(moduleName) : [root]
for (var i = 0; i < items.length; i++) {
if (items[i] && typeof items[i][method] === "function") items[i][method]()
}
}
// Read a single value from this widget's inline shell.json entry, with a
// fallback for missing/null values. Every widget that takes user-tunable
// settings needs this; defining it once on the base keeps the wiring
// consistent.
function setting(name, fallback) {
var value = settings ? settings[name] : undefined
return value === undefined || value === null ? fallback : value
}
}
@@ -0,0 +1,54 @@
import QtQuick
import QtQuick.Shapes
import qs.compat.omarchy.Commons
import "../Commons/BorderGeometry.js" as Geometry
// Visual-only border renderer. It draws closed side-run contours, or a
// compound winding path for all four sides, so asymmetric/gradient borders
// do not require touching odd-even paths. Flat uniform borders use Rectangle.border.
Item {
id: root
property var borderSpec: Border.none()
property real radius: 0
readonly property var _widths: borderSpec && borderSpec.widths ? borderSpec.widths : Geometry.parseWidthSpec(0, 0)
readonly property bool hasBorder: Geometry.maxWidth(_widths) > 0
readonly property var _gradient: borderSpec && borderSpec.gradient ? borderSpec.gradient : ({ colors: [], angle: 0, enabled: false })
readonly property var _colors: _gradient.enabled ? _gradient.colors : [Border.color(borderSpec), Border.color(borderSpec)]
readonly property var _endpoints: Geometry.gradientEndpoints(width, height, _gradient.angle || 0)
readonly property string _path: Geometry.ringPath(width, height, radius, _widths)
visible: hasBorder && width > 0 && height > 0
anchors.fill: parent
z: 100000
Shape {
anchors.fill: parent
preferredRendererType: Shape.CurveRenderer
ShapePath {
fillRule: ShapePath.WindingFill
strokeWidth: 0
fillGradient: LinearGradient {
x1: root._endpoints.x1
y1: root._endpoints.y1
x2: root._endpoints.x2
y2: root._endpoints.y2
GradientStop { position: Geometry.stopPosition(root._colors, 0); color: Geometry.stopColor(root._colors, 0) }
GradientStop { position: Geometry.stopPosition(root._colors, 1); color: Geometry.stopColor(root._colors, 1) }
GradientStop { position: Geometry.stopPosition(root._colors, 2); color: Geometry.stopColor(root._colors, 2) }
GradientStop { position: Geometry.stopPosition(root._colors, 3); color: Geometry.stopColor(root._colors, 3) }
GradientStop { position: Geometry.stopPosition(root._colors, 4); color: Geometry.stopColor(root._colors, 4) }
GradientStop { position: Geometry.stopPosition(root._colors, 5); color: Geometry.stopColor(root._colors, 5) }
GradientStop { position: Geometry.stopPosition(root._colors, 6); color: Geometry.stopColor(root._colors, 6) }
GradientStop { position: Geometry.stopPosition(root._colors, 7); color: Geometry.stopColor(root._colors, 7) }
GradientStop { position: Geometry.stopPosition(root._colors, 8); color: Geometry.stopColor(root._colors, 8) }
GradientStop { position: Geometry.stopPosition(root._colors, 9); color: Geometry.stopColor(root._colors, 9) }
}
PathSvg { path: root._path }
}
}
}
@@ -0,0 +1,39 @@
import QtQuick
import qs.compat.omarchy.Commons
// Rectangle-compatible surface with Omarchy border specs. Uses native
// Rectangle.border for cheap flat/uniform borders and BorderOverlay for
// gradients or per-side widths.
Rectangle {
id: root
property var borderSpec: Border.none()
property real padding: 0
property real topPadding: padding
property real rightPadding: padding
property real bottomPadding: padding
property real leftPadding: padding
readonly property real borderTop: Border.top(borderSpec)
readonly property real borderRight: Border.right(borderSpec)
readonly property real borderBottom: Border.bottom(borderSpec)
readonly property real borderLeft: Border.left(borderSpec)
readonly property real contentTopInset: borderTop + topPadding
readonly property real contentRightInset: borderRight + rightPadding
readonly property real contentBottomInset: borderBottom + bottomPadding
readonly property real contentLeftInset: borderLeft + leftPadding
readonly property bool usesOverlayBorder: Border.needsOverlay(borderSpec)
border.color: Border.canUseNative(borderSpec) ? Border.color(borderSpec) : "transparent"
border.width: Border.canUseNative(borderSpec) ? Border.uniformWidth(borderSpec) : 0
Loader {
anchors.fill: parent
active: root.usesOverlayBorder
sourceComponent: BorderOverlay {
anchors.fill: parent
radius: root.radius
borderSpec: root.borderSpec
}
}
}
+208
View File
@@ -0,0 +1,208 @@
import QtQuick
import QtQuick.Controls
import qs.compat.omarchy.Commons
// The button. One component for every clickable thing in the kit.
// States compose independently and are applied in priority order:
//
// pressed (mouse down) pressed fill
// activeFocus (Tab focus) focus fill + focus border token
// hasCursor || hover hover-cursor fill (+ border if `bordered`)
// selected selected fill + optional selected border
// active selected fill
// idle transparent or normal border if `bordered`
//
// All fills/borders come from `qs.Commons.Style` tokens, so themes
// control the look via [controls] in shell.toml.
//
// Emits `hovered(bool)` so panels with their own keyboard cursor model
// can update state on mouse enter/leave.
BorderSurface {
id: root
property string text: ""
property string iconText: ""
property string tooltipText: ""
// State flags (see comment above for paint priority).
property bool selected: false
property bool active: false
property bool hasCursor: false
property bool focusable: false
property bool bordered: false
// Colors. Defaults track the theme; per-instance overrides are honored.
property color foreground: Color.foreground
property color background: "transparent"
property color accent: Color.accent
// Sizing.
property string fontFamily: Style.font.family
property real fontSize: Style.font.body
property real iconSize: Style.font.icon
property real iconRotation: 0
property bool iconSpinning: false
property real horizontalPadding: Style.spacing.controlPaddingX
property real verticalPadding: Style.spacing.controlPaddingY
property bool leftAlign: false
leftPadding: horizontalPadding
rightPadding: horizontalPadding
topPadding: verticalPadding
bottomPadding: verticalPadding
// Tooltip palette. Auto-rendered if tooltipText is set. Defaults pull
// from [tooltip] in shell.toml; override per-instance only when a button
// intentionally wants a tooltip that diverges from the theme.
property color tooltipBackground: Color.tooltip.background
property color tooltipForeground: Color.tooltip.text
property color tooltipBorder: Color.tooltip.border
signal clicked()
signal rightClicked()
signal hovered(bool isHovered)
activeFocusOnTab: focusable
Keys.onReturnPressed: if (focusable) root.clicked()
Keys.onEnterPressed: if (focusable) root.clicked()
Keys.onSpacePressed: if (focusable) root.clicked()
// Reserve the largest border any visual state can paint. Otherwise a
// borderless idle button grows by a pixel per side on hover/focus and
// relayouts neighboring controls.
implicitWidth: row.implicitWidth + horizontalPadding * 2 + _reservedBorderLeft + _reservedBorderRight
implicitHeight: row.implicitHeight + verticalPadding * 2 + _reservedBorderTop + _reservedBorderBottom
radius: Style.cornerRadius
readonly property bool hot: mouseArea.containsMouse || hasCursor
readonly property bool _showFocusRing: focusable && activeFocus
readonly property color _selectedColor: Style.selectedStateColor(root.foreground, root.accent)
readonly property var _tooltipBorderSpec: Border.localOrSurfaceSpec("tooltip", "border", root.tooltipBorder, Color.tooltip.border, Math.max(1, Style.normalBorderWidth))
readonly property var _focusBorderSpec: Border.controlSpec("focus", root.foreground, root.accent)
readonly property var _hoverBorderSpec: Border.controlSpec("hover-cursor", root.foreground, root.accent)
readonly property var _selectedBorderSpec: Border.controlSpec("selected", root.foreground, root.accent)
readonly property var _normalBorderSpec: Border.controlSpec("normal", root.foreground, root.accent)
readonly property real _reservedBorderTop: Math.max(
focusable ? Border.top(_focusBorderSpec) : 0,
Border.top(_hoverBorderSpec),
Border.top(_selectedBorderSpec),
bordered ? Border.top(_normalBorderSpec) : 0)
readonly property real _reservedBorderRight: Math.max(
focusable ? Border.right(_focusBorderSpec) : 0,
Border.right(_hoverBorderSpec),
Border.right(_selectedBorderSpec),
bordered ? Border.right(_normalBorderSpec) : 0)
readonly property real _reservedBorderBottom: Math.max(
focusable ? Border.bottom(_focusBorderSpec) : 0,
Border.bottom(_hoverBorderSpec),
Border.bottom(_selectedBorderSpec),
bordered ? Border.bottom(_normalBorderSpec) : 0)
readonly property real _reservedBorderLeft: Math.max(
focusable ? Border.left(_focusBorderSpec) : 0,
Border.left(_hoverBorderSpec),
Border.left(_selectedBorderSpec),
bordered ? Border.left(_normalBorderSpec) : 0)
readonly property real _reservedContentLeftInset: _reservedBorderLeft + leftPadding
readonly property var _borderSpec: _showFocusRing ? _focusBorderSpec
: hot ? _hoverBorderSpec
: selected ? (Border.controlHasWidth("selected") ? _selectedBorderSpec : (bordered ? _normalBorderSpec : Border.none()))
: bordered ? _normalBorderSpec
: Border.none()
color: mouseArea.pressed ? Style.pressedFillFor(root.foreground, root.accent)
: _showFocusRing ? Style.focusFillFor(root.foreground, root.accent)
: hot ? Style.hoverFillFor(root.foreground, root.accent)
: selected ? Style.selectedFillFor(root.foreground, root.accent)
: active ? Style.selectedFillFor(root.foreground, root.accent)
: background
// Border follows the same state precedence as fill. Buttons stay
// borderless at rest unless `bordered` is set, but hover-cursor/focus
// always use the shared cursor border so the keyboard target is visible
// and consistent with the rest of the kit. Selected borders are off by
// default for plain buttons; explicitly bordered buttons keep their
// normal border when selected unless selected-border-width opts in to a
// dedicated selected border.
borderSpec: _borderSpec
Behavior on color { ColorAnimation { duration: Style.duration(120) } }
ToolTip {
visible: root.tooltipText !== "" && mouseArea.containsMouse
text: root.tooltipText
delay: 400
padding: 0
background: BorderSurface {
color: root.tooltipBackground
borderSpec: root._tooltipBorderSpec
radius: 0
}
contentItem: Text {
textFormat: Text.PlainText
text: root.tooltipText
color: root.tooltipForeground
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
leftPadding: Border.left(root._tooltipBorderSpec) + Style.spacing.controlPaddingX
rightPadding: Border.right(root._tooltipBorderSpec) + Style.spacing.controlPaddingX
topPadding: Border.top(root._tooltipBorderSpec) + Style.spacing.controlPaddingY
bottomPadding: Border.bottom(root._tooltipBorderSpec) + Style.spacing.controlPaddingY
}
}
Row {
id: row
anchors.verticalCenter: parent.verticalCenter
anchors.left: root.leftAlign ? parent.left : undefined
anchors.leftMargin: root.leftAlign ? root._reservedContentLeftInset : 0
anchors.horizontalCenter: root.leftAlign ? undefined : parent.horizontalCenter
spacing: Style.spacing.controlGap
Text {
textFormat: Text.PlainText
visible: root.iconText !== ""
text: root.iconText
color: root.selected ? root._selectedColor : root.foreground
font.family: root.fontFamily
font.pixelSize: root.iconSize
rotation: root.iconSpinning ? 0 : root.iconRotation
transformOrigin: Item.Center
anchors.verticalCenter: parent.verticalCenter
RotationAnimation on rotation {
from: 0
to: 360
duration: 900
loops: Animation.Infinite
running: root.iconSpinning && !Style.reduceMotion
}
}
Text {
textFormat: Text.PlainText
visible: root.text !== ""
text: root.text
color: root.selected ? root._selectedColor : root.foreground
font.family: root.fontFamily
font.pixelSize: root.fontSize
font.bold: root.selected
anchors.verticalCenter: parent.verticalCenter
}
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: function(mouse) {
if (root.focusable) root.forceActiveFocus()
if (mouse.button === Qt.RightButton) root.rightClicked()
else root.clicked()
}
}
HoverHandler {
onHoveredChanged: root.hovered(hovered)
}
}
@@ -0,0 +1,131 @@
import QtQuick
import qs.compat.omarchy.Commons
// Mutually-exclusive row of Buttons — the form-style "pick one of N"
// pattern (bar position top/right/bottom/left, theme preset chips, etc.).
// Emits `changed(value)` when the user activates a different option.
//
// `options` is either a plain string[] (label == value) or an array of
// { value, label, icon?, tooltip? } objects. Mixing is fine.
//
// Keyboard navigation. The group itself is a single Tab stop, not one
// stop per chip — so in a form that walks `activeFocusOnTab` items with
// Tab / j / k, the cursor enters the group as a unit. Once focused,
// h / l / Left / Right walks between chips and Enter / Space activates
// the current one. The selected chip is the default landing point so
// users see their existing choice on arrival.
//
// Panel-cursor consumers (the bar widget panels) drive `cursorIndex`
// directly and listen on `hovered` to sync the mouse — Tab focus and
// `cursorIndex` are independent; either one paints the chip's hot
// state, and the bar widget panels never give Tab focus to a
// ButtonGroup so they only see the cursorIndex path.
Row {
id: root
property var options: []
property string value: ""
property color foreground: Color.foreground
property color background: Color.background
property color accent: Color.accent
property string fontFamily: Style.font.family
property real fontSize: Style.font.body
property bool focusable: true
// -1 disables the external cursor highlight (the panel-cursor case).
// Driven by a containing panel; the group's own Tab-focus h/l
// tracking is internal and lives in _focusedIndex.
property int cursorIndex: -1
// Internal: which chip h / l / Left / Right is currently sitting on
// when the group itself has Tab focus. Reset to the selected option
// each time focus arrives so the user sees their existing choice.
property int _focusedIndex: -1
signal changed(string value)
signal hovered(int index, bool isHovered)
spacing: Style.spacing.md
activeFocusOnTab: focusable
function optionValue(o) {
return (o && typeof o === "object") ? String(o.value) : String(o)
}
function optionLabel(o) {
return (o && typeof o === "object" && o.label !== undefined) ? String(o.label) : String(o)
}
function optionIcon(o) {
return (o && typeof o === "object" && o.icon) ? String(o.icon) : ""
}
function optionTooltip(o) {
return (o && typeof o === "object" && o.tooltip) ? String(o.tooltip) : ""
}
function selectedOptionIndex() {
for (var i = 0; i < options.length; i++)
if (optionValue(options[i]) === value) return i
return -1
}
function activateFocused() {
if (_focusedIndex < 0 || _focusedIndex >= options.length) return
var v = optionValue(options[_focusedIndex])
root.changed(v)
}
onActiveFocusChanged: {
if (activeFocus) {
var idx = selectedOptionIndex()
_focusedIndex = idx < 0 ? 0 : idx
} else {
_focusedIndex = -1
}
}
Keys.priority: Keys.BeforeItem
Keys.onPressed: function(event) {
if (event.key === Qt.Key_Left || event.key === Qt.Key_H
|| event.text === "h") {
_focusedIndex = Math.max(0, (_focusedIndex < 0 ? 0 : _focusedIndex) - 1)
event.accepted = true
} else if (event.key === Qt.Key_Right || event.key === Qt.Key_L
|| event.text === "l") {
var max = options.length - 1
var next = (_focusedIndex < 0 ? 0 : _focusedIndex) + 1
_focusedIndex = Math.min(max, next)
event.accepted = true
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter
|| event.key === Qt.Key_Space) {
activateFocused()
event.accepted = true
}
}
Repeater {
model: root.options
delegate: Button {
required property var modelData
required property int index
text: root.optionLabel(modelData)
iconText: root.optionIcon(modelData)
tooltipText: root.optionTooltip(modelData)
selected: root.optionValue(modelData) === root.value
// Chip lights up when either the external panel cursor lands here
// or the group has Tab focus and h/l has walked to this index.
hasCursor: root.cursorIndex === index
|| (root.activeFocus && root._focusedIndex === index)
// Every chip carries the standard bordered-button chrome so the
// group reads as a row of distinct options. selected / hover-cursor /
// focus are all painted by Button from Style's shared state tokens.
bordered: true
foreground: root.foreground
background: root.background
accent: root.accent
fontFamily: root.fontFamily
fontSize: root.fontSize
onClicked: root.changed(root.optionValue(modelData))
onHovered: function(h) { root.hovered(index, h) }
}
}
}
@@ -0,0 +1,132 @@
import QtQuick
import qs.compat.omarchy.Commons
Item {
id: root
property bool opened: false
property string message: ""
property string cancelText: "Cancel"
property string confirmText: "Confirm"
property int selectedIndex: 1
property color background: Color.background
property color foreground: Color.foreground
property color scrim: Util.alpha(Color.background, 0.7)
property color selectedBackground: Util.alpha(Color.foreground, 0.08)
property color selectedText: Color.accent
property string fontFamily: Style.font.family
property int cornerRadius: Style.cornerRadius
signal canceled()
signal confirmed()
function handleKey(event) {
if (!root.opened) return false
if (event.key === Qt.Key_Escape) {
root.canceled()
return true
} else if (event.key === Qt.Key_Left || event.key === Qt.Key_Right || event.key === Qt.Key_Tab || event.key === Qt.Key_Backtab) {
root.selectedIndex = root.selectedIndex === 0 ? 1 : 0
return true
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
if (root.selectedIndex === 0) root.canceled()
else root.confirmed()
return true
}
return false
}
visible: opened
Rectangle {
anchors.fill: parent
color: root.scrim
MouseArea { anchors.fill: parent; onClicked: root.canceled() }
BorderSurface {
id: card
width: Math.min(parent.width - Style.space(32), Style.space(370))
// Grows with the wrapped message so narrow hosts (like the menu card)
// don't squeeze the text into the buttons.
height: card.contentTopInset + card.contentBottomInset + messageText.implicitHeight + Style.space(20) + Style.space(34)
anchors.centerIn: parent
color: root.background
borderSpec: Border.flat(root.selectedText, Style.normalBorderWidth)
padding: Style.space(18)
radius: root.cornerRadius
MouseArea { anchors.fill: parent; onClicked: {} }
Item {
anchors.fill: parent
anchors.topMargin: card.contentTopInset
anchors.rightMargin: card.contentRightInset
anchors.bottomMargin: card.contentBottomInset
anchors.leftMargin: card.contentLeftInset
Text {
id: messageText
textFormat: Text.PlainText
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
text: root.message
color: root.foreground
font.family: root.fontFamily
font.pixelSize: Style.font.title
wrapMode: Text.WordWrap
}
Row {
anchors.right: parent.right
anchors.bottom: parent.bottom
spacing: Style.space(10)
Repeater {
model: [root.cancelText, root.confirmText]
BorderSurface {
required property int index
required property string modelData
readonly property bool selected: root.selectedIndex === index
readonly property bool destructive: index === 1
width: Style.space(88)
height: Style.space(34)
color: selected
? (destructive ? Util.alpha(Color.urgent, 0.22) : root.selectedBackground)
: "transparent"
borderSpec: Border.flat(destructive
? (selected ? Color.urgent : Util.alpha(Color.urgent, 0.56))
: (selected ? root.selectedText : Util.alpha(root.foreground, 0.38)), Style.normalBorderWidth)
radius: 0
Text {
textFormat: Text.PlainText
anchors.centerIn: parent
text: modelData
color: destructive ? (selected ? Color.urgent : root.foreground) : (selected ? root.selectedText : root.foreground)
font.family: root.fontFamily
font.pixelSize: Style.font.caption
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onEntered: root.selectedIndex = index
onClicked: {
if (index === 0) root.canceled()
else root.confirmed()
}
}
}
}
}
}
}
}
}
@@ -0,0 +1,40 @@
import QtQuick
import qs.compat.omarchy.Commons
// Shared visual chrome for keyboard-and-mouse-navigable items inside a panel.
// Contract: items must NOT read `containsMouse` for color/border. Mouse
// hover updates the panel's cursor state at the root; visuals derive from
// `hasCursor` / `current`. That's what guarantees a single highlight on
// screen at any time across both keyboard and mouse interaction.
//
// Cursor paint is always the shared hover-cursor fill plus optional
// hover-cursor border. `outline` remains as a compatibility flag for
// callers that used to request border-only rows, but slider rows still
// receive the same hover-cursor background as every other row.
BorderSurface {
id: root
property bool hasCursor: false
property bool current: false
property bool outline: false
property bool bordered: false
property color foreground: Color.foreground
property color accent: Color.accent
property color fill: Style.hoverFillFor(foreground, accent)
property color currentFill: Style.selectedFillFor(foreground, accent)
radius: Style.cornerRadius
color: hasCursor ? fill : (current ? currentFill : "transparent")
borderSpec: root.hasCursor
? Border.controlSpec("hover-cursor", root.foreground, root.accent)
: (root.current
? Border.controlSpec("selected", root.foreground, root.accent)
: (root.bordered
? Border.controlSpec("normal", root.foreground, root.accent)
: Border.none()))
Behavior on color {
ColorAnimation { duration: Style.duration(60) }
}
}
+243
View File
@@ -0,0 +1,243 @@
import QtQuick
import QtQuick.Controls
import qs.compat.omarchy.Commons
// Themed single-select dropdown. Trigger row paints with the kit's focus
// chrome; the popup anchors below and uses Color.popups.background +
// Color.popups.border so it reads as a panel surface rather than the
// platform-native ComboBox look.
//
// `options` accepts either a plain string[] or an array of
// { value, label } objects (label is what we render; value is what we
// emit). Mixing is fine — each row is interpreted independently.
//
// Keyboard: Tab to focus the trigger, Enter/Space opens, Esc closes,
// j/k or Up/Down walks options inside the open popup, Enter selects.
// A sibling SearchableDropdown reuses the same visuals but adds an
// embedded filter input — keep the two separate so each stays simple.
Item {
id: root
property string label: ""
property string value: ""
property var options: []
property color foreground: Color.popups.text
property color background: Color.popups.background
property color popupBorder: Color.popups.border
property color accent: Color.accent
readonly property var popupBorderSpec: Border.localOrSurfaceSpec("popups", "border", popupBorder, Color.popups.border, Style.normalBorderWidth)
property string fontFamily: Style.font.family
property int rowHeight: Style.spacing.controlHeight
property int popupRowHeight: Style.spacing.popupRowHeight
property bool showLabel: true
// Panel-cursor flag. When true, the trigger renders the shared
// hover-cursor state. Active Qt focus defaults to the same visuals.
// Emits `hovered(bool)` on pointer enter/leave so the panel can keep
// its cursor state in sync with the mouse.
property bool hasCursor: false
// popupOpen + open()/close()/toggle() let a parent panel know when the
// dropdown owns keys (its embedded ListView is active) and suspend its
// own keyCatcher so j/k inside the popup don't double-drive the panel
// cursor.
readonly property bool popupOpen: popup.opened
function open() { popup.open() }
function close() { popup.close() }
function toggle() { popup.opened ? popup.close() : popup.open() }
signal changed(string value)
signal hovered(bool isHovered)
function optionValue(o) {
return (o && typeof o === "object") ? String(o.value) : String(o)
}
function optionLabel(o) {
return (o && typeof o === "object") ? String(o.label) : String(o)
}
function currentLabel() {
for (var i = 0; i < options.length; i++) {
if (optionValue(options[i]) === value) return optionLabel(options[i])
}
return value
}
implicitWidth: Style.spacing.dropdownWidth
implicitHeight: showLabel && label !== "" ? rowHeight + Style.spacing.huge : rowHeight
Column {
anchors.fill: parent
spacing: Style.spacing.labelGap
Text {
textFormat: Text.PlainText
visible: root.showLabel && root.label !== ""
text: root.label
color: Qt.darker(root.foreground, 1.4)
font.family: root.fontFamily
font.pixelSize: Style.font.caption
font.bold: true
}
BorderSurface {
id: trigger
width: parent.width
height: root.rowHeight
radius: Style.cornerRadius
readonly property bool _focused: trigger.activeFocus
readonly property bool _hot: triggerHover.hovered || root.hasCursor
readonly property var _borderSpec: Border.controlSpec(trigger._focused ? "focus" : (trigger._hot ? "hover-cursor" : "normal"), root.foreground, root.accent)
color: Style.controlFill(trigger._focused, trigger._hot, root.foreground, root.accent)
borderSpec: _borderSpec
activeFocusOnTab: true
HoverHandler {
id: triggerHover
onHoveredChanged: root.hovered(hovered)
}
Keys.onPressed: function(event) {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter
|| event.key === Qt.Key_Space || event.key === Qt.Key_Down) {
popup.opened ? popup.close() : popup.open()
event.accepted = true
} else if (event.key === Qt.Key_Escape && popup.opened) {
popup.close(); event.accepted = true
}
}
Text {
textFormat: Text.PlainText
anchors.left: parent.left
anchors.right: chevron.left
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: trigger.borderLeft + Style.spacing.controlPaddingX
anchors.rightMargin: trigger.borderRight + Style.spacing.md
text: root.currentLabel()
color: root.foreground
font.family: root.fontFamily
font.pixelSize: Style.font.body
elide: Text.ElideRight
}
Text {
id: chevron
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: trigger.borderRight + Style.spacing.controlGap
text: "󰅀"
color: Qt.darker(root.foreground, 1.2)
font.family: root.fontFamily
font.pixelSize: Style.font.body
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
trigger.forceActiveFocus()
popup.opened ? popup.close() : popup.open()
}
}
Popup {
id: popup
x: 0
y: trigger.height + Style.spacing.xxs
width: trigger.width
implicitHeight: Math.min(root.options.length * root.popupRowHeight + Math.max(0, root.options.length - 1) * Style.spacing.labelGap + Style.spacing.xxs,
root.popupRowHeight * 8 + 7 * Style.spacing.labelGap + Style.spacing.xxs)
padding: Style.spacing.hairline
leftPadding: Border.left(root.popupBorderSpec) + Style.spacing.hairline
rightPadding: Border.right(root.popupBorderSpec) + Style.spacing.hairline
topPadding: Border.top(root.popupBorderSpec) + Style.spacing.hairline
bottomPadding: Border.bottom(root.popupBorderSpec) + Style.spacing.hairline
focus: true
background: BorderSurface {
color: root.background
borderSpec: root.popupBorderSpec
radius: Style.cornerRadius
}
onOpened: {
optionList.currentIndex = Math.max(0, optionList.indexOfValue(root.value))
optionList.forceActiveFocus()
}
contentItem: ListView {
id: optionList
spacing: Style.spacing.labelGap
Keys.priority: Keys.BeforeItem
Keys.onPressed: function(event) {
if (event.key === Qt.Key_Escape) { popup.close(); event.accepted = true }
else if (event.key === Qt.Key_Down || event.text === "j") {
optionList.currentIndex = Math.min(root.options.length - 1, optionList.currentIndex + 1)
event.accepted = true
} else if (event.key === Qt.Key_Up || event.text === "k") {
optionList.currentIndex = Math.max(0, optionList.currentIndex - 1)
event.accepted = true
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
optionList.selectCurrent(); event.accepted = true
}
}
implicitHeight: contentHeight
clip: true
boundsBehavior: Flickable.StopAtBounds
model: root.options
currentIndex: -1
function indexOfValue(v) {
for (var i = 0; i < root.options.length; i++)
if (root.optionValue(root.options[i]) === v) return i
return -1
}
function selectCurrent() {
if (currentIndex < 0 || currentIndex >= root.options.length) return
var v = root.optionValue(root.options[currentIndex])
root.value = v
root.changed(v)
popup.close()
}
delegate: Rectangle {
required property var modelData
required property int index
width: optionList.width
height: root.popupRowHeight
color: index === optionList.currentIndex
? Style.hoverFillFor(root.foreground, root.accent)
: "transparent"
Text {
textFormat: Text.PlainText
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: Style.spacing.controlPaddingX
anchors.rightMargin: Style.spacing.controlPaddingX
text: root.optionLabel(modelData)
color: index === optionList.currentIndex ? Style.hoverStateColor(root.foreground, root.accent) : root.foreground
font.family: root.fontFamily
font.pixelSize: Style.font.body
elide: Text.ElideRight
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onPositionChanged: optionList.currentIndex = parent.index
onClicked: optionList.selectCurrent()
}
}
}
}
}
}
}
@@ -0,0 +1,172 @@
import QtQuick
import Quickshell
import Quickshell.Hyprland
import Quickshell.Wayland
import qs.compat.omarchy.Commons
import "../../../components" as C
import "../../../core" as Core
import "../../../theme" as G
// glassMxrph base for Omarchy's PopupCard and KeyboardPanel: the popup is a
// glassMxrph bar drawer that grows out of the bar under its anchor, with the
// same glass, ears and animation as the shell's own panels. The public API
// (sizes, fitted*/capped* helpers, open/close, owner, focusTarget, popout
// coordination) matches Omarchy so plugins work unchanged.
//
// mode: "keyboard" — exclusive keyboard focus, outside clicks close (like the
// Control Center); "click" — focus grab, outside clicks
// close; "hover" — passive, the owner opens/closes it.
PanelWindow {
id: root
required property Item anchorItem
required property QtObject bar
property var owner: null
property string mode: "keyboard"
property int margin: 8
property int padding: Style.spacing.popupPadding
property int contentWidth: Style.space(280)
property int contentHeight: Style.space(200)
property var borderSpec: Border.none()
property color borderColor: G.Theme.border
property bool centerOnBar: false
property bool open: false
property int gap: 0
property bool popoutSwitching: false
property bool popoutSwitchClosing: false
property bool focusPrimed: true
property Item focusTarget: null
default property alias contentItem: contentHolder.children
readonly property var coordinatorKey: owner || root
readonly property var anchorWindow: anchorItem ? anchorItem.QsWindow.window : null
readonly property string barPos: "top"
readonly property bool containsMouse: drawer.hovered
function close() {
if (owner && "close" in owner) owner.close()
else root.open = false
}
function beginFocusPrime() {
}
screen: anchorWindow ? anchorWindow.screen : null
readonly property real screenW: screen ? screen.width : 0
readonly property real screenH: screen ? screen.height : 0
readonly property real sideSpace: 2 * (Core.BarDrawers.margin + Core.BarDrawers.radius + Core.BarDrawers.ear)
readonly property real availableCardWidth: screenW > 0 ? Math.max(120, screenW - sideSpace) : 0
readonly property real availableCardHeight: screenH > 0 ? Math.max(120, screenH - Core.BarDrawers.bottom - 20) : 0
readonly property real verticalContentInset: padding * 2
function fittedContentWidth(width, cap) {
var desired = Math.max(1, Number(width) || 1)
var maxWidth = root.availableCardWidth > 0 ? root.availableCardWidth : desired
if (cap !== undefined && Number(cap) > 0) maxWidth = Math.min(maxWidth, Number(cap))
return Math.round(Math.min(desired, maxWidth))
}
function fittedContentHeight(implicitHeight, cap) {
var desired = Math.max(root.verticalContentInset, (Number(implicitHeight) || 0) + root.verticalContentInset)
var maxHeight = root.availableCardHeight > 0 ? root.availableCardHeight : desired
if (cap !== undefined && Number(cap) > 0) maxHeight = Math.min(maxHeight, Number(cap))
return Math.round(Math.min(desired, maxHeight))
}
function cappedContentHeight(height) {
var desired = Math.max(root.padding * 2, Number(height) || root.padding * 2)
var maxHeight = root.availableCardHeight > 0 ? root.availableCardHeight : desired
return Math.round(Math.min(desired, maxHeight))
}
readonly property real barW: anchorWindow ? anchorWindow.width : screenW
readonly property real barH: Core.BarDrawers.bottom
// Re-read on open: mapToItem is not reactive to layout changes.
readonly property point anchorScreenPos: {
root.open
if (!anchorItem || !anchorWindow) return Qt.point(0, 0)
return anchorItem.mapToItem(anchorWindow.contentItem, 0, 0)
}
readonly property real anchorW: anchorItem ? anchorItem.width : 0
readonly property real anchorH: anchorItem ? anchorItem.height : 0
readonly property real outerWidth: drawer.width
readonly property real drawerX: centerOnBar
? Math.round((screenW - outerWidth) / 2)
: Core.BarDrawers.clampX(anchorScreenPos.x + anchorW / 2, outerWidth, screenW)
readonly property point cardOrigin: Qt.point(drawerX + drawer.ear, Core.BarDrawers.bottom)
// Hang from the bar: the layer starts at the screen top so the join with
// the bar is inside its box (no HyprGlass edge there).
anchors {
top: true
left: true
}
// qmllint disable unqualified unresolved-type
margins.left: root.drawerX
// qmllint enable unqualified unresolved-type
implicitWidth: Math.max(1, Math.round(drawer.width))
implicitHeight: Math.max(1, Math.round(Core.BarDrawers.bottom + drawer.contentHeight))
visible: open || drawer.shown || popoutSwitching
color: "transparent"
exclusionMode: ExclusionMode.Ignore
WlrLayershell.namespace: "glassMxrph-plugin-popup"
WlrLayershell.layer: WlrLayer.Overlay
WlrLayershell.keyboardFocus: !open ? WlrKeyboardFocus.None : mode === "keyboard" ? WlrKeyboardFocus.Exclusive : mode === "click" ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None
// Passive popups only take input on the drawer itself.
Region {
id: bodyMask
item: drawer.body
}
mask: mode === "keyboard" ? null : bodyMask
onOpenChanged: {
if (open && focusTarget) Qt.callLater(function() {
if (root.open && root.focusTarget) root.focusTarget.forceActiveFocus()
})
if (!bar) return
if (open) {
popoutSwitchClosing = false
if (bar.requestPopout) bar.requestPopout(coordinatorKey)
} else {
popoutSwitchClosing = !!(owner && owner.popoutSwitchClosing)
if (bar.activePopout === coordinatorKey && bar.releasePopout) bar.releasePopout(coordinatorKey)
}
}
// Keyboard mode: Hyprland routes every click to the exclusive layer, so
// outside clicks arrive here with out-of-bounds coordinates (see ControlCenter).
MouseArea {
x: -20000
y: -20000
width: 40000
height: 40000
enabled: root.open && root.mode === "keyboard"
acceptedButtons: Qt.AllButtons
onPressed: root.close()
}
HyprlandFocusGrab {
active: root.open && root.mode === "click"
windows: root.anchorWindow ? [root, root.anchorWindow] : [root]
onCleared: root.close()
}
C.BarDrawer {
id: drawer
y: Core.BarDrawers.bottom
open: root.open
contentWidth: root.contentWidth
contentHeight: root.contentHeight
drawerId: "plugin-popup-" + (root.owner && root.owner.moduleName ? root.owner.moduleName : "")
screenName: root.screen ? root.screen.name : ""
screenX: root.drawerX
// Swallow clicks on the card so they never reach the outside catcher.
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.AllButtons
}
Item {
id: contentHolder
anchors.fill: parent
anchors.margins: root.padding
}
}
}
@@ -0,0 +1,6 @@
import QtQuick
// glassMxrph: Omarchy's keyboard-driven bar panel, drawn as a glassMxrph bar
// drawer. See GlassPopupBase for the shared implementation and API.
GlassPopupBase {
mode: "keyboard"
}
@@ -0,0 +1,622 @@
import QtQuick
import QtQuick.Controls as QQC
import QtQuick.Window
import Quickshell.Io
import qs.compat.omarchy.Commons
// Searchable multi-select dropdown. Trigger shape matches Dropdown /
// SearchableDropdown; the popup shows a search field, an optional refresh
// button, and a checkbox list. Click rows to toggle. Use when callers
// need to pick zero or more items from a (possibly long, possibly
// dynamic) list.
//
// Options are either:
// - static `options`: string[] or [{ value, label, description? }]
// - dynamic `optionsCommand`: argv array. The command's stdout is
// parsed as JSON when it trims to start with `[`, otherwise as
// one option per non-empty newline. Re-runs whenever the popup opens
// and via the refresh button.
//
// `values` is the persisted selection — always an array of strings.
// Emits `changed(values)` whenever the selection mutates.
Item {
id: root
property string label: ""
property var values: []
property var options: []
property var optionsCommand: []
property string optionsCommandCwd: ""
property string placeholderText: "Search..."
property string emptyText: "No options"
property string noSelectionText: "None selected"
property string triggerLabel: ""
property bool showLabel: true
property color foreground: Color.popups.text
property color background: Color.popups.background
property color popupBorder: Color.popups.border
property color accent: Color.accent
readonly property var popupBorderSpec: Border.localOrSurfaceSpec("popups", "border", popupBorder, Color.popups.border, Style.normalBorderWidth)
property string fontFamily: Style.font.family
property int rowHeight: Style.spacing.controlHeight
property int popupRowHeight: Style.spacing.popupRowHeight
property int popupMinHeight: Style.spacing.searchablePopupMinHeight
property bool hasCursor: false
readonly property bool popupOpen: popup.opened
function open() { popup.open() }
function close() { popup.close() }
function toggle() { popup.opened ? popup.close() : popup.open() }
signal changed(var values)
signal hovered(bool isHovered)
// Loaded options after merging static + dynamic. Always normalized
// into the [{ value, label, description }] shape for delegate use.
property var resolvedOptions: []
property bool loadingOptions: false
property string optionsError: ""
function normalizeOption(o) {
if (o && typeof o === "object") {
return {
value: String(o.value),
label: String(o.label !== undefined ? o.label : o.value),
description: o.description ? String(o.description) : ""
}
}
var s = String(o)
return { value: s, label: s, description: "" }
}
// QML schema arrays sometimes arrive as JSValue lists that fail
// `Array.isArray`. arrayFrom accepts anything array-like (`.length`
// numeric) and returns a real JS array so the rest of the component can
// rely on standard array operations.
function arrayFrom(v) {
if (!v || typeof v.length !== "number" || typeof v === "string") return []
var out = []
for (var i = 0; i < v.length; i++) out.push(v[i])
return out
}
function normalizeAll(arr) {
var out = []
var src = arrayFrom(arr)
var seen = ({})
for (var i = 0; i < src.length; i++) {
var n = normalizeOption(src[i])
if (!n.value) continue
if (seen[n.value]) continue
seen[n.value] = true
out.push(n)
}
return out
}
function valueSet() {
var set = ({})
var arr = arrayFrom(values)
for (var i = 0; i < arr.length; i++) set[String(arr[i])] = true
return set
}
function isSelected(value) {
var set = valueSet()
return !!set[String(value)]
}
function toggleValue(value) {
var v = String(value)
var arr = arrayFrom(values)
var idx = arr.indexOf(v)
if (idx === -1) arr.push(v)
else arr.splice(idx, 1)
root.values = arr
root.changed(arr)
}
function selectionLabel() {
var arr = arrayFrom(values)
if (arr.length === 0) return ""
var labels = []
var byValue = ({})
for (var i = 0; i < resolvedOptions.length; i++)
byValue[resolvedOptions[i].value] = resolvedOptions[i].label
for (var j = 0; j < arr.length; j++)
labels.push(byValue[String(arr[j])] || String(arr[j]))
if (labels.length <= 3) return labels.join(", ")
return arr.length + " selected"
}
property var filtered: resolvedOptions
function recomputeFiltered() {
var q = searchField.text.toLowerCase()
if (!q) { filtered = resolvedOptions; return }
var out = []
for (var i = 0; i < resolvedOptions.length; i++) {
var o = resolvedOptions[i]
if (o.label.toLowerCase().indexOf(q) !== -1
|| o.description.toLowerCase().indexOf(q) !== -1
|| o.value.toLowerCase().indexOf(q) !== -1) out.push(o)
}
filtered = out
}
function rebuildFromStatic() {
resolvedOptions = normalizeAll(options)
recomputeFiltered()
}
// Parse stdout from a dynamic optionsCommand into `{ options, error }`.
// Output starting with `[` is parsed strictly as JSON — a malformed array
// surfaces as an error rather than silently falling back to newline
// parsing, which would render the broken text as a literal option label.
// Output not starting with `[` is treated as one value per non-empty line.
function parseCommandOutput(text) {
var raw = String(text || "").trim()
if (raw === "") return { options: [], error: "" }
if (raw.charAt(0) === "[") {
try {
var parsed = JSON.parse(raw)
return { options: parsed, error: "" }
} catch (e) {
return { options: [], error: "Options command emitted invalid JSON" }
}
}
var out = []
var lines = raw.split(/\r?\n/)
for (var i = 0; i < lines.length; i++) {
var line = lines[i].trim()
if (line !== "") out.push(line)
}
return { options: out, error: "" }
}
// Monotonic request id so stale stdout/exit signals from a previous
// refresh can't clobber the resolvedOptions of a newer refresh, and
// a runaway command can be detected after a timeout.
property int refreshSeq: 0
readonly property int refreshTimeoutMs: 6000
function refresh() {
var cmd = arrayFrom(optionsCommand)
if (cmd.length === 0) {
rebuildFromStatic()
return
}
refreshSeq++
loadingOptions = true
optionsError = ""
optionsProcess.command = cmd
optionsProcess.workingDirectory = optionsCommandCwd
optionsProcess.running = false
optionsProcess.running = true
refreshTimeoutTimer.restart()
}
Timer {
id: refreshTimeoutTimer
interval: root.refreshTimeoutMs
repeat: false
onTriggered: {
if (!root.loadingOptions) return
optionsProcess.running = false
root.loadingOptions = false
root.optionsError = "Options command timed out"
}
}
onOptionsChanged: if (arrayFrom(optionsCommand).length === 0) rebuildFromStatic()
onOptionsCommandChanged: refresh()
Component.onCompleted: refresh()
Process {
id: optionsProcess
running: false
command: []
property int seq: 0
stdout: StdioCollector {
waitForEnd: true
onStreamFinished: {
if (optionsProcess.seq !== root.refreshSeq) return
var result = root.parseCommandOutput(text)
if (result.error) {
root.optionsError = result.error
root.resolvedOptions = root.normalizeAll(root.options)
} else {
var combined = root.arrayFrom(root.options)
for (var j = 0; j < result.options.length; j++) combined.push(result.options[j])
root.resolvedOptions = root.normalizeAll(combined)
}
root.recomputeFiltered()
root.loadingOptions = false
refreshTimeoutTimer.stop()
}
}
onRunningChanged: if (running) seq = root.refreshSeq
onExited: function(exitCode, exitStatus) {
if (seq !== root.refreshSeq) return
refreshTimeoutTimer.stop()
if (exitCode !== 0) {
root.loadingOptions = false
root.optionsError = "Options command exited " + exitCode
}
}
}
implicitWidth: Style.spacing.searchableDropdownWidth
implicitHeight: showLabel && label !== "" ? rowHeight + Style.spacing.huge : rowHeight
Column {
anchors.fill: parent
spacing: Style.spacing.labelGap
Text {
textFormat: Text.PlainText
visible: root.showLabel && root.label !== ""
text: root.label
color: Qt.darker(root.foreground, 1.4)
font.family: root.fontFamily
font.pixelSize: Style.font.caption
font.bold: true
}
BorderSurface {
id: trigger
width: parent.width
height: root.rowHeight
radius: Style.cornerRadius
readonly property bool _focused: trigger.activeFocus
readonly property bool _hot: triggerHover.hovered || root.hasCursor
readonly property var _borderSpec: Border.controlSpec(trigger._focused ? "focus" : (trigger._hot ? "hover-cursor" : "normal"), root.foreground, root.accent)
color: Style.controlFill(trigger._focused, trigger._hot, root.foreground, root.accent)
borderSpec: _borderSpec
activeFocusOnTab: true
HoverHandler {
id: triggerHover
onHoveredChanged: root.hovered(hovered)
}
Keys.onPressed: function(event) {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter
|| event.key === Qt.Key_Space || event.key === Qt.Key_Down) {
popup.opened ? popup.close() : popup.open()
event.accepted = true
} else if (event.key === Qt.Key_Escape && popup.opened) {
popup.close(); event.accepted = true
}
}
Text {
textFormat: Text.PlainText
anchors.left: parent.left
anchors.right: chevron.left
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: trigger.borderLeft + Style.spacing.controlPaddingX
anchors.rightMargin: trigger.borderRight + Style.spacing.md
text: root.selectionLabel() || root.triggerLabel || root.noSelectionText
color: root.selectionLabel() ? root.foreground : Qt.darker(root.foreground, 1.5)
font.family: root.fontFamily
font.pixelSize: Style.font.body
elide: Text.ElideRight
}
Text {
id: chevron
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: trigger.borderRight + Style.spacing.controlGap
text: "󰅀"
color: Qt.darker(root.foreground, 1.2)
font.family: root.fontFamily
font.pixelSize: Style.font.body
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
trigger.forceActiveFocus()
popup.opened ? popup.close() : popup.open()
}
}
QQC.Popup {
id: popup
// Reparent to the window's content item so the popup is free of any
// clipping ancestor. Position
// and available height are recomputed on open and any time the
// trigger's geometry changes, since a binding on mapToItem alone
// won't reliably re-evaluate when ancestors scroll or resize.
parent: trigger.Window.window ? trigger.Window.window.contentItem : trigger
property real _anchorX: 0
property real _anchorY: 0
property real _availableBelow: 0
readonly property real _windowHeight: parent ? parent.height : 0
readonly property real _idealContent: resultList.contentHeight + Style.space(50)
readonly property real _maxRowsHeight: root.popupRowHeight * 6 + 5 * Style.spacing.labelGap + Style.space(50)
function reposition() {
if (!parent) return
var p = trigger.mapToItem(parent, 0, trigger.height + Style.spacing.xxs)
_anchorX = p.x
_anchorY = p.y
_availableBelow = Math.max(0, _windowHeight - _anchorY - Style.space(12))
}
x: _anchorX
y: _anchorY
width: trigger.width
// Clamp to whatever fits below the trigger; don't force popupMinHeight
// when there isn't room, otherwise the popup overflows the window.
implicitHeight: Math.min(_availableBelow, _idealContent, _maxRowsHeight)
padding: Style.spacing.hairline
leftPadding: Border.left(root.popupBorderSpec) + Style.spacing.hairline
rightPadding: Border.right(root.popupBorderSpec) + Style.spacing.hairline
topPadding: Border.top(root.popupBorderSpec) + Style.spacing.hairline
bottomPadding: Border.bottom(root.popupBorderSpec) + Style.spacing.hairline
focus: true
Connections {
target: trigger
function onXChanged() { popup.reposition() }
function onYChanged() { popup.reposition() }
function onWidthChanged() { popup.reposition() }
function onHeightChanged() { popup.reposition() }
}
background: BorderSurface {
color: root.background
borderSpec: root.popupBorderSpec
radius: Style.cornerRadius
}
onOpened: {
reposition()
searchField.text = ""
root.refresh()
root.recomputeFiltered()
Qt.callLater(function() { searchField.forceActiveFocus() })
}
onClosed: searchField.text = ""
contentItem: Column {
spacing: 0
Item {
id: searchHeader
width: parent.width
height: root.popupRowHeight + Style.spacing.controlPaddingX
Row {
anchors.fill: parent
anchors.margins: Style.spacing.md
spacing: Style.spacing.rowGap
TextField {
id: searchField
width: parent.width - refreshButton.width - parent.spacing
height: parent.height
placeholderText: root.placeholderText
foreground: root.foreground
accent: root.accent
font.family: root.fontFamily
font.pixelSize: Style.font.body
onTextChanged: {
root.recomputeFiltered()
if (resultList.count > 0) resultList.currentIndex = 0
}
Keys.onPressed: function(event) {
if (event.key === Qt.Key_Escape) {
popup.close(); event.accepted = true
} else if (event.key === Qt.Key_Down) {
if (resultList.count > 0) {
resultList.currentIndex = 0
resultList.forceActiveFocus()
}
event.accepted = true
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
if (resultList.count > 0) {
resultList.currentIndex = 0
resultList.toggleCurrent()
}
event.accepted = true
}
}
}
BorderSurface {
id: refreshButton
visible: root.arrayFrom(root.optionsCommand).length > 0
enabled: !root.loadingOptions
width: parent.height
height: parent.height
radius: Style.cornerRadius
color: refreshHover.hovered
? Style.hoverFillFor(root.foreground, root.accent)
: Style.normalFillFor(root.foreground, root.accent)
borderSpec: refreshHover.hovered
? Border.controlSpec("hover-cursor", root.foreground, root.accent)
: Border.controlSpec("normal", root.foreground, root.accent)
Text {
textFormat: Text.PlainText
anchors.centerIn: parent
text: root.loadingOptions ? "󰦖" : "󰑐"
color: root.foreground
font.family: root.fontFamily
font.pixelSize: Style.font.body
RotationAnimator on rotation {
running: root.loadingOptions && !Style.reduceMotion
from: 0; to: 360
duration: 800
loops: Animation.Infinite
}
}
HoverHandler { id: refreshHover }
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: root.refresh()
}
}
}
}
Rectangle {
width: parent.width
height: 1
color: Util.alpha(root.foreground, 0.10)
}
Item {
width: parent.width
height: popup.height - searchHeader.height - Style.spacing.xxs - 1
Text {
textFormat: Text.PlainText
anchors.centerIn: parent
visible: resultList.count === 0
text: root.loadingOptions ? "Loading…" : (root.optionsError !== "" ? root.optionsError : root.emptyText)
color: Qt.darker(root.foreground, 1.6)
font.family: root.fontFamily
font.pixelSize: Style.font.body
}
ListView {
id: resultList
anchors.fill: parent
spacing: Style.spacing.labelGap
clip: true
boundsBehavior: Flickable.StopAtBounds
model: root.filtered
currentIndex: -1
keyNavigationEnabled: false
function toggleCurrent() {
if (currentIndex < 0 || currentIndex >= root.filtered.length) return
root.toggleValue(root.filtered[currentIndex].value)
}
Keys.priority: Keys.BeforeItem
Keys.onPressed: function(event) {
if (event.key === Qt.Key_Escape) {
popup.close(); event.accepted = true
} else if (event.key === Qt.Key_Down || event.text === "j") {
if (resultList.currentIndex >= resultList.count - 1) {
event.accepted = true; return
}
resultList.currentIndex = resultList.currentIndex + 1
event.accepted = true
} else if (event.key === Qt.Key_Up || event.text === "k") {
if (resultList.currentIndex <= 0) {
searchField.forceActiveFocus()
event.accepted = true; return
}
resultList.currentIndex = resultList.currentIndex - 1
event.accepted = true
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter
|| event.key === Qt.Key_Space) {
resultList.toggleCurrent(); event.accepted = true
}
}
delegate: Rectangle {
required property var modelData
required property int index
readonly property bool selected: root.isSelected(modelData.value)
width: resultList.width
height: Math.max(root.popupRowHeight, rowContent.implicitHeight + Style.spacing.rowPaddingX)
color: index === resultList.currentIndex
? Style.hoverFillFor(root.foreground, root.accent)
: "transparent"
Row {
id: rowContent
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: Style.spacing.controlPaddingX
anchors.rightMargin: Style.spacing.controlPaddingX
spacing: Style.spacing.rowGap
BorderSurface {
id: checkbox
width: Style.space(16)
height: Style.space(16)
radius: Math.max(2, Style.cornerRadius / 2)
anchors.verticalCenter: parent.verticalCenter
color: selected ? Style.selectedFillFor(root.foreground, root.accent) : "transparent"
borderSpec: selected
? Border.controlSpec("selected", root.foreground, root.accent)
: Border.controlSpec("normal", root.foreground, root.accent)
Text {
anchors.centerIn: parent
visible: selected
text: "✓"
color: Style.selectedStateColor(root.foreground, root.accent)
font.family: root.fontFamily
font.pixelSize: Math.round(checkbox.height * 0.85)
font.bold: true
}
}
Column {
width: parent.width - checkbox.width - parent.spacing
anchors.verticalCenter: parent.verticalCenter
spacing: Style.spacing.xxs
Text {
textFormat: Text.PlainText
text: modelData.label
color: index === resultList.currentIndex ? Style.hoverStateColor(root.foreground, root.accent) : root.foreground
font.family: root.fontFamily
font.pixelSize: Style.font.body
elide: Text.ElideRight
width: parent.width
}
Text {
textFormat: Text.PlainText
visible: text !== ""
text: modelData.description
color: Qt.darker(root.foreground, 1.5)
font.family: root.fontFamily
font.pixelSize: Style.font.caption
elide: Text.ElideRight
width: parent.width
}
}
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onPositionChanged: resultList.currentIndex = parent.index
onClicked: root.toggleValue(modelData.value)
}
}
}
}
}
}
}
}
}
@@ -0,0 +1,84 @@
import QtQuick
import QtQuick.Controls as QQC
import qs.compat.omarchy.Commons
Column {
id: root
property string label: ""
property int value: 0
property int from: 0
property int to: 100
property int stepSize: 1
property color foreground: Color.foreground
property color accent: Color.accent
property string fontFamily: Style.font.family
property real fontSize: Style.font.body
property real fieldWidth: Style.spacing.numberFieldWidth
property bool hasCursor: false
property bool _hovered: false
property alias field: spin
signal modified(int value)
signal hovered(bool on)
spacing: Style.spacing.md
Text {
textFormat: Text.PlainText
visible: root.label !== ""
text: root.label
color: Qt.darker(root.foreground, 1.4)
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
}
QQC.SpinBox {
id: spin
width: root.fieldWidth
implicitHeight: Math.max(Style.spacing.controlHeight, root.fontSize + Style.spacing.controlPaddingY * 2)
from: root.from
to: root.to
stepSize: root.stepSize
value: root.value
editable: true
font.family: root.fontFamily
font.pixelSize: root.fontSize
readonly property bool _focused: spin.activeFocus
readonly property bool _hot: root._hovered || root.hasCursor
readonly property var _borderSpec: Border.controlSpec(_focused ? "focus" : (_hot ? "hover-cursor" : "normal"), root.foreground, root.accent)
leftPadding: Border.left(_borderSpec) + Style.spacing.controlPaddingX
rightPadding: Border.right(_borderSpec) + Style.spacing.controlPaddingX
topPadding: Border.top(_borderSpec)
bottomPadding: Border.bottom(_borderSpec)
onValueModified: root.modified(value)
background: BorderSurface {
color: Style.controlFill(spin._focused, spin._hot, root.foreground, root.accent)
borderSpec: spin._borderSpec
radius: Style.cornerRadius
HoverHandler {
onHoveredChanged: {
root._hovered = hovered
root.hovered(hovered)
}
}
}
contentItem: TextInput {
text: spin.displayText
font: spin.font
color: root.foreground
selectionColor: Style.selectionFillFor(root.foreground, root.accent)
selectedTextColor: root.foreground
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
readOnly: !spin.editable
validator: spin.validator
inputMethodHints: Qt.ImhFormattedNumbersOnly
}
}
}
@@ -0,0 +1,57 @@
import QtQuick
import qs.compat.omarchy.Commons
Item {
id: root
property string text: ""
property string fontFamily: Style.font.family
property real fontSize: Style.font.body
property color color: Color.foreground
property bool debugBounds: false
readonly property int renderedFontSize: Math.max(1, Math.round(fontSize))
readonly property real tightWidth: Math.max(1, glyphMetrics.tightBoundingRect.width)
readonly property real horizontalCorrection: glyph.implicitWidth / 2 - (glyphMetrics.tightBoundingRect.x + tightWidth / 2)
readonly property real paintedCenterX: glyph.x + glyphMetrics.tightBoundingRect.x + tightWidth / 2
readonly property real baselineY: glyph.y + glyph.baselineOffset
TextMetrics {
id: glyphMetrics
font.family: root.fontFamily
font.pixelSize: root.renderedFontSize
text: root.text
}
Text {
id: glyph
textFormat: Text.PlainText
// Keep the shared line box and baseline intact. Correcting only the
// horizontal painted bounds avoids per-glyph vertical drift.
// The correction is fractional, so x is set exactly: centerIn would snap it
// to a whole pixel and undo it. y still snaps, keeping the baseline crisp.
x: (root.width - width) / 2 + root.horizontalCorrection
y: Math.round((root.height - height) / 2)
text: root.text
color: root.color
font.family: root.fontFamily
font.pixelSize: root.renderedFontSize
renderType: Text.NativeRendering
}
Rectangle {
visible: root.debugBounds
anchors.fill: parent
color: "transparent"
border.width: 1
border.color: "#4488ff"
}
Rectangle {
visible: root.debugBounds
x: 0
y: Math.round(root.baselineY)
width: parent.width
height: 1
color: "#44ff88"
}
}
@@ -0,0 +1,56 @@
import QtQuick
import Quickshell
import Quickshell.Hyprland
import Quickshell.Wayland
// A fullscreen overlay whose surface outlives each open. A fresh surface draws
// its first frames before the compositor sends its fractional scale, so an
// overlay mapped per open flashed blurry until the scale arrived. Closed, the
// surface parks as a 1x1, input-less, content-less layer below windows: small
// enough to cost nothing, off the overlay layer so it never blocks direct
// scanout for fullscreen apps. Opening only resizes and raises it.
PanelWindow {
id: window
// Whether the overlay is showing. Drive this instead of visible.
property bool shown: false
property int shownLayer: WlrLayer.Overlay
property int shownKeyboardFocus: WlrKeyboardFocus.Exclusive
// The surface no longer lands on the focused output by being mapped there,
// so it follows the focused monitor each time it is shown. Unset until the
// first show lets the compositor choose.
property var targetScreen: null
property Region emptyRegion: Region {}
function focusedScreen() {
var monitor = Hyprland.focusedMonitor
var name = monitor ? String(monitor.name || "") : ""
for (var i = 0; i < Quickshell.screens.length; i++) {
if (Quickshell.screens[i].name === name) return Quickshell.screens[i]
}
return null
}
onShownChanged: if (shown) targetScreen = focusedScreen() || targetScreen
visible: true
screen: targetScreen
anchors { top: true; left: true; bottom: shown; right: shown }
implicitWidth: 1
implicitHeight: 1
mask: shown ? null : emptyRegion
color: "transparent"
exclusionMode: ExclusionMode.Ignore
WlrLayershell.layer: shown ? shownLayer : WlrLayer.Bottom
WlrLayershell.keyboardFocus: shown ? shownKeyboardFocus : WlrKeyboardFocus.None
// Draw nothing until the surface has actually grown. A frame drawn while it
// is still 1x1 holds only the scrim's color, which the compositor would
// stretch across the whole screen until the fullscreen frame arrives.
Binding {
target: window.contentItem
property: "visible"
value: window.shown && window.width > 1 && window.height > 1
}
}
+58
View File
@@ -0,0 +1,58 @@
import QtQuick
import Quickshell.Io
import qs.compat.omarchy.Commons
// Base item for plugin popup widgets. Many first-party plugins expose a bar
// button plus a popup from one QML entry point; this base owns the shared
// IPC-backed open/close lifecycle while implementations own button behavior,
// keyboard navigation, and content.
Item {
id: root
property QtObject bar: null
property string moduleName: ""
property var settings: ({})
property string ipcTarget: ""
property bool manageIpc: true
property alias controller: panelController
property bool popoutSwitching: false
property bool popoutSwitchClosing: false
readonly property bool opened: panelController.open
readonly property color barForeground: bar ? bar.barForeground : Color.foreground
function open() { panelController.show() }
function close() { panelController.hide() }
function closeForPopoutSwitch() {
popoutSwitchClosing = true
close()
Qt.callLater(function() { popoutSwitchClosing = false })
}
function toggle() { opened ? close() : open() }
function switchPanel(direction) {
if (bar && typeof bar.switchPanelFrom === "function") return bar.switchPanelFrom(root, direction)
return false
}
// Read a single value from this panel's inline shell.json entry, with a
// fallback for missing/null values. Matches BarWidget.setting().
function setting(name, fallback) {
var value = settings ? settings[name] : undefined
return value === undefined || value === null ? fallback : value
}
PanelController {
id: panelController
}
ShellIpc {
enabled: root.manageIpc && root.ipcTarget !== ""
target: root.ipcTarget
function open(): void { root.open() }
function close(): void { root.close() }
function show(): void { root.open() }
function hide(): void { root.close() }
function toggle(): void { root.toggle() }
}
}
@@ -0,0 +1,99 @@
import QtQuick
import qs.compat.omarchy.Commons
// Small (22×22 by default) icon button used at the right edge of panel rows
// for inline actions — forget network, confirm passphrase, unpair device,
// etc. Two visual modes are supported via `hoverColor`:
// - default: hoverColor === foreground → subtle foreground-tint hover
// - urgent: hoverColor === bar.urgent → red-tint hover for destructive
// actions like forget/unpair
//
// `enabled` gates clicks and dims the icon. The component owns its own
// hover state visuals; mouse hover does NOT update any panel cursor state
// here because action buttons are not cursor targets — the row they live
// in is.
//
// Set `focusable: true` to make the button keyboard-tabbable with the
// shared hover-cursor/focus tokens. Use this
// in form contexts where Tab walks a list
// of controls; leave it false for the right-edge actions on panel rows
// where the row's CursorSurface owns the keyboard cursor.
//
// Set `hasCursor: true` to have the button render the same hover state as
// mouse hover — so a panel's keyboard cursor lands on it identically.
// Use this when a PanelActionButton is itself the cursor target (rather
// than living inside a CursorSurface row). Emits `hovered(bool)` on
// pointer enter/leave so the panel can update its cursor state to match.
BorderSurface {
id: root
property string iconText: ""
property string tooltipText: ""
property color foreground: Color.foreground
property color hoverColor: foreground
property string fontFamily: Style.font.family
property real fontSize: Style.font.icon
property real size: Math.max(Style.space(22), fontSize + Style.spacing.sm * 2)
property bool focusable: false
property bool hasCursor: false
property bool bordered: false
signal clicked()
signal hovered(bool isHovered)
activeFocusOnTab: focusable
Keys.onReturnPressed: if (focusable) root.clicked()
Keys.onEnterPressed: if (focusable) root.clicked()
Keys.onSpacePressed: if (focusable) root.clicked()
implicitWidth: size
implicitHeight: size
radius: Style.cornerRadius
readonly property bool _showFocusRing: focusable && activeFocus
readonly property bool _hot: (mouse.containsMouse || root.hasCursor) && root.enabled
readonly property var _borderSpec: _showFocusRing
? Border.controlSpec("focus", hoverColor, hoverColor)
: (_hot && bordered
? Border.controlSpec("hover-cursor", hoverColor, hoverColor)
: (bordered ? Border.controlSpec("normal", foreground, Color.accent) : Border.none()))
color: _showFocusRing
? Style.focusFillFor(hoverColor, hoverColor)
: (_hot
? Style.hoverFillFor(hoverColor, hoverColor)
: "transparent")
borderSpec: _borderSpec
Behavior on color { ColorAnimation { duration: Style.duration(60) } }
Text {
textFormat: Text.PlainText
anchors.centerIn: parent
text: root.iconText
color: root.enabled
? (root._hot ? root.hoverColor : root.foreground)
: Qt.darker(root.foreground, 2.0)
font.family: root.fontFamily
font.pixelSize: root.fontSize
}
MouseArea {
id: mouse
anchors.fill: parent
hoverEnabled: true
cursorShape: root.enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
enabled: root.enabled
onContainsMouseChanged: root.hovered(containsMouse)
onClicked: {
if (root.focusable) root.forceActiveFocus()
root.clicked()
}
}
PanelToolTip {
visible: root.tooltipText !== "" && mouse.containsMouse
text: root.tooltipText
fontFamily: root.fontFamily
}
}
@@ -0,0 +1,16 @@
import QtQuick
// Stores the open state for a shell panel. Panel owns the public lifecycle
// methods and IPC wiring; this object only keeps state separate from the
// panel implementation's own properties.
//
// Usage:
// PanelController { id: panelController }
QtObject {
id: root
property bool open: false
function toggle() { open = !open }
function show() { if (!open) open = true }
function hide() { open = false }
}
+110
View File
@@ -0,0 +1,110 @@
import QtQuick
import qs.compat.omarchy.Commons
Item {
id: root
property Component iconComponent: null
property string title: ""
property string meta: ""
property string detail: ""
property color foreground: Color.foreground
property string fontFamily: Style.font.family
property real iconSize: Style.font.display
property real iconOpacity: 1.0
property alias metaOpacity: metaText.opacity
// Optional control pinned to the trailing edge of the hero — a ToggleSwitch,
// a small button. The hero centers it against the labels and reserves the
// space itself, so callers never do the geometry.
property Component trailingControl: null
readonly property color dim: Qt.darker(foreground, 1.4)
readonly property real trailingInset: trailingLoader.item && trailingLoader.item.visible ? trailingLoader.width + Style.space(12) : 0
width: parent ? parent.width : implicitWidth
implicitHeight: Math.max(iconLoader.implicitHeight, heroLabels.implicitHeight, trailingLoader.implicitHeight)
Loader {
id: iconLoader
sourceComponent: root.iconComponent
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
opacity: root.iconOpacity
}
Column {
id: heroLabels
anchors.left: iconLoader.right
anchors.leftMargin: Style.space(14)
anchors.right: parent.right
anchors.rightMargin: root.trailingInset
anchors.verticalCenter: parent.verticalCenter
spacing: Style.space(2)
Row {
id: titleRow
visible: root.title !== "" || detailPill.visible
width: parent.width
Text {
textFormat: Text.PlainText
visible: root.title !== ""
text: root.title
width: Math.min(implicitWidth, Math.max(0, parent.width - (detailPill.visible ? detailPill.implicitWidth + Style.space(8) : 0)))
color: root.foreground
font.family: root.fontFamily
font.pixelSize: Style.font.title
font.bold: true
elide: Text.ElideRight
}
Item {
width: Math.max(0, parent.width - parent.children[0].width - detailPill.implicitWidth)
height: 1
}
BorderSurface {
id: detailPill
visible: root.detail !== ""
implicitWidth: detailText.implicitWidth + Style.space(10)
implicitHeight: detailText.implicitHeight + Style.space(4)
anchors.verticalCenter: parent.verticalCenter
color: "transparent"
borderSpec: Border.controlSpec("normal", root.foreground, Color.accent)
radius: Style.cornerRadius
Text {
id: detailText
textFormat: Text.PlainText
anchors.centerIn: parent
text: root.detail
color: root.dim
font.family: root.fontFamily
font.pixelSize: Style.font.body
font.bold: true
}
}
}
Text {
id: metaText
textFormat: Text.PlainText
width: parent.width
text: root.meta.toUpperCase()
visible: text !== ""
color: root.dim
font.family: root.fontFamily
font.pixelSize: Style.font.caption
font.bold: true
font.letterSpacing: 1.2
elide: Text.ElideRight
}
}
Loader {
id: trailingLoader
sourceComponent: root.trailingControl
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
}
}
@@ -0,0 +1,97 @@
import QtQuick
// Drop-in key dispatcher for keyboard-driven panels. Wraps panel content
// and emits semantic signals so each panel keeps its own state machine
// (focusSection, selectedIndex, action rules) while the boilerplate
// key handling lives here.
//
// Usage:
// Common.KeyboardPanel {
// ...
// PanelKeyCatcher {
// anchors.fill: parent
// onMoveRequested: function(dx, dy) { root.moveCursor(dx, dy) }
// onActivateRequested: root.activateCursor()
// onCloseRequested: root.close()
// onDeleteRequested: root.deleteSelected()
// onTextKey: function(t, modifiers) { if (t === "r") root.refresh() }
//
// Column { ... panel content ... }
// }
// }
//
// Keys.priority: Keys.BeforeItem means this handler gets keys first,
// even when a descendant has activeFocus. That's what lets Up/Down
// arrows drive the cursor instead of being consumed by an inner
// Flickable's built-in scroll handling. When a panel has an inline
// editor (wifi passphrase, gallery TextField demo) the panel must
// set `blocked: editor.activeFocus` so this handler short-circuits
// and the editor receives keys normally.
//
// blocked: when true, ALL keys are forwarded to descendants without
// triggering signals.
Item {
id: root
property bool blocked: false
// Panels that let items be reordered set this, and Ctrl+Up/Down (or
// Ctrl+k/j) then asks to move the current item instead of the cursor.
property bool reorderable: false
signal moveRequested(int dx, int dy)
signal reorderRequested(int dy)
signal activateRequested()
signal returnRequested()
signal closeRequested()
signal deleteRequested()
signal tabRequested(int direction)
// The held modifiers ride along, so a panel can tell Alt+T from T.
signal textKey(string text, int modifiers)
focus: true
Keys.priority: Keys.BeforeItem
Keys.onPressed: function(event) {
if (blocked) return
if (event.key === Qt.Key_Escape) {
closeRequested(); event.accepted = true; return
}
if (event.key === Qt.Key_Tab || event.key === Qt.Key_Backtab) {
tabRequested((event.modifiers & Qt.ShiftModifier) || event.key === Qt.Key_Backtab ? -1 : 1)
event.accepted = true
return
}
if (reorderable && (event.modifiers & Qt.ControlModifier)) {
var up = event.key === Qt.Key_Up || event.key === Qt.Key_K
var down = event.key === Qt.Key_Down || event.key === Qt.Key_J
if (up || down) {
reorderRequested(down ? 1 : -1); event.accepted = true; return
}
}
if (event.key === Qt.Key_Down || event.text === "j") {
moveRequested(0, 1); event.accepted = true; return
}
if (event.key === Qt.Key_Up || event.text === "k") {
moveRequested(0, -1); event.accepted = true; return
}
if (event.key === Qt.Key_Right || event.text === "l") {
moveRequested(1, 0); event.accepted = true; return
}
if (event.key === Qt.Key_Left || event.text === "h") {
moveRequested(-1, 0); event.accepted = true; return
}
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
returnRequested()
activateRequested(); event.accepted = true; return
}
if (event.key === Qt.Key_Space) {
activateRequested(); event.accepted = true; return
}
if (event.key === Qt.Key_Delete || event.text === "x" || event.text === "X") {
deleteRequested(); event.accepted = true; return
}
if (event.text && event.text.length === 1) {
textKey(event.text, event.modifiers)
}
}
}
@@ -0,0 +1,29 @@
import QtQuick
import qs.compat.omarchy.Commons
// Small-caps-style label that introduces a panel section ("DNS provider",
// "Wi-Fi networks", "Output device", "Paired devices"). Sits between a
// PanelSeparator and the content rows.
Text {
id: root
property color foreground: Color.foreground
property string fontFamily: Style.font.family
property real fontSize: Style.font.caption
// Callers bind `text` from outside this file, so the default has to be set
// here. AutoText would let a section title that happens to carry a device or
// network name promote itself to rich text.
textFormat: Text.PlainText
color: Qt.darker(foreground, 1.4)
font.family: fontFamily
font.pixelSize: fontSize
font.bold: true
// Glyphs can paint above the box Text reserves for them: JetBrainsMono Nerd
// Font's outlines run 10% of the em past its own ascent, and a patched or
// user-chosen family can be worse. That sliver is invisible in normal flow,
// but a header sitting at the top of a clipping list — bluetooth's device
// list, network's station list — loses it to the clip and renders beheaded.
// Reserve the overshoot here so every panel is covered at once.
topPadding: Math.ceil(fontSize * 0.15)
}
@@ -0,0 +1,17 @@
import QtQuick
import qs.compat.omarchy.Commons
// 1px horizontal divider for panel sections. The alpha-on-foreground tint
// keeps the rule legible against the panel background without competing
// with text or borders.
Rectangle {
id: root
property color foreground: Color.foreground
property real strength: 0.12
width: parent ? parent.width : implicitWidth
implicitWidth: 100
implicitHeight: 1
height: 1
color: Qt.rgba(foreground.r, foreground.g, foreground.b, strength)
}
@@ -0,0 +1,149 @@
import QtQuick
import qs.compat.omarchy.Commons
import "../../../theme" as G
Item {
id: root
property QtObject bar: null
property real value: 0
property real minimum: 0
property real maximum: 1
property real step: 0.05
property bool integer: false
property color trackColor: G.Theme.surfaceVariant
property color fillColor: G.Theme.accent
property color knobColor: G.Theme.text
property bool dragging: false
property real trackHeight: Math.max(4, Math.round(Style.spacing.controlHeight * 0.11))
property real knobSize: Math.max(14, Math.round(Style.spacing.controlHeight * 0.38))
property real liveValue: value
// macOS-style notches. When > 1, that many evenly-spaced tick marks are cut
// into the track (drawn in the panel background color, so only the part
// crossing the track shows). Purely visual — snapping is the caller's job via
// `integer`/`step` or an index-based value. Default 0 leaves the track plain.
property int tickCount: 0
property color tickColor: bar ? bar.background : Color.background
onValueChanged: if (!dragging) liveValue = value
signal moved(real value)
signal released(real value)
// Right-click is a secondary action on the whole track — audio uses it to
// mute the channel the slider belongs to. Dragging stays left-button only.
signal rightClicked()
implicitWidth: Style.space(200)
implicitHeight: Math.max(Style.space(22), knobSize + Style.spacing.md)
readonly property real range: Math.max(0.0001, maximum - minimum)
readonly property real progress: Math.max(0, Math.min(1, (liveValue - minimum) / range))
readonly property bool _hot: mouseArea.containsMouse || root.dragging
Rectangle {
id: track
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.right: parent.right
height: root.trackHeight
radius: height / 2
color: root.trackColor
}
Rectangle {
id: fill
anchors.verticalCenter: track.verticalCenter
anchors.left: track.left
height: track.height
radius: track.radius
color: root.fillColor
width: track.width * root.progress
Behavior on width {
enabled: !root.dragging
NumberAnimation { duration: Style.duration(140); easing.type: Easing.OutCubic }
}
}
Repeater {
model: root.tickCount > 1 ? root.tickCount : 0
Rectangle {
required property int index
width: Math.max(1, Style.space(2))
height: root.trackHeight + Style.space(4)
radius: 1
color: root.tickColor
anchors.verticalCenter: track.verticalCenter
x: Math.max(0, Math.min(track.width - width,
track.width * (index / (root.tickCount - 1)) - width / 2))
}
}
BorderSurface {
id: knob
width: root.knobSize
height: root.knobSize
radius: root.knobSize / 2
color: root.knobColor
borderSpec: Border.flat(root.bar ? root.bar.background : "#101315", Math.max(1, Style.space(2)))
anchors.verticalCenter: track.verticalCenter
x: Math.max(0, Math.min(track.width - width, track.width * root.progress - width / 2))
scale: root._hot ? 1.15 : 1.0
Behavior on x {
enabled: !root.dragging
NumberAnimation { duration: Style.duration(140); easing.type: Easing.OutCubic }
}
Behavior on scale {
NumberAnimation { duration: Style.duration(110); easing.type: Easing.OutCubic }
}
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.RightButton
function valueFromX(x) {
var clamped = Math.max(0, Math.min(track.width, x))
var raw = root.minimum + (clamped / track.width) * root.range
if (root.integer) raw = Math.round(raw)
return Math.max(root.minimum, Math.min(root.maximum, raw))
}
onPressed: function(mouse) {
if (mouse.button !== Qt.LeftButton) return
root.dragging = true
var next = valueFromX(mouse.x)
root.liveValue = next
root.moved(next)
}
onClicked: function(mouse) {
if (mouse.button === Qt.RightButton) root.rightClicked()
}
onPositionChanged: function(mouse) {
if (!root.dragging) return
var next = valueFromX(mouse.x)
root.liveValue = next
root.moved(next)
}
onReleased: function(mouse) {
if (mouse.button !== Qt.LeftButton) return
root.dragging = false
root.released(root.liveValue)
root.liveValue = root.value
}
onWheel: function(wheel) {
var delta = wheel.angleDelta.y > 0 ? root.step : -root.step
var next = Math.max(root.minimum, Math.min(root.maximum, root.liveValue + delta))
if (root.integer) next = Math.round(next)
root.liveValue = next
root.moved(next)
root.released(next)
}
}
}
@@ -0,0 +1,48 @@
import QtQuick
import QtQuick.Controls
import qs.compat.omarchy.Commons
// Styled wrapper around Qt Quick Controls ToolTip. Drop-in: declare inside
// the hovered item and bind `visible` to the hover state, e.g.
// PanelToolTip {
// visible: mouse.containsMouse
// text: "Forget network"
// }
//
// Defaults pull from [tooltip] in shell.toml via Color.tooltip.*. Override
// the panel* properties per-instance only when you need a tooltip that
// intentionally diverges from the theme.
//
// Property names are prefixed `panel*` to avoid clashing with ToolTip's
// built-in `background`/`font` properties.
ToolTip {
id: root
property color panelForeground: Color.tooltip.text
property color panelBackground: Color.tooltip.background
property color panelBorder: Color.tooltip.border
property string fontFamily: Style.font.family
property real fontSize: Style.font.bodySmall
readonly property var panelBorderSpec: Border.localOrSurfaceSpec("tooltip", "border", panelBorder, Color.tooltip.border, Style.normalBorderWidth)
delay: 400
padding: 0
background: BorderSurface {
color: root.panelBackground
borderSpec: root.panelBorderSpec
radius: Style.cornerRadius
}
contentItem: Text {
textFormat: Text.PlainText
text: root.text
color: root.panelForeground
font.family: root.fontFamily
font.pixelSize: root.fontSize
leftPadding: Border.left(root.panelBorderSpec) + Style.spacing.controlPaddingX
rightPadding: Border.right(root.panelBorderSpec) + Style.spacing.controlPaddingX
topPadding: Border.top(root.panelBorderSpec) + Style.spacing.controlPaddingY
bottomPadding: Border.bottom(root.panelBorderSpec) + Style.spacing.controlPaddingY
}
}
@@ -0,0 +1,87 @@
import QtQuick
// Bar surface exposed to an installed third-party widget. Scalar presentation
// state is mirrored by Bar.qml and operations are delegated through scoped
// callbacks. The facade avoids direct host-Bar injection; it cannot isolate a
// visual child from the parent hierarchy of the QML scene that renders it.
QtObject {
id: api
required property string pluginId
required property string moduleName
property var shell: null
property color foreground: "transparent"
property color barForeground: "transparent"
property color background: "transparent"
property color urgent: "transparent"
property string fontFamily: ""
property string position: "top"
property bool vertical: false
property int barSize: 0
property bool transparent: false
property bool foregroundAnimationEnabled: true
property bool centerSectionRevealHeld: false
property bool _centerHoverRevealSuppressed: false
readonly property bool centerHoverRevealSuppressed: _centerHoverRevealSuppressed
property var activePopout: null
property var clickTargets: []
property var layoutConfig: ({})
readonly property var foreignPopoutMarker: ({ foreign: true })
property var _showTooltip: null
property var _hideTooltip: null
property var _registerClickTarget: null
property var _unregisterClickTarget: null
property var _requestPopout: null
property var _releasePopout: null
property var _switchPanelFrom: null
property var _targetBelongsToWindow: null
property var _moduleWidgets: null
property var _run: null
property var _setCenterHoverRevealSuppressed: null
function setCenterHoverRevealSuppressed(value) {
if (_setCenterHoverRevealSuppressed) _setCenterHoverRevealSuppressed(!!value)
}
function showTooltip(target, text) {
if (_showTooltip) _showTooltip(target, String(text || ""))
}
function hideTooltip(target) {
if (_hideTooltip) _hideTooltip(target)
}
function registerClickTarget(target) {
if (_registerClickTarget) _registerClickTarget(target)
}
function unregisterClickTarget(target) {
if (_unregisterClickTarget) _unregisterClickTarget(target)
}
function requestPopout(owner) {
if (_requestPopout) _requestPopout(owner)
}
function releasePopout(owner) {
if (_releasePopout) _releasePopout(owner)
}
function switchPanelFrom(owner, direction) {
return _switchPanelFrom ? _switchPanelFrom(owner, direction) : false
}
function targetBelongsToWindow(target, window) {
return _targetBelongsToWindow ? _targetBelongsToWindow(target, window) : false
}
function moduleWidgets(id) {
return _moduleWidgets ? _moduleWidgets(String(id || "")) : []
}
function run(command) {
if (_run) _run(String(command || ""))
}
}
@@ -0,0 +1,54 @@
import QtQuick
// Filters synthetic hover churn from moving delegates under a stationary
// pointer. Call reset() after keyboard/list mutations, then moved() from a
// row MouseArea's onPositionChanged before changing cursor selection. A
// transition known to originate from the pointer can call allowInitialSample()
// so the item under the stationary pointer remains selected.
QtObject {
id: root
property Item referenceItem: null
property real threshold: 1
property bool primed: false
property bool initialSampleAllowed: false
property real lastX: 0
property real lastY: 0
function reset() {
root.primed = false
root.initialSampleAllowed = false
root.lastX = 0
root.lastY = 0
}
function allowInitialSample() {
root.reset()
root.initialSampleAllowed = true
}
function moved(item, mouse) {
if (!item || !mouse) {
root.reset()
return false
}
var target = root.referenceItem || item
var point = item.mapToItem(target, mouse.x, mouse.y)
var firstSample = !root.primed
var didMove = !firstSample
? Math.abs(point.x - root.lastX) > root.threshold || Math.abs(point.y - root.lastY) > root.threshold
: root.initialSampleAllowed
// Keep the previous accepted position while filtering jitter so slow,
// sub-threshold steps accumulate into deliberate pointer movement.
if (firstSample || didMove) {
root.lastX = point.x
root.lastY = point.y
}
root.primed = true
root.initialSampleAllowed = false
return didMove
}
}
@@ -0,0 +1,8 @@
import QtQuick
// glassMxrph: Omarchy's click/hover popup card, drawn as a glassMxrph bar
// drawer. "click" closes on outside clicks; "hover" leaves opening and closing
// to its owner. See GlassPopupBase for the shared implementation and API.
GlassPopupBase {
property string triggerMode: "click"
mode: triggerMode === "hover" ? "hover" : "click"
}
@@ -0,0 +1,43 @@
import QtQuick
// Hyprland leaves an already-mapped layer surface at its old global position
// when its monitor moves within the layout: undocking disables the internal
// panel, the external monitor shifts to x=0, and long-lived surfaces such as
// the bar and background keep rendering at the old offset — or entirely
// off-screen — until they are unmapped and remapped. Watch the screen's
// origin and pulse `remapping` when it moves; the owning window folds that
// into its `visible` binding so the compositor re-places the surface at the
// monitor's new origin.
Item {
id: root
required property var window
readonly property var screen: window ? window.screen : null
// Fold into the window's binding: visible: <shown> && !guard.remapping
property bool remapping: false
visible: false
// A layout reshuffle can move the monitor more than once before it lands.
// Let the positions settle before the single remap pulse.
Timer {
id: settleTimer
interval: 200
onTriggered: root.remapping = true
}
// Hold the surface unmapped for a beat so the compositor processes the
// unmap before the remap instead of coalescing them into a no-op.
Timer {
interval: 50
running: root.remapping
onTriggered: root.remapping = false
}
Connections {
target: root.screen
function onXChanged() { settleTimer.restart() }
function onYChanged() { settleTimer.restart() }
}
}
@@ -0,0 +1,352 @@
import QtQuick
import QtQuick.Controls as QQC
import qs.compat.omarchy.Commons
// Searchable single-select dropdown. Same trigger shape as Dropdown, but
// the popup leads with an embedded TextField that filters the option
// list in real time. Use for pickers with enough options that scanning
// is friction.
//
// Filtering is case-insensitive substring against each option's label.
// Options can be string[] or [{ value, label, description? }] — the same
// shape Dropdown accepts. The filter clears whenever the popup closes.
//
// Keyboard: Tab to focus the trigger, Enter/Space opens (search focused
// immediately). Down arrow from the search jumps to the first match;
// Up from the first match returns to the search. Enter selects, Esc
// closes (and clears the filter).
Item {
id: root
property string label: ""
property string value: ""
property var options: []
property string placeholderText: "Search..."
property string emptyText: "No matches"
property string triggerLabel: ""
property color foreground: Color.popups.text
property color background: Color.popups.background
property color popupBorder: Color.popups.border
property color accent: Color.accent
readonly property var popupBorderSpec: Border.localOrSurfaceSpec("popups", "border", popupBorder, Color.popups.border, Style.normalBorderWidth)
property string fontFamily: Style.font.family
property int rowHeight: Style.spacing.controlHeight
property int popupRowHeight: Style.spacing.popupRowHeight
property int popupMinHeight: Style.spacing.searchablePopupMinHeight
property bool showLabel: true
// Panel-cursor flag. When true, the trigger renders the shared
// hover-cursor state. Active Qt focus defaults to the same visuals.
// Emits `hovered(bool)` on pointer enter/leave so the panel can keep
// its cursor state in sync with the mouse.
property bool hasCursor: false
// popupOpen + open()/close()/toggle() let a parent panel know when the
// dropdown owns keys (search field + result list are active) and
// suspend its own keyCatcher so typing into the filter doesn't drive
// the panel cursor.
readonly property bool popupOpen: popup.opened
function open() { popup.open() }
function close() { popup.close() }
function toggle() { popup.opened ? popup.close() : popup.open() }
signal changed(string value)
signal hovered(bool isHovered)
function optionValue(o) {
return (o && typeof o === "object") ? String(o.value) : String(o)
}
function optionLabel(o) {
return (o && typeof o === "object") ? String(o.label) : String(o)
}
function optionDescription(o) {
return (o && typeof o === "object" && o.description) ? String(o.description) : ""
}
function currentLabel() {
for (var i = 0; i < options.length; i++) {
if (optionValue(options[i]) === value) return optionLabel(options[i])
}
return value
}
property var filtered: options
function recomputeFiltered() {
var q = searchField.text.toLowerCase()
if (!q) { filtered = options; return }
var out = []
for (var i = 0; i < options.length; i++) {
var lbl = optionLabel(options[i]).toLowerCase()
var desc = optionDescription(options[i]).toLowerCase()
if (lbl.indexOf(q) !== -1 || desc.indexOf(q) !== -1) out.push(options[i])
}
filtered = out
}
onOptionsChanged: recomputeFiltered()
implicitWidth: Style.spacing.searchableDropdownWidth
implicitHeight: showLabel && label !== "" ? rowHeight + Style.spacing.huge : rowHeight
Column {
anchors.fill: parent
spacing: Style.spacing.labelGap
Text {
textFormat: Text.PlainText
visible: root.showLabel && root.label !== ""
text: root.label
color: Qt.darker(root.foreground, 1.4)
font.family: root.fontFamily
font.pixelSize: Style.font.caption
font.bold: true
}
BorderSurface {
id: trigger
width: parent.width
height: root.rowHeight
radius: Style.cornerRadius
readonly property bool _focused: trigger.activeFocus
readonly property bool _hot: triggerHover.hovered || root.hasCursor
readonly property var _borderSpec: Border.controlSpec(trigger._focused ? "focus" : (trigger._hot ? "hover-cursor" : "normal"), root.foreground, root.accent)
color: Style.controlFill(trigger._focused, trigger._hot, root.foreground, root.accent)
borderSpec: _borderSpec
activeFocusOnTab: true
HoverHandler {
id: triggerHover
onHoveredChanged: root.hovered(hovered)
}
Keys.onPressed: function(event) {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter
|| event.key === Qt.Key_Space || event.key === Qt.Key_Down) {
popup.opened ? popup.close() : popup.open()
event.accepted = true
} else if (event.key === Qt.Key_Escape && popup.opened) {
popup.close(); event.accepted = true
}
}
Text {
textFormat: Text.PlainText
anchors.left: parent.left
anchors.right: chevron.left
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: trigger.borderLeft + Style.spacing.controlPaddingX
anchors.rightMargin: trigger.borderRight + Style.spacing.md
text: root.currentLabel() || root.triggerLabel || root.placeholderText
color: (root.currentLabel() || root.triggerLabel) ? root.foreground : Qt.darker(root.foreground, 1.5)
font.family: root.fontFamily
font.pixelSize: Style.font.body
elide: Text.ElideRight
}
Text {
id: chevron
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: trigger.borderRight + Style.spacing.controlGap
text: "󰅀"
color: Qt.darker(root.foreground, 1.2)
font.family: root.fontFamily
font.pixelSize: Style.font.body
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
trigger.forceActiveFocus()
popup.opened ? popup.close() : popup.open()
}
}
QQC.Popup {
id: popup
x: 0
y: trigger.height + Style.spacing.xxs
width: trigger.width
implicitHeight: Math.max(root.popupMinHeight,
Math.min(resultList.contentHeight + Style.space(50),
root.popupRowHeight * 6 + 5 * Style.spacing.labelGap + Style.space(50)))
padding: Style.spacing.hairline
leftPadding: Border.left(root.popupBorderSpec) + Style.spacing.hairline
rightPadding: Border.right(root.popupBorderSpec) + Style.spacing.hairline
topPadding: Border.top(root.popupBorderSpec) + Style.spacing.hairline
bottomPadding: Border.bottom(root.popupBorderSpec) + Style.spacing.hairline
focus: true
background: BorderSurface {
color: root.background
borderSpec: root.popupBorderSpec
radius: Style.cornerRadius
}
onOpened: {
searchField.text = ""
root.recomputeFiltered()
Qt.callLater(function() { searchField.forceActiveFocus() })
}
onClosed: searchField.text = ""
contentItem: Column {
spacing: 0
Item {
id: searchHeader
width: parent.width
height: root.popupRowHeight + Style.spacing.controlPaddingX
TextField {
id: searchField
anchors.fill: parent
anchors.margins: Style.spacing.md
placeholderText: root.placeholderText
foreground: root.foreground
accent: root.accent
font.family: root.fontFamily
font.pixelSize: Style.font.body
onTextChanged: {
root.recomputeFiltered()
if (resultList.count > 0) resultList.currentIndex = 0
}
Keys.onPressed: function(event) {
if (event.key === Qt.Key_Escape) {
popup.close(); event.accepted = true
} else if (event.key === Qt.Key_Down) {
if (resultList.count > 0) {
resultList.currentIndex = 0
resultList.forceActiveFocus()
}
event.accepted = true
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
if (resultList.count > 0) {
resultList.currentIndex = 0
resultList.selectCurrent()
}
event.accepted = true
}
}
}
}
Rectangle {
width: parent.width
height: 1
color: Util.alpha(root.foreground, 0.10)
}
Item {
width: parent.width
height: popup.height - searchHeader.height - Style.spacing.xxs - 1
Text {
textFormat: Text.PlainText
anchors.centerIn: parent
visible: resultList.count === 0
text: root.emptyText
color: Qt.darker(root.foreground, 1.6)
font.family: root.fontFamily
font.pixelSize: Style.font.body
}
ListView {
id: resultList
anchors.fill: parent
spacing: Style.spacing.labelGap
clip: true
boundsBehavior: Flickable.StopAtBounds
model: root.filtered
currentIndex: -1
keyNavigationEnabled: false
function selectCurrent() {
if (currentIndex < 0 || currentIndex >= root.filtered.length) return
var v = root.optionValue(root.filtered[currentIndex])
root.value = v
root.changed(v)
popup.close()
}
Keys.priority: Keys.BeforeItem
Keys.onPressed: function(event) {
if (event.key === Qt.Key_Escape) {
popup.close(); event.accepted = true
} else if (event.key === Qt.Key_Down || event.text === "j") {
if (resultList.currentIndex >= resultList.count - 1) {
event.accepted = true; return
}
resultList.currentIndex = resultList.currentIndex + 1
event.accepted = true
} else if (event.key === Qt.Key_Up || event.text === "k") {
if (resultList.currentIndex <= 0) {
searchField.forceActiveFocus()
event.accepted = true; return
}
resultList.currentIndex = resultList.currentIndex - 1
event.accepted = true
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
resultList.selectCurrent(); event.accepted = true
}
}
delegate: Rectangle {
required property var modelData
required property int index
width: resultList.width
height: Math.max(root.popupRowHeight, rowContent.implicitHeight + Style.spacing.rowPaddingX)
color: index === resultList.currentIndex
? Style.hoverFillFor(root.foreground, root.accent)
: "transparent"
Column {
id: rowContent
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: Style.spacing.controlPaddingX
anchors.rightMargin: Style.spacing.controlPaddingX
spacing: Style.spacing.xxs
Text {
textFormat: Text.PlainText
text: root.optionLabel(modelData)
color: index === resultList.currentIndex ? Style.hoverStateColor(root.foreground, root.accent) : root.foreground
font.family: root.fontFamily
font.pixelSize: Style.font.body
elide: Text.ElideRight
width: parent.width
}
Text {
textFormat: Text.PlainText
visible: text !== ""
text: root.optionDescription(modelData)
color: Qt.darker(root.foreground, 1.5)
font.family: root.fontFamily
font.pixelSize: Style.font.caption
elide: Text.ElideRight
width: parent.width
}
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onPositionChanged: resultList.currentIndex = parent.index
onClicked: resultList.selectCurrent()
}
}
}
}
}
}
}
}
}
@@ -0,0 +1,411 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Shapes
import Quickshell
import Quickshell.Wayland
import qs.compat.omarchy.Commons
import qs.compat.omarchy.Ui
// Centered speed test overlay shared by the network and disk speed tests. No
// card: like the Tucson's floating cluster, the two dials sit directly on a
// darkened scrim -- open 270° arcs, faint tick rings, hubless gradient
// needles, and a digital readout in the middle. Esc, the scrim, or the corner
// dismiss close it; the needles sweep to full scale and back on open, then
// track the live readings. Callers name the dials, the unit, and the scale.
PanelWindow {
id: root
required property string fontFamily
required property bool running
required property string leftLabel
required property string rightLabel
property string unit: "Mbps"
property string title: ""
property string layerNamespace: "omarchy-speed-test"
property string runAgainTooltip: "Measure again"
property real leftValue: 0
property real rightValue: 0
property bool leftLive: false
property bool rightLive: false
property string error: ""
property bool open: false
// Full-scale latch points for the dials, smallest first. The first stop is
// the base scale a fresh run starts from.
property var scaleStops: [100, 250, 500, 1000, 2500, 5000, 10000]
property real fullScale: scaleStops[0]
signal closeRequested()
signal runAgainRequested()
readonly property bool failed: error !== ""
function resetScale() {
fullScale = scaleStops[0]
}
function expandScale(value) {
// Either reading ranges the entire cluster upward. Keeping this latch on
// the overlay ensures both dials always describe the same scale.
for (var i = 0; i < scaleStops.length; i++) {
if (value <= scaleStops[i] * 0.92) {
if (scaleStops[i] > fullScale) fullScale = scaleStops[i]
return
}
}
fullScale = scaleStops[scaleStops.length - 1]
}
onRunningChanged: if (running) resetScale()
onScaleStopsChanged: resetScale()
onLeftValueChanged: expandScale(leftValue)
onRightValueChanged: expandScale(rightValue)
Behavior on fullScale {
NumberAnimation { duration: Style.duration(400); easing.type: Easing.OutCubic }
}
// The scrim below is a fixed near-black regardless of theme, so text and
// ticks on it need a fixed light palette, not the themed bar.foreground.
readonly property color onScrim: "white"
readonly property color onScrimDim: Qt.rgba(1, 1, 1, 0.55)
readonly property color onScrimUrgent: "#ff6b6b"
visible: open
// The window is instantiated hidden, so re-acquire focus after mapping and
// fire the ignition sweep once the surface is actually on screen.
onOpenChanged: {
if (open) Qt.callLater(function() {
if (!root.open) return
keyCatcher.forceActiveFocus()
leftDial.ignite()
rightDial.ignite()
})
}
anchors { top: true; bottom: true; left: true; right: true }
color: "transparent"
exclusionMode: ExclusionMode.Ignore
WlrLayershell.namespace: root.layerNamespace
WlrLayershell.layer: WlrLayer.Overlay
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
// Deep scrim: with no card behind them, the floating dials need the
// backdrop to carry the contrast on any wallpaper, like the near-black
// panel behind a real cluster.
Rectangle {
anchors.fill: parent
color: Qt.rgba(0, 0, 0, 0.78)
MouseArea {
anchors.fill: parent
onClicked: root.closeRequested()
}
}
Item {
id: keyCatcher
anchors.fill: parent
focus: true
Keys.onEscapePressed: root.closeRequested()
Keys.onReturnPressed: if (!root.running) root.runAgainRequested()
Keys.onEnterPressed: if (!root.running) root.runAgainRequested()
Item {
id: cluster
anchors.centerIn: parent
width: content.implicitWidth
height: content.implicitHeight
// Narrow or heavily scaled outputs: shrink the whole cluster rather
// than clipping it at the screen edge.
scale: Math.min(1,
(keyCatcher.width - Style.space(32)) / Math.max(1, width),
(keyCatcher.height - Style.space(32)) / Math.max(1, height))
// Swallow clicks so only the scrim outside the cluster dismisses.
MouseArea { anchors.fill: parent; onClicked: {} }
ColumnLayout {
id: content
anchors.fill: parent
spacing: Style.space(16)
Text {
textFormat: Text.PlainText
visible: root.title !== ""
text: root.title.toUpperCase()
color: root.onScrimDim
font.family: root.fontFamily
font.pixelSize: Style.font.caption
font.bold: true
font.letterSpacing: 2
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
}
Row {
spacing: Style.space(48)
Layout.alignment: Qt.AlignHCenter
SpeedDial {
id: leftDial
label: root.leftLabel
value: root.leftValue
live: root.leftLive
}
SpeedDial {
id: rightDial
label: root.rightLabel
value: root.rightValue
live: root.rightLive
}
}
// Centered on the dial pair. Fades rather than unmounts while a run
// is in flight, so the cluster never shifts.
Button {
text: "Run Again"
tooltipText: root.runAgainTooltip
bordered: true
enabled: !root.running
opacity: root.running ? 0 : 1
foreground: root.onScrim
fontFamily: root.fontFamily
fontSize: Style.font.bodySmall
horizontalPadding: Style.space(14)
verticalPadding: Style.space(4)
Layout.alignment: Qt.AlignHCenter
onClicked: root.runAgainRequested()
Behavior on opacity {
NumberAnimation { duration: Style.duration(240); easing.type: Easing.OutCubic }
}
}
Text {
textFormat: Text.PlainText
visible: root.failed
text: root.error
color: root.onScrimUrgent
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
wrapMode: Text.Wrap
Layout.fillWidth: true
Layout.maximumWidth: Style.space(440)
horizontalAlignment: Text.AlignHCenter
}
}
}
}
// One floating cluster dial: an open 270° scale with the gap at the
// bottom, a faint tick ring, a glowing accent value arc, a hubless needle
// that fades toward the pivot, and a digital readout in the middle. All
// writes to the needle funnel through `shown` so the ignition sweep and
// live readings share one animation.
component SpeedDial: Item {
id: dial
required property string label
required property real value
required property bool live
readonly property real diameter: Style.space(210)
// 0° = 3 o'clock, increasing clockwise (PathAngleArc's convention).
readonly property real dialStart: 135
readonly property real dialSweep: 270
readonly property int tickCount: 46
readonly property real arcWidth: Style.space(4)
readonly property real arcRadius: diameter / 2 - arcWidth
readonly property color trackColor: Qt.rgba(1, 1, 1, 0.14)
readonly property color minorTickColor: Qt.rgba(1, 1, 1, 0.12)
readonly property color majorTickColor: Qt.rgba(1, 1, 1, 0.3)
// The dial that isn't measuring yet sits dimmed until it gets a figure.
readonly property bool engaged: live || value > 0
property real shown: 0
// The digital readout stays on the real figure while the ignition sweep
// drives the needle -- a cluster sweeps its gauges, not its numerals.
readonly property real reading: ignition.running ? value : shown
readonly property real fullScale: root.fullScale
readonly property real fraction: fullScale > 0 ? Math.max(0, Math.min(1, shown / fullScale)) : 0
readonly property bool arcVisible: fraction > 0.004
width: diameter
height: diameter
opacity: engaged ? 1 : 0.5
Behavior on opacity {
NumberAnimation { duration: Style.duration(240); easing.type: Easing.OutCubic }
}
// Live readings land once a second; glide between them rather than snap.
Behavior on shown {
enabled: !ignition.running
NumberAnimation { duration: Style.duration(600); easing.type: Easing.OutCubic }
}
onValueChanged: {
if (!ignition.running) shown = value
}
function ignite() {
ignition.restart()
}
// Car-cluster power-on: needle sweeps to full scale and falls back before
// the live figures take over.
SequentialAnimation {
id: ignition
NumberAnimation { target: dial; property: "shown"; to: dial.fullScale; duration: Style.duration(550); easing.type: Easing.InOutCubic }
NumberAnimation { target: dial; property: "shown"; to: 0; duration: Style.duration(650); easing.type: Easing.OutCubic }
onFinished: dial.shown = dial.value
}
Shape {
anchors.fill: parent
preferredRendererType: Shape.CurveRenderer
// Track: the full scale, always visible, dim.
ShapePath {
strokeWidth: dial.arcWidth
strokeColor: dial.trackColor
fillColor: "transparent"
capStyle: ShapePath.RoundCap
PathAngleArc {
centerX: dial.width / 2
centerY: dial.height / 2
radiusX: dial.arcRadius
radiusY: dial.arcRadius
startAngle: dial.dialStart
sweepAngle: dial.dialSweep
}
}
// Soft under-glow beneath the value arc, standing in for the backlit
// ring of a real cluster. Both arcs go transparent at rest, or their
// round caps would leave a stray dot at the foot of the scale.
ShapePath {
strokeWidth: dial.arcWidth * 3
strokeColor: dial.arcVisible ? Qt.rgba(Color.accent.r, Color.accent.g, Color.accent.b, 0.18) : "transparent"
fillColor: "transparent"
capStyle: ShapePath.RoundCap
PathAngleArc {
centerX: dial.width / 2
centerY: dial.height / 2
radiusX: dial.arcRadius
radiusY: dial.arcRadius
startAngle: dial.dialStart
sweepAngle: dial.dialSweep * dial.fraction
}
}
// Value: fills behind the needle.
ShapePath {
strokeWidth: dial.arcWidth
strokeColor: dial.arcVisible ? Color.accent : "transparent"
fillColor: "transparent"
capStyle: ShapePath.RoundCap
PathAngleArc {
centerX: dial.width / 2
centerY: dial.height / 2
radiusX: dial.arcRadius
radiusY: dial.arcRadius
startAngle: dial.dialStart
sweepAngle: dial.dialSweep * dial.fraction
}
}
}
// Faint tick ring just inside the arc; every fifth tick is a major.
Repeater {
model: dial.tickCount
Item {
required property int index
readonly property bool major: index % 5 === 0
anchors.fill: parent
rotation: dial.dialStart + (index / (dial.tickCount - 1)) * dial.dialSweep - 270
Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
y: dial.arcWidth * 2 + (parent.major ? 0 : Style.space(2))
width: parent.major ? Math.max(2, Style.space(2)) : 1
height: parent.major ? Style.space(10) : Style.space(6)
radius: width / 2
color: parent.major ? dial.majorTickColor : dial.minorTickColor
}
}
}
// Hubless needle: a slender sliver that fades out toward the pivot, so
// it reads as floating like the rest of the cluster.
Item {
anchors.fill: parent
rotation: dial.dialStart + dial.fraction * dial.dialSweep - 270
Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
y: dial.arcWidth * 2 + Style.space(10)
width: Math.max(2, Style.space(3))
height: dial.diameter * 0.32
radius: width / 2
gradient: Gradient {
GradientStop { position: 0.0; color: Color.accent }
GradientStop { position: 0.55; color: Color.accent }
GradientStop { position: 1.0; color: "transparent" }
}
}
}
Column {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.verticalCenter
anchors.topMargin: Style.space(14)
spacing: 0
Text {
textFormat: Text.PlainText
anchors.horizontalCenter: parent.horizontalCenter
// Both branches go through the locale: a reading is a measurement, so
// its separators follow the system's number conventions rather than the
// interface language. toFixed would have hardcoded a dot below 10 while
// everything above it was already grouped for the locale.
text: dial.reading < 10
? dial.reading.toLocaleString(Qt.locale(), 'f', 1)
: Math.round(dial.reading).toLocaleString(Qt.locale(), 'f', 0)
color: root.onScrim
font.family: root.fontFamily
font.pixelSize: Style.font.display
font.bold: true
}
Text {
textFormat: Text.PlainText
anchors.horizontalCenter: parent.horizontalCenter
text: root.unit
color: root.onScrimDim
font.family: root.fontFamily
font.pixelSize: Style.font.caption
}
}
// The 90° gap at the bottom of the scale is where a cluster prints its
// unit; here it names the direction.
Text {
textFormat: Text.PlainText
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
text: dial.label
color: root.onScrimDim
font.family: root.fontFamily
font.pixelSize: Style.font.caption
font.bold: true
font.letterSpacing: 1.5
}
}
}
@@ -0,0 +1,56 @@
import QtQuick
import QtQuick.Controls
import qs.compat.omarchy.Commons
// Single-line text input with the kit's focus + selection styling. Inherits
// from Qt Quick Controls TextField so the underlying type's API (text,
// placeholderText, accepted, editingFinished, validator, ...) is available
// to callers without re-exposing each property.
//
// Defaults bind to qs.Commons.Color so a caller with no theme overrides
// just works; foreground / accent / selectionTint can be overridden per
// instance. activeFocus and mouse hover / panel cursor use the same
// hover-cursor defaults, so text inputs match Button, Toggle, and Dropdown.
//
// Sizing is driven by font.pixelSize + verticalPadding. The default 30px
// implicitHeight fits dialog forms; inline callers (wifi's row-embedded
// passphrase prompt) drop verticalPadding to match a 22-26px row.
TextField {
id: root
property color foreground: Color.foreground
property color accent: Color.accent
property color selectionTint: Style.selectionFillFor(foreground, accent)
property bool password: false
property real horizontalPadding: Style.spacing.controlPaddingX
property real verticalPadding: Style.spacing.inputPaddingY
// Panel-cursor flag. When true (and the field isn't already focused),
// the background paints the shared hover/cursor state.
// For mouse-enter/leave the consumer reads QQC TextField's inherited
// `hovered` property (via onHoveredChanged) — we don't add a sibling
// signal because the inherited property would shadow it.
property bool hasCursor: false
readonly property bool _focused: activeFocus
readonly property bool _hot: hovered || hasCursor
readonly property var _borderSpec: Border.controlSpec(_focused ? "focus" : (_hot ? "hover-cursor" : "normal"), root.foreground, root.accent)
echoMode: password ? TextInput.Password : TextInput.Normal
font.family: Style.font.family
font.pixelSize: Style.font.body
color: foreground
selectionColor: selectionTint
selectedTextColor: foreground
placeholderTextColor: Qt.darker(foreground, 1.6)
leftPadding: horizontalPadding + Border.left(_borderSpec)
rightPadding: horizontalPadding + Border.right(_borderSpec)
topPadding: verticalPadding + Border.top(_borderSpec)
bottomPadding: verticalPadding + Border.bottom(_borderSpec)
background: BorderSurface {
color: Style.controlFill(root._focused, root._hot, root.foreground, root.accent)
borderSpec: root._borderSpec
radius: Style.cornerRadius
}
}
+116
View File
@@ -0,0 +1,116 @@
import QtQuick
import qs.compat.omarchy.Commons
// Labeled toggle row: title + optional description on the left, a
// `ToggleSwitch` on the right. Clicking anywhere on the row emits `clicked()`;
// consumers flip `checked` in response (the component is stateless about the
// actual value so it composes cleanly with model-driven UI).
//
// Cursor and focus styling match the rest of the kit: hasCursor / mouse
// hover and activeFocus share the hover-cursor defaults.
//
// `rounded` is forwarded to the switch, which auto-detects from
// Style.cornerRadius: pill shape when Hyprland corners are rounded, square on
// sharp. Callers can override per-instance.
BorderSurface {
id: root
property string label: ""
property string description: ""
property bool checked: false
// Panel-cursor flag. Same role as Button.hasCursor:
// panels with their own keyboard cursor bind this to drive the highlight
// separately from activeFocus. Visuals use the same hover-cursor tokens.
property bool hasCursor: false
// Switch shape follows the theme by default: pill on round, square on sharp.
// Override per-instance if a caller wants the opposite.
property bool rounded: Style.cornerRadius > 0
property color foreground: Color.foreground
property color accent: Color.accent
property string fontFamily: Style.font.family
property real titleSize: Style.font.subtitle
property real descriptionSize: Style.font.caption
signal clicked()
signal hovered(bool isHovered)
activeFocusOnTab: true
Keys.onReturnPressed: root.clicked()
Keys.onEnterPressed: root.clicked()
Keys.onSpacePressed: root.clicked()
implicitHeight: Math.max(54, content.implicitHeight + Style.spacing.huge)
implicitWidth: Style.space(240)
radius: Style.cornerRadius
readonly property bool _hot: hasCursor || mouse.containsMouse
readonly property var _borderSpec: Border.controlSpec(activeFocus ? "focus" : (_hot ? "hover-cursor" : "normal"), foreground, accent)
color: Style.controlFill(activeFocus, _hot, foreground, accent)
borderSpec: _borderSpec
Behavior on color { ColorAnimation { duration: Style.duration(100) } }
Row {
id: content
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: root.borderLeft + Style.spacing.rowPaddingX
anchors.rightMargin: root.borderRight + Style.spacing.rowPaddingX
spacing: Style.spacing.rowPaddingX
Column {
width: parent.width - track.width - parent.spacing
spacing: Style.spacing.xs
anchors.verticalCenter: parent.verticalCenter
Text {
textFormat: Text.PlainText
text: root.label
color: root.foreground
font.family: root.fontFamily
font.pixelSize: root.titleSize
font.bold: true
elide: Text.ElideRight
width: parent.width
}
Text {
textFormat: Text.PlainText
visible: root.description !== ""
text: root.description
color: Qt.darker(root.foreground, 1.5)
font.family: root.fontFamily
font.pixelSize: root.descriptionSize
wrapMode: Text.WordWrap
width: parent.width
}
}
// The row owns the click, so the switch is presentation only here.
ToggleSwitch {
id: track
checked: root.checked
rounded: root.rounded
foreground: root.foreground
accent: root.accent
interactive: false
anchors.verticalCenter: parent.verticalCenter
}
}
MouseArea {
id: mouse
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: root.clicked()
}
HoverHandler {
onHoveredChanged: root.hovered(hovered)
}
}
@@ -0,0 +1,110 @@
import QtQuick
import qs.compat.omarchy.Commons
import "../../../theme" as G
// Bare on/off switch: a track with a sliding knob and no label. This is the
// switch `Toggle` parks at the end of its labeled row, factored out so panel
// headers and other compact controls render the identical thing.
//
// The caller owns the value: bind `checked` to real state and flip it in
// response to `toggled()`. Services that already track a desired state
// optimistically (see the Tailscale service's `_desired`) get an instant knob
// throw for free, because `checked` is already the optimistic value.
//
// `busy` marks an operation in flight and swallows further clicks, but leaves
// hover, cursor, and tooltips alone so the control does not flicker every time
// a background refresh runs.
//
// The cursor is a ring drawn outside the track rather than a state on the
// track itself: themes give normal chrome a stronger border than hover-cursor
// (0.4 vs 0.25 by default), which is right for controls that are borderless at
// rest but would make a bordered track go *fainter* under the cursor. On the
// panel background the ring reads immediately. `cursorRing` follows
// `interactive` — a switch whose surrounding row owns the click owns the
// cursor too.
//
// `rounded` auto-detects from Style.cornerRadius so the switch follows the
// theme: pill shape when Hyprland corners are rounded, square on sharp.
Item {
id: root
property bool checked: false
property bool busy: false
// Off when the surrounding row owns the click, as in `Toggle`.
property bool interactive: true
// Panel-cursor flag. Same role as Button.hasCursor: panels with their own
// keyboard cursor bind this to drive the highlight separately from hover.
property bool hasCursor: false
property bool cursorRing: interactive
property int cursorPad: Style.space(6)
property bool rounded: Style.cornerRadius > 0
property color foreground: Color.foreground
property color accent: Color.accent
signal toggled()
signal hovered(bool isHovered)
readonly property alias containsMouse: mouse.containsMouse
readonly property bool hot: hasCursor || mouse.containsMouse
// `trackHeight` is settable so a compact placement — a switch riding a panel
// section header, say — can ask for a genuinely smaller control instead of
// scaling a big one down, which lands the track and knob on fractional pixels
// and blurs their edges. The derived sizes only carry floors low enough to
// stay out of an override's way; at the default track height each one is
// already above its floor, so nothing about the normal switch changes.
property int trackHeight: Math.max(22, Math.round(Style.spacing.controlHeight * 0.55))
property int trackWidth: Math.round(trackHeight * 1.9)
property int knobSize: Math.max(6, Math.round(trackHeight * 0.72))
property int knobInset: Math.max(1, Math.round((trackHeight - knobSize) / 2))
readonly property int _pad: cursorRing ? cursorPad : 0
implicitWidth: trackWidth + _pad * 2
implicitHeight: trackHeight + _pad * 2
BorderSurface {
anchors.fill: parent
visible: root.cursorRing && root.hot
color: "transparent"
radius: Style.cornerRadius
borderSpec: Border.controlSpec("hover-cursor", root.foreground, root.accent)
}
BorderSurface {
id: track
width: root.trackWidth
height: root.trackHeight
anchors.centerIn: parent
// glassMxrph switch: solid accent when on, tinted glass when off.
radius: height / 2
color: root.checked ? G.Theme.accent : G.Theme.surfaceVariant
borderSpec: root.checked ? Border.none() : Border.controlSpec("normal", root.foreground, root.accent)
Behavior on color { ColorAnimation { duration: Style.duration(120) } }
Rectangle {
width: root.knobSize
height: root.knobSize
radius: height / 2
x: root.checked ? track.width - width - root.knobInset : root.knobInset
anchors.verticalCenter: parent.verticalCenter
color: root.checked ? G.Theme.accentText : G.Theme.text
Behavior on x { NumberAnimation { duration: Style.duration(120); easing.type: Easing.OutCubic } }
Behavior on color { ColorAnimation { duration: Style.duration(120) } }
}
}
MouseArea {
id: mouse
anchors.fill: parent
enabled: root.interactive
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onContainsMouseChanged: root.hovered(containsMouse)
onClicked: if (!root.busy) root.toggled()
}
}
@@ -0,0 +1,143 @@
import QtQuick
import qs.compat.omarchy.Commons
import "../../../theme" as G
Item {
id: root
property var bar: null
property string text: ""
property string fontFamily: bar ? bar.fontFamily : Style.font.family
property real fontSize: Style.font.body
property color foreground: bar ? bar.barForeground : Color.foreground
property color activeColor: bar ? bar.urgent : Color.urgent
property bool active: false
property real horizontalMargin: 8.5
property real verticalPadding: 6
property real fixedWidth: -1
property real fixedHeight: -1
property real textRotation: 0
property bool keepSpace: false
property bool dimmed: false
property bool concealed: false
property bool interactive: true
property bool pressable: true
property bool useActiveColor: true
property bool maintainIndicatorReveal: false
property bool labelVisible: true
// Off for icon-font labels, whose figure metrics say nothing about the glyph.
property bool centerFigures: true
property bool hasVisualContent: text !== ""
property var revealHost: bar
property string tooltipText: ""
property var registeredBar: null
signal pressed(int button)
signal wheelMoved(int delta)
function triggerPress(button) {
if (root.bar) root.bar.hideTooltip(root)
root.pressed(button)
}
function hideOwnTooltip() {
if (root.bar) root.bar.hideTooltip(root)
}
function syncClickRegistration() {
if (registeredBar && registeredBar.unregisterClickTarget) registeredBar.unregisterClickTarget(root)
registeredBar = root.bar
if (registeredBar && registeredBar.registerClickTarget) registeredBar.registerClickTarget(root)
}
onBarChanged: syncClickRegistration()
onVisibleChanged: if (!visible) hideOwnTooltip()
onInteractiveChanged: if (!interactive) hideOwnTooltip()
onConcealedChanged: if (concealed) hideOwnTooltip()
Component.onCompleted: syncClickRegistration()
Component.onDestruction: if (registeredBar && registeredBar.unregisterClickTarget) registeredBar.unregisterClickTarget(root)
readonly property bool vertical: bar ? bar.vertical : false
readonly property int barSize: bar ? bar.barSize : Style.bar.sizeHorizontal
readonly property real scaledHorizontalMargin: Style.spaceReal(horizontalMargin)
readonly property real scaledVerticalPadding: Style.spaceReal(verticalPadding)
readonly property bool tooltipHovered: visible && interactive && !concealed && mouseArea.containsMouse
// Width of the painted label, for bar chrome that wants to line up with the
// text rather than with the slot it sits in. Zero on icon-only buttons.
readonly property real labelWidth: label.visible ? label.implicitWidth : 0
visible: hasVisualContent || keepSpace
opacity: !hasVisualContent || concealed ? 0 : (dimmed ? 0.45 : 1)
implicitWidth: fixedWidth > 0 ? fixedWidth : (vertical ? barSize : Math.max(12, label.implicitWidth + scaledHorizontalMargin * 2))
implicitHeight: fixedHeight > 0 ? fixedHeight : (vertical ? Math.max(12, label.implicitHeight + scaledVerticalPadding * 2) : barSize)
Behavior on opacity {
NumberAnimation { duration: Style.duration(140); easing.type: Easing.OutCubic }
}
// glassMxrph: the same rounded hover highlight as the tray and window pills.
Rectangle {
anchors.fill: parent
anchors.margins: 2
radius: height / 2
visible: root.interactive && root.pressable
color: mouseArea.pressed ? Qt.alpha(G.Theme.text, 0.16) : mouseArea.containsMouse ? G.Theme.hover : "transparent"
Behavior on color {
ColorAnimation { duration: Style.duration(G.Theme.duration) }
}
}
Text {
id: label
textFormat: Text.PlainText
visible: root.labelVisible
anchors.centerIn: parent
// Centering the line box puts the figures above the bar's middle, since
// the box keeps room for descenders. Center the figure height instead, so
// labels line up with the icons beside them.
anchors.verticalCenterOffset: !root.centerFigures || root.vertical || root.text.indexOf("\n") !== -1
? 0
: (labelMetrics.descent - labelMetrics.ascent + labelMetrics.tightBoundingRect("0").height) / 2
text: root.text
color: root.active && root.useActiveColor ? root.activeColor : root.foreground
font.family: root.fontFamily
font.pixelSize: root.fontSize
rotation: root.textRotation
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
Behavior on color {
enabled: !root.bar || root.bar.foregroundAnimationEnabled
ColorAnimation { duration: Style.duration(160) }
}
}
FontMetrics {
id: labelMetrics
font: label.font
}
MouseArea {
id: mouseArea
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
enabled: root.interactive
hoverEnabled: true
cursorShape: root.pressable ? Qt.PointingHandCursor : Qt.ArrowCursor
onEntered: {
if (root.bar) {
root.bar.showTooltip(root, root.tooltipText)
}
if (root.maintainIndicatorReveal && root.revealHost && root.revealHost.setIndicatorItemHovered)
root.revealHost.setIndicatorItemHovered(true)
}
onExited: {
if (root.bar) {
root.bar.hideTooltip(root)
}
if (root.maintainIndicatorReveal && root.revealHost && root.revealHost.setIndicatorItemHovered)
root.revealHost.setIndicatorItemHovered(false)
}
onClicked: function(mouse) { if (root.pressable) root.triggerPress(mouse.button) }
onWheel: function(wheel) { root.wheelMoved(wheel.angleDelta.y) }
}
}
+36
View File
@@ -0,0 +1,36 @@
BarIndicator 1.0 BarIndicator.qml
BarIconButton 1.0 BarIconButton.qml
BarWidget 1.0 BarWidget.qml
BackgroundMedia 1.0 BackgroundMedia.qml
BorderOverlay 1.0 BorderOverlay.qml
BorderSurface 1.0 BorderSurface.qml
Button 1.0 Button.qml
ButtonGroup 1.0 ButtonGroup.qml
ConfirmDialog 1.0 ConfirmDialog.qml
CursorSurface 1.0 CursorSurface.qml
Dropdown 1.0 Dropdown.qml
KeyboardPanel 1.0 KeyboardPanel.qml
MultiSelect 1.0 MultiSelect.qml
NumberField 1.0 NumberField.qml
OpticalGlyph 1.0 OpticalGlyph.qml
OverlayWindow 1.0 OverlayWindow.qml
Panel 1.0 Panel.qml
PanelActionButton 1.0 PanelActionButton.qml
PanelController 1.0 PanelController.qml
PanelKeyCatcher 1.0 PanelKeyCatcher.qml
PanelHero 1.0 PanelHero.qml
PanelSectionHeader 1.0 PanelSectionHeader.qml
PanelSeparator 1.0 PanelSeparator.qml
PanelSlider 1.0 PanelSlider.qml
PanelToolTip 1.0 PanelToolTip.qml
PluginBarApi 1.0 PluginBarApi.qml
PointerMoveGate 1.0 PointerMoveGate.qml
ScreenMoveRemap 1.0 ScreenMoveRemap.qml
PopupCard 1.0 PopupCard.qml
SearchableDropdown 1.0 SearchableDropdown.qml
SpeedTestOverlay 1.0 SpeedTestOverlay.qml
TextField 1.0 TextField.qml
Toggle 1.0 Toggle.qml
ToggleSwitch 1.0 ToggleSwitch.qml
WidgetButton 1.0 WidgetButton.qml
GlassPopupBase 1.0 GlassPopupBase.qml
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# omarchy:summary=Returns a list of all the available power profiles on the system.
# omarchy:args=[--active-state]
if [[ ${1:-} != "" && ${1:-} != "--active-state" ]]; then
echo "Usage: omarchy-powerprofiles-list [--active-state]" >&2
exit 1
fi
powerprofilesctl list 2>/dev/null |
awk -v with_state="${1:+1}" '/^\s*[* ]\s*[a-zA-Z0-9-]+:$/ {
active = ($1 == "*") ? 1 : 0
gsub(/^[*[:space:]]+|:$/, "")
print $0 (with_state ? "\t" active : "")
}' |
tac