feat(StatusCheckbox): introduced new `leftSide` prop

- `leftSide` determines whether to display check box on the left or right
side, defaulted to left
This commit is contained in:
Sale Djenic 2022-08-09 08:07:52 +02:00 committed by saledjenic
parent 9fa6fb2324
commit e1d8d934b3
2 changed files with 18 additions and 9 deletions

View File

@ -119,6 +119,9 @@ GridLayout {
}
StatusCheckBox {}
StatusCheckBox { checkState: Qt.Checked}
StatusCheckBox { text: "Check me on left side"}
StatusCheckBox { text: "Check me on right side"; leftSide: false}
StatusChatInfoButton {
title: "Iuri Matias"

View File

@ -8,15 +8,19 @@ import StatusQ.Components 0.1
CheckBox {
id: statusCheckBox
id: root
property bool leftSide: true
indicator: Rectangle {
anchors.left: root.leftSide? parent.left : undefined
anchors.right: !root.leftSide? parent.right : undefined
implicitWidth: 18
implicitHeight: 18
x: statusCheckBox.leftPadding
x: !root.leftSide? root.rightPadding : root.leftPadding
y: parent.height / 2 - height / 2
radius: 2
color: (statusCheckBox.down || statusCheckBox.checked) ? Theme.palette.primaryColor1
color: (root.down || root.checked) ? Theme.palette.primaryColor1
: Theme.palette.directColor8
StatusIcon {
@ -26,19 +30,21 @@ CheckBox {
anchors.centerIn: parent
anchors.horizontalCenterOffset: 1
color: Theme.palette.white
visible: statusCheckBox.down || statusCheckBox.checked
visible: root.down || root.checked
}
}
contentItem: StatusBaseText {
text: statusCheckBox.text
font.pixelSize: statusCheckBox.font.pixelSize
text: root.text
font.pixelSize: root.font.pixelSize
opacity: enabled ? 1.0 : 0.3
verticalAlignment: Text.AlignVCenter
wrapMode: Text.WordWrap
width: parent.width
color: Theme.palette.directColor1
leftPadding: !!statusCheckBox.text ? statusCheckBox.indicator.width + statusCheckBox.spacing
: statusCheckBox.indicator.width
leftPadding: root.leftSide? (!!root.text ? root.indicator.width + root.spacing
: root.indicator.width) : 0
rightPadding: !root.leftSide? (!!root.text ? root.indicator.width + root.spacing
: root.indicator.width) : 0
}
}