mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-03 20:32:07 -04:00
fix: Defer DankCircularImage saving until the window is available
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user