C

Qt Quick Ultralite Watch Demo

/****************************************************************************** ** ** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Quick Ultralite module. ** ** $QT_BEGIN_LICENSE:COMM$ ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** $QT_END_LICENSE$ ** ******************************************************************************/
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; } } } }