C

Qt Quick Ultralite swipe_game Demo

/****************************************************************************** ** ** Copyright (C) 2021 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.0 import StyleModule 1.0 /* This component is the root element of the SwipeGame demo. It doesn't have a width and height set so that Qt for MCU automatically resizes it. On MCUs it should be resized to the display size and on desktop to some default size. It passes the size to the Style.qml for UI scaling. In addition it controls the visibility of the configuration and game parts of the SwipeGame. The whole demo is meant to be displayed on a circular display. On a rectangular display the shorter dimension will be used as radius for the circular elements which be positioned at the center of the screen. */ Item { id: root onWidthChanged: resizeTimer.restart() onHeightChanged: resizeTimer.restart() // rectangular background required for rectangular displays Rectangle { anchors.fill: parent color: Style.colorAppBackground } ConfigContainer { id: configContainer anchors.centerIn: parent onStartRequested: { Globals.initGameData() visible = false gameContainer.visible = true } } GameContainer { id: gameContainer anchors.centerIn: parent visible: false onGameAborted: { if (Globals.fails === Globals.tries) { // if the game was played to the end, add a highscore configContainer.addHighscore() } visible = false configContainer.visible = true } } // use timer to avoid multiple resizes when width/height change quickly Timer { id: resizeTimer interval: 40 onTriggered: { Style.appSize = Math.min(root.width, root.height) } } }