Warning, /education/marble/examples/cpp/marble-game/GamesView.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2014 Abhinav Gangwar <abhgang@gmail.com>
0004 //
0005 
0006 
0007 import QtQuick 2.0
0008 import QtQuick.Controls 1.2
0009 import QtQuick.Controls.Styles 1.2
0010 
0011 Rectangle {
0012     id: gamesDisplayPanel
0013     objectName: "gamesDisplayPanel"
0014 
0015     signal quitGame(int score)
0016     signal requestNextQuestion()
0017     signal requestAnswerDisplay()
0018 
0019     property int gamesDisplayWidth: 200
0020     property int gamesDisplayHeight: 600
0021     property alias currentIndex: gameView.currentIndex
0022 
0023     width: gamesDisplayWidth
0024     height: gamesDisplayHeight
0025 
0026     /*
0027      * The Model contains data for
0028      * UI for different types of available
0029      * games. Whenever user opts for a
0030      * particular game we switch the view
0031      * to that game. View is controlled by
0032      * ListView element defined below
0033      */
0034     VisualItemModel {
0035         id: gamesModel
0036 
0037         CountryByShape {
0038             id: countryByShapeGame
0039             panelWidth: gamesDisplayPanel.width
0040             panelHeight: gamesDisplayPanel.height
0041             onGameQuitRequested: {
0042                 quitGame(score);
0043             }
0044             onNextQuestionRequested: {
0045                 requestNextQuestion();
0046             }
0047         }
0048 
0049         CountryByFlag {
0050             id: countryByFlagGame
0051             panelWidth: gamesDisplayPanel.width
0052             panelHeight: gamesDisplayPanel.height
0053             onGameQuitRequested: {
0054                 quitGame(score);
0055             }
0056             onNextQuestionRequested: {
0057                 requestNextQuestion();
0058             }
0059         }
0060 
0061         ClickOnThat {
0062             id: clickOnThat
0063             panelWidth: gamesDisplayPanel.width
0064             panelHeight: gamesDisplayPanel.height
0065             onGameQuitRequested: {
0066                 quitGame(score);
0067             }
0068             onNextQuestionRequested: {
0069                 requestNextQuestion();
0070             }
0071             onAnswerDisplayRequested: {
0072                 requestAnswerDisplay();
0073             }
0074         }
0075     }
0076 
0077     /*
0078      * View to display game model
0079      */
0080     ListView {
0081         id: gameView
0082         objectName: "gameView"
0083         width: gamesDisplayPanel.width
0084         height: gamesDisplayPanel.height
0085         anchors.centerIn: parent
0086 
0087         model: gamesModel
0088         highlightMoveDuration: 250
0089         highlightRangeMode: ListView.StrictlyEnforceRange
0090 
0091         orientation: ListView.Vertical
0092     }
0093 
0094     /*
0095      * These are functions which tell a
0096      * particular type of game to display
0097      * the question data
0098      */
0099     function postCountryShapeQuestion( answerOptions, correctAnswer ) {
0100         gameView.currentItem.setQuestion( answerOptions, correctAnswer );
0101     }
0102 
0103     function postCountryFlagQuestion( answerOptions, imageSource, correctAnswer ) {
0104         gameView.currentItem.setQuestion( answerOptions, imageSource, correctAnswer );
0105     }
0106 
0107     function postClickOnThatQuestion( countryName ) {
0108         gameView.currentItem.setQuestion( countryName );
0109     }
0110 
0111     function initGame() {
0112         gameView.currentItem.initGame()
0113     }
0114 
0115     function displayResult( result ) {
0116         gameView.currentItem.displayResult( result )
0117     }
0118 
0119     function setMaximumQuestionsCounts( questionsCount ) {
0120         gameView.currentItem.setMaximumQuestions( questionsCount );
0121     }
0122 }