2014-08-19 15:37:24 +00:00
|
|
|
import QtQuick 2.0
|
2014-08-28 08:29:12 +00:00
|
|
|
import QtGraphicalEffects 1.0
|
2014-08-19 15:37:24 +00:00
|
|
|
|
|
|
|
Item {
|
2014-08-27 13:18:08 +00:00
|
|
|
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
|
2014-08-28 08:29:12 +00:00
|
|
|
color: "#cccccc"
|
2014-08-19 15:37:24 +00:00
|
|
|
radius: 8
|
|
|
|
|
|
|
|
opacity: parent.selected ? 1.0 : (parent.hovered ? 0.5 : 0.0)
|
|
|
|
Behavior on opacity {
|
|
|
|
PropertyAnimation {
|
|
|
|
duration: 200
|
|
|
|
}
|
|
|
|
}
|
2014-08-28 08:29:12 +00:00
|
|
|
RectangularGlow {
|
|
|
|
anchors.fill: glow
|
|
|
|
glowRadius: 8
|
|
|
|
spread: 0.2
|
|
|
|
color: "white"
|
|
|
|
cornerRadius: glow.radius + glowRadius
|
|
|
|
}
|
2014-08-19 15:37:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: image
|
2014-08-27 13:18:08 +00:00
|
|
|
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-28 08:29:12 +00:00
|
|
|
antialiasing: true
|
|
|
|
}
|
|
|
|
DropShadow {
|
|
|
|
anchors.fill: image
|
|
|
|
horizontalOffset: 2
|
|
|
|
verticalOffset: 2
|
|
|
|
radius: 4.0
|
|
|
|
samples: 16
|
|
|
|
color: "#80000000"
|
|
|
|
source: image
|
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
|
|
|
}
|
|
|
|
}
|