Changeset View
Changeset View
Standalone View
Standalone View
applets/notifications/package/contents/ui/NotificationItem.qml
Show All 33 Lines | 29 | Item { | |||
---|---|---|---|---|---|
34 | // We need to clip here because we support displaying images through <img/> | 34 | // We need to clip here because we support displaying images through <img/> | ||
35 | // and if we don't clip, they will be painted over the borders of the dialog/item | 35 | // and if we don't clip, they will be painted over the borders of the dialog/item | ||
36 | clip: true | 36 | clip: true | ||
37 | 37 | | |||
38 | signal close | 38 | signal close | ||
39 | signal configure | 39 | signal configure | ||
40 | signal action(string actionId) | 40 | signal action(string actionId) | ||
41 | 41 | | |||
42 | property alias textItem: textItemLoader.sourceComponent | | |||
43 | property bool compact: false | 42 | property bool compact: false | ||
44 | 43 | | |||
45 | property alias icon: appIconItem.source | 44 | property alias icon: appIconItem.source | ||
46 | property alias image: imageItem.image | 45 | property alias image: imageItem.image | ||
47 | property alias summary: summaryLabel.text | 46 | property alias summary: summaryLabel.text | ||
47 | property alias body: bodyText.text | ||||
48 | property alias configurable: settingsButton.visible | 48 | property alias configurable: settingsButton.visible | ||
49 | property var created | 49 | property var created | ||
50 | 50 | | |||
51 | property ListModel actions: ListModel { } | 51 | property ListModel actions: ListModel { } | ||
52 | 52 | | |||
53 | function updateTimeLabel() { | 53 | function updateTimeLabel() { | ||
54 | if (!created || created.getTime() <= 0) { | 54 | if (!created || created.getTime() <= 0) { | ||
55 | timeLabel.text = "" | 55 | timeLabel.text = "" | ||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Line(s) | 119 | ColumnLayout { | |||
184 | RowLayout { | 184 | RowLayout { | ||
185 | id: bottomPart | 185 | id: bottomPart | ||
186 | Layout.alignment: Qt.AlignTop | 186 | Layout.alignment: Qt.AlignTop | ||
187 | 187 | | |||
188 | // Force the whole thing to collapse if the children are invisible | 188 | // Force the whole thing to collapse if the children are invisible | ||
189 | // If there is a big notification followed by a small one, the height | 189 | // If there is a big notification followed by a small one, the height | ||
190 | // of the popup does not always shrink back, so this forces it to | 190 | // of the popup does not always shrink back, so this forces it to | ||
191 | // height=0 when those are invisible. -1 means "default to implicitHeight" | 191 | // height=0 when those are invisible. -1 means "default to implicitHeight" | ||
192 | Layout.maximumHeight: textItemLoader.visible || actionsColumn.visible ? -1 : 0 | 192 | Layout.maximumHeight: bodyText.visible || actionsColumn.visible ? -1 : 0 | ||
193 | | ||||
194 | MouseArea { | ||||
195 | id: contextMouseArea | ||||
193 | 196 | | |||
194 | Loader { | | |||
195 | id: textItemLoader | | |||
196 | Layout.fillWidth: true | 197 | Layout.fillWidth: true | ||
197 | Layout.fillHeight: true | 198 | | ||
198 | visible: textItemLoader.item && textItemLoader.item.text !== "" | | |||
199 | anchors { | 199 | anchors { | ||
200 | leftMargin: units.smallSpacing * 2 | 200 | leftMargin: units.smallSpacing * 2 | ||
201 | rightMargin: units.smallSpacing * 2 | 201 | rightMargin: units.smallSpacing * 2 | ||
202 | } | 202 | } | ||
203 | | ||||
204 | implicitHeight: bodyText.paintedHeight | ||||
205 | | ||||
206 | acceptedButtons: Qt.RightButton | ||||
207 | preventStealing: true | ||||
208 | | ||||
209 | onPressed: contextMenu.open(mouse.x, mouse.y) | ||||
210 | | ||||
211 | PlasmaComponents.ContextMenu { | ||||
212 | id: contextMenu | ||||
213 | visualParent: contextMouseArea | ||||
214 | | ||||
215 | PlasmaComponents.MenuItem { | ||||
216 | text: i18n("Copy") | ||||
217 | onClicked: bodyText.copy() | ||||
218 | } | ||||
219 | | ||||
220 | PlasmaComponents.MenuItem { | ||||
221 | text: i18n("Select All") | ||||
222 | onClicked: bodyText.selectAll() | ||||
223 | } | ||||
203 | } | 224 | } | ||
204 | 225 | | |||
226 | TextEdit { | ||||
227 | id: bodyText | ||||
228 | enabled: !Settings.isMobile | ||||
229 | anchors.fill: parent | ||||
230 | visible: bodyText.length !== 0 | ||||
231 | | ||||
232 | color: PlasmaCore.ColorScope.textColor | ||||
233 | selectedTextColor: theme.viewBackgroundColor | ||||
234 | selectionColor: theme.viewFocusColor | ||||
235 | font.capitalization: theme.defaultFont.capitalization | ||||
236 | font.family: theme.defaultFont.family | ||||
237 | font.italic: theme.defaultFont.italic | ||||
238 | font.letterSpacing: theme.defaultFont.letterSpacing | ||||
239 | font.pointSize: theme.defaultFont.pointSize | ||||
240 | font.strikeout: theme.defaultFont.strikeout | ||||
241 | font.underline: theme.defaultFont.underline | ||||
242 | font.weight: theme.defaultFont.weight | ||||
243 | font.wordSpacing: theme.defaultFont.wordSpacing | ||||
244 | renderType: Text.NativeRendering | ||||
245 | selectByMouse: true | ||||
246 | readOnly: true | ||||
247 | wrapMode: Text.Wrap | ||||
248 | textFormat: TextEdit.RichText | ||||
249 | | ||||
250 | onLinkActivated: Qt.openUrlExternally(link) | ||||
251 | } | ||||
252 | } | ||||
205 | 253 | | |||
206 | ColumnLayout { | 254 | ColumnLayout { | ||
207 | id: actionsColumn | 255 | id: actionsColumn | ||
208 | Layout.alignment: Qt.AlignTop | 256 | Layout.alignment: Qt.AlignTop | ||
209 | Layout.maximumWidth: theme.mSize(theme.defaultFont).width * (compact ? 8 : 12) | 257 | Layout.maximumWidth: theme.mSize(theme.defaultFont).width * (compact ? 8 : 12) | ||
210 | 258 | | |||
211 | spacing: units.smallSpacing | 259 | spacing: units.smallSpacing | ||
212 | visible: notificationItem.actions && notificationItem.actions.count > 0 | 260 | visible: notificationItem.actions && notificationItem.actions.count > 0 | ||
Show All 16 Lines |