paysages3d/src/interface/modeler/quickapp/qml/BaseChoiceItem.qml

62 lines
1.2 KiB
QML
Raw Normal View History

2014-08-28 13:09:47 +00:00
import QtQuick 2.0
import QtQuick.Controls 1.1
Rectangle {
id: choice_item
property string icon
property bool checked: false
property ExclusiveGroup exclusiveGroup: null
property int value
2015-08-19 23:15:08 +00:00
property int padding: 4
2014-08-28 13:09:47 +00:00
color: "#333333"
2015-08-19 23:15:08 +00:00
radius: padding * 2
2014-08-28 13:09:47 +00:00
signal toggled(bool value)
2015-08-19 23:15:08 +00:00
width: 40
height: 40
2014-08-28 13:09:47 +00:00
Image {
2015-08-19 23:15:08 +00:00
id: icon_image
2014-08-28 13:09:47 +00:00
source: parent.icon
2015-08-19 23:15:08 +00:00
width: parent.width - 2 * parent.padding
height: parent.height - 2 * parent.padding
anchors.centerIn: parent
antialiasing: true
2014-08-28 13:09:47 +00:00
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: checked = true
}
onExclusiveGroupChanged: {
if (exclusiveGroup) {
exclusiveGroup.bindCheckable(choice_item);
}
}
onCheckedChanged: choice_item.toggled(checked)
2015-08-19 23:15:08 +00:00
Behavior on color {
PropertyAnimation {
duration: 200
}
}
2014-08-28 13:09:47 +00:00
states: [
State {
name: "Checked"
when: checked
PropertyChanges {
target: choice_item
2015-08-19 23:15:08 +00:00
color: "#dddddd"
2014-08-28 13:09:47 +00:00
}
}
]
}