checkbox redesign

This commit is contained in:
Jaquee 2017-08-06 18:12:37 +02:00
parent 0e6028aacf
commit 085dfe114a

View file

@ -29,61 +29,70 @@
import QtQuick 2.0 import QtQuick 2.0
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
Item { RowLayout {
id: checkBox id: checkBox
property alias text: label.text property alias text: label.text
property string checkedIcon property string checkedIcon
property string uncheckedIcon property string uncheckedIcon
property bool checked: false property bool checked: false
property alias background: backgroundRect.color property alias background: backgroundRect.color
property int fontSize: 14 property int fontSize: 14 * scaleRatio
property alias fontColor: label.color property alias fontColor: label.color
signal clicked() signal clicked()
height: 25 height: 25 * scaleRatio
width: label.x + label.width
Layout.minimumWidth: label.x + label.contentWidth
clip: true
Rectangle { function toggle(){
anchors.left: parent.left checkBox.checked = !checkBox.checked
height: parent.height - 1 checkBox.clicked()
width: 25
//radius: 4
y: 0
color: "#DBDBDB"
} }
Rectangle { RowLayout {
id: backgroundRect Layout.fillWidth: true
anchors.left: parent.left Rectangle {
height: parent.height - 1 anchors.left: parent.left
width: 25 width: 25 * scaleRatio
//radius: 4 height: checkBox.height - 1
y: 1 //radius: 4
color: "#FFFFFF" y: 0
color: "#DBDBDB"
Image {
anchors.centerIn: parent
source: checkBox.checked ? checkBox.checkedIcon :
checkBox.uncheckedIcon
} }
}
Text { Rectangle {
id: label id: backgroundRect
anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left
anchors.left: parent.left width: 25 * scaleRatio
anchors.leftMargin: 25 + 12 height: checkBox.height - 1
font.family: "Arial" //radius: 4
font.pixelSize: checkBox.fontSize y: 1
color: "#525252" color: "#FFFFFF"
}
MouseArea { Image {
anchors.fill: parent anchors.centerIn: parent
onClicked: { source: checkBox.checked ? checkBox.checkedIcon :
checkBox.checked = !checkBox.checked checkBox.uncheckedIcon
checkBox.clicked() }
MouseArea {
anchors.fill: parent
onClicked: {
toggle()
}
}
}
Text {
id: label
font.family: "Arial"
font.pixelSize: checkBox.fontSize
color: "#525252"
wrapMode: Text.Wrap
Layout.fillWidth: true
MouseArea {
anchors.fill: parent
onClicked: {
toggle()
}
}
} }
} }
} }