summaryrefslogtreecommitdiffstats
path: root/examples/declarative/inputmethods/spellcheck/Key.qml
blob: d32c7453494adf0601f07365cdd40390147e803b (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
import QtQuick 2.0

Rectangle {
    property string text
    property string displayText
    property alias font: keyText.font
    property int key: 0

    id: root
    radius: 2

    width: 28
    height: 28

    gradient: Gradient {
        GradientStop { position: 0.0; color: "darkgrey" }
        GradientStop { position: 1.0; color: "grey" }
    }

    Text {
        id: keyText

        anchors.fill: parent

        horizontalAlignment: Text.AlignHCenter
        verticalAlignment: Text.AlignVCenter

        font.pixelSize: 18
        font.capitalization: keyboard.shift && displayText == "" ? Font.AllUppercase : Font.MixedCase

        text: root.displayText != "" ? root.displayText : root.text

        style: !mouseArea.pressed ? Text.Raised : Text.Normal
        color: "white"
        styleColor: "grey"
    }

    MouseArea {
        id: mouseArea

        anchors.fill: parent
        onPressed: keyboard.keyPress(key, text)
        onReleased: keyboard.keyRelease(key, text)
    }
}