84 lines
1.6 KiB
QML
Raw Normal View History

2019-07-29 19:48:22 +03:00
import QtQuick 2.12
import QtQuick.Controls.Material 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.3
2019-07-29 19:48:22 +03:00
import QtGraphicalEffects 1.12
Item {
2019-07-29 15:29:07 +03:00
id: imageView
property int size: 50
property double ratio: 1
2019-07-29 15:29:07 +03:00
property string drawItem: ""
property bool hovered: false
property bool hold: false
signal clicked();
width: size * ratio
height: size
Image {
id: img
2019-07-29 19:48:22 +03:00
fillMode: Image.PreserveAspectFit
2019-07-29 15:29:07 +03:00
source: drawItem
2019-07-29 19:48:22 +03:00
sourceSize: Qt.size(width, height)
smooth: true
visible: false
2019-07-29 19:48:22 +03:00
anchors.fill: parent
}
DropShadow {
anchors.fill: img
horizontalOffset: (hold)? 20: (hovered)? 10: 5
verticalOffset: (hold)? 20: (hovered)? 10: 5
radius: 8.0
samples: 17
Behavior on horizontalOffset {
ColorAnimation {
duration: 200
}
}
Behavior on verticalOffset {
ColorAnimation {
duration: 200
}
}
Behavior on color {
ColorAnimation {
duration: 200
}
}
2019-07-29 19:48:22 +03:00
color: (hold)? "#80000000": (hovered)? "#60000000": "#40000000"
source: img
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: {
parent.hovered = true;
}
onExited: {
parent.hovered = false;
}
onReleased: {
parent.hold = false;
2019-07-29 15:29:07 +03:00
imageView.clicked();
}
2019-07-29 15:29:07 +03:00
onPressed: {
parent.hold = true;
}
}
}