C
Qt Quick Ultralite Watch Demo
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
import QtQuick 2.15
import Watch 1.0
import QtQuickUltralite.Extras 2.0
import Benchmark 1.0
import QtQuickUltralite.Profiling
Rectangle {
id: window
color: Theme.backgroundColor
// The desktop platform requires to set the root item size to know the size
// of the main window
height: Theme.isDesktop ? Theme.appHeight : 0
width: Theme.isDesktop ? Theme.appWidth : 0
Rectangle {
height: Theme.appHeight
width: Theme.appWidth
anchors.centerIn: parent
color: Theme.backgroundColor
clip: true
WidgetsRow {
id: widgets
anchors.fill: parent
visible: !MainModel.compassOn
}
CompassWidget {
id: compass
visible: MainModel.compassOn
}
}
QulPerfOverlay {
id: benchmarkResult
anchors.horizontalCenter: parent.horizontalCenter;
anchors.verticalCenter: parent.verticalCenter;
visible: false
}
Timer {
id: benchmarkTimer
interval: 30000
running: true
repeat: false
onTriggered: {
simulationTimer.running = false
compass.visible = false
QulPerf.recording = false;
benchmarkResult.visible = true
}
}
Component.onCompleted: {
QulPerf.recording = true
}
property int simulationState: 0;
property int repetitionCount: 0;
property int flickDirection: 1;
Timer {
id: simulationTimer
interval: 2000
running: true
repeat: true
onTriggered: {
switch(simulationState) {
case 0:
if(!FlickControl.running()) {
FlickControl.startFlick(window.width/2, window.height/2, (flickDirection?1:-1)*10, 0);
if(++repetitionCount >= 3) {
repetitionCount = 0;
simulationState = 1;
simulationTimer.interval = 10;
}
}
break;
case 1:
if(!FlickControl.running()) {
FlickControl.startFlick(window.width/2, window.height/2, 0, (flickDirection?1:-1)*10);
flickDirection = 1 - flickDirection
if(++repetitionCount >= 12) {
repetitionCount = 0;
MainModel.compassOn = true;
simulationTimer.running = false;
}
}
break;
}
}
}
}