main.qml Example File
threejs/cellphone/qml/cellphone/main.qml
import QtQuick 2.6
import QtQuick.Window 2.2
Window {
property int initialWidth: 800
property int initialHeight: 600
id: mainView
width: initialWidth
height: initialHeight
visible: true
title: "Interactive Mobile Phone Demo"
color: "black"
Item {
id: textureSource
layer.enabled: true
layer.smooth: true
layer.textureMirroring: ShaderEffectSource.NoMirroring
anchors.centerIn: parent
width: 512
height: 1024
z: -2
transform: [
Scale {
origin.y: textureSource.height / 2
origin.x: textureSource.width / 2
yScale: 0.5 * mainView.height / mainView.initialHeight
xScale: 0.5 * mainView.height / mainView.initialHeight
}
]
opacity: 0.0
CellphoneApp {
id: cellphoneApp
anchors.fill: parent
backgroundColor: "black"
textColor: "white"
onLocked: canvas3d.state = "running"
}
}
CellphoneCanvas {
id: canvas3d
anchors.fill:parent
textureSource: textureSource
onRotationStopped: {
cellphoneApp.resetLockTimer()
textureSource.z = 1
}
onRotationStarted: {
textureSource.z = -1
}
}
ColorSelector {
anchors.right: parent.right
anchors.top: parent.top
width: parent.width / 16
onSelectedColorChanged: canvas3d.caseColor = selectedColor
}
FpsDisplay {
anchors.left: parent.left
anchors.top: parent.top
width: 32
height: 64
fps: canvas3d.fps
}
}