diff --git a/package/contents/config/main.xml b/package/contents/config/main.xml index 54923cc..42b8cb3 100644 --- a/package/contents/config/main.xml +++ b/package/contents/config/main.xml @@ -185,6 +185,10 @@ + + + -1 + 0 diff --git a/package/contents/ui/KomplexModel.qml b/package/contents/ui/KomplexModel.qml index 8f2585e..996841d 100644 --- a/package/contents/ui/KomplexModel.qml +++ b/package/contents/ui/KomplexModel.qml @@ -42,6 +42,8 @@ Item property vector4d iMouse property var iDate property bool running: true + property bool ready: false + // Individual channel resolutions to customize performance and quality property var iChannelResolution: [Qt.vector3d(wallpaper.configuration.iChannel0_resolution_x, wallpaper.configuration.iChannel0_resolution_y, pixelRatio), @@ -53,11 +55,20 @@ Item property string iChannel1: "" property string iChannel2: "" property string iChannel3: "" + + property var pack: wallpaper.configuration.shader_package - property var bufferA: ShaderChannel { visible: true; width: mainItem.width; height: mainItem.height } - property var bufferB: ShaderChannel { visible: true; width: mainItem.width; height: mainItem.height } - property var bufferC: ShaderChannel { visible: true; width: mainItem.width; height: mainItem.height } - property var bufferD: ShaderChannel { visible: true; width: mainItem.width; height: mainItem.height } + onPackChanged: ()=> + { + 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 @@ -139,17 +150,15 @@ Item // Load the default shader pack configuration on component completion Component.onCompleted: { - data.buffers.set("{bufferA}", mainItem.bufferA) - data.buffers.set("{bufferB}", mainItem.bufferB) - data.buffers.set("{bufferC}", mainItem.bufferC) - data.buffers.set("{bufferD}", mainItem.bufferD) - - console.log(data.buffers.has("{bufferA}")) + data.buffers.set("{bufferA}", bufferA) + data.buffers.set("{bufferB}", bufferB) + data.buffers.set("{bufferC}", bufferC) + data.buffers.set("{bufferD}", bufferD) if(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 @@ -158,8 +167,8 @@ Item var source = getFilePath(json.source) channel.frameBufferChannel = json.frame_buffer_channel !== undefined ? json.frame_buffer_channel : -1 - channel.type = json.type ? json.type : typeDefault - channel.anchors.fill = mainItem + channel.type = json.type !== undefined ? json.type : typeDefault + channel.anchors.fill = channel.parent channel.visible = false channel.iMouse = Qt.binding(() => { return mainItem.iMouse; }) channel.iTime = Qt.binding(() => { return mainItem.iTime; }) @@ -295,13 +304,13 @@ Item var currentChannel = null; if (pack.bufferA) - parseChannel(mainItem.bufferA, pack.bufferA, 2); + parseChannel(bufferA, pack.bufferA, 2); if (pack.bufferB) - parseChannel(mainItem.bufferB, pack.bufferB, 2); + parseChannel(bufferB, pack.bufferB, 2); if (pack.bufferC) - parseChannel(mainItem.bufferC, pack.bufferC, 2); + parseChannel(bufferC, pack.bufferC, 2); if (pack.bufferD) - parseChannel(mainItem.bufferD, pack.bufferD, 2); + parseChannel(bufferD, pack.bufferD, 2); parseChannel(channelOutput, pack, 2) diff --git a/package/contents/ui/ShaderChannel.qml b/package/contents/ui/ShaderChannel.qml index deb4fcc..46ff47a 100644 --- a/package/contents/ui/ShaderChannel.qml +++ b/package/contents/ui/ShaderChannel.qml @@ -98,7 +98,7 @@ Item Loader { id: loader - anchors.fill: channel.invert ? null : parent + anchors.fill: parent sourceComponent: channelImage diff --git a/package/contents/ui/ShaderChannelConfiguration.qml b/package/contents/ui/ShaderChannelConfiguration.qml index 718f9e1..d2b9031 100644 --- a/package/contents/ui/ShaderChannelConfiguration.qml +++ b/package/contents/ui/ShaderChannelConfiguration.qml @@ -607,19 +607,15 @@ Item { case ShaderChannel.Type.CubeMapChannel: window.currentFolder = window.cubemapFolder - window.tmp_source = "" break; case ShaderChannel.Type.ImageChannel: window.currentFolder = window.imageFolder - window.tmp_source = "" break; case ShaderChannel.Type.ShaderChannel: window.currentFolder = window.shaderFolder - window.tmp_source = "" break; case ShaderChannel.Type.VideoChannel: window.currentFolder = window.videoFolder - window.tmp_source = "" break; case ShaderChannel.Type.AudioChannel: window.tmp_source = "Audio Channel" diff --git a/package/contents/ui/config.qml b/package/contents/ui/config.qml index 2bf0ad1..da378a7 100644 --- a/package/contents/ui/config.qml +++ b/package/contents/ui/config.qml @@ -122,46 +122,15 @@ Kirigami.FormLayout onCurrentIndexChanged: root.cfg_komplex_mode = currentIndex textRole: "label" model: [ - { "label": i18nd("@option:komplex_mode", "ShaderToys") }, + { "label": i18nd("@option:komplex_mode", "Simple") }, { "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 - { - 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; - } - } - } + RowLayout { - visible: root.cfg_komplex_mode === 0 && navBar.currentIndex === 0 + visible: root.cfg_komplex_mode === 0 id: shaderOutputLayout 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 RowLayout { @@ -743,83 +820,63 @@ Kirigami.FormLayout Qt.openUrlExternally("https://ko-fi.com/digitalartifex"); } } - + RowLayout { visible: root.cfg_komplex_mode === 1 && navBar.currentIndex === 0 - - spacing: Kirigami.Units.smallSpacing - Kirigami.FormData.label: i18nd("com.github.digitalartifex.komplex", "Shader Pack:") - ComboBox + Kirigami.FormData.label: i18nd("com.github.digitalartifex.komplex", "Author:") + Text { - property string shader - - id: selectedShaderPack Layout.preferredWidth: Kirigami.Units.gridUnit * 11 - model: FolderListModel - { - id: packListModel - 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" - 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; - - if (root.cfg_selectedShaderIndex === -1) - return; - - var source = model.get(currentIndex, "fileUrl"); - shader = source; - } + text: shaderPackModel.metadata.author + horizontalAlignment: Text.AlignLeft + color: palette.text } + } + + RowLayout + { + visible: root.cfg_komplex_mode === 1 && navBar.currentIndex === 0 - Button + Kirigami.FormData.label: i18nd("com.github.digitalartifex.komplex", "Description:") + Text { - 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(); - } + Layout.preferredWidth: Kirigami.Units.gridUnit * 16 + text: shaderPackModel.metadata.description + horizontalAlignment: Text.AlignLeft + color: palette.text + wrapMode: Text.WordWrap + maximumLineCount: 2 + elide: Text.ElideRight } + } + + RowLayout + { + visible: root.cfg_komplex_mode === 1 && navBar.currentIndex === 0 - FileDialog + Kirigami.FormData.label: i18nd("com.github.digitalartifex.komplex", "License:") + Text { - 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; - } + Layout.preferredWidth: Kirigami.Units.gridUnit * 11 + text: shaderPackModel.metadata.license + horizontalAlignment: Text.AlignLeft + color: palette.text + } + } + + RowLayout + { + visible: root.cfg_komplex_mode === 1 && navBar.currentIndex === 0 + + Kirigami.FormData.label: i18nd("com.github.digitalartifex.komplex", "Version:") + Text + { + Layout.preferredWidth: Kirigami.Units.gridUnit * 11 + text: shaderPackModel.metadata.version + horizontalAlignment: Text.AlignLeft + color: palette.text } } }