main.qml 4.96 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* GCompris - main.qml
 *
 * Copyright (C) 2014 Bruno Coudoin
 *
 * Authors:
 *   Bruno Coudoin <bruno.coudoin@gcompris.net>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
21
22
23
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Window 2.1
24
import QtMultimedia 5.0
25

26
27
import GCompris 1.0

28
Window {
29
30
31
    id: main
    width: 800
    height: 520
32
33
    minimumWidth: 600
    minimumHeight: 400
34
    title: "GCompris"
35

36
37
38
39
40
41
42
    Audio {
        id: audio
        source: "qrc:/gcompris/src/core/resource/intro.ogg"
        onError: console.log("intro play error: " + errorString)
        autoPlay: true
    }

43
44
45
    StackView {
        id: pageView
        anchors.fill: parent
46
        initialItem: "qrc:/gcompris/src/activities/" + ActivityInfoTree.rootMenu.name
47
        delegate: StackViewDelegate {
48
49
50
            id: root
            function getTransition(properties)
            {
51
52
53
54
55
                properties.exitItem.pause()
                if(!properties.exitItem.isDialog) {
                    properties.enterItem.start()
                }

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
                if(properties.name === "pushTransition") {
                    if(properties.enterItem.isDialog) {
                        return pushVTransition
                    } else {
                        return pushHTransition
                    }
                } else {
                    if(properties.exitItem.isDialog) {
                        return popVTransition
                    } else {
                        return popHTransition
                    }

                }
            }

72
73
74
75
76
77
            function transitionFinished(properties)
            {
                properties.exitItem.opacity = 1
                properties.enterItem.play()
                if(!properties.enterItem.isDialog) {
                    properties.exitItem.stop()
78
                }
79
80
81
            }

            property Component pushHTransition: StackViewTransition {
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
                PropertyAnimation {
                    target: enterItem
                    property: "x"
                    from: target.width
                    to: 0
                    duration: 500
                    easing.type: Easing.OutSine
                }
                PropertyAnimation {
                    target: exitItem
                    property: "x"
                    from: 0
                    to: -target.width
                    duration: 500
                    easing.type: Easing.OutSine
                }
            }
99
100

            property Component popHTransition: StackViewTransition {
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
                PropertyAnimation {
                    target: enterItem
                    property: "x"
                    from: -target.width
                    to: 0
                    duration: 500
                    easing.type: Easing.OutSine
                }
                PropertyAnimation {
                    target: exitItem
                    property: "x"
                    from: 0
                    to: target.width
                    duration: 500
                    easing.type: Easing.OutSine
116
117
                }
            }
118

119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
            property Component pushVTransition: StackViewTransition {
                PropertyAnimation {
                    target: enterItem
                    property: "y"
                    from: -target.height
                    to: 0
                    duration: 500
                    easing.type: Easing.OutSine
                }
                PropertyAnimation {
                    target: exitItem
                    property: "y"
                    from: 0
                    to: target.height
                    duration: 500
                    easing.type: Easing.OutSine
                }
            }

            property Component popVTransition: StackViewTransition {
                PropertyAnimation {
                    target: enterItem
                    property: "y"
                    from: target.height
                    to: 0
                    duration: 500
                    easing.type: Easing.OutSine
                }
                PropertyAnimation {
                    target: exitItem
                    property: "y"
                    from: 0
                    to: -target.height
                    duration: 500
                    easing.type: Easing.OutSine
154
155
                }
            }
156
157

            property Component replaceTransition: pushHTransition
158
159
160
        }
    }
}