summaryrefslogtreecommitdiffstats
path: root/examples/demos/calqlatr/content/CalculatorButton.qml
blob: 12a66784f9e01a5469e8d450d29f1da4cfe1b2bb (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
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Controls

Button {
    id: button
    property bool dimmable: false
    property bool dimmed: false
    property color textColor: "#eceeea"

    width: 30
    height: 50
    contentItem: Text {
        text: button.text
        font.pixelSize: 48
        wrapMode: Text.WordWrap
        lineHeight: 0.75
        color: (button.dimmable && button.dimmed) ? Qt.darker(button.textColor) : button.textColor
        Behavior on color {
            ColorAnimation {
                duration: 120
                easing.type: Easing.OutElastic
            }
        }
        states: [
            State {
                name: "pressed"
                when: button.pressed && !button.dimmed
                PropertyChanges {
                    target: button.contentItem
                    color: Qt.lighter(button.textColor)
                }
            }
        ]
    }

    background: null
}