Warning, /education/gcompris/src/activities/guesscount/Admin.qml is written in an unsupported language. File is not indexed.

0001 /* GCompris - Admin.qml
0002  *
0003  * SPDX-FileCopyrightText: 2016 RAHUL YADAV <rahulyadav170923@gmail.com>
0004  *
0005  * Authors:
0006  *   Pascal Georges <pascal.georges1@free.fr> (GTK+ version)
0007  *   RAHUL YADAV <rahulyadav170923@gmail.com> (Qt Quick port)
0008  *
0009  *   SPDX-License-Identifier: GPL-3.0-or-later
0010  */
0011 
0012 import QtQuick 2.12
0013 import "../../core"
0014 
0015 Row {
0016     id: admin
0017     spacing: 20
0018     property int level
0019     Rectangle {
0020         id: operator
0021         width: parent.width*0.23
0022         height: parent.height
0023         radius: 10.0;
0024         color: "#E6E6E6"
0025         state: "selected"
0026         GCText {
0027             anchors.horizontalCenter: parent.horizontalCenter
0028             anchors.verticalCenter: parent.verticalCenter
0029             fontSize: smallSize
0030             text: qsTr("Level %1").arg(level+1)
0031         }
0032     }
0033     Repeater {
0034         id: tileRepeater
0035         model: ['+','-','*','/']
0036         delegate: Rectangle {
0037             id: tile
0038             width: parent.width*0.15
0039             height: parent.height
0040             radius: 20
0041             state: activityConfiguration.adminLevelArr[level].indexOf(modelData) != -1 ? "selected" : "notselected"
0042 
0043             function refreshTile() {
0044                 if(activityConfiguration.adminLevelArr[level].indexOf(modelData) != -1) {
0045                     state = "selected"
0046                   }
0047                 else {
0048                     state = "notselected"
0049                 }
0050             }
0051             GCText {
0052                 anchors.horizontalCenter: parent.horizontalCenter
0053                 anchors.verticalCenter: parent.verticalCenter
0054                 text: modelData
0055                 fontSize: smallSize
0056             }
0057             MouseArea {
0058                 anchors.fill: parent
0059                 onClicked: {
0060                     if(tile.state == "selected") {
0061                         if(activityConfiguration.adminLevelArr[level].length > 1) {
0062                             tile.state = "notselected"
0063                             activityConfiguration.adminLevelArr[level].splice(activityConfiguration.adminLevelArr[level].indexOf(modelData), 1)
0064                         }
0065                     }
0066                     else {
0067                         tile.state = "selected"
0068                         activityConfiguration.adminLevelArr[level].push(modelData)
0069                     }
0070                 }
0071             }
0072             states: [
0073                 State {
0074                     name: "selected"
0075                     PropertyChanges { target: tile; color: "#5cc854" }
0076                 },
0077                 State {
0078                     name: "notselected"
0079                     PropertyChanges { target: tile; color: "#d94444" }
0080                 }
0081             ]
0082         }
0083     }
0084     function refreshAllTiles() {
0085        for(var i = 0; i < tileRepeater.count; i++) {
0086            tileRepeater.itemAt(i).refreshTile()
0087        }
0088     }
0089 }