Make sure we display enabled ListItem on hover

Summary:
I just realized there was a weird workaround in plasma-nm where it gets
checked so it's shown.
Properly use the declarative API instead of listening to a ton of signals.

Test Plan: Tested with plasma-nm and org.kde.plasma.notifications plasmoids

Reviewers: #plasma, mart

Reviewed By: mart

Subscribers: mart, davidedmundson, plasma-devel, #frameworks

Tags: #plasma, #frameworks

Differential Revision: https://phabricator.kde.org/D4214
This commit is contained in:
Aleix Pol 2017-01-20 00:44:08 +01:00
parent 979e0ea54c
commit 54e87fe879

View File

@ -90,24 +90,14 @@ Item {
implicitHeight: paddingItem.childrenRect.height + background.margins.top + background.margins.bottom
Connections {
target: listItem
onCheckedChanged: background.prefix = (listItem.checked ? "pressed" : "normal")
onSectionDelegateChanged: background.prefix = (listItem.sectionDelegate ? "section" : "normal")
}
PlasmaCore.FrameSvgItem {
id : background
imagePath: "widgets/listitem"
prefix: "normal"
prefix: (listItem.sectionDelegate ? "section" :
(itemMouse.pressed || listItem.checked) ? "pressed" : "normal")
anchors.fill: parent
visible: listItem.ListView.view ? listItem.ListView.view.highlight === null : true
opacity: itemMouse.containsMouse && !itemMouse.pressed ? 0.5 : 1
Component.onCompleted: {
prefix = (listItem.sectionDelegate ? "section" : (listItem.checked ? "pressed" : "normal"))
}
Behavior on opacity { NumberAnimation { duration: units.longDuration } }
}
PlasmaCore.SvgItem {
@ -131,9 +121,6 @@ Item {
onClicked: listItem.clicked()
onPressAndHold: listItem.pressAndHold()
onPressed: if (changeBackgroundOnPress) background.prefix = "pressed"
onReleased: if (changeBackgroundOnPress) background.prefix = "normal"
onCanceled: if (changeBackgroundOnPress) background.prefix = "normal"
Item {
id: paddingItem