File: ImageButton.qml

package info (click to toggle)
qflipper 1.3.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,320 kB
  • sloc: cpp: 18,500; sh: 247; ansic: 191; xml: 38; python: 14; makefile: 5
file content (53 lines) | stat: -rw-r--r-- 1,262 bytes parent folder | download | duplicates (2)
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
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Controls.impl 2.15

AbstractButton {
    id: control

    property string iconPath
    property string iconName

    icon.width: 20
    icon.height: 20

    implicitWidth: icon.width + padding * 2
    implicitHeight: icon.height + padding * 2

    opacity: enabled ? 1.0 : 0.5

    padding: 0

    background: Item {}

    contentItem: Item {
        width: control.icon.width
        height: control.icon.height

        IconImage {
            source: "%1/%2.svg".arg(iconPath).arg(iconName)
            sourceSize: Qt.size(control.icon.width, control.icon.height)
        }

        IconImage {
            source: "%1/%2_hover.svg".arg(iconPath).arg(iconName)
            sourceSize: Qt.size(control.icon.width, control.icon.height)

            opacity: control.hovered ? 1 : 0

            Behavior on opacity {
                PropertyAnimation {
                    duration: 200
                    easing.type: Easing.OutQuad
                }
            }
        }

        IconImage {
            source: "%1/%2_down.svg".arg(iconPath).arg(iconName)
            sourceSize: Qt.size(control.icon.width, control.icon.height)

            opacity: control.down ? 1 : 0
        }
    }
}