Warning, /education/gcompris/src/activities/traffic/Traffic.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - Traffic.qml 0002 * 0003 * SPDX-FileCopyrightText: 2014 Holger Kaelberer <holger.k@elberer.de> 0004 * 0005 * Authors: 0006 * Bruno Coudoin <bruno.coudoin@gcompris.net> (GTK+ version) 0007 * Holger Kaelberer <holger.k@elberer.de> (Qt Quick port) 0008 * 0009 * SPDX-License-Identifier: GPL-3.0-or-later 0010 */ 0011 0012 import QtQuick 2.12 0013 import GCompris 1.0 0014 0015 import "../../core" 0016 import "traffic.js" as Activity 0017 0018 ActivityBase { 0019 id: activity 0020 0021 onStart: focus = true 0022 onStop: {} 0023 0024 pageComponent: Rectangle { 0025 id: background 0026 color: "#64B560" 0027 0028 signal start 0029 signal stop 0030 0031 property string mode: "IMAGE" // allow to choose between "COLOR" and "IMAGE" 0032 Component.onCompleted: { 0033 dialogActivityConfig.initialize() 0034 activity.start.connect(start) 0035 activity.stop.connect(stop) 0036 } 0037 0038 QtObject { 0039 id: items 0040 property Item main: activity.main 0041 property GCSfx audioEffects: activity.audioEffects 0042 property alias background: background 0043 property int currentLevel: activity.currentLevel 0044 property alias bonus: bonus 0045 property alias score: score 0046 property alias jamBox: jamBox 0047 property alias jamGrid: jamGrid 0048 property bool isVertical: background.width < background.height - 64 * ApplicationInfo.ratio 0049 } 0050 0051 onStart: { Activity.start(items, mode) } 0052 onStop: { Activity.stop() } 0053 0054 Rectangle { 0055 color: "#9EC282" 0056 width: jamBox.width * 1.075 0057 height: width 0058 radius: width * 0.15 0059 anchors.centerIn: jamBox 0060 } 0061 Rectangle { 0062 color: "#9EC282" 0063 width: background.width * 0.5 0064 height: jamBox.height * 0.2 0065 anchors.left: jamBox.horizontalCenter 0066 anchors.verticalCenter: outsideRoad.verticalCenter 0067 } 0068 Rectangle { 0069 id: outsideRoad 0070 color: "#444444" 0071 width: background.width * 0.5 0072 height: jamBox.height * 0.125 0073 anchors.left: jamBox.horizontalCenter 0074 anchors.bottom: jamBox.verticalCenter 0075 } 0076 0077 Image { 0078 id: jamBox 0079 source: "qrc:/gcompris/src/activities/traffic/resource/jamBox.svg" 0080 width: parent.height - 64 * ApplicationInfo.ratio 0081 height: width 0082 sourceSize.width: width 0083 sourceSize.height: height 0084 anchors.horizontalCenter: background.horizontalCenter 0085 states: [ 0086 State { 0087 name: "verticalLayout" 0088 when: items.isVertical 0089 PropertyChanges { 0090 target: jamBox 0091 width: parent.width 0092 } 0093 AnchorChanges { 0094 target: jamBox 0095 anchors.top: undefined 0096 anchors.verticalCenter: background.verticalCenter 0097 } 0098 }, 0099 State { 0100 name: "horizontalLayout" 0101 when: !items.isVertical 0102 PropertyChanges { 0103 target: jamBox 0104 width: parent.height - 64 * ApplicationInfo.ratio 0105 } 0106 AnchorChanges { 0107 target: jamBox 0108 anchors.top: parent.top 0109 anchors.verticalCenter: undefined 0110 } 0111 } 0112 ] 0113 0114 Grid { 0115 id: jamGrid 0116 anchors.centerIn: parent 0117 width: parent.width * 0.75 0118 height: width 0119 columns: 6 0120 rows: 6 0121 spacing: 0 0122 // Add an alias to mode so it can be used on Car items 0123 property alias mode: background.mode 0124 Repeater { 0125 id: gridRepeater 0126 model: jamGrid.columns * jamGrid.rows 0127 0128 delegate: Rectangle { 0129 id: gridDelegate 0130 height: jamGrid.height / jamGrid.rows 0131 width: height 0132 border.width: 1 0133 border.color: "#A2A2A2" 0134 color: "transparent" 0135 } 0136 } 0137 } 0138 } 0139 0140 DialogHelp { 0141 id: dialogHelp 0142 onClose: home() 0143 } 0144 0145 DialogChooseLevel { 0146 id: dialogActivityConfig 0147 currentActivity: activity.activityInfo 0148 0149 onClose: { 0150 home() 0151 } 0152 onLoadData: { 0153 if(activityData && activityData["mode"]) { 0154 background.mode = activityData["mode"]; 0155 } 0156 } 0157 } 0158 0159 Bar { 0160 id: bar 0161 level: items.currentLevel + 1 0162 content: BarEnumContent { value: help | home | level | reload | activityConfig } 0163 onHelpClicked: { 0164 displayDialog(dialogHelp) 0165 } 0166 onPreviousLevelClicked: Activity.previousLevel() 0167 onNextLevelClicked: Activity.nextLevel() 0168 onHomeClicked: activity.home() 0169 onReloadClicked: Activity.initLevel() 0170 onActivityConfigClicked: { 0171 displayDialog(dialogActivityConfig) 0172 } 0173 } 0174 0175 Bonus { 0176 id: bonus 0177 Component.onCompleted: win.connect(Activity.nextLevel) 0178 } 0179 0180 Score { 0181 id: score 0182 anchors.top: parent.top 0183 anchors.topMargin: 10 * ApplicationInfo.ratio 0184 anchors.right: parent.right 0185 anchors.rightMargin: 10 * ApplicationInfo.ratio 0186 anchors.bottom: undefined 0187 onStop: Activity.nextSubLevel() 0188 } 0189 } 0190 }