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

70 lines
1.6 KiB
QML
Raw Normal View History

2014-08-19 15:37:24 +00:00
import QtQuick 2.0
Item {
property string picture
2014-08-19 15:37:24 +00:00
property bool selected: false
property bool hovered: false
2014-08-27 15:23:59 +00:00
property string helptext
property string hovertext
2014-08-19 15:37:24 +00:00
width: image.width + 10
height: image.height + 10
Rectangle {
id: glow
anchors.fill: parent
color: "white"
radius: 8
opacity: parent.selected ? 1.0 : (parent.hovered ? 0.5 : 0.0)
Behavior on opacity {
PropertyAnimation {
duration: 200
}
}
}
Image {
id: image
source: parent.picture
2014-08-19 15:37:24 +00:00
anchors.centerIn: parent
2014-08-27 15:23:59 +00:00
width: 32
height: 32
2014-08-19 15:37:24 +00:00
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
2014-08-27 15:23:59 +00:00
cursorShape: Qt.PointingHandCursor
2014-08-19 15:37:24 +00:00
2014-08-27 15:23:59 +00:00
onEntered: {
parent.hovered = true;
tooltip_widget.hovertext = hovertext;
}
onExited: {
parent.hovered = false;
tooltip_widget.hovertext = "";
}
onClicked: {
parent.selected = !parent.selected;
if (parent.selected)
{
var toolbar = parent.parent;
for (var i = 0; i < toolbar.children.length; ++i)
{
var child = toolbar.children[i]
if (child !== parent)
{
child.selected = false;
}
}
tooltip_widget.helptext = helptext;
}
else
{
tooltip_widget.helptext = "";
}
}
2014-08-19 15:37:24 +00:00
}
}