Compare commits

...

2 commits

Author SHA1 Message Date
Epicalert 0bd8421332 Update output TexSlot when pack is finished 2024-09-11 06:07:51 +08:00
Epicalert 6a8255f67a Make TexSlots draggable 2024-09-10 23:47:18 +08:00
4 changed files with 41 additions and 8 deletions

View file

@ -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"
}
}
}

View file

@ -11,7 +11,6 @@ DropArea {
width: 128
height: 128
Rectangle {
id: rectangle
anchors.fill: parent
@ -22,10 +21,35 @@ DropArea {
anchors.centerIn: parent
source: filePath
width: 96
height: 96
MouseArea {
id: imageMouseArea
anchors.fill: parent
Drag.dragType: Drag.Automatic
Drag.supportedActions: Qt.CopyAction
Drag.mimeData: {
"text/uri-list": filePath
}
DragHandler {
id: dragHandler
onActiveChanged:
if (active) {
parent.grabToImage(function(result) {
parent.Drag.imageSource = result.url
parent.Drag.active = true
})
} else {
parent.Drag.active = false
}
}
}
}
}
@ -47,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;
}
}

View file

@ -4,7 +4,7 @@ TextureCrafter::TextureCrafter(QObject *parent)
: QObject{parent}
{}
void TextureCrafter::packChannels(QVector<QUrl> imagePaths) {
QUrl TextureCrafter::packChannels(QVector<QUrl> imagePaths) {
QVector<QImage> sourceImages;
int width = 0, height = 0;
@ -55,6 +55,7 @@ void TextureCrafter::packChannels(QVector<QUrl> 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<QUrl> imagePaths) {
printf("chat its so over\n");
}
return QUrl();
//do we need to close these??? idk lets hope qt handles it
}

View file

@ -13,7 +13,7 @@ class TextureCrafter : public QObject
public:
explicit TextureCrafter(QObject *parent = nullptr);
Q_INVOKABLE void packChannels(QVector<QUrl> images);
Q_INVOKABLE QUrl packChannels(QVector<QUrl> images);
signals:
private: