~baltix/gcompris-qt/0.97.1

« back to all changes in this revision

Viewing changes to src/activities/categorization/CategoryReview.qml

  • Committer: Mantas Kriaučiūnas
  • Date: 2020-07-06 18:07:11 UTC
  • Revision ID: baltix@gmail.com-20200706180711-g254osu02cn8bc8p
GCompris-QT 0.97.1 with Lithuanian translation

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GCompris - CategoryReview.qml
 
2
 *
 
3
 * Copyright (C) 2016 Divyam Madaan <divyam3897@gmail.com>
 
4
 *
 
5
 * Authors:
 
6
 *   Divyam Madaan <divyam3897@gmail.com>
 
7
 *
 
8
 *   This program is free software; you can redistribute it and/or modify
 
9
 *   it under the terms of the GNU General Public License as published by
 
10
 *   the Free Software Foundation; either version 3 of the License, or
 
11
 *   (at your option) any later version.
 
12
 *
 
13
 *   This program is distributed in the hope that it will be useful,
 
14
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 *   GNU General Public License for more details.
 
17
 *
 
18
 *   You should have received a copy of the GNU General Public License
 
19
 *   along with this program; if not, see <https://www.gnu.org/licenses/>.
 
20
 */
 
21
import QtQuick 2.6
 
22
import GCompris 1.0
 
23
 
 
24
import "../../core"
 
25
import "categorization.js" as Activity
 
26
 
 
27
Item {
 
28
    id: rootItem
 
29
    property alias score: score
 
30
    property alias categoryDataset: categoryDataset
 
31
    property alias instructionBox: instructionBox
 
32
    property alias categoryImage: categoryImage
 
33
    property bool isDropped: true
 
34
    property bool leftAreaContainsDrag: false
 
35
    property bool rightAreaContainsDrag: false
 
36
    property bool started: rootItem.opacity == 1
 
37
    property bool horizontalLayout: categoryBackground.width >= categoryBackground.height
 
38
    property alias leftZone: leftZone.model
 
39
    property alias rightZone: rightZone.model
 
40
    property alias middleZone: middleZone.model
 
41
    property alias leftScreen: leftScreen
 
42
    property alias middleScreen: middleScreen
 
43
    property alias rightScreen: rightScreen
 
44
    anchors.fill: parent
 
45
 
 
46
    Loader {
 
47
        id: categoryDataset
 
48
        asynchronous: false
 
49
    }
 
50
 
 
51
    Image {
 
52
        id: categoryBackground
 
53
        source: "qrc:/gcompris/src/activities/categorization/resource/background.svg"
 
54
        anchors.fill: parent
 
55
        sourceSize.width:parent.width
 
56
 
 
57
        Zone {
 
58
            id: leftZone
 
59
            x: 0.012 * middleScreen.width
 
60
            z: 2
 
61
            y: 0.05 * parent.height
 
62
            spacing: x
 
63
        }
 
64
 
 
65
        Rectangle {
 
66
            id: leftScreen
 
67
            width: parent.width/3
 
68
            height: parent.height
 
69
            x: 0
 
70
            color: leftAreaContainsDrag ? "#F9F8B4" : "#F9B4B4"
 
71
            border.width: 5
 
72
            border.color: "#EC1313"
 
73
            opacity: 0.5
 
74
        }
 
75
 
 
76
        Zone {
 
77
            id: rightZone
 
78
            spacing: leftZone.x
 
79
            x: leftScreen.width + middleScreen.width + spacing 
 
80
            z: 2
 
81
            anchors.top: categoryBackground.top
 
82
            anchors.topMargin: items.mode != "expert" ? rootItem.categoryImage.height + 0.027 * rightScreen.height : 0.05 * categoryBackground.height
 
83
        }
 
84
 
 
85
        Rectangle {
 
86
            id: rightScreen
 
87
            width: parent.width/3
 
88
            height: parent.height
 
89
            x: leftScreen.width + middleScreen.width
 
90
            color: rightAreaContainsDrag ? "#F9F8B4" : "#B4F9C5"
 
91
            border.width: 5
 
92
            border.color: "#13EC52"
 
93
            opacity: 0.5
 
94
        }
 
95
 
 
96
        Rectangle {
 
97
            id: middleScreen
 
98
            width: parent.width/3
 
99
            height: parent.height
 
100
            x: leftScreen.width
 
101
            color: "#00FFFFFF"
 
102
        }
 
103
 
 
104
        Rectangle {
 
105
            id: instructionBox
 
106
            anchors.left: categoryBackground.left
 
107
            anchors.right: categoryImage.left
 
108
            anchors.leftMargin: 0.32 * parent.width
 
109
            anchors.rightMargin: 0.03 * parent.width
 
110
            color: "black"
 
111
            opacity: items.instructionsVisible ? 0.85 : 0
 
112
            z: 3
 
113
            radius: 10
 
114
            border.width: 2
 
115
            width: horizontalLayout ? parent.width/5 : parent.width/3
 
116
            height: horizontalLayout ? parent.height/6 : parent.height * 0.09
 
117
            gradient: Gradient {
 
118
                GradientStop { position: 0.0; color: "#000" }
 
119
                GradientStop { position: 0.9; color: "#666" }
 
120
                GradientStop { position: 1.0; color: "#AAA" }
 
121
            }
 
122
        }
 
123
 
 
124
        Zone {
 
125
            id: middleZone
 
126
            spacing: 0.012 * middleScreen.width
 
127
            anchors {
 
128
                left: leftScreen.right
 
129
                right: rightScreen.left
 
130
                top: parent.top
 
131
                topMargin: 0.05 * parent.height
 
132
                bottom: categoryBackground.bottom
 
133
                leftMargin: 0.015 * middleScreen.width
 
134
            }
 
135
        }
 
136
 
 
137
        GCText {
 
138
            id: instructions
 
139
            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")
 
140
            visible: items.instructionsVisible
 
141
            anchors.fill: instructionBox
 
142
            anchors.bottom: instructionBox.bottom
 
143
            fontSizeMode: Text.Fit
 
144
            wrapMode: Text.Wrap
 
145
            z: 3
 
146
            color: "white"
 
147
            verticalAlignment: Text.AlignVCenter
 
148
            horizontalAlignment: Text.AlignHCenter
 
149
        }
 
150
 
 
151
        Image {
 
152
            id: categoryImage
 
153
            fillMode: Image.PreserveAspectFit
 
154
            source: items.details && items.details[bar.level-1] && items.details[bar.level-1].image ? items.details[bar.level-1].image : ""
 
155
            sourceSize.width: horizontalLayout ? rightZone.width * 0.35 : rightZone.width * 0.35
 
156
            width: sourceSize.width
 
157
            height: sourceSize.width
 
158
            y: 0.015*parent.height
 
159
            visible: items.categoryImageChecked
 
160
            anchors {
 
161
                left: middleScreen.right
 
162
                leftMargin: 0.15 * rightZone.width
 
163
            }
 
164
        }
 
165
 
 
166
        BarButton {
 
167
            id: validate
 
168
            source: "qrc:/gcompris/src/core/resource/bar_ok.svg"
 
169
            width: horizontalLayout ? rightZone.width * 0.20 : rightZone.width * 0.35
 
170
            height: width
 
171
            sourceSize.width: width
 
172
            sourceSize.height: height
 
173
            y: parent.height*0.8
 
174
            z: 2
 
175
            anchors {
 
176
                rightMargin: 14 * ApplicationInfo.ratio
 
177
                right: parent.right
 
178
            }
 
179
 
 
180
            MouseArea {
 
181
                anchors.fill: parent
 
182
                onClicked: {
 
183
                    Activity.allPlaced();
 
184
                }
 
185
            }
 
186
        }
 
187
 
 
188
        DropArea {
 
189
            id: rightArea
 
190
            anchors.fill: rightZone
 
191
        }
 
192
 
 
193
        DropArea {
 
194
            id: leftArea
 
195
            anchors.fill: leftZone
 
196
        }
 
197
 
 
198
        DialogHelp {
 
199
            id: dialogHelp
 
200
            onClose: home()
 
201
        }
 
202
        
 
203
        Score {
 
204
            id: score
 
205
            visible: items.scoreChecked
 
206
            width: rightZone.width * 0.4
 
207
            height: width * 0.6
 
208
            margins: 10 * ApplicationInfo.ratio
 
209
            anchors {
 
210
                top: parent.top
 
211
                right: parent.right
 
212
                left: undefined
 
213
                bottom: undefined
 
214
            }
 
215
        }
 
216
    }
 
217
 
 
218
    Keys.onEscapePressed: { Activity.launchMenuScreen(); }
 
219
 
 
220
    Keys.onReleased: {
 
221
        if (event.key === Qt.Key_Back) {
 
222
            event.accepted = true
 
223
            Activity.launchMenuScreen()
 
224
        }
 
225
    }
 
226
 
 
227
    function stop() {
 
228
        if(items.mode == "expert")
 
229
            items.menuScreen.iAmReady.visible = true
 
230
        focus = false
 
231
        rootItem.visible = false
 
232
    }
 
233
 
 
234
    function start() {
 
235
        focus = true
 
236
        rootItem.visible = true
 
237
    }
 
238
}