summaryrefslogtreecommitdiffstats
path: root/basicsuite/qt5-cinematicdemo/content/DetailsView.qml
blob: b3ff9524e70624a15ff4b02def405c28181a0d8b (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
import QtQuick 2.0

Item {
    id: root

    property bool isShown: false
    property string image
    property string name
    property string year
    property string director
    property string cast
    property string overview
    property alias rating: ratingsItem.rating

    anchors.fill: parent
    opacity: 0
    visible: opacity
    scale: 0.3

    function show() {
        mainView.scheduleUpdate();
        root.isShown = true;
        showAnimation.restart();
    }
    function hide() {
        hideAnimation.restart();
    }

    Binding {
        target: mainView
        property: "blurAmount"
        value: 40 * root.opacity
        when: root.isShown
    }

    ParallelAnimation {
        id: showAnimation
        NumberAnimation { target: root; property: "opacity"; to: 1.0; duration: 500; easing.type: Easing.InOutQuad }
        NumberAnimation { target: root; property: "scale"; to: 1.0; duration: 500; easing.type: Easing.InOutQuad }
    }
    SequentialAnimation {
        id: hideAnimation
        ParallelAnimation {
            NumberAnimation { target: root; property: "opacity"; to: 0; duration: 500; easing.type: Easing.InOutQuad }
            NumberAnimation { target: root; property: "scale"; to: 0.3; duration: 500; easing.type: Easing.InOutQuad }
        }
        PropertyAction { target: root; property: "isShown"; value: false }
    }

    MouseArea {
        anchors.fill: parent
        onClicked: {
            root.hide();
        }
    }

    Rectangle {
        id: backgroundItem
        anchors.centerIn: parent
        width: Math.min(620, parent.width - 32)
        height: Math.min(840, parent.height - 32)
        border.color: "#808080"
        border.width: 1
        opacity: 0.9
        gradient: Gradient {
            GradientStop { position: 0.0; color: "#101010" }
            GradientStop { position: 0.3; color: "#404040" }
            GradientStop { position: 1.0; color: "#090909" }
        }
    }

    Flickable {
        anchors.top: backgroundItem.top
        anchors.left: backgroundItem.left
        anchors.right: backgroundItem.right
        anchors.bottom: bottomSeparator.top
        anchors.margins: 1
        anchors.bottomMargin: 0

        contentWidth: backgroundItem.width
        contentHeight: ratingsItem.y + descriptionTextItem.height + 64
        flickableDirection: Flickable.VerticalFlick
        clip: true

        Image {
            id: movieImageItem
            x: 8
            y: 24
            width: 192
            height: 192
            source: root.image ? "images/" + root.image : ""
            fillMode: Image.PreserveAspectFit
            smooth: true
        }

        Column {
            id: topColumn
            y: 20
            anchors.left: movieImageItem.right
            anchors.leftMargin: 10
            anchors.right: parent.right
            anchors.rightMargin: 26
            spacing: 8
            Text {
                id: titleTextItem
                width: parent.width
                wrapMode: Text.WordWrap
                color: "#ffffff"
                font.pixelSize: text.length < 12 ? settings.fontL  : settings.fontMM
                text: root.name
            }
            Text {
                id: yearTextItem
                width: parent.width
                wrapMode: Text.WordWrap
                color: "#ffffff"
                font.pixelSize: settings.fontS
                text: "<b>Published:</b> " + root.year
            }
            Text {
                id: directorsTextItem
                width: parent.width
                wrapMode: Text.WordWrap
                color: "#ffffff"
                font.pixelSize: settings.fontS
                text: "<b>Director:</b> " + root.director
            }
            Text {
                id: castTextItem
                width: parent.width
                wrapMode: Text.WordWrap
                color: "#ffffff"
                font.pixelSize: settings.fontS
                text: "<b>Cast:</b> " + root.cast
            }
        }

        RatingsItem {
            id: ratingsItem
            x: 10
            y: Math.max(topColumn.height, movieImageItem.height) + 40
            rating: root.rating
        }

        Text {
            id: descriptionTextItem
            anchors.top: ratingsItem.bottom
            anchors.topMargin: 16
            width: parent.width - 32
            anchors.horizontalCenter: parent.horizontalCenter
            wrapMode: Text.WordWrap
            color: "#ffffff"
            font.pixelSize: settings.fontM
            text: "<b>Description:</b> " + root.overview
        }
    }

    Rectangle {
        id: bottomSeparator
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.bottom: backgroundItem.bottom
        anchors.bottomMargin: 80
        width: backgroundItem.width - 16
        height: 1
        color: "#808080"
    }

    Button {
        anchors.bottom: backgroundItem.bottom
        anchors.bottomMargin: 8
        anchors.left: backgroundItem.left
        anchors.leftMargin: 32
        text: "Back"
        effectsOn: false
        onClicked: {
            root.hide();
        }
    }
    Button {
        anchors.bottom: backgroundItem.bottom
        anchors.bottomMargin: 8
        anchors.right: backgroundItem.right
        anchors.rightMargin: 32
        effectsOn: root.visible
        text: "Order"
        onClicked: {
            console.debug("Order! TODO: implement");
        }
    }
}