Warning, /education/gcompris/src/activities/categorization/CategoryReview.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - CategoryReview.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 import QtQuick 2.12 0011 import GCompris 1.0 0012 0013 import "../../core" 0014 import "categorization.js" as Activity 0015 import "qrc:/gcompris/src/core/core.js" as Core 0016 0017 0018 Item { 0019 id: rootItem 0020 property alias score: score 0021 property alias categoryDataset: categoryDataset 0022 property alias instructionBox: instructionBox 0023 property alias categoryImage: categoryImage 0024 property bool isDropped: true 0025 property bool leftAreaContainsDrag: false 0026 property bool rightAreaContainsDrag: false 0027 property bool started: rootItem.opacity == 1 0028 property bool horizontalLayout: categoryBackground.width >= categoryBackground.height 0029 property alias leftZone: leftZone.model 0030 property alias rightZone: rightZone.model 0031 property alias middleZone: middleZone.model 0032 property alias leftScreen: leftScreen 0033 property alias middleScreen: middleScreen 0034 property alias rightScreen: rightScreen 0035 property int itemWidth: Core.fitItems(middleScreen.width * 0.95, middleScreen.height * 0.94, 12) 0036 property int zoneWidth: rootItem.width / 3 0037 property int zoneSpacing: 0.012 * middleScreen.width 0038 anchors.fill: parent 0039 0040 Loader { 0041 id: categoryDataset 0042 asynchronous: false 0043 } 0044 0045 Image { 0046 id: categoryBackground 0047 source: "qrc:/gcompris/src/activities/categorization/resource/background.svg" 0048 anchors.fill: parent 0049 sourceSize.width:parent.width 0050 0051 Zone { 0052 id: leftZone 0053 anchors.centerIn: leftScreen 0054 width: zoneWidth - zoneSpacing * 2 0055 height: parent.height - zoneSpacing * 2 0056 z: 2 0057 spacing: zoneSpacing 0058 } 0059 0060 Rectangle { 0061 id: leftScreen 0062 width: zoneWidth 0063 height: parent.height 0064 anchors.top: parent.top 0065 anchors.left: parent.left 0066 x: 0 0067 color: leftAreaContainsDrag ? "#F9F8B4" : "#F9B4B4" 0068 border.width: zoneSpacing 0069 border.color: "#EC1313" 0070 opacity: 0.5 0071 } 0072 0073 Zone { 0074 id: rightZone 0075 width: zoneWidth - zoneSpacing * 2 0076 spacing: zoneSpacing 0077 z: 2 0078 anchors.top: rightScreen.top 0079 anchors.bottom: rightScreen.bottom 0080 anchors.left: rightScreen.left 0081 anchors.leftMargin: zoneSpacing 0082 anchors.topMargin: rootItem.categoryImage.height + zoneSpacing * 2 0083 } 0084 0085 Rectangle { 0086 id: rightScreen 0087 width: zoneWidth 0088 height: parent.height 0089 anchors.top: parent.top 0090 anchors.right: parent.right 0091 color: rightAreaContainsDrag ? "#F9F8B4" : "#B4F9C5" 0092 border.width: zoneSpacing 0093 border.color: "#13EC52" 0094 opacity: 0.5 0095 } 0096 0097 Rectangle { 0098 id: middleScreen 0099 width: zoneWidth 0100 height: parent.height 0101 x: leftScreen.width 0102 color: "#00FFFFFF" 0103 } 0104 0105 Rectangle { 0106 id: instructionBox 0107 anchors.left: middleScreen.left 0108 anchors.right: middleScreen.right 0109 anchors.verticalCenter: middleScreen.verticalCenter 0110 color: "#373737" 0111 opacity: items.instructionsVisible ? 1 : 0 0112 z: 3 0113 radius: 10 0114 border.color: "#121212" 0115 border.width: 2 0116 height: parent.height * 0.3 0117 } 0118 0119 Zone { 0120 id: middleZone 0121 anchors.centerIn: middleScreen 0122 width: zoneWidth - zoneSpacing * 2 0123 height: parent.height - zoneSpacing * 2 0124 spacing: zoneSpacing 0125 z: 2 0126 } 0127 0128 GCText { 0129 id: instructions 0130 text: items.mode !== "expert" && items.details && items.details[bar.level-1] && items.details[bar.level - 1].instructions ? items.details[bar.level - 1].instructions : qsTr("Place the majority category images to the right and other images to the left") 0131 visible: items.instructionsVisible 0132 anchors.fill: instructionBox 0133 anchors.centerIn: instructionBox 0134 fontSizeMode: Text.Fit 0135 wrapMode: Text.Wrap 0136 z: 3 0137 color: "white" 0138 verticalAlignment: Text.AlignVCenter 0139 horizontalAlignment: Text.AlignHCenter 0140 } 0141 0142 Image { 0143 id: categoryImage 0144 fillMode: Image.PreserveAspectFit 0145 source: items.details && items.details[bar.level-1] && items.details[bar.level-1].image ? items.details[bar.level-1].image : "" 0146 sourceSize.width: itemWidth 0147 width: sourceSize.width 0148 height: sourceSize.width 0149 visible: items.categoryImageChecked 0150 anchors { 0151 top: rightScreen.top 0152 left: rightScreen.left 0153 topMargin: zoneSpacing 0154 leftMargin: zoneSpacing 0155 } 0156 } 0157 0158 BarButton { 0159 id: validate 0160 source: "qrc:/gcompris/src/core/resource/bar_ok.svg" 0161 width: bar.height * 0.8 0162 height: width 0163 sourceSize.width: width 0164 sourceSize.height: height 0165 enabled: items.okEnabled 0166 anchors { 0167 rightMargin: 14 * ApplicationInfo.ratio 0168 right: parent.right 0169 bottom: parent.bottom 0170 bottomMargin: 14 * ApplicationInfo.ratio 0171 } 0172 onClicked: { 0173 items.okEnabled = false; 0174 Activity.allPlaced(); 0175 } 0176 } 0177 0178 DropArea { 0179 id: rightArea 0180 anchors.fill: rightZone 0181 } 0182 0183 DropArea { 0184 id: leftArea 0185 anchors.fill: leftZone 0186 } 0187 0188 DialogHelp { 0189 id: dialogHelp 0190 onClose: home() 0191 } 0192 0193 Score { 0194 id: score 0195 visible: items.scoreChecked 0196 width: rightZone.width * 0.4 0197 height: width * 0.6 0198 margins: 10 * ApplicationInfo.ratio 0199 anchors { 0200 top: parent.top 0201 right: parent.right 0202 left: undefined 0203 bottom: undefined 0204 } 0205 } 0206 } 0207 0208 Keys.onEscapePressed: { Activity.launchMenuScreen(); } 0209 0210 Keys.onReleased: { 0211 if (event.key === Qt.Key_Back) { 0212 event.accepted = true 0213 Activity.launchMenuScreen() 0214 } 0215 } 0216 0217 function stop() { 0218 if(items.mode == "expert") 0219 items.menuScreen.iAmReady.visible = true 0220 focus = false 0221 rootItem.visible = false 0222 } 0223 0224 function start() { 0225 focus = true 0226 rootItem.visible = true 0227 } 0228 }