Changeset View
Changeset View
Standalone View
Standalone View
src/declarativeimports/plasmacomponents/qml/ListItem.qml
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 31 | Item { | |||
---|---|---|---|---|---|
85 | */ | 85 | */ | ||
86 | property bool separatorVisible: true | 86 | property bool separatorVisible: true | ||
87 | 87 | | |||
88 | width: parent ? parent.width : childrenRect.width | 88 | width: parent ? parent.width : childrenRect.width | ||
89 | height: paddingItem.childrenRect.height + background.margins.top + background.margins.bottom | 89 | height: paddingItem.childrenRect.height + background.margins.top + background.margins.bottom | ||
90 | 90 | | |||
91 | implicitHeight: paddingItem.childrenRect.height + background.margins.top + background.margins.bottom | 91 | implicitHeight: paddingItem.childrenRect.height + background.margins.top + background.margins.bottom | ||
92 | 92 | | |||
93 | | ||||
94 | Connections { | | |||
95 | target: listItem | | |||
96 | onCheckedChanged: background.prefix = (listItem.checked ? "pressed" : "normal") | | |||
97 | onSectionDelegateChanged: background.prefix = (listItem.sectionDelegate ? "section" : "normal") | | |||
98 | } | | |||
99 | | ||||
100 | PlasmaCore.FrameSvgItem { | 93 | PlasmaCore.FrameSvgItem { | ||
101 | id : background | 94 | id : background | ||
102 | imagePath: "widgets/listitem" | 95 | imagePath: "widgets/listitem" | ||
103 | prefix: "normal" | 96 | prefix: (listItem.sectionDelegate ? "section" : | ||
97 | (itemMouse.pressed || listItem.checked) ? "pressed" : "normal") | ||||
davidedmundson: why are you now following containsMouse. That's a behavioural change
How can background. | |||||
Yes, I meant to put itemMouse.pressed. I wonder why QML doesn't complain... It's barely a behavioral change, in fact it's what it was supposed to happen in the first place: give feedback on hover when the item is clickable. apol: Yes, I meant to put `itemMouse.pressed`. I wonder why QML doesn't complain...
It's barely a… | |||||
We have the highlight for the item under mouse. davidedmundson: >in fact it's what it was supposed to happen in the first place
We have the highlight for the… | |||||
If that's the case, then we should remove the opacity change on hover altogether then. apol: If that's the case, then we should remove the opacity change on hover altogether then.
And make… | |||||
when the item contains the mouse the prefix shouldn't be "pressed" mart: when the item contains the mouse the prefix shouldn't be "pressed"
I'm fine with using the… | |||||
104 | 98 | | |||
105 | anchors.fill: parent | 99 | anchors.fill: parent | ||
106 | visible: listItem.ListView.view ? listItem.ListView.view.highlight === null : true | 100 | visible: listItem.ListView.view ? listItem.ListView.view.highlight === null : true | ||
107 | opacity: itemMouse.containsMouse && !itemMouse.pressed ? 0.5 : 1 | | |||
108 | Component.onCompleted: { | | |||
109 | prefix = (listItem.sectionDelegate ? "section" : (listItem.checked ? "pressed" : "normal")) | | |||
110 | } | | |||
111 | Behavior on opacity { NumberAnimation { duration: units.longDuration } } | 101 | Behavior on opacity { NumberAnimation { duration: units.longDuration } } | ||
112 | } | 102 | } | ||
113 | PlasmaCore.SvgItem { | 103 | PlasmaCore.SvgItem { | ||
114 | svg: PlasmaCore.Svg {imagePath: "widgets/listitem"} | 104 | svg: PlasmaCore.Svg {imagePath: "widgets/listitem"} | ||
115 | elementId: "separator" | 105 | elementId: "separator" | ||
116 | anchors { | 106 | anchors { | ||
117 | left: parent.left | 107 | left: parent.left | ||
118 | right: parent.right | 108 | right: parent.right | ||
119 | top: parent.top | 109 | top: parent.top | ||
120 | } | 110 | } | ||
121 | height: naturalSize.height | 111 | height: naturalSize.height | ||
122 | visible: separatorVisible && (listItem.sectionDelegate || (typeof(index) != "undefined" && index > 0 && !listItem.checked && !itemMouse.pressed)) | 112 | visible: separatorVisible && (listItem.sectionDelegate || (typeof(index) != "undefined" && index > 0 && !listItem.checked && !itemMouse.pressed)) | ||
123 | } | 113 | } | ||
124 | 114 | | |||
125 | MouseArea { | 115 | MouseArea { | ||
126 | id: itemMouse | 116 | id: itemMouse | ||
127 | property bool changeBackgroundOnPress: !listItem.checked && !listItem.sectionDelegate | 117 | property bool changeBackgroundOnPress: !listItem.checked && !listItem.sectionDelegate | ||
128 | anchors.fill: background | 118 | anchors.fill: background | ||
129 | enabled: false | 119 | enabled: false | ||
130 | hoverEnabled: Config.mouseOverEnabled | 120 | hoverEnabled: Config.mouseOverEnabled | ||
131 | 121 | | |||
132 | onClicked: listItem.clicked() | 122 | onClicked: listItem.clicked() | ||
133 | onPressAndHold: listItem.pressAndHold() | 123 | onPressAndHold: listItem.pressAndHold() | ||
134 | onPressed: if (changeBackgroundOnPress) background.prefix = "pressed" | | |||
135 | onReleased: if (changeBackgroundOnPress) background.prefix = "normal" | | |||
136 | onCanceled: if (changeBackgroundOnPress) background.prefix = "normal" | | |||
137 | 124 | | |||
138 | Item { | 125 | Item { | ||
139 | id: paddingItem | 126 | id: paddingItem | ||
140 | anchors { | 127 | anchors { | ||
141 | fill: parent | 128 | fill: parent | ||
142 | leftMargin: background.margins.left | 129 | leftMargin: background.margins.left | ||
143 | topMargin: background.margins.top | 130 | topMargin: background.margins.top | ||
144 | rightMargin: background.margins.right | 131 | rightMargin: background.margins.right | ||
145 | bottomMargin: background.margins.bottom | 132 | bottomMargin: background.margins.bottom | ||
146 | } | 133 | } | ||
147 | } | 134 | } | ||
148 | } | 135 | } | ||
149 | 136 | | |||
150 | Accessible.role: Accessible.ListItem | 137 | Accessible.role: Accessible.ListItem | ||
151 | } | 138 | } |
why are you now following containsMouse. That's a behavioural change
How can background.pressed be true. I don't see where it exists?
do you mean itemMouse.pressed?