add image render

This commit is contained in:
王劲鹏
2021-04-23 17:56:08 +08:00
committed by osborn
parent 8ae5af13e9
commit 0a29cc2876
12 changed files with 254 additions and 9 deletions

View File

@@ -0,0 +1,86 @@
import QtQuick 2.12
import QtQuick.Controls 2.5
import "util.mjs" as Util
AnimatedImage {
property var wrapper
property var uuid: Util.uuidv4()
property var tag: "Image"
Rectangle {
id: bg
color: "transparent"
}
onSourceChanged: {
console.log(tag, uuid + " onSourceChanged: " + this.source)
}
onStatusChanged: {
if (this.status === Image.Null) {
console.log(tag, uuid + " onStatusChanged: Image.Null")
imageBridge.onNull(wrapper);
} else if (this.status === Image.Ready) {
console.log(tag, uuid + " onStatusChanged: Image.Ready")
if (this.width !== 0 && this.height !== 0 && this.status === Image.Ready) {
imageBridge.onReady(wrapper);
}
} else if (this.status === Image.Loading) {
console.log(tag, uuid + " onStatusChanged: Image.Loading")
imageBridge.onLoading(wrapper);
} else if (this.status === Image.Error) {
console.log(tag, uuid + " onStatusChanged: Image.Error")
imageBridge.onError(wrapper);
}
}
onProgressChanged: {
console.log(tag, uuid + " onProgressChanged: " + this.progress)
}
onWidthChanged: {
console.log(tag, uuid + " onWidthChanged: " + this.width)
bg.width = this.width
if (this.width !== 0 && this.height !== 0 && this.status === Image.Ready) {
imageBridge.onReady(wrapper);
}
}
onHeightChanged: {
console.log(tag, uuid + " onHeightChanged: " + this.height)
bg.height = this.height
if (this.width !== 0 && this.height !== 0 && this.status === Image.Ready) {
imageBridge.onReady(wrapper);
}
}
property var backgroundColor
onBackgroundColorChanged: {
bg.color = backgroundColor
}
property var borderWidth: 0
onBorderWidthChanged: {
bg.border.width = borderWidth
}
property var borderColor: ""
onBorderColorChanged: {
bg.border.color = borderColor
}
MouseArea {
anchors.fill: parent
onClicked: {
console.log(tag, uuid + " wrapper: " + wrapper)
mouseAreaBridge.onClick(wrapper)
}
}
}

View File

@@ -3,8 +3,8 @@ import QtQuick.Controls 2.5
ApplicationWindow {
visible: true
width: 405
height: 720
width: 600
height: 800
title: qsTr("Scroll")
ScrollView {

View File

@@ -4,7 +4,7 @@ import QtQuick.Layouts 1.15
ApplicationWindow {
visible: true
width: 450
width: 600
height: 800
title: qsTr("Scroll")