Update IconCheckBox

pull/19/head
reionwong 4 years ago
parent 5771c1e977
commit 8a8aa5f2e2

@ -31,7 +31,7 @@ Item {
property alias text: label.text property alias text: label.text
property bool checked: false property bool checked: false
property var iconSize: 104 property var iconSize: 106
signal clicked signal clicked
@ -43,59 +43,72 @@ Item {
ColumnLayout { ColumnLayout {
id: mainLayout id: mainLayout
anchors.fill: parent anchors.fill: parent
spacing: FishUI.Units.smallSpacing
Image { Rectangle {
id: icon id: _box
width: control.iconSize width: control.iconSize
height: width height: width
sourceSize: Qt.size(icon.width, icon.height) color: "transparent"
opacity: 1 border.width: 3
border.color: control.checked ? FishUI.Theme.highlightColor : "transparent"
layer.enabled: true
layer.effect: OpacityMask {
maskSource: Item {
width: icon.width
height: icon.height
Rectangle {
anchors.fill: parent
radius: FishUI.Theme.bigRadius
}
}
}
Behavior on opacity { Behavior on border.color {
NumberAnimation { ColorAnimation {
duration: 100 duration: 125
easing.type: Easing.InOutCubic easing.type: Easing.InOutCubic
} }
} }
MouseArea { radius: FishUI.Theme.bigRadius + control.iconSpacing
visible: true
Image {
id: icon
anchors.fill: parent anchors.fill: parent
hoverEnabled: true anchors.margins: FishUI.Units.smallSpacing
sourceSize: Qt.size(icon.width, icon.height)
opacity: 1
layer.enabled: true
layer.effect: OpacityMask {
maskSource: Item {
width: icon.width
height: icon.height
Rectangle {
anchors.fill: parent
radius: FishUI.Theme.bigRadius
}
}
}
onEntered: function() { Behavior on opacity {
icon.opacity = 0.8 NumberAnimation {
duration: 100
easing.type: Easing.InOutCubic
}
} }
onExited: function() {
icon.opacity = 1.0 MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: function() {
icon.opacity = 0.8
}
onExited: function() {
icon.opacity = 1.0
}
} }
} }
} }
Label { Label {
id: label id: label
color: control.checked ? FishUI.Theme.highlightColor : FishUI.Theme.textColor
visible: label.text visible: label.text
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
} }
RadioButton {
checkable: false
checked: control.checked
Layout.alignment: Qt.AlignHCenter
}
} }
Behavior on scale { Behavior on scale {

Loading…
Cancel
Save