summaryrefslogtreecommitdiff
path: root/x11-themes/redcore-theme-sddm/files/redcore/Components/RevealButton.qml
blob: 9c1afa5d387740c01181315eb6e6b78745a7e0e1 (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
import QtQuick 2.15
import QtQuick.Controls 2.15

Button {
    id: revealButton
    hoverEnabled: true
    width: 32
    height: 32

    x: passwordField.width - loginButton.width

    Text {
        id: revealText
        color: "black"
        text: String.fromCodePoint(0xe18b)
        font.family: Qt.resolvedUrl("../fonts") ? "Segoe MDL2 Assets" : iconfont.name
        font.pointSize: 10
        renderType: Text.NativeRendering
        anchors.centerIn: parent
    }

    background: Rectangle {
        id: revealButtonBackground
        color: "white"
    }

    states: [
        State {
            name: "on"
            when: revealButton.down
            PropertyChanges {
                target: passwordField
                echoMode: TextInput.Normal
            }
            PropertyChanges {
                target: passwordFieldPin
                echoMode: TextInput.Normal
            }
            PropertyChanges {
                target: revealButtonBackground
                color: config.color
            }
            PropertyChanges {
                target: revealText
                color: "white"
            }
        },
        State {
            name: "off"
            PropertyChanges {
                target: passwordField
                echoMode: TextInput.Password
            }
            PropertyChanges {
                target: passwordFieldPin
                echoMode: TextInput.Password
            }
        },
        State {
            name: "hovered"
            when: revealButton.hovered
            PropertyChanges {
                target: revealText
                color: config.color
            }
        }
    ]
}