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 + 0.5 * units.smallSpacing // the close takes up about 1 unit | ||||
36 | } | ||||
37 | if (appIconItem.valid || imageItem.nativeWidth > 0) { | ||||
38 | return Math.max((mainLayout.height + 1.5 * units.smallSpacing),(units.iconSizes.large + 2 * units.smallSpacing)) | ||||
39 | } | ||||
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 // close button again, 0.5 units above and below | ||||
44 | } | ||||
45 | } | ||||
34 | 46 | | |||
35 | // We need to clip here because we support displaying images through <img/> | 47 | // We need to clip here because we support displaying images through <img/> | ||
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… | |||||
36 | // and if we don't clip, they will be painted over the borders of the dialog/item | 48 | // and if we don't clip, they will be painted over the borders of the dialog/item | ||
37 | clip: true | 49 | clip: true | ||
38 | 50 | | |||
39 | signal close | 51 | signal close | ||
40 | signal configure | 52 | signal configure | ||
41 | signal action(string actionId) | 53 | signal action(string actionId) | ||
42 | signal openUrl(url url) | 54 | signal openUrl(url url) | ||
43 | 55 | | |||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Line(s) | 174 | QImageItem { | |||
167 | visible: nativeWidth > 0 | 179 | visible: nativeWidth > 0 | ||
168 | } | 180 | } | ||
169 | 181 | | |||
170 | ColumnLayout { | 182 | ColumnLayout { | ||
171 | id: mainLayout | 183 | id: mainLayout | ||
172 | 184 | | |||
173 | anchors { | 185 | anchors { | ||
174 | top: parent.top | 186 | top: parent.top | ||
175 | topMargin: bodyText.lineCount > 1 ? 0 : units.smallSpacing // Lift up heading if bodyText is long | 187 | 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 | 188 | left: appIconItem.valid || imageItem.nativeWidth > 0 ? appIconItem.right : parent.left | ||
177 | right: parent.right | 189 | right: parent.right | ||
178 | leftMargin: units.smallSpacing * 2 | 190 | leftMargin: units.smallSpacing * 2 | ||
179 | rightMargin: units.smallSpacing // Equal padding on either side (notification icon margin) | 191 | rightMargin: units.smallSpacing // Equal padding on either side (notification icon margin) | ||
180 | } | 192 | } | ||
181 | 193 | | |||
182 | spacing: Math.round(units.smallSpacing / 2) | 194 | spacing: Math.round(units.smallSpacing / 2) | ||
183 | 195 | | |||
▲ Show 20 Lines • Show All 235 Lines • Show Last 20 Lines |
Can you please untangle this into a proper if statement