From e9b78c6313a79731299120abc25511bd69ed86c2 Mon Sep 17 00:00:00 2001 From: Digital Artifex <7929434+DigitalArtifex@users.noreply.github.com> Date: Mon, 4 Aug 2025 03:35:31 -0400 Subject: [PATCH] Expanded source path resolution --- package/contents/ui/KomplexModel.qml | 46 ++++++++++++++++++---------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/package/contents/ui/KomplexModel.qml b/package/contents/ui/KomplexModel.qml index a86f0cf..37de619 100644 --- a/package/contents/ui/KomplexModel.qml +++ b/package/contents/ui/KomplexModel.qml @@ -23,6 +23,7 @@ * along with this program. If not, see */ +import QtCore import QtQuick import com.github.digitalartifex.komplex 1.0 as Komplex @@ -154,16 +155,14 @@ Item if (pack.channel3) channelOutput.iChannel3 = parseChannel(pack.channel3); - var source - - // Ensure the source path is correctly resolved for relative paths - if(!pack.source.startsWith("/") && !pack.source.startsWith("file://")) - source = Qt.resolvedUrl(shaderPackModel.shaderPackPath + "/" + pack.source); - else if(!pack.source.startsWith("file://")) - source = Qt.resolvedUrl("file://" + pack.source); - - channelOutput.source = "file://" + (source || ""); // Set the shader source file + channelOutput.source = getFilePath(pack.source); // Set the shader source file channelOutput.type = ShaderChannel.Type.ShaderChannel; // Set the shader + + if(pack.mouse_scale) + channelOutput.mouseBias = pack.mouse_scale + + if(pack.speed) + channelOutput.iTimeScale = pack.speed } // Recursive helper function to parse channels @@ -171,13 +170,7 @@ Item { if (!channel) return; - var source - - // Ensure the source path is correctly resolved for relative paths - if(!channel.source.startsWith("/") && !channel.source.startsWith("file://")) - source = Qt.resolvedUrl(shaderPackModel.shaderPackPath + "/" + channel.source); - else if(!channel.source.startsWith("file://")) - source = Qt.resolvedUrl("file://" + channel.source); + var source = getFilePath(channel.source) var result = Qt.createQmlObject(`ShaderChannel { @@ -190,6 +183,7 @@ Item type: ${channel.type || 0} iTime: mainItem.iTime * ${channel.time_scale || 1.0} iMouse: mainItem.iMouse + mouseBias: ${channel.mouse_scale || 1.0} iResolution: Qt.vector3d(${(channel.resolution_x || mainItem.width) * (channel.resolution_scale || 1.0)}, ${(channel.resolution_y || mainItem.width) * (channel.resolution_scale || 1.0)}, pixelRatio) }`, mainItem); @@ -204,4 +198,24 @@ Item return result; } + + function getFilePath(source) + { + if(source === "") + return ""; + + // Ensure the source path is correctly resolved for relative paths + if(source.startsWith("./")) + { + var temp = source.replace("./", "file://" + shaderPackModel.shaderPackPath + "/") + return Qt.resolvedUrl(temp); + } + else if(source.startsWith("$/")) + { + var temp = source.replace("$/", "file://" + StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/.local/share/komplex/") + return Qt.resolvedUrl(temp); + } + else if(!source.startsWith("file://")) + return Qt.resolvedUrl("file://" + source); + } }