fix(Utils): use the more robust QClipboardProxy checks
- when verifying whether an image has a suitable size or extension
This commit is contained in:
parent
b5a7df685a
commit
b83b8e7466
|
@ -3,6 +3,8 @@ pragma Singleton
|
||||||
import QtQuick 2.13
|
import QtQuick 2.13
|
||||||
|
|
||||||
import shared 1.0
|
import shared 1.0
|
||||||
|
|
||||||
|
import StatusQ 0.1
|
||||||
import StatusQ.Core.Theme 0.1
|
import StatusQ.Core.Theme 0.1
|
||||||
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
||||||
|
|
||||||
|
@ -335,16 +337,15 @@ QtObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidDragNDropImage(url) {
|
function isValidDragNDropImage(url) {
|
||||||
let lowerCaseUrl = url.toLowerCase()
|
return url.startsWith(Constants.dataImagePrefix) ||
|
||||||
return Constants.acceptedDragNDropImageExtensions.some(ext => lowerCaseUrl.endsWith(ext)) ||
|
QClipboardProxy.isValidImageUrl(url, Constants.acceptedDragNDropImageExtensions)
|
||||||
lowerCaseUrl.startsWith(Constants.dataImagePrefix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isFilesizeValid(img) {
|
function isFilesizeValid(img) {
|
||||||
if (img.startsWith(Constants.dataImagePrefix)) {
|
if (img.startsWith(Constants.dataImagePrefix)) {
|
||||||
return img.length < maxImgSizeBytes
|
return img.length < maxImgSizeBytes
|
||||||
}
|
}
|
||||||
let size = parseInt(globalUtils.getFileSize(img))
|
const size = QClipboardProxy.getFileSize(img)
|
||||||
return size <= maxImgSizeBytes
|
return size <= maxImgSizeBytes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue