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 controls the positioning and transitions of the configuration views */ Item { id: root function addHighscore() { highscoreView.addHighscore() } function setState(newState : string) { root.state = newState } signal startRequested() implicitWidth: Style.appSize implicitHeight: Style.appSize clip: true state: "Start" states: [ State { name: "Start" PropertyChanges { target: viewContainer; x: 0; y: 0 } }, State { name: "Config" PropertyChanges { target: viewContainer; x: 0; y: viewContainer.height } }, State { name: "Highscore" PropertyChanges { target: viewContainer; x: 0; y: -viewContainer.height } }, State { name: "Time" PropertyChanges { target: viewContainer; x: viewContainer.width; y: 0 } }, State { name: "Number" PropertyChanges { target: viewContainer; x: -viewContainer.width; y: 0 } } ] Item { id: viewContainer width: Style.appSize height: Style.appSize Behavior on x { NumberAnimation { duration: Globals.useViewAnimations ? Style.animationDuration : 0 } } Behavior on y { NumberAnimation { duration: Globals.useViewAnimations ? Style.animationDuration : 0 } } StartView { id: startView onSwipeDownTriggered: setState("Config") onSwipeUpTriggered: setState("Highscore") onSwipeLeftTriggered: setState("Number") onSwipeRightTriggered: setState("Time") onStartRequested: root.startRequested() } ConfigView { id: configView y: -height onSwipeTriggered: setState("Start") } HighscoreView { id: highscoreView y: height onSwipeTriggered: setState("Start") } TimeView { id: timeView x: -width onSwipeTriggered: setState("Start") } NumberView { id: numberView x: width onSwipeTriggered: setState("Start") } } }