ca8eb43500d80c49fe992868ff9f3a10ca52936e
[profile/ivi/qtdeclarative.git] / tests / testapplications / elements / content / MouseAreaElement.qml
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
6 **
7 ** This file is part of the test suite of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 import QtQuick 2.0
43
44 Item {
45     id: mouseareaelementtest
46     anchors.fill: parent
47     property string testtext: ""
48     property int sidelength: 1500
49
50     focus: true
51     Rectangle {
52         id: mouseareaelementbox
53         color: "lightgray"; border.color: "gray"; radius: 5; clip: true; opacity: .7; height: 300; width: 300
54         anchors.centerIn: parent
55         MouseArea {
56             id: mouseareaelement
57             hoverEnabled: true
58             anchors.fill: parent
59         }
60         Rectangle {
61             id: topleft
62             height: 50; width: 50; color: metopleft.containsMouse ? "green" : "blue"
63             anchors { top: mouseareaelementbox.top; left: mouseareaelementbox.left; margins: 5 }
64             MouseArea {
65                 id: metopleft
66                 hoverEnabled: true
67                 anchors.fill: parent
68                 onContainsMouseChanged: { if (containsMouse && statenum == 1) { advance(); } }
69             }
70         }
71         Rectangle {
72             id: topright
73             height: 50; width: 50; color: metopright.containsMouse ? "green" : "blue"
74             anchors { top: mouseareaelementbox.top; right: mouseareaelementbox.right; topMargin: 5; rightMargin: 5 }
75             MouseArea {
76                 id: metopright
77                 hoverEnabled: true
78                 anchors.fill: parent
79                 onContainsMouseChanged: { if (containsMouse && statenum == 4) { advance(); } }
80             }
81         }
82         Rectangle {
83             id: bottomleft
84             height: 50; width: 50; color: mebottomleft.containsMouse ? "green" : "blue"
85             anchors { bottom: mouseareaelementbox.bottom; left: mouseareaelementbox.left; bottomMargin: 5; leftMargin: 5 }
86             MouseArea {
87                 id: mebottomleft
88                 hoverEnabled: true
89                 anchors.fill: parent
90                 onContainsMouseChanged: { if (containsMouse && statenum == 3) { advance(); } }
91             }
92         }
93         Rectangle {
94             id: bottomright
95             height: 50; width: 50; color: mebottomright.containsMouse ? "green" : "blue"
96             anchors { bottom: mouseareaelementbox.bottom; right: mouseareaelementbox.right; bottomMargin: 5; rightMargin: 5 }
97             MouseArea {
98                 id: mebottomright
99                 hoverEnabled: true
100                 anchors.fill: parent
101                 onContainsMouseChanged: { if (containsMouse && statenum == 2) { advance(); } }
102             }
103         }
104
105         Rectangle {
106             height: 10; width: 10; radius: 5; x: mouseareaelement.mouseX; y: mouseareaelement.mouseY; color: "red"
107         }
108
109     }
110
111     SystemTestHelp { id: helpbubble; visible: statenum != 0
112         anchors { top: parent.top; horizontalCenter: parent.horizontalCenter; topMargin: 50 }
113     }
114     BugPanel { id: bugpanel }
115
116     states: [
117         State { name: "start"; when: statenum == 1
118             PropertyChanges { target: helpbubble; showadvance: false }
119             PropertyChanges { target: mouseareaelementtest
120                 testtext: "This test contains a number of MouseArea elements. At present there should be four rectangles\n"+
121                 "Next, move the pointer to the top left of the square" }
122         },
123         State { name: "topleft"; when: statenum == 2
124             PropertyChanges { target: helpbubble; showadvance: false }
125             PropertyChanges { target: topleft; color: "yellow" }
126             PropertyChanges { target: mouseareaelementtest; testtext: "Good. Now move it down to the bottom right." }
127         },
128         State { name: "bottomright"; when: statenum == 3
129             PropertyChanges { target: helpbubble; showadvance: false }
130             PropertyChanges { target: bottomright; color: "yellow" }
131             PropertyChanges { target: mouseareaelementtest; testtext: "To the bottom left." }
132         },
133         State { name: "bottomleft"; when: statenum == 4
134             PropertyChanges { target: helpbubble; showadvance: false }
135             PropertyChanges { target: bottomleft; color: "yellow" }
136             PropertyChanges { target: mouseareaelementtest; testtext: "Then to top right" }
137         },
138         State { name: "topright"; when: statenum == 5
139             PropertyChanges { target: helpbubble; showadvance: false }
140             PropertyChanges { target: topright; color: "yellow" }
141             PropertyChanges { target: mouseareaelementtest
142                 testtext: "Excellent.\n"+
143                 "Modifiers test not yet defined." }
144         },
145         State { name: "modifiers"; when: statenum == 6
146             PropertyChanges { target: helpbubble; showadvance: true }
147             PropertyChanges { target: mouseareaelementtest
148                 testtext: "Test has completed\n"+
149                 "Advance to restart the test." }
150         }
151     ]
152
153 }