aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/quickcontrols/styles-cover-flow/CoverFlowDelegate.qml
blob: 9fabbd60deed140944ecad4eea82e9ceaf056003 (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
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

import QtGraphicalEffects
import QtQuick

Item {
    id: root
    width: PathView.view.delegateSize
    height: width
    z: PathView.zOrder

    transform: [
        Rotation {
            angle: root.PathView.rotateY
            origin.x: sourceImage.width / 2
            origin.y: sourceImage.height * 0.3
            axis.x: 0
            axis.y: 1
            axis.z: 0
        },
        Scale {
            xScale: 1.0
            yScale: root.PathView.scale
            origin.x: sourceImage.width / 2
            origin.y: sourceImage.height * 0.4
        }
    ]

    Image {
        id: sourceImage
        width: root.PathView.view.delegateSize
        height: width
        fillMode: Image.PreserveAspectFit
        source: "file:/" + docImagesDir + model.source

        Rectangle {
            x: (sourceImage.width - sourceImage.paintedWidth) / 2
            width: sourceImage.paintedWidth + (index == 6 ? 2 : 1)
            height: sourceImage.height
            color: "transparent"
            border.color: "#f4f4f4"
            antialiasing: true
            visible: !model.dark
        }
    }

    ShaderEffectSource {
        id: reflection
        sourceItem: sourceImage
        y: sourceItem.height
        width: sourceItem.width
        height: sourceItem.height

        transform: [
            Rotation {
                origin.x: reflection.width / 2
                origin.y: reflection.height / 2
                axis.x: 1
                axis.y: 0
                axis.z: 0
                angle: 180
            }
        ]
    }

    Rectangle {
        objectName: sourceImage.source.toString().slice(-20)
        x: (parent.width - sourceImage.paintedWidth) / 2// + (paintedWidthDiff > 0 ? 1.0 - paintedWidthDiff : 0)
        y: reflection.y
        width: sourceImage.paintedWidth + (index == 6 ? 2 : 1)
        height: sourceImage.paintedHeight

        // TODO: figure out how to get perfect x/width without using the current width hack
//        readonly property real paintedWidthDiff: sourceImage.paintedWidth - Math.floor(sourceImage.paintedWidth)

        gradient: Gradient {
            GradientStop {
                position: 0.0
                color: Qt.rgba(backgroundColor.r, backgroundColor.g, backgroundColor.b, 0.33)
            }
            GradientStop {
                // This determines the point at which the reflection fades out.
                position: 1.0
                color: backgroundColor
            }
        }
    }
}