Various bug fixes

This commit is contained in:
Digital Artifex
2025-08-19 09:37:19 -04:00
parent a49c96a56d
commit edfae84b55
5 changed files with 188 additions and 122 deletions

View File

@@ -185,6 +185,10 @@
<label>Shader Package</label> <label>Shader Package</label>
<default></default> <default></default>
</entry> </entry>
<entry name="shader_package_index" type="Int">
<label>Shader Package Index</label>
<default>-1</default>
</entry>
<entry name="komplex_mode" type="Int"> <entry name="komplex_mode" type="Int">
<label>Use the Komplex Mode</label> <label>Use the Komplex Mode</label>
<default>0</default> <default>0</default>

View File

@@ -42,6 +42,8 @@ Item
property vector4d iMouse property vector4d iMouse
property var iDate property var iDate
property bool running: true property bool running: true
property bool ready: false
// Individual channel resolutions to customize performance and quality // Individual channel resolutions to customize performance and quality
property var iChannelResolution: [Qt.vector3d(wallpaper.configuration.iChannel0_resolution_x, wallpaper.configuration.iChannel0_resolution_y, pixelRatio), property var iChannelResolution: [Qt.vector3d(wallpaper.configuration.iChannel0_resolution_x, wallpaper.configuration.iChannel0_resolution_y, pixelRatio),
@@ -54,10 +56,19 @@ Item
property string iChannel2: "" property string iChannel2: ""
property string iChannel3: "" property string iChannel3: ""
property var bufferA: ShaderChannel { visible: true; width: mainItem.width; height: mainItem.height } property var pack: wallpaper.configuration.shader_package
property var bufferB: ShaderChannel { visible: true; width: mainItem.width; height: mainItem.height }
property var bufferC: ShaderChannel { visible: true; width: mainItem.width; height: mainItem.height } onPackChanged: ()=>
property var bufferD: ShaderChannel { visible: true; width: mainItem.width; height: mainItem.height } {
if(mainItem.ready)
shaderPackModel.loadJson(pack)
}
ShaderChannel { id: bufferA; visible: true; anchors.fill: parent }
ShaderChannel { id: bufferB; visible: true; anchors.fill: parent }
ShaderChannel { id: bufferC; visible: true; anchors.fill: parent }
ShaderChannel { id: bufferD; visible: true; anchors.fill: parent }
id: mainItem id: mainItem
@@ -139,17 +150,15 @@ Item
// Load the default shader pack configuration on component completion // Load the default shader pack configuration on component completion
Component.onCompleted: Component.onCompleted:
{ {
data.buffers.set("{bufferA}", mainItem.bufferA) data.buffers.set("{bufferA}", bufferA)
data.buffers.set("{bufferB}", mainItem.bufferB) data.buffers.set("{bufferB}", bufferB)
data.buffers.set("{bufferC}", mainItem.bufferC) data.buffers.set("{bufferC}", bufferC)
data.buffers.set("{bufferD}", mainItem.bufferD) data.buffers.set("{bufferD}", bufferD)
console.log(data.buffers.has("{bufferA}"))
if(wallpaper.configuration.shader_package) if(wallpaper.configuration.shader_package)
shaderPackModel.loadJson(wallpaper.configuration.shader_package); shaderPackModel.loadJson(wallpaper.configuration.shader_package);
else
shaderPackModel.loadJson("/home/parametheus/kde/src/komplex/pack.json"); // Load a default shader pack if none is specified ready = true
} }
// Recursive helper function to parse channels // Recursive helper function to parse channels
@@ -158,8 +167,8 @@ Item
var source = getFilePath(json.source) var source = getFilePath(json.source)
channel.frameBufferChannel = json.frame_buffer_channel !== undefined ? json.frame_buffer_channel : -1 channel.frameBufferChannel = json.frame_buffer_channel !== undefined ? json.frame_buffer_channel : -1
channel.type = json.type ? json.type : typeDefault channel.type = json.type !== undefined ? json.type : typeDefault
channel.anchors.fill = mainItem channel.anchors.fill = channel.parent
channel.visible = false channel.visible = false
channel.iMouse = Qt.binding(() => { return mainItem.iMouse; }) channel.iMouse = Qt.binding(() => { return mainItem.iMouse; })
channel.iTime = Qt.binding(() => { return mainItem.iTime; }) channel.iTime = Qt.binding(() => { return mainItem.iTime; })
@@ -295,13 +304,13 @@ Item
var currentChannel = null; var currentChannel = null;
if (pack.bufferA) if (pack.bufferA)
parseChannel(mainItem.bufferA, pack.bufferA, 2); parseChannel(bufferA, pack.bufferA, 2);
if (pack.bufferB) if (pack.bufferB)
parseChannel(mainItem.bufferB, pack.bufferB, 2); parseChannel(bufferB, pack.bufferB, 2);
if (pack.bufferC) if (pack.bufferC)
parseChannel(mainItem.bufferC, pack.bufferC, 2); parseChannel(bufferC, pack.bufferC, 2);
if (pack.bufferD) if (pack.bufferD)
parseChannel(mainItem.bufferD, pack.bufferD, 2); parseChannel(bufferD, pack.bufferD, 2);
parseChannel(channelOutput, pack, 2) parseChannel(channelOutput, pack, 2)

View File

@@ -98,7 +98,7 @@ Item
Loader Loader
{ {
id: loader id: loader
anchors.fill: channel.invert ? null : parent anchors.fill: parent
sourceComponent: channelImage sourceComponent: channelImage

View File

@@ -607,19 +607,15 @@ Item
{ {
case ShaderChannel.Type.CubeMapChannel: case ShaderChannel.Type.CubeMapChannel:
window.currentFolder = window.cubemapFolder window.currentFolder = window.cubemapFolder
window.tmp_source = ""
break; break;
case ShaderChannel.Type.ImageChannel: case ShaderChannel.Type.ImageChannel:
window.currentFolder = window.imageFolder window.currentFolder = window.imageFolder
window.tmp_source = ""
break; break;
case ShaderChannel.Type.ShaderChannel: case ShaderChannel.Type.ShaderChannel:
window.currentFolder = window.shaderFolder window.currentFolder = window.shaderFolder
window.tmp_source = ""
break; break;
case ShaderChannel.Type.VideoChannel: case ShaderChannel.Type.VideoChannel:
window.currentFolder = window.videoFolder window.currentFolder = window.videoFolder
window.tmp_source = ""
break; break;
case ShaderChannel.Type.AudioChannel: case ShaderChannel.Type.AudioChannel:
window.tmp_source = "Audio Channel" window.tmp_source = "Audio Channel"

View File

@@ -122,46 +122,15 @@ Kirigami.FormLayout
onCurrentIndexChanged: root.cfg_komplex_mode = currentIndex onCurrentIndexChanged: root.cfg_komplex_mode = currentIndex
textRole: "label" textRole: "label"
model: [ model: [
{ "label": i18nd("@option:komplex_mode", "ShaderToys") }, { "label": i18nd("@option:komplex_mode", "Simple") },
{ "label": i18nd("@option:komplex_mode", "Komplex") } { "label": i18nd("@option:komplex_mode", "Komplex") }
] ]
} }
} }
TabBar
{
Layout.fillWidth: true
id: navBar
width: parent.width
TabButton {
text: qsTr("Shader")
}
TabButton {
text: qsTr("Shader Settings")
}
TabButton {
text: qsTr("Extra Settings")
}
}
RowLayout RowLayout
{ {
Layout.fillWidth: true visible: root.cfg_komplex_mode === 0
Kirigami.InlineMessage
{
id: warningResources
Layout.fillWidth: true
type: Kirigami.MessageType.Warning
text: qsTr("Some shaders might consume more power and resources than others, beware!")
showCloseButton: true
visible: !root.cfg_warningResources_dismissed
onVisibleChanged: () =>
{
root.cfg_warningResources_dismissed = true;
}
}
}
RowLayout
{
visible: root.cfg_komplex_mode === 0 && navBar.currentIndex === 0
id: shaderOutputLayout id: shaderOutputLayout
spacing: Kirigami.Units.smallSpacing spacing: Kirigami.Units.smallSpacing
@@ -239,6 +208,114 @@ Kirigami.FormLayout
} }
} }
RowLayout
{
visible: root.cfg_komplex_mode === 1
spacing: Kirigami.Units.smallSpacing
Kirigami.FormData.label: i18nd("com.github.digitalartifex.komplex", "Shader Pack:")
ComboBox
{
property string shader
id: selectedShaderPack
Layout.preferredWidth: Kirigami.Units.gridUnit * 11
model: shaderPackModel.availableShaderPacks
delegate: Component
{
id: packListDelegate
ItemDelegate
{
width: parent ? parent.width : 0
text: modelData
}
}
textRole: "modelData"
currentIndex: root.cfg_shader_package_index
displayText: currentIndex === -1 ? "Custom File" : currentText.replace("_", " ").charAt(0).toUpperCase() + currentText.replace("_", " ").slice(1)
onCurrentTextChanged:
{
root.cfg_shader_package_index = currentIndex;
if (root.cfg_shader_package_index === -1)
return;
var source = currentText
shaderPackModel.loadMetadata(source)
root.cfg_shader_package = "file://" + shaderPackModel.path(source)
}
}
Button
{
id: packFileButton
icon.name: "folder-symbolic"
text: i18nd("@button:toggle_select_shader", "Select File")
Layout.preferredWidth: Kirigami.Units.gridUnit * 9
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
onClicked:
{
packDialog.currentFolder = "file://" + shaderPackModel.shaderPackInstallPath;
packDialog.open();
}
}
FileDialog
{
id: packDialog
fileMode: FileDialog.OpenFile
title: i18nd("@dialog_title:choose_shader", "Choose a shader")
// will accept and auto convert .frag in the near future
nameFilters: ["Shader Package files (*.json)", "All files (*)"]
visible: false
currentFolder: "file://" + shaderPackModel.shaderPackInstallPath
onAccepted:
{
root.cfg_shader_package_index = -1;
root.cfg_shader_package = selectedFile;
shaderPackModel.loadMetadataFromFile(selectedFile)
}
}
}
TabBar
{
Layout.fillWidth: true
id: navBar
width: parent.width
TabButton {
height: 36
text: root.cfg_komplex_mode === 0 ? qsTr("Channels") : qsTr("Information")
}
TabButton {
height: 36
text: qsTr("Settings")
}
TabButton {
height: 36
text: qsTr("Extra Settings")
}
}
RowLayout
{
Layout.fillWidth: true
Kirigami.InlineMessage
{
id: warningResources
Layout.fillWidth: true
type: Kirigami.MessageType.Warning
text: qsTr("Some shaders might consume more power and resources than others, beware!")
showCloseButton: true
visible: !root.cfg_warningResources_dismissed
onVisibleChanged: () =>
{
root.cfg_warningResources_dismissed = true;
}
}
}
// iChannel0 Configuration // iChannel0 Configuration
RowLayout RowLayout
{ {
@@ -748,78 +825,58 @@ Kirigami.FormLayout
{ {
visible: root.cfg_komplex_mode === 1 && navBar.currentIndex === 0 visible: root.cfg_komplex_mode === 1 && navBar.currentIndex === 0
spacing: Kirigami.Units.smallSpacing Kirigami.FormData.label: i18nd("com.github.digitalartifex.komplex", "Author:")
Kirigami.FormData.label: i18nd("com.github.digitalartifex.komplex", "Shader Pack:") Text
ComboBox
{ {
property string shader
id: selectedShaderPack
Layout.preferredWidth: Kirigami.Units.gridUnit * 11 Layout.preferredWidth: Kirigami.Units.gridUnit * 11
model: FolderListModel text: shaderPackModel.metadata.author
{ horizontalAlignment: Text.AlignLeft
id: packListModel color: palette.text
showDirs: true
showFiles: false
showHidden: false
nameFilters: ["*.frag.qsb"]
folder: "file://" + shaderPackModel.shadersPath + "/generative"
}
delegate: Component
{
id: packListDelegate
ItemDelegate
{
width: parent ? parent.width : 0
text: fileBaseName.replace("_", " ").charAt(0).toUpperCase() + fileBaseName.replace("_", " ").slice(1)
} }
} }
textRole: "fileBaseName" RowLayout
currentIndex: root.cfg_shader_package_index
displayText: currentIndex === -1 ? "Custom File" : currentText.replace("_", " ").charAt(0).toUpperCase() + currentText.replace("_", " ").slice(1)
onCurrentTextChanged:
{ {
root.cfg_selectedShaderIndex = currentIndex; visible: root.cfg_komplex_mode === 1 && navBar.currentIndex === 0
if (root.cfg_selectedShaderIndex === -1) Kirigami.FormData.label: i18nd("com.github.digitalartifex.komplex", "Description:")
return; Text
{
var source = model.get(currentIndex, "fileUrl"); Layout.preferredWidth: Kirigami.Units.gridUnit * 16
shader = source; text: shaderPackModel.metadata.description
horizontalAlignment: Text.AlignLeft
color: palette.text
wrapMode: Text.WordWrap
maximumLineCount: 2
elide: Text.ElideRight
} }
} }
Button RowLayout
{ {
id: packFileButton visible: root.cfg_komplex_mode === 1 && navBar.currentIndex === 0
icon.name: "folder-symbolic"
text: i18nd("@button:toggle_select_shader", "Select File") Kirigami.FormData.label: i18nd("com.github.digitalartifex.komplex", "License:")
Layout.preferredWidth: Kirigami.Units.gridUnit * 9 Text
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
onClicked:
{ {
packDialog.currentFolder = "file://" + shaderPackModel.shaderPackInstallPath; Layout.preferredWidth: Kirigami.Units.gridUnit * 11
packDialog.open(); text: shaderPackModel.metadata.license
horizontalAlignment: Text.AlignLeft
color: palette.text
} }
} }
FileDialog RowLayout
{ {
id: packDialog visible: root.cfg_komplex_mode === 1 && navBar.currentIndex === 0
fileMode: FileDialog.OpenFile
title: i18nd("@dialog_title:choose_shader", "Choose a shader") Kirigami.FormData.label: i18nd("com.github.digitalartifex.komplex", "Version:")
// will accept and auto convert .frag in the near future Text
nameFilters: ["Shader Package files (*.json)", "All files (*)"]
visible: false
currentFolder: "file://" + shaderPackModel.shaderPackInstallPath
onAccepted:
{ {
root.cfg_shader_package_index = -1; Layout.preferredWidth: Kirigami.Units.gridUnit * 11
root.cfg_shader_package = selectedFile; text: shaderPackModel.metadata.version
} horizontalAlignment: Text.AlignLeft
color: palette.text
} }
} }
} }