diff --git a/quickshell/Widgets/DankCircularImage.qml b/quickshell/Widgets/DankCircularImage.qml index 45231487..d7911eac 100644 --- a/quickshell/Widgets/DankCircularImage.qml +++ b/quickshell/Widgets/DankCircularImage.qml @@ -1,4 +1,5 @@ import QtQuick +import QtQuick.Window import QtQuick.Effects import qs.Common import qs.Widgets @@ -18,9 +19,30 @@ Rectangle { signal imageSaved(string filePath) + property string _pendingSavePath: "" + property var _attachedWindow: root.Window.window + + on_AttachedWindowChanged: { + if (_attachedWindow && _pendingSavePath !== "") { + Qt.callLater(function () { + if (root._pendingSavePath !== "") { + let path = root._pendingSavePath; + root._pendingSavePath = ""; + root.saveImageToFile(path); + } + }); + } + } + function saveImageToFile(filePath) { if (activeImage.status !== Image.Ready) return false; + + if (!activeImage.Window.window) { + _pendingSavePath = filePath; + return true; + } + activeImage.grabToImage(function (result) { if (result && result.saveToFile(filePath)) { root.imageSaved(filePath);