Changeset 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: Math.max(appIconItem.valid || imageItem.nativeWidth > 0 ? units.iconSizes.large : 0, mainLayout.height) | 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))) | ||
hein: Adding 1.75 pixels is just too arbitrary (and not an even number, and not scaled by device… | |||||
Much better. Only part I don't understand, then ship it! from me. Assuming there's no icon For multiline
For one line we effectively get:
Why the 0.5? Surely that would be inconsistent? (In all your examples the icon is bigger so we don't see it) davidedmundson: Much better.
Only part I don't understand, then ship it! from me.
Assuming there's no icon… | |||||
You're right! I never tested it with just the heading, There's an extra 0.5 * units.smallSpacing of padding there. But I needed that 0.5 units to provide even padding to notifications that are "Heading + One line of description". Is there any way I can put in a condition that if it's just a heading that it not put that 0.5 * units.smallSpacing there? rooty: You're right! I never tested it with just the heading, There's an extra 0.5 * units. | |||||
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) | ||
Show All 21 Lines | |||||
63 | onClicked: { | 63 | onClicked: { | ||
64 | // the MEL would close the notification before the action button | 64 | // the MEL would close the notification before the action button | ||
65 | // onClicked handler would fire effectively breaking notification actions | 65 | // onClicked handler would fire effectively breaking notification actions | ||
66 | if (pressedAction()) { | 66 | if (pressedAction()) { | ||
67 | return | 67 | return | ||
68 | } | 68 | } | ||
69 | 69 | | |||
70 | if (hasDefaultAction) { | 70 | if (hasDefaultAction) { | ||
71 | // the notifications was clicked, trigger the default action if set | 71 | // the notification was clicked, trigger the default action if set | ||
72 | action("default") | 72 | action("default") | ||
73 | } | 73 | } | ||
74 | } | 74 | } | ||
75 | 75 | | |||
76 | function pressedAction() { | 76 | function pressedAction() { | ||
77 | for (var i = 0, count = actionRepeater.count; i < count; ++i) { | 77 | for (var i = 0, count = actionRepeater.count; i < count; ++i) { | ||
78 | var item = actionRepeater.itemAt(i) | 78 | var item = actionRepeater.itemAt(i) | ||
79 | if (item.pressed) { | 79 | if (item.pressed) { | ||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 145 | PlasmaCore.IconItem { | |||
146 | id: appIconItem | 146 | id: appIconItem | ||
147 | 147 | | |||
148 | width: units.iconSizes.large | 148 | width: units.iconSizes.large | ||
149 | height: units.iconSizes.large | 149 | height: units.iconSizes.large | ||
150 | 150 | | |||
151 | anchors { | 151 | anchors { | ||
152 | top: parent.top | 152 | top: parent.top | ||
153 | left: parent.left | 153 | left: parent.left | ||
154 | leftMargin: units.smallSpacing | ||||
155 | topMargin: units.smallSpacing | ||||
154 | } | 156 | } | ||
155 | 157 | | |||
156 | visible: imageItem.nativeWidth == 0 && valid | 158 | visible: imageItem.nativeWidth == 0 && valid | ||
157 | animated: false | 159 | animated: false | ||
158 | } | 160 | } | ||
159 | 161 | | |||
160 | QImageItem { | 162 | QImageItem { | ||
161 | id: imageItem | 163 | id: imageItem | ||
162 | anchors.fill: appIconItem | 164 | anchors.fill: appIconItem | ||
163 | 165 | | |||
164 | smooth: true | 166 | smooth: true | ||
165 | visible: nativeWidth > 0 | 167 | visible: nativeWidth > 0 | ||
166 | } | 168 | } | ||
167 | 169 | | |||
168 | ColumnLayout { | 170 | ColumnLayout { | ||
169 | id: mainLayout | 171 | id: mainLayout | ||
170 | 172 | | |||
171 | anchors { | 173 | anchors { | ||
172 | top: parent.top | 174 | top: parent.top | ||
175 | topMargin: bodyText.lineCount > 1 ? 0 : units.smallSpacing // Lift up heading if bodyText is long | ||||
Fractions of smallSpacing can lead to subpixel positioning causing blurry text. hein: Fractions of smallSpacing can lead to subpixel positioning causing blurry text. | |||||
Is there any way around this? Because if it's not 0.75 then it's shifted too far down (uneven padding) rooty: Is there any way around this? Because if it's not 0.75 then it's shifted too far down (uneven… | |||||
If that's the case, adjust the other side, even adjust the window if you need to. davidedmundson: >Is there any way around this? Because if it's not 0.75 then it's shifted too far down (uneven… | |||||
Nate's right though, I should abandon the idea of totally even padding because it'll never hold up as you change fonts or scaling... then again it doesn't have to be perfect, right? Just close enough? rooty: Nate's right though, I should abandon the idea of totally even padding because it'll never hold… | |||||
173 | left: appIconItem.valid || imageItem.nativeWidth > 0 ? appIconItem.right : parent.left | 176 | left: appIconItem.valid || imageItem.nativeWidth > 0 ? appIconItem.right : parent.left | ||
174 | right: parent.right | 177 | right: parent.right | ||
175 | leftMargin: units.smallSpacing | 178 | leftMargin: units.smallSpacing * 2 | ||
179 | rightMargin: units.smallSpacing // Equal padding on either side (notification icon margin) | ||||
176 | } | 180 | } | ||
177 | 181 | | |||
178 | spacing: Math.round(units.smallSpacing / 2) | 182 | spacing: Math.round(units.smallSpacing / 2) | ||
179 | 183 | | |||
180 | RowLayout { | 184 | RowLayout { | ||
181 | id: titleBar | 185 | id: titleBar | ||
182 | spacing: units.smallSpacing | 186 | spacing: units.smallSpacing | ||
183 | 187 | | |||
▲ Show 20 Lines • Show All 231 Lines • Show Last 20 Lines |
Adding 1.75 pixels is just too arbitrary (and not an even number, and not scaled by device pixel ratio).