C

Qt Quick Ultralite滑动游戏演示

/****************************************************************************** ** ** 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 view displays the game's starting value and provides a switch to change the game mode. It will start the game automatically if the mode wasn't changes for specific amount of time. */ BaseView { id: root signal gameStarted() onVisibleChanged: { if (visible) { delayTimer.restart() } else { delayTimer.stop() } } Text { id: userHint anchors { top: parent.top topMargin: Style.marginDefault horizontalCenter: parent.horizontalCenter } font: Style.textFontSmall color: Style.colorLightText text: "longpress to stop" } Text { id: questionText anchors { top: userHint.bottom topMargin: Style.marginDefault horizontalCenter: parent.horizontalCenter } font: Style.textFontDefault color: Style.colorText text: "Start Value" } Text { id: startValue anchors.centerIn: parent font: Globals.isNumberMode() ? Style.textFontBig : Style.textFontDefault color: Style.colorText text: Globals.isNumberMode() ? Globals.gameStartNumber : Globals.gameStartCountry } LabeledSwitch { id: modeSwitch anchors { bottom: parent.bottom bottomMargin: Style.marginBig horizontalCenter: parent.horizontalCenter } text: "Mode" font: Style.textFontSmall checked: Globals.isNumberMode() onTriggered: { Globals.switchGameMode() delayTimer.restart() } } Timer { id: delayTimer interval: Style.gameStartDelay onTriggered: { Globals.requestNewValue() root.gameStarted() } } }