From 0bd84213329d1a1517617f18612d0e252e078831 Mon Sep 17 00:00:00 2001 From: Epicalert Date: Wed, 11 Sep 2024 06:07:51 +0800 Subject: [PATCH] Update output TexSlot when pack is finished --- Main.qml | 10 +++++++--- TexSlot.qml | 9 +++++++-- texturecrafter.cpp | 4 +++- texturecrafter.h | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Main.qml b/Main.qml index 5752306..d3b2d84 100644 --- a/Main.qml +++ b/Main.qml @@ -54,7 +54,11 @@ ApplicationWindow { Layout.alignment: Qt.AlignHCenter text: qsTr("Craft!") - onClicked: crafter.packChannels([texSlotR.filePath, texSlotG.filePath, texSlotB.filePath]) + onClicked: { + var outUrl = crafter.packChannels([texSlotR.filePath, texSlotG.filePath, texSlotB.filePath]); + + outSlot.filePath = outUrl; + } } } @@ -64,9 +68,9 @@ ApplicationWindow { Layout.alignment: Qt.AlignHCenter TexSlot { + id: outSlot - - rectColor: "green" + rectColor: "gray" } } } diff --git a/TexSlot.qml b/TexSlot.qml index 551616c..90e4af4 100644 --- a/TexSlot.qml +++ b/TexSlot.qml @@ -21,6 +21,8 @@ DropArea { anchors.centerIn: parent + source: filePath + width: 96 height: 96 @@ -69,12 +71,15 @@ DropArea { console.log(drop.urls); filePath = drop.urls[0]; - huh.text = drop.urls[0]; - image.source = drop.urls[0]; + } rectangle.color = rectColor; } onExited: { rectangle.color = rectColor; } + + onFilePathChanged: { + huh.text = filePath; + } } diff --git a/texturecrafter.cpp b/texturecrafter.cpp index 67044a8..4e2880c 100644 --- a/texturecrafter.cpp +++ b/texturecrafter.cpp @@ -4,7 +4,7 @@ TextureCrafter::TextureCrafter(QObject *parent) : QObject{parent} {} -void TextureCrafter::packChannels(QVector imagePaths) { +QUrl TextureCrafter::packChannels(QVector imagePaths) { QVector sourceImages; int width = 0, height = 0; @@ -55,6 +55,7 @@ void TextureCrafter::packChannels(QVector imagePaths) { //TODO: use libpng and do progressive write to update the progress bar if (outImage.save(outFileName)) { printf("cool ^-^\n"); + return QUrl::fromLocalFile(outFileName); } else { //TODO: return some error value to show the user printf("that dream is fucked it is fucking fucked\n"); @@ -63,5 +64,6 @@ void TextureCrafter::packChannels(QVector imagePaths) { printf("chat its so over\n"); } + return QUrl(); //do we need to close these??? idk lets hope qt handles it } diff --git a/texturecrafter.h b/texturecrafter.h index c076641..4eccda2 100644 --- a/texturecrafter.h +++ b/texturecrafter.h @@ -13,7 +13,7 @@ class TextureCrafter : public QObject public: explicit TextureCrafter(QObject *parent = nullptr); - Q_INVOKABLE void packChannels(QVector images); + Q_INVOKABLE QUrl packChannels(QVector images); signals: private: