Welcome to mirror list, hosted at ThFree Co, Russian Federation.

CustomTextButton.qml « tray « gui « src - github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9268b194deec0e5b5c2dc6998604597be0bc3b06 (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
import QtQuick 2.15
import QtQuick.Controls 2.3
import Style 1.0

Label {
    id: root

    property string toolTipText: ""
    property Action action: null
    property alias acceptedButtons: mouseArea.acceptedButtons
    property bool hovered: mouseArea.containsMouse

    height: implicitHeight

    property color textColor: Style.ncTextColor
    property color textColorHovered: Style.ncSecondaryTextColor

    Accessible.role: Accessible.Button
    Accessible.name: text
    Accessible.onPressAction: root.clicked(null)

    text: action ? action.text : ""
    textFormat: Text.PlainText
    enabled: !action || action.enabled
    onClicked: if (action) action.trigger()

    font.underline: true
    color: root.hovered ? root.textColorHovered : root.textColor
    horizontalAlignment: Text.AlignLeft
    verticalAlignment: Text.AlignVCenter
    elide: Text.ElideRight

    signal pressed(QtObject mouse)
    signal clicked(QtObject mouse)

    NCToolTip {
        text: root.toolTipText
        visible: root.toolTipText !== "" && root.hovered
    }

    MouseArea {
        id: mouseArea
        anchors.fill: parent
        hoverEnabled: true

        onClicked: root.clicked(mouse)
        onPressed: root.pressed(mouse)
    }
}