summaryrefslogtreecommitdiff
path: root/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/Indicator.qml
blob: 3ffab90ac9e239280357cb075f43d8d34c79a5c8 (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
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0

import QtQuick
import QtQuick.Templates as T
import StudioTheme 1.0 as StudioTheme

Item {
    id: control

    property StudioTheme.ControlStyle style: StudioTheme.Values.controlStyle

    property alias icon: icon
    property bool hover: mouseArea.containsMouse
    property bool pressed: mouseArea.pressed

    implicitWidth: control.style.squareControlSize.width
    implicitHeight: control.style.squareControlSize.height

    signal clicked
    z: 10

    T.Label {
        id: icon
        anchors.fill: parent
        text: StudioTheme.Constants.actionIcon
        color: control.style.icon.idle
        font.family: StudioTheme.Constants.iconFont.family
        font.pixelSize: control.style.baseIconFontSize
        verticalAlignment: Text.AlignVCenter
        horizontalAlignment: Text.AlignHCenter

        states: [
            State {
                name: "hover"
                when: control.hover && !control.pressed && control.enabled
                PropertyChanges {
                    target: icon
                    scale: 1.2
                    visible: true
                }
            },
            State {
                name: "disable"
                when: !control.enabled
                PropertyChanges {
                    target: icon
                    color: control.style.icon.disabled
                }
            }
        ]
    }

    MouseArea {
        id: mouseArea
        anchors.fill: parent
        hoverEnabled: true
        onClicked: control.clicked()
    }
}