Changeset View
Changeset View
Standalone View
Standalone View
applets/notifications/package/contents/ui/NotificationItem.qml
Show All 23 Lines | |||||
24 | 24 | | |||
25 | import org.kde.plasma.core 2.0 as PlasmaCore | 25 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
26 | import org.kde.plasma.components 2.0 as PlasmaComponents | 26 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
27 | import org.kde.plasma.extras 2.0 as PlasmaExtras | 27 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||
28 | import org.kde.kquickcontrolsaddons 2.0 | 28 | import org.kde.kquickcontrolsaddons 2.0 | ||
29 | 29 | | |||
30 | MouseArea { | 30 | MouseArea { | ||
31 | id: notificationItem | 31 | id: notificationItem | ||
32 | width: parent.width | 32 | width: parent.width | ||
33 | implicitHeight: bodyText.lineCount > 1 ? mainLayout.height : (appIconItem.valid || imageItem.nativeWidth > 0 ? (Math.max((mainLayout.height + 2 * units.smallSpacing),(units.iconSizes.large + 2 * units.smallSpacing))) : (bottomPart.height != 0 ? (mainLayout.height + 2 * units.smallSpacing) : (mainLayout.height + units.smallSpacing))) | 33 | implicitHeight: { | ||
broulik: Can you please untangle this into a proper if statement | |||||
34 | if (bodyText.lineCount > 1) { | ||||
35 | return mainLayout.height | ||||
36 | } else { | ||||
37 | if (appIconItem.valid || imageItem.nativeWidth > 0) { | ||||
38 | return Math.max((mainLayout.height + 1.5 * units.smallSpacing),(units.iconSizes.large + 2 * units.smallSpacing)) | ||||
39 | } else { | ||||
40 | if (bottomPart.height != 0) { | ||||
41 | return mainLayout.height + (mainLayout.height > units.iconSizes.large ? 1.5 : 2) * units.smallSpacing | ||||
42 | } else { | ||||
43 | return mainLayout.height + units.smallSpacing // because of the close button | ||||
44 | } | ||||
45 | } | ||||
46 | } | ||||
47 | } | ||||
When you have return you don't need else branch if (bodyText.lineCount > 1) { return mainLayout.height } if (appIconItem.valid || imageItem.nativeWidth > 0) { return Math.max((mainLayout.height + 1.5 * units.smallSpacing),(units.iconSizes.large + 2 * units.smallSpacing)) } and so on anthonyfieroni: When you have return you don't need else branch
```
if (bodyText.lineCount > 1) {
return… | |||||
34 | 48 | | |||
35 | // We need to clip here because we support displaying images through <img/> | 49 | // We need to clip here because we support displaying images through <img/> | ||
36 | // and if we don't clip, they will be painted over the borders of the dialog/item | 50 | // and if we don't clip, they will be painted over the borders of the dialog/item | ||
37 | clip: true | 51 | clip: true | ||
38 | 52 | | |||
39 | signal close | 53 | signal close | ||
40 | signal configure | 54 | signal configure | ||
41 | signal action(string actionId) | 55 | signal action(string actionId) | ||
▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Line(s) | 176 | QImageItem { | |||
167 | visible: nativeWidth > 0 | 181 | visible: nativeWidth > 0 | ||
168 | } | 182 | } | ||
169 | 183 | | |||
170 | ColumnLayout { | 184 | ColumnLayout { | ||
171 | id: mainLayout | 185 | id: mainLayout | ||
172 | 186 | | |||
173 | anchors { | 187 | anchors { | ||
174 | top: parent.top | 188 | top: parent.top | ||
175 | topMargin: bodyText.lineCount > 1 ? 0 : units.smallSpacing // Lift up heading if bodyText is long | 189 | topMargin: bodyText.lineCount > 1 ? 0 : (mainLayout.height > units.iconSizes.large ? 0.5 : 1) * units.smallSpacing // Lift up heading if bodyText is long | ||
broulik: Is `smallSpacing` always even? | |||||
rooty: That's the idea yes | |||||
176 | left: appIconItem.valid || imageItem.nativeWidth > 0 ? appIconItem.right : parent.left | 190 | left: appIconItem.valid || imageItem.nativeWidth > 0 ? appIconItem.right : parent.left | ||
177 | right: parent.right | 191 | right: parent.right | ||
178 | leftMargin: units.smallSpacing * 2 | 192 | leftMargin: units.smallSpacing * 2 | ||
179 | rightMargin: units.smallSpacing // Equal padding on either side (notification icon margin) | 193 | rightMargin: units.smallSpacing // Equal padding on either side (notification icon margin) | ||
180 | } | 194 | } | ||
181 | 195 | | |||
182 | spacing: Math.round(units.smallSpacing / 2) | 196 | spacing: Math.round(units.smallSpacing / 2) | ||
183 | 197 | | |||
▲ Show 20 Lines • Show All 235 Lines • Show Last 20 Lines |
Can you please untangle this into a proper if statement