summaryrefslogtreecommitdiffstats
path: root/doc/Key.qml
blob: 6eb5ae027ec58552b0b57ecb4904e77257dfb7e2 (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
/* Copyright (C) 2015, Jaguar Land Rover. All Rights Reserved.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import QtQuick 2.0
import QtGraphicalEffects 1.0
import utils 1.0

Item {
    id: root

    width: 90
    height: 130

    property color color: Style.orangeViv
    property alias text: textItem.text
    property alias symbol: symbolItem.text
    property real fade: 0.16
    property string icon: ""

    signal clicked()

    Rectangle {
        id: keyRect
        anchors.fill: parent
        radius: 10
    }

    LinearGradient {
        anchors.fill: parent
        source: keyRect
        start: Qt.point(0, 0)
        end: Qt.point(0, 130)
        gradient: Gradient {
            GradientStop { position: 0.0; color: root.color }
            GradientStop { position: root.fade; color: Qt.darker(root.color, 2.0) }
            GradientStop { position: 0.8; color: "black" }
        }
    }

    Rectangle {
        anchors.fill: parent
        color: "transparent"
        radius: 10
        border.width: 4
        border.color: Style.orangeLt

        Text {
            id: symbolItem
            visible: icon === ""
            anchors.top: parent.top
            anchors.right: parent.right
            anchors.topMargin: 15
            anchors.rightMargin: 20
            font.pixelSize: 28
            font.family: "Source Sans Pro"
            color: "white"
        }

        Text {
            id: textItem
            visible: icon === ""
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 10
            font.pixelSize: 60
            font.family: "Source Sans Pro"
            color: "white"
        }

        Image {
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 30
            source: icon === "" ? icon : "images/" + icon + ".png"
        }
    }

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