pressed effect

This commit is contained in:
Marco Martin 2015-04-27 13:33:48 +02:00
parent 5efb820769
commit fc430058bf
3 changed files with 32 additions and 3 deletions

View file

@ -18,7 +18,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
import QtQuick 2.0 import QtQuick 2.4
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.components 2.0 as PlasmaComponents
@ -39,7 +39,22 @@ PlasmaComponents.Label {
property var pressedCallback property var pressedCallback
property var releasedCallback property var releasedCallback
Rectangle {
anchors.fill: parent
z: -1
color: PlasmaCore.ColorScope.highlightColor
radius: units.smallSpacing
opacity: mouse.pressed ? 0.4 : 0
Behavior on opacity {
OpacityAnimator {
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}
}
MouseArea { MouseArea {
id: mouse
anchors.fill: parent anchors.fill: parent
onPressed: { onPressed: {
if (pressedCallback) { if (pressedCallback) {

View file

@ -18,7 +18,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
import QtQuick 2.0 import QtQuick 2.4
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.components 2.0 as PlasmaComponents
@ -36,6 +36,20 @@ Item {
property alias source: icon.source property alias source: icon.source
property alias text: label.text property alias text: label.text
Rectangle {
anchors.fill: parent
z: -1
color: PlasmaCore.ColorScope.highlightColor
radius: units.smallSpacing
opacity: mouse.pressed ? 0.4 : 0
Behavior on opacity {
OpacityAnimator {
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}
}
Row { Row {
anchors.centerIn: parent anchors.centerIn: parent
PlasmaCore.IconItem { PlasmaCore.IconItem {
@ -54,6 +68,7 @@ Item {
} }
MouseArea { MouseArea {
id: mouse
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
if (callback) { if (callback) {

View file

@ -134,7 +134,6 @@ ApplicationWindow {
) )
historyModel.remove(index); historyModel.remove(index);
} }
//END FUNCTIONS //END FUNCTIONS