mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Merge branch 'main' of https://github.com/noctalia-dev/noctalia-shell
This commit is contained in:
+18
-7
@@ -129,18 +129,29 @@ Item {
|
||||
target: BarService
|
||||
function onWidgetsRevisionChanged() {
|
||||
Logger.d("Bar", "onWidgetsRevisionChanged, revision:", BarService.widgetsRevision, "screen:", root.screen?.name);
|
||||
var widgets = Settings.getBarWidgetsForScreen(root.screen?.name);
|
||||
if (widgets) {
|
||||
root.syncWidgetModel(root.leftWidgetsModel, widgets.left);
|
||||
root.syncWidgetModel(root.centerWidgetsModel, widgets.center);
|
||||
root.syncWidgetModel(root.rightWidgetsModel, widgets.right);
|
||||
}
|
||||
Qt.callLater(root._syncFromRevision);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize models
|
||||
function _syncFromRevision() {
|
||||
var widgets = Settings.getBarWidgetsForScreen(screen?.name);
|
||||
if (widgets) {
|
||||
syncWidgetModel(leftWidgetsModel, widgets.left);
|
||||
syncWidgetModel(centerWidgetsModel, widgets.center);
|
||||
syncWidgetModel(rightWidgetsModel, widgets.right);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize models — deferred to next event-loop tick via Qt.callLater to avoid
|
||||
// re-entrant incubation: Component.onCompleted fires during QQmlObjectCreator::finalize,
|
||||
// and ListModel.append synchronously creates Repeater delegates whose own finalization
|
||||
// can corrupt the V4 heap (SIGSEGV in QV4::Object::insertMember).
|
||||
Component.onCompleted: {
|
||||
Logger.d("Bar", "Bar Component.onCompleted for screen:", screen?.name);
|
||||
Qt.callLater(root._initModels);
|
||||
}
|
||||
|
||||
function _initModels() {
|
||||
var widgets = Settings.getBarWidgetsForScreen(screen?.name);
|
||||
if (widgets) {
|
||||
syncWidgetModel(leftWidgetsModel, widgets.left);
|
||||
|
||||
@@ -22,8 +22,9 @@ Item {
|
||||
readonly property bool isScaling: internal.isScaling
|
||||
|
||||
// All Desktop widgets have these settings, but fallback just in case
|
||||
property bool showBackground: widgetData.showBackground !== undefined ? widgetData.showBackground : (widgetMetadata?.showBackground ?? true)
|
||||
property bool roundedCorners: widgetData.roundedCorners !== undefined ? widgetData.roundedCorners : (widgetMetadata?.roundedCorners ?? true)
|
||||
readonly property var _metadata: widgetData?.id ? DesktopWidgetRegistry.widgetMetadata[widgetData.id] : null
|
||||
property bool showBackground: widgetData.showBackground !== undefined ? widgetData.showBackground : (_metadata?.showBackground ?? true)
|
||||
property bool roundedCorners: widgetData.roundedCorners !== undefined ? widgetData.roundedCorners : (_metadata?.roundedCorners ?? true)
|
||||
|
||||
property real widgetScale: 1.0
|
||||
property real minScale: 0.5
|
||||
|
||||
@@ -131,18 +131,19 @@ ShapePath {
|
||||
fillColor: isRenderable ? Qt.rgba(backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a * opacityFactor) : "transparent"
|
||||
fillRule: isFramed ? ShapePath.OddEvenFill : ShapePath.WindingFill
|
||||
|
||||
// Starting position — falls back to off-screen (-1,-1) when not renderable so that
|
||||
// all subsequent path elements form a valid non-degenerate 1×1 off-screen square,
|
||||
// preventing CurveRenderer triangulation crashes on zero-area or bare-moveto paths.
|
||||
startX: isRenderable ? (isFramed ? 0 : (barMappedPos.x + leftEdgeOvs + tlRadius * tlMultX)) : -1
|
||||
// Starting position — falls back to off-screen when not renderable so that
|
||||
// all subsequent path elements form a valid non-degenerate off-screen square.
|
||||
// Each edge is split between PathLine and PathArc so no arc has zero displacement,
|
||||
// preventing CurveRenderer triangulation crashes on degenerate arcs.
|
||||
startX: isRenderable ? (isFramed ? 0 : (barMappedPos.x + leftEdgeOvs + tlRadius * tlMultX)) : -0.75
|
||||
startY: isRenderable ? (isFramed ? 0 : (barMappedPos.y + topEdgeOvs)) : -1
|
||||
|
||||
// ========== PATH DEFINITION ==========
|
||||
|
||||
// 1. Main Bar / Outer Screen Rectangle
|
||||
// When !isRenderable all elements use fallback coordinates forming a valid 1×1
|
||||
// off-screen square ((-1,-1)→(0,-1)→(0,0)→(-1,0)→(-1,-1)) so CurveRenderer
|
||||
// never receives a zero-area or bare-moveto path.
|
||||
// off-screen square with non-degenerate arcs so CurveRenderer never receives
|
||||
// a zero-area, bare-moveto, or zero-displacement arc path.
|
||||
PathLine {
|
||||
x: root.isRenderable ? (root.isFramed ? root.screenWidth : (root.barMappedPos.x + root.barWidth + root.rightEdgeOvs - root.trRadius * root.trMultX)) : 0
|
||||
y: root.isRenderable ? (root.isFramed ? 0 : (root.barMappedPos.y + root.topEdgeOvs)) : -1
|
||||
@@ -151,7 +152,7 @@ ShapePath {
|
||||
// Bar top-right corner (only if not framed)
|
||||
PathArc {
|
||||
x: root.isRenderable ? (root.isFramed ? root.screenWidth : (root.barMappedPos.x + root.barWidth + root.rightEdgeOvs)) : 0
|
||||
y: root.isRenderable ? (root.isFramed ? 0 : (root.barMappedPos.y + root.topEdgeOvs + root.trRadius * root.trMultY)) : -1
|
||||
y: root.isRenderable ? (root.isFramed ? 0 : (root.barMappedPos.y + root.topEdgeOvs + root.trRadius * root.trMultY)) : -0.75
|
||||
radiusX: root.isRenderable ? (root.isFramed ? 0 : root.trRadius) : 0
|
||||
radiusY: root.isRenderable ? (root.isFramed ? 0 : root.trRadius) : 0
|
||||
direction: ShapeCornerHelper.getArcDirection(root.trMultX, root.trMultY)
|
||||
@@ -164,7 +165,7 @@ ShapePath {
|
||||
|
||||
// Bar bottom-right corner (only if not framed)
|
||||
PathArc {
|
||||
x: root.isRenderable ? (root.isFramed ? root.screenWidth : (root.barMappedPos.x + root.barWidth + root.rightEdgeOvs - root.brRadius * root.brMultX)) : 0
|
||||
x: root.isRenderable ? (root.isFramed ? root.screenWidth : (root.barMappedPos.x + root.barWidth + root.rightEdgeOvs - root.brRadius * root.brMultX)) : -0.25
|
||||
y: root.isRenderable ? (root.isFramed ? root.screenHeight : (root.barMappedPos.y + root.barHeight + root.bottomEdgeOvs)) : 0
|
||||
radiusX: root.isRenderable ? (root.isFramed ? 0 : root.brRadius) : 0
|
||||
radiusY: root.isRenderable ? (root.isFramed ? 0 : root.brRadius) : 0
|
||||
@@ -179,7 +180,7 @@ ShapePath {
|
||||
// Bar bottom-left corner (only if not framed)
|
||||
PathArc {
|
||||
x: root.isRenderable ? (root.isFramed ? 0 : (root.barMappedPos.x + root.leftEdgeOvs)) : -1
|
||||
y: root.isRenderable ? (root.isFramed ? root.screenHeight : (root.barMappedPos.y + root.barHeight + root.bottomEdgeOvs - root.blRadius * root.blMultY)) : 0
|
||||
y: root.isRenderable ? (root.isFramed ? root.screenHeight : (root.barMappedPos.y + root.barHeight + root.bottomEdgeOvs - root.blRadius * root.blMultY)) : -0.25
|
||||
radiusX: root.isRenderable ? (root.isFramed ? 0 : root.blRadius) : 0
|
||||
radiusY: root.isRenderable ? (root.isFramed ? 0 : root.blRadius) : 0
|
||||
direction: ShapeCornerHelper.getArcDirection(root.blMultX, root.blMultY)
|
||||
@@ -192,7 +193,7 @@ ShapePath {
|
||||
|
||||
// Bar top-left corner (only if not framed, back to start)
|
||||
PathArc {
|
||||
x: root.isRenderable ? (root.isFramed ? 0 : (root.barMappedPos.x + root.leftEdgeOvs + root.tlRadius * root.tlMultX)) : -1
|
||||
x: root.isRenderable ? (root.isFramed ? 0 : (root.barMappedPos.x + root.leftEdgeOvs + root.tlRadius * root.tlMultX)) : -0.75
|
||||
y: root.isRenderable ? (root.isFramed ? 0 : (root.barMappedPos.y + root.topEdgeOvs)) : -1
|
||||
radiusX: root.isRenderable ? (root.isFramed ? 0 : root.tlRadius) : 0
|
||||
radiusY: root.isRenderable ? (root.isFramed ? 0 : root.tlRadius) : 0
|
||||
@@ -208,7 +209,7 @@ ShapePath {
|
||||
readonly property real _nhX: barMappedPos.x + barWidth / 2
|
||||
readonly property real _nhY: barMappedPos.y + barHeight / 2
|
||||
PathMove {
|
||||
x: root.isRenderable ? (root.isFramed ? (root.holeX + root.frameRadius) : root._nhX) : -3
|
||||
x: root.isRenderable ? (root.isFramed ? (root.holeX + root.frameRadius) : (root._nhX + 0.25)) : -2.75
|
||||
y: root.isRenderable ? (root.isFramed ? root.holeY : root._nhY) : -3
|
||||
}
|
||||
|
||||
@@ -221,7 +222,7 @@ ShapePath {
|
||||
// Top-right corner
|
||||
PathArc {
|
||||
x: root.isRenderable ? (root.isFramed ? (root.holeX + root.holeWidth) : (root._nhX + 1)) : -2
|
||||
y: root.isRenderable ? (root.isFramed ? (root.holeY + root.frameRadius) : root._nhY) : -3
|
||||
y: root.isRenderable ? (root.isFramed ? (root.holeY + root.frameRadius) : (root._nhY + 0.25)) : -2.75
|
||||
radiusX: root.isRenderable ? (root.isFramed ? root.frameRadius : 0) : 0
|
||||
radiusY: root.isRenderable ? (root.isFramed ? root.frameRadius : 0) : 0
|
||||
direction: PathArc.Clockwise
|
||||
@@ -235,7 +236,7 @@ ShapePath {
|
||||
|
||||
// Bottom-right corner
|
||||
PathArc {
|
||||
x: root.isRenderable ? (root.isFramed ? (root.holeX + root.holeWidth - root.frameRadius) : (root._nhX + 1)) : -2
|
||||
x: root.isRenderable ? (root.isFramed ? (root.holeX + root.holeWidth - root.frameRadius) : (root._nhX + 0.75)) : -2.25
|
||||
y: root.isRenderable ? (root.isFramed ? (root.holeY + root.holeHeight) : (root._nhY + 1)) : -2
|
||||
radiusX: root.isRenderable ? (root.isFramed ? root.frameRadius : 0) : 0
|
||||
radiusY: root.isRenderable ? (root.isFramed ? root.frameRadius : 0) : 0
|
||||
@@ -251,7 +252,7 @@ ShapePath {
|
||||
// Bottom-left corner
|
||||
PathArc {
|
||||
x: root.isRenderable ? (root.isFramed ? root.holeX : root._nhX) : -3
|
||||
y: root.isRenderable ? (root.isFramed ? (root.holeY + root.holeHeight - root.frameRadius) : (root._nhY + 1)) : -2
|
||||
y: root.isRenderable ? (root.isFramed ? (root.holeY + root.holeHeight - root.frameRadius) : (root._nhY + 0.75)) : -2.25
|
||||
radiusX: root.isRenderable ? (root.isFramed ? root.frameRadius : 0) : 0
|
||||
radiusY: root.isRenderable ? (root.isFramed ? root.frameRadius : 0) : 0
|
||||
direction: PathArc.Clockwise
|
||||
@@ -265,7 +266,7 @@ ShapePath {
|
||||
|
||||
// Top-left corner (back to start)
|
||||
PathArc {
|
||||
x: root.isRenderable ? (root.isFramed ? (root.holeX + root.frameRadius) : root._nhX) : -3
|
||||
x: root.isRenderable ? (root.isFramed ? (root.holeX + root.frameRadius) : (root._nhX + 0.25)) : -2.75
|
||||
y: root.isRenderable ? (root.isFramed ? root.holeY : root._nhY) : -3
|
||||
radiusX: root.isRenderable ? (root.isFramed ? root.frameRadius : 0) : 0
|
||||
radiusY: root.isRenderable ? (root.isFramed ? root.frameRadius : 0) : 0
|
||||
|
||||
@@ -89,7 +89,9 @@ ShapePath {
|
||||
strokeWidth: -1 // No stroke, fill only
|
||||
|
||||
// Start point - use tiny off-screen non-degenerate fallback when not renderable.
|
||||
startX: isRenderable ? (panelX + tlRadius * tlMultX) : -1
|
||||
// Fallback forms a 1×1 off-screen square where each edge is split between a PathLine
|
||||
// and a PathArc, ensuring no arc has zero displacement (which can crash qTriangulate).
|
||||
startX: isRenderable ? (panelX + tlRadius * tlMultX) : -0.75
|
||||
startY: isRenderable ? panelY : -1
|
||||
|
||||
fillColor: isRenderable ? effectiveBackgroundColor : "transparent"
|
||||
@@ -100,14 +102,14 @@ ShapePath {
|
||||
|
||||
// Top edge (moving right)
|
||||
PathLine {
|
||||
relativeX: root.isRenderable ? (root.panelWidth - root.tlRadius * root.tlMultX - root.trRadius * root.trMultX) : 1
|
||||
relativeX: root.isRenderable ? (root.panelWidth - root.tlRadius * root.tlMultX - root.trRadius * root.trMultX) : 0.75
|
||||
relativeY: 0
|
||||
}
|
||||
|
||||
// Top-right corner arc
|
||||
PathArc {
|
||||
relativeX: root.isRenderable ? (root.trRadius * root.trMultX) : 0
|
||||
relativeY: root.isRenderable ? (root.trRadius * root.trMultY) : 0
|
||||
relativeY: root.isRenderable ? (root.trRadius * root.trMultY) : 0.25
|
||||
radiusX: root.isRenderable ? root.trRadius : 0
|
||||
radiusY: root.isRenderable ? root.trRadius : 0
|
||||
direction: ShapeCornerHelper.getArcDirection(root.trMultX, root.trMultY)
|
||||
@@ -116,12 +118,12 @@ ShapePath {
|
||||
// Right edge (moving down)
|
||||
PathLine {
|
||||
relativeX: 0
|
||||
relativeY: root.isRenderable ? (root.panelHeight - root.trRadius * root.trMultY - root.brRadius * root.brMultY) : 1
|
||||
relativeY: root.isRenderable ? (root.panelHeight - root.trRadius * root.trMultY - root.brRadius * root.brMultY) : 0.75
|
||||
}
|
||||
|
||||
// Bottom-right corner arc
|
||||
PathArc {
|
||||
relativeX: root.isRenderable ? (-root.brRadius * root.brMultX) : 0
|
||||
relativeX: root.isRenderable ? (-root.brRadius * root.brMultX) : -0.25
|
||||
relativeY: root.isRenderable ? (root.brRadius * root.brMultY) : 0
|
||||
radiusX: root.isRenderable ? root.brRadius : 0
|
||||
radiusY: root.isRenderable ? root.brRadius : 0
|
||||
@@ -130,14 +132,14 @@ ShapePath {
|
||||
|
||||
// Bottom edge (moving left)
|
||||
PathLine {
|
||||
relativeX: root.isRenderable ? (-(root.panelWidth - root.brRadius * root.brMultX - root.blRadius * root.blMultX)) : -1
|
||||
relativeX: root.isRenderable ? (-(root.panelWidth - root.brRadius * root.brMultX - root.blRadius * root.blMultX)) : -0.75
|
||||
relativeY: 0
|
||||
}
|
||||
|
||||
// Bottom-left corner arc
|
||||
PathArc {
|
||||
relativeX: root.isRenderable ? (-root.blRadius * root.blMultX) : 0
|
||||
relativeY: root.isRenderable ? (-root.blRadius * root.blMultY) : 0
|
||||
relativeY: root.isRenderable ? (-root.blRadius * root.blMultY) : -0.25
|
||||
radiusX: root.isRenderable ? root.blRadius : 0
|
||||
radiusY: root.isRenderable ? root.blRadius : 0
|
||||
direction: ShapeCornerHelper.getArcDirection(root.blMultX, root.blMultY)
|
||||
@@ -146,12 +148,12 @@ ShapePath {
|
||||
// Left edge (moving up) - closes the path back to start
|
||||
PathLine {
|
||||
relativeX: 0
|
||||
relativeY: root.isRenderable ? (-(root.panelHeight - root.blRadius * root.blMultY - root.tlRadius * root.tlMultY)) : -1
|
||||
relativeY: root.isRenderable ? (-(root.panelHeight - root.blRadius * root.blMultY - root.tlRadius * root.tlMultY)) : -0.75
|
||||
}
|
||||
|
||||
// Top-left corner arc (back to start)
|
||||
PathArc {
|
||||
relativeX: root.isRenderable ? (root.tlRadius * root.tlMultX) : 0
|
||||
relativeX: root.isRenderable ? (root.tlRadius * root.tlMultX) : 0.25
|
||||
relativeY: root.isRenderable ? (-root.tlRadius * root.tlMultY) : 0
|
||||
radiusX: root.isRenderable ? root.tlRadius : 0
|
||||
radiusY: root.isRenderable ? root.tlRadius : 0
|
||||
|
||||
@@ -441,8 +441,8 @@ Singleton {
|
||||
// Use git sparse-checkout to clone only the plugin subfolder
|
||||
// GIT_TERMINAL_PROMPT=0 prevents hanging on private repos that need auth
|
||||
// Note: We download from the original pluginId folder in the repo, but save to compositeKey folder
|
||||
var downloadCmd = "temp_dir=$(mktemp -d) && GIT_TERMINAL_PROMPT=0 git clone --filter=blob:none --sparse --depth=1 --quiet '" + repoUrl + "' \"$temp_dir\" 2>/dev/null && cd \"$temp_dir\" && git sparse-checkout set '" + pluginId + "' 2>/dev/null && mkdir -p '" + pluginDir + "' && cp -r \"$temp_dir/" + pluginId + "/.\" '" + pluginDir
|
||||
+ "/'; exit_code=$?; rm -rf \"$temp_dir\"; exit $exit_code";
|
||||
var downloadCmd = "temp_dir=$(mktemp -d) && GIT_TERMINAL_PROMPT=0 git clone --filter=blob:none --sparse --depth=1 --quiet '" + repoUrl + "' \"$temp_dir\" 2>/dev/null && cd \"$temp_dir\" && git sparse-checkout set '" + pluginId + "' 2>/dev/null && mkdir -p '" + pluginDir + "' && rm -f \"$temp_dir/" + pluginId + "/settings.json\" && cp -r \"$temp_dir/" + pluginId
|
||||
+ "/.\" '" + pluginDir + "/'; exit_code=$?; rm -rf \"$temp_dir\"; exit $exit_code";
|
||||
|
||||
// Mark as installing
|
||||
var newInstalling = Object.assign({}, root.installingPlugins);
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
#version 450
|
||||
|
||||
layout(location = 0) in vec2 qt_TexCoord0;
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
|
||||
layout(binding = 1) uniform sampler2D dataSource;
|
||||
|
||||
layout(std140, binding = 0) uniform buf {
|
||||
mat4 qt_Matrix;
|
||||
float qt_Opacity;
|
||||
vec4 fillColor;
|
||||
float count;
|
||||
float texWidth;
|
||||
float vertical;
|
||||
};
|
||||
|
||||
// Sample amplitude from data texture (R channel)
|
||||
float fetchData(float idx) {
|
||||
float i = clamp(idx, 0.0, texWidth - 1.0);
|
||||
float u = (floor(i) + 0.5) / texWidth;
|
||||
return texture(dataSource, vec2(u, 0.5)).r;
|
||||
}
|
||||
|
||||
// Cubic Hermite interpolation for smooth wave curves
|
||||
float cubicHermite(float y0, float y1, float y2, float y3, float t) {
|
||||
float m1 = (y2 - y0) * 0.25;
|
||||
float m2 = (y3 - y1) * 0.25;
|
||||
float t2 = t * t;
|
||||
float t3 = t2 * t;
|
||||
return (2.0 * t3 - 3.0 * t2 + 1.0) * y1
|
||||
+ (t3 - 2.0 * t2 + t) * m1
|
||||
+ (-2.0 * t3 + 3.0 * t2) * y2
|
||||
+ (t3 - t2) * m2;
|
||||
}
|
||||
|
||||
// Evaluate interpolated amplitude at fractional data index
|
||||
float evalCurve(float dataIdx) {
|
||||
float i = floor(dataIdx);
|
||||
float t = dataIdx - i;
|
||||
return cubicHermite(
|
||||
fetchData(i - 1.0),
|
||||
fetchData(i),
|
||||
fetchData(i + 1.0),
|
||||
fetchData(i + 2.0),
|
||||
t
|
||||
);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 uv = qt_TexCoord0;
|
||||
|
||||
// Swap axes for vertical mode
|
||||
float axisPos = (vertical > 0.5) ? uv.y : uv.x;
|
||||
float crossPos = (vertical > 0.5) ? uv.x : uv.y;
|
||||
|
||||
// Mirror: value[0] at center, value[count-1] at edges
|
||||
float distFromCenter = abs(axisPos - 0.5) * 2.0;
|
||||
float dataIdx = distFromCenter * max(count - 1.0, 1.0);
|
||||
|
||||
// Interpolated amplitude, clamped to valid range
|
||||
float amplitude = clamp(evalCurve(dataIdx), 0.0, 1.0);
|
||||
|
||||
// Wave fills center ± amplitude/2 in the cross axis
|
||||
float halfAmp = amplitude * 0.5;
|
||||
float distFromMid = abs(crossPos - 0.5);
|
||||
|
||||
// Antialiased edge (~1px smooth transition)
|
||||
float edge = fwidth(crossPos) * 1.5;
|
||||
float mask = smoothstep(halfAmp + edge, halfAmp - edge, distFromMid);
|
||||
|
||||
// Premultiplied alpha output
|
||||
float a = mask * fillColor.a;
|
||||
fragColor = vec4(fillColor.rgb * a, a) * qt_Opacity;
|
||||
}
|
||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
import QtQuick
|
||||
import QtQuick.Shapes
|
||||
import Quickshell
|
||||
import qs.Commons
|
||||
|
||||
Item {
|
||||
@@ -14,115 +14,57 @@ Item {
|
||||
property bool showMinimumSignal: false
|
||||
property real minimumSignalValue: 0.05 // Default to 5% of height
|
||||
|
||||
// Safe degenerate-path fallback: valid off-screen line that renders nothing visible.
|
||||
// Bare move-to paths like "M 0 0" can crash Qt's CurveRenderer triangulation.
|
||||
readonly property string _safeFallbackPath: "M -1 -1 L -1 0"
|
||||
readonly property int valuesCount: (values && Array.isArray(values)) ? values.length : 0
|
||||
readonly property bool hasData: valuesCount >= 2
|
||||
|
||||
// Reactive path that updates when values change
|
||||
readonly property string svgPath: {
|
||||
if (!values || !Array.isArray(values) || values.length === 0) {
|
||||
return _safeFallbackPath;
|
||||
}
|
||||
// Data texture: one pixel per value, R channel = amplitude
|
||||
Item {
|
||||
id: dataRow
|
||||
width: Math.max(root.valuesCount, 4)
|
||||
height: 1
|
||||
|
||||
if (!isFinite(width) || !isFinite(height) || width <= 0 || height <= 0)
|
||||
return _safeFallbackPath;
|
||||
Repeater {
|
||||
model: dataRow.width
|
||||
|
||||
// Apply minimum signal if enabled
|
||||
const processedValues = showMinimumSignal ? values.map(v => v === 0 ? minimumSignalValue : v) : values;
|
||||
|
||||
// Create the mirrored values
|
||||
const partToMirror = processedValues.slice(1).reverse();
|
||||
const mirroredValues = partToMirror.concat(processedValues);
|
||||
|
||||
if (mirroredValues.length < 2) {
|
||||
return _safeFallbackPath;
|
||||
}
|
||||
|
||||
const count = mirroredValues.length;
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
if (!isFinite(mirroredValues[i]))
|
||||
return _safeFallbackPath;
|
||||
}
|
||||
|
||||
if (vertical) {
|
||||
const stepY = height / (count - 1);
|
||||
const centerX = width / 2;
|
||||
const amplitude = width / 2;
|
||||
|
||||
if (!isFinite(stepY) || !isFinite(centerX) || !isFinite(amplitude))
|
||||
return _safeFallbackPath;
|
||||
|
||||
let xOffset = mirroredValues[0] * amplitude;
|
||||
if (!isFinite(xOffset))
|
||||
return _safeFallbackPath;
|
||||
let path = `M ${centerX - xOffset} 0`;
|
||||
|
||||
for (let i = 1; i < count; i++) {
|
||||
const y = i * stepY;
|
||||
xOffset = mirroredValues[i] * amplitude;
|
||||
if (!isFinite(y) || !isFinite(xOffset))
|
||||
return _safeFallbackPath;
|
||||
path += ` L ${centerX - xOffset} ${y}`;
|
||||
Rectangle {
|
||||
required property int index
|
||||
x: index
|
||||
width: 1
|
||||
height: 1
|
||||
color: {
|
||||
if (index >= root.valuesCount)
|
||||
return Qt.rgba(0, 0, 0, 1);
|
||||
var v = root.values[index];
|
||||
if (v === undefined || v === null || !isFinite(v))
|
||||
v = 0;
|
||||
if (root.showMinimumSignal && v === 0)
|
||||
v = root.minimumSignalValue;
|
||||
return Qt.rgba(Math.max(0, Math.min(1, v)), 0, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = count - 1; i >= 0; i--) {
|
||||
const y = i * stepY;
|
||||
xOffset = mirroredValues[i] * amplitude;
|
||||
if (!isFinite(y) || !isFinite(xOffset))
|
||||
return _safeFallbackPath;
|
||||
path += ` L ${centerX + xOffset} ${y}`;
|
||||
}
|
||||
|
||||
return path + " Z";
|
||||
} else {
|
||||
const stepX = width / (count - 1);
|
||||
const centerY = height / 2;
|
||||
const amplitude = height / 2;
|
||||
|
||||
if (!isFinite(stepX) || !isFinite(centerY) || !isFinite(amplitude))
|
||||
return _safeFallbackPath;
|
||||
|
||||
let yOffset = mirroredValues[0] * amplitude;
|
||||
if (!isFinite(yOffset))
|
||||
return _safeFallbackPath;
|
||||
let path = `M 0 ${centerY - yOffset}`;
|
||||
|
||||
for (let i = 1; i < count; i++) {
|
||||
const x = i * stepX;
|
||||
yOffset = mirroredValues[i] * amplitude;
|
||||
if (!isFinite(x) || !isFinite(yOffset))
|
||||
return _safeFallbackPath;
|
||||
path += ` L ${x} ${centerY - yOffset}`;
|
||||
}
|
||||
|
||||
for (let i = count - 1; i >= 0; i--) {
|
||||
const x = i * stepX;
|
||||
yOffset = mirroredValues[i] * amplitude;
|
||||
if (!isFinite(x) || !isFinite(yOffset))
|
||||
return _safeFallbackPath;
|
||||
path += ` L ${x} ${centerY + yOffset}`;
|
||||
}
|
||||
|
||||
return path + " Z";
|
||||
}
|
||||
}
|
||||
|
||||
Shape {
|
||||
id: shape
|
||||
ShaderEffectSource {
|
||||
id: dataTex
|
||||
sourceItem: dataRow
|
||||
textureSize: Qt.size(dataRow.width, 1)
|
||||
live: true
|
||||
smooth: false
|
||||
hideSource: true
|
||||
}
|
||||
|
||||
ShaderEffect {
|
||||
anchors.fill: parent
|
||||
preferredRendererType: Shape.CurveRenderer
|
||||
containsMode: Shape.FillContains
|
||||
visible: root.hasData && root.width > 0 && root.height > 0
|
||||
|
||||
ShapePath {
|
||||
id: shapePath
|
||||
fillColor: root.fillColor
|
||||
strokeColor: root.strokeWidth > 0 ? root.strokeColor : "transparent"
|
||||
strokeWidth: root.strokeWidth
|
||||
property variant dataSource: dataTex
|
||||
property color fillColor: root.fillColor
|
||||
property real count: root.valuesCount
|
||||
property real texWidth: dataRow.width
|
||||
property real vertical: root.vertical ? 1.0 : 0.0
|
||||
|
||||
PathSvg {
|
||||
path: root.svgPath
|
||||
}
|
||||
}
|
||||
fragmentShader: Qt.resolvedUrl(Quickshell.shellDir + "/Shaders/qsb/wave_spectrum.frag.qsb")
|
||||
blending: true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user