Changeset View
Changeset View
Standalone View
Standalone View
applets/notifications/package/contents/ui/NotificationItem.qml
Show All 24 Lines | |||||
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: bodyText.lineCount > 1 ? mainLayout.height : (appIconItem.valid || imageItem.nativeWidth > 0 ? (Math.max((mainLayout.height + 1.5 * units.smallSpacing),(units.iconSizes.large + 2 * units.smallSpacing))) : (bottomPart.height != 0 ? (mainLayout.height + (mainLayout.height > units.iconSizes.large ? 1.5 : 2) * units.smallSpacing) : (mainLayout.height + units.smallSpacing))) | ||
broulik: Can you please untangle this into a proper if statement | |||||
34 | 34 | | |||
35 | // We need to clip here because we support displaying images through <img/> | 35 | // 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 | 36 | // and if we don't clip, they will be painted over the borders of the dialog/item | ||
37 | clip: true | 37 | clip: true | ||
38 | 38 | | |||
39 | signal close | 39 | signal close | ||
40 | signal configure | 40 | signal configure | ||
41 | signal action(string actionId) | 41 | signal action(string actionId) | ||
42 | signal openUrl(url url) | 42 | signal openUrl(url url) | ||
43 | 43 | | |||
44 | property bool compact: false | 44 | property bool compact: false | ||
45 | 45 | | |||
46 | property alias icon: appIconItem.source | 46 | property alias icon: appIconItem.source | ||
47 | property alias image: imageItem.image | 47 | property alias image: imageItem.image | ||
48 | property alias summary: summaryLabel.text | 48 | property alias summary: summaryLabel.text | ||
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… | |||||
49 | property alias body: bodyText.text | 49 | property alias body: bodyText.text | ||
50 | property alias configurable: settingsButton.visible | 50 | property alias configurable: settingsButton.visible | ||
51 | property var created | 51 | property var created | ||
52 | property var urls: [] | 52 | property var urls: [] | ||
53 | 53 | | |||
54 | property int maximumTextHeight: -1 | 54 | property int maximumTextHeight: -1 | ||
55 | 55 | | |||
56 | property ListModel actions: ListModel { } | 56 | property ListModel actions: ListModel { } | ||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Line(s) | 162 | QImageItem { | |||
167 | visible: nativeWidth > 0 | 167 | visible: nativeWidth > 0 | ||
168 | } | 168 | } | ||
169 | 169 | | |||
170 | ColumnLayout { | 170 | ColumnLayout { | ||
171 | id: mainLayout | 171 | id: mainLayout | ||
172 | 172 | | |||
173 | anchors { | 173 | anchors { | ||
174 | top: parent.top | 174 | top: parent.top | ||
175 | topMargin: bodyText.lineCount > 1 ? 0 : units.smallSpacing // Lift up heading if bodyText is long | 175 | topMargin: bodyText.lineCount > 1 ? 0 : (mainLayout.height > units.iconSizes.large ? 0.5 : 1) * units.smallSpacing // Lift up heading if bodyText is long or if text droops due to font size | ||
broulik: Is `smallSpacing` always even? | |||||
rooty: That's the idea yes | |||||
176 | left: appIconItem.valid || imageItem.nativeWidth > 0 ? appIconItem.right : parent.left | 176 | left: appIconItem.valid || imageItem.nativeWidth > 0 ? appIconItem.right : parent.left | ||
177 | right: parent.right | 177 | right: parent.right | ||
178 | leftMargin: units.smallSpacing * 2 | 178 | leftMargin: units.smallSpacing * 2 | ||
179 | rightMargin: units.smallSpacing // Equal padding on either side (notification icon margin) | 179 | rightMargin: units.smallSpacing // Equal padding on either side (notification icon margin) | ||
180 | } | 180 | } | ||
181 | 181 | | |||
182 | spacing: Math.round(units.smallSpacing / 2) | 182 | spacing: Math.round(units.smallSpacing / 2) | ||
183 | 183 | | |||
▲ Show 20 Lines • Show All 235 Lines • Show Last 20 Lines |
Can you please untangle this into a proper if statement