summaryrefslogtreecommitdiffstats
path: root/multilayer-dashboard/TapWidget.qml
blob: e3442ccab8604e3d02cb8c45a6d1ff7b5583f0b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import Qt 4.7
import Qt.labs.gestures 1.0

Rectangle {
    id: testWidget
    width: 160
    height: 160
    property alias color: innerWidget.color
    property variant reparentWidget : testWidget

    Rectangle {
	id: innerWidget
	color: "steelblue"
	radius: 10
	opacity: 0.3
	anchors.fill: testWidget

	property bool fullScreen : false

	Text {
	    id: labelText
	    text: "Press me, Hold me!!!"
	    anchors.centerIn: parent
	}

	MouseArea {
	    anchors.fill: parent
	    hoverEnabled: true
	    onEntered: { if (!innerWidget.fullScreen) parent.opacity = 0.8 }
	    onExited: { if (!innerWidget.fullScreen) parent.opacity = 0.3 }
	}

	GestureArea {
	    id: tapGestureArea
	    anchors.fill: parent
	    TapAndHold {
                onFinished: {
		    if (!innerWidget.fullScreen) {
                        innerWidget.opacity = 1.0

			innerWidget.fullScreen = true

                        innerWidget.parent = testWidget.reparentWidget
                        innerWidget.anchors.fill = testWidget.reparentWidget
			labelText.text = "Full Screen Widget"
		    }
		    else {
			innerWidget.parent = testWidget
			innerWidget.anchors.fill = testWidget
			innerWidget.fullScreen = false
			labelText.text = "Press me, Hold me!!!"
		    }
		}
	    }
	}
    }
}