checkbox redesign

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

View File

@@ -29,25 +29,29 @@
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
function toggle(){
checkBox.checked = !checkBox.checked
checkBox.clicked()
}
RowLayout {
Layout.fillWidth: true
Rectangle { Rectangle {
anchors.left: parent.left anchors.left: parent.left
height: parent.height - 1 width: 25 * scaleRatio
width: 25 height: checkBox.height - 1
//radius: 4 //radius: 4
y: 0 y: 0
color: "#DBDBDB" color: "#DBDBDB"
@@ -56,8 +60,8 @@ Item {
Rectangle { Rectangle {
id: backgroundRect id: backgroundRect
anchors.left: parent.left anchors.left: parent.left
height: parent.height - 1 width: 25 * scaleRatio
width: 25 height: checkBox.height - 1
//radius: 4 //radius: 4
y: 1 y: 1
color: "#FFFFFF" color: "#FFFFFF"
@@ -67,23 +71,28 @@ Item {
source: checkBox.checked ? checkBox.checkedIcon : source: checkBox.checked ? checkBox.checkedIcon :
checkBox.uncheckedIcon checkBox.uncheckedIcon
} }
}
Text {
id: label
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 25 + 12
font.family: "Arial"
font.pixelSize: checkBox.fontSize
color: "#525252"
}
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
checkBox.checked = !checkBox.checked toggle()
checkBox.clicked() }
}
}
Text {
id: label
font.family: "Arial"
font.pixelSize: checkBox.fontSize
color: "#525252"
wrapMode: Text.Wrap
Layout.fillWidth: true
MouseArea {
anchors.fill: parent
onClicked: {
toggle()
}
}
} }
} }
} }