2019-08-18 03:01:43 +10:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
import "../utils.js" as Utils
|
|
|
|
|
|
|
|
CheckBox {
|
|
|
|
id: box
|
|
|
|
spacing: theme.spacing
|
2019-08-21 18:46:40 +10:00
|
|
|
leftPadding: spacing / 1.5
|
|
|
|
rightPadding: spacing / 1.5
|
|
|
|
topPadding: spacing / 2
|
|
|
|
bottomPadding: spacing / 2
|
2019-08-21 08:31:20 +10:00
|
|
|
opacity: enabled ? 1 : theme.disabledElementsOpacity
|
|
|
|
|
|
|
|
|
|
|
|
Behavior on opacity { HNumberAnimation { factor: 2 } }
|
2019-08-18 03:01:43 +10:00
|
|
|
|
|
|
|
|
|
|
|
indicator: Rectangle {
|
|
|
|
implicitWidth: implicitHeight
|
|
|
|
implicitHeight: box.contentItem.font.pixelSize * 1.5
|
|
|
|
x: box.leftPadding
|
|
|
|
y: box.topPadding + box.availableHeight / 2 - height / 2
|
|
|
|
radius: theme.radius / 1.5
|
|
|
|
|
2019-08-21 08:31:20 +10:00
|
|
|
color: theme.controls.checkBox.boxBackground
|
|
|
|
border.color:
|
|
|
|
box.enabled && box.pressed ?
|
|
|
|
theme.controls.checkBox.boxPressedBorder :
|
|
|
|
|
|
|
|
(box.enabled && box.hovered) || box.visualFocus ?
|
|
|
|
theme.controls.checkBox.boxHoveredBorder :
|
|
|
|
|
|
|
|
theme.controls.checkBox.boxBorder
|
2019-08-18 03:01:43 +10:00
|
|
|
|
|
|
|
Behavior on border.color { HColorAnimation { factor: 0.5 } }
|
|
|
|
|
|
|
|
HIcon {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
dimension: parent.width - 2
|
|
|
|
svgName: "check-mark"
|
2019-08-29 06:30:48 +10:00
|
|
|
colorize: theme.controls.checkBox.checkIconColorize
|
2019-08-18 03:01:43 +10:00
|
|
|
|
|
|
|
visible: scale > 0
|
|
|
|
scale: box.checked ? 1 : 0
|
2019-08-18 03:35:43 +10:00
|
|
|
Behavior on scale {
|
|
|
|
HNumberAnimation {
|
|
|
|
overshoot: 4
|
|
|
|
easing.type: Easing.InOutBack
|
|
|
|
}
|
|
|
|
}
|
2019-08-18 03:01:43 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: HLabel {
|
|
|
|
text: box.text
|
2019-08-21 08:31:20 +10:00
|
|
|
color: theme.controls.checkBox.text
|
2019-08-18 03:01:43 +10:00
|
|
|
|
|
|
|
// Set a width on CheckBox for wrapping to work, e.g. Layout.fillWidth
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
leftPadding: box.indicator.width + box.spacing
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
}
|
|
|
|
}
|