Warning, /education/gcompris/src/activities/categorization/Categorization.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - categorization.qml 0002 * 0003 * SPDX-FileCopyrightText: 2016 Divyam Madaan <divyam3897@gmail.com> 0004 * 0005 * Authors: 0006 * Divyam Madaan <divyam3897@gmail.com> 0007 * 0008 * SPDX-License-Identifier: GPL-3.0-or-later 0009 */ 0010 0011 import QtQuick 2.12 0012 import GCompris 1.0 0013 0014 import "../../core" 0015 import "categorization.js" as Activity 0016 import "qrc:/gcompris/src/core/core.js" as Core 0017 import "." 0018 0019 ActivityBase { 0020 id: activity 0021 0022 onStart: focus = true 0023 onStop: {} 0024 0025 property bool vert: background.width <= background.height 0026 0027 pageComponent: Image { 0028 id: background 0029 source: "qrc:/gcompris/src/activities/guesscount/resource/backgroundW01.svg" 0030 anchors.fill: parent 0031 sourceSize.width: parent.width 0032 signal start 0033 signal stop 0034 0035 Component.onCompleted: { 0036 dialogActivityConfig.initialize() 0037 activity.start.connect(start) 0038 activity.stop.connect(stop) 0039 } 0040 0041 // Add here the QML items you need to access in javascript 0042 QtObject { 0043 id: items 0044 property Item main: activity.main 0045 property alias background: background 0046 property int currentLevel: activity.currentLevel 0047 property alias bonus: bonus 0048 property alias categoryReview: categoryReview 0049 property alias menuScreen: menuScreen 0050 property alias menuModel: menuScreen.menuModel 0051 property alias dialogActivityConfig: dialogActivityConfig 0052 property string mode: "easy" 0053 property bool instructionsVisible: true 0054 property bool categoryImageChecked: (mode === "easy" || mode === "medium") 0055 property bool scoreChecked: (mode === "easy" || mode === "expert") 0056 property bool iAmReadyChecked: (mode === "expert") 0057 property bool displayUpdateDialogAtStart: true 0058 property var details 0059 property bool categoriesFallback 0060 property alias file: file 0061 property var categories: activity.datasetLoader.data 0062 property bool okEnabled: true 0063 } 0064 0065 onStart: { 0066 Activity.init(items) 0067 Activity.start() 0068 } 0069 0070 MenuScreen { 0071 id: menuScreen 0072 0073 File { 0074 id: file 0075 onError: console.error("File error: " + msg); 0076 } 0077 } 0078 0079 Rectangle { 0080 id: categoryArea 0081 color: "#00ffffff" 0082 anchors.top: background.top 0083 anchors.bottom: bar.top 0084 anchors.left: background.left 0085 anchors.right: background.right 0086 anchors.bottomMargin: bar.height * 0.2 0087 CategoryReview { 0088 id: categoryReview 0089 } 0090 } 0091 0092 DialogChooseLevel { 0093 id: dialogActivityConfig 0094 currentActivity: activity.activityInfo 0095 0096 onLoadData: { 0097 if(activityData && activityData["mode"]) 0098 items.mode = activityData["mode"] 0099 if(activityData && activityData["displayUpdateDialogAtStart"] !== undefined) 0100 items.displayUpdateDialogAtStart = (activityData["displayUpdateDialogAtStart"] === "true") ? true : false 0101 } 0102 0103 onSaveData: { 0104 activityData["displayUpdateDialogAtStart"] = items.displayUpdateDialogAtStart 0105 levelFolder = dialogActivityConfig.chosenLevels 0106 currentActivity.currentLevels = dialogActivityConfig.chosenLevels 0107 ApplicationSettings.setCurrentLevels(currentActivity.name, dialogActivityConfig.chosenLevels) 0108 } 0109 0110 onStartActivity: { 0111 items.mode = activityData["mode"] 0112 items.menuScreen.iAmReady.visible = (activityData["mode"] === "expert") ? true : false; 0113 background.stop(); 0114 background.start() 0115 } 0116 onClose: home() 0117 } 0118 0119 DialogHelp { 0120 id: dialogHelp 0121 onClose: home() 0122 } 0123 0124 Bar { 0125 id: bar 0126 level: items.currentLevel + 1 0127 content: menuScreen.started ? withConfig : withoutConfig 0128 property BarEnumContent withConfig: BarEnumContent { value: help | home | activityConfig} 0129 property BarEnumContent withoutConfig: BarEnumContent { value: home | level } 0130 onPreviousLevelClicked: Activity.previousLevel() 0131 onNextLevelClicked: Activity.nextLevel() 0132 onHelpClicked: { 0133 displayDialog(dialogHelp) 0134 } 0135 onHomeClicked: { 0136 if(items.menuScreen.started) 0137 activity.home() 0138 else if(items.categoryReview.started) 0139 Activity.launchMenuScreen() 0140 } 0141 onActivityConfigClicked: { 0142 displayDialog(dialogActivityConfig) 0143 } 0144 } 0145 0146 Bonus { 0147 id: bonus 0148 Component.onCompleted: win.connect(Activity.nextLevel) 0149 onStop: items.okEnabled = true 0150 } 0151 0152 Loader { 0153 id: categoriesFallbackDialog 0154 sourceComponent: GCDialog { 0155 parent: activity.main 0156 isDestructible: false 0157 message: qsTr("You don't have all the images for this activity. " + 0158 "Click on 'Update the image set' to download the full word image set. " + 0159 "Click on the cross or on 'Never show this dialog again' to play with the demo version.") 0160 button1Text: qsTr("Update the image set") 0161 button2Text: qsTr("Never show this dialog again") 0162 onClose: items.categoriesFallback = false 0163 onButton1Hit: DownloadManager.downloadResource(GCompris.WORDSET) 0164 onButton2Hit: { items.displayUpdateDialogAtStart = false; items.dialogActivityConfig.saveData()} 0165 } 0166 anchors.fill: parent 0167 focus: true 0168 active: items.categoriesFallback && items.displayUpdateDialogAtStart && ApplicationInfo.isDownloadAllowed; 0169 onStatusChanged: if (status == Loader.Ready) item.start() 0170 } 0171 } 0172 }