fix(Utils): use the more robust QClipboardProxy checks

- when verifying whether an image has a suitable size or extension
This commit is contained in:
Lukáš Tinkl 2023-06-07 17:51:15 +02:00 committed by Lukáš Tinkl
parent b5a7df685a
commit b83b8e7466
1 changed files with 5 additions and 4 deletions

View File

@ -3,6 +3,8 @@ pragma Singleton
import QtQuick 2.13
import shared 1.0
import StatusQ 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Core.Utils 0.1 as StatusQUtils
@ -335,16 +337,15 @@ QtObject {
}
function isValidDragNDropImage(url) {
let lowerCaseUrl = url.toLowerCase()
return Constants.acceptedDragNDropImageExtensions.some(ext => lowerCaseUrl.endsWith(ext)) ||
lowerCaseUrl.startsWith(Constants.dataImagePrefix);
return url.startsWith(Constants.dataImagePrefix) ||
QClipboardProxy.isValidImageUrl(url, Constants.acceptedDragNDropImageExtensions)
}
function isFilesizeValid(img) {
if (img.startsWith(Constants.dataImagePrefix)) {
return img.length < maxImgSizeBytes
}
let size = parseInt(globalUtils.getFileSize(img))
const size = QClipboardProxy.getFileSize(img)
return size <= maxImgSizeBytes
}