Remove fade effect from toolbar buttons

This commit is contained in:
Brad Davis 2016-07-14 15:49:32 -07:00
parent ffdaadf13c
commit fdcbf71623

View file

@ -4,7 +4,7 @@ import QtQuick.Controls 1.4
Item {
id: button
property alias imageURL: image.source
property alias alpha: button.opacity
property alias alpha: image.opacity
property var subImage;
property int yOffset: 0
property int buttonState: 0
@ -14,32 +14,11 @@ Item {
width: size; height: size
property bool pinned: false
clip: true
Behavior on opacity {
NumberAnimation {
duration: 150
easing.type: Easing.InOutCubic
}
}
property alias fadeTargetProperty: button.opacity
onFadeTargetPropertyChanged: {
visible = (fadeTargetProperty !== 0.0);
}
onVisibleChanged: {
if ((!visible && fadeTargetProperty != 0.0) || (visible && fadeTargetProperty == 0.0)) {
var target = visible;
visible = !visible;
fadeTargetProperty = target ? 1.0 : 0.0;
return;
}
}
function updateOffset() {
yOffset = size * (buttonState + hoverOffset);
}
onButtonStateChanged: {
hoverOffset = 0; // subtle: show the new state without hover. don't wait for mouse to be moved away
// The above is per UX design, but ALSO avoid a subtle issue that would be a problem because
@ -64,11 +43,19 @@ Item {
width: parent.width
}
Timer {
id: asyncClickSender
interval: 10
repeat: false
running: false
onTriggered: button.clicked();
}
MouseArea {
id: mouseArea
hoverEnabled: true
anchors.fill: parent
onClicked: button.clicked();
onClicked: asyncClickSender.start();
onEntered: {
hoverOffset = 2;
updateOffset();