Zhao Yuhang
2023-12-18 44fee9aa1e3087635d1394612c6f6ceab44ba7b0
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
import QtQuick 2.15
import QtQuick.Controls 2.15
 
Button {
    id: root
    width: height * 1.5
    property alias source: image.source
    contentItem: Item {
        anchors.fill: parent
 
        Image {
            id: image
            anchors.centerIn: parent
            mipmap: true
            width: 10
            height: 10
        }
    }
    background: Rectangle {
        anchors.fill: parent
        color: {
            if (!root.enabled) {
                return "gray";
            }
            if (root.pressed) {
                return Qt.rgba(0, 0, 0, 0.15);
            }
            if (root.hovered) {
                return Qt.rgba(0, 0, 0, 0.15);
            }
            return "transparent";
        }
    }
}