Changeset View
Changeset View
Standalone View
Standalone View
applets/notifications/package/contents/ui/NotificationItem.qml
Show First 20 Lines • Show All 291 Lines • ▼ Show 20 Line(s) | 33 | ColumnLayout { | |||
---|---|---|---|---|---|
292 | } | 292 | } | ||
293 | 293 | | |||
294 | Item { | 294 | Item { | ||
295 | id: actionContainer | 295 | id: actionContainer | ||
296 | Layout.fillWidth: true | 296 | Layout.fillWidth: true | ||
297 | Layout.preferredHeight: Math.max(actionFlow.implicitHeight, replyLoader.height) | 297 | Layout.preferredHeight: Math.max(actionFlow.implicitHeight, replyLoader.height) | ||
298 | visible: actionRepeater.count > 0 | 298 | visible: actionRepeater.count > 0 | ||
299 | 299 | | |||
300 | states: [ | | |||
301 | State { | | |||
302 | when: notificationItem.replying | | |||
303 | PropertyChanges { | | |||
304 | target: actionFlow | | |||
305 | enabled: false | | |||
306 | opacity: 0 | | |||
307 | } | | |||
308 | PropertyChanges { | | |||
309 | target: replyLoader | | |||
310 | active: true | | |||
311 | visible: true | | |||
312 | opacity: 1 | | |||
313 | x: 0 | | |||
314 | } | | |||
315 | } | | |||
316 | ] | | |||
317 | | ||||
318 | transitions: [ | | |||
319 | Transition { | | |||
320 | to: "*" // any state | | |||
321 | NumberAnimation { | | |||
322 | targets: [actionFlow, replyLoader] | | |||
323 | properties: "opacity,scale,x" | | |||
324 | duration: units.longDuration | | |||
325 | easing.type: Easing.InOutQuad | | |||
326 | } | | |||
327 | } | | |||
328 | ] | | |||
329 | | ||||
330 | // Notification actions | 300 | // Notification actions | ||
331 | Flow { // it's a Flow so it can wrap if too long | 301 | Flow { // it's a Flow so it can wrap if too long | ||
332 | id: actionFlow | 302 | id: actionFlow | ||
333 | width: parent.width | 303 | width: parent.width | ||
334 | spacing: units.smallSpacing | 304 | spacing: units.smallSpacing | ||
335 | layoutDirection: Qt.RightToLeft | 305 | layoutDirection: Qt.RightToLeft | ||
306 | enabled: !replyLoader.active | ||||
307 | opacity: replyLoader.active ? 0 : 1 | ||||
308 | Behavior on opacity { | ||||
309 | NumberAnimation { | ||||
310 | duration: units.longDuration | ||||
311 | easing.type: Easing.InOutQuad | ||||
312 | } | ||||
313 | } | ||||
336 | 314 | | |||
337 | Repeater { | 315 | Repeater { | ||
338 | id: actionRepeater | 316 | id: actionRepeater | ||
339 | 317 | | |||
340 | model: { | 318 | model: { | ||
341 | var buttons = []; | 319 | var buttons = []; | ||
342 | // HACK We want the actions to be right-aligned but Flow also reverses | 320 | // HACK We want the actions to be right-aligned but Flow also reverses | ||
343 | var actionNames = (notificationItem.actionNames || []).reverse(); | 321 | var actionNames = (notificationItem.actionNames || []).reverse(); | ||
Show All 18 Lines | |||||
362 | PlasmaComponents.ToolButton { | 340 | PlasmaComponents.ToolButton { | ||
363 | flat: false | 341 | flat: false | ||
364 | // why does it spit "cannot assign undefined to string" when a notification becomes expired? | 342 | // why does it spit "cannot assign undefined to string" when a notification becomes expired? | ||
365 | text: modelData.label || "" | 343 | text: modelData.label || "" | ||
366 | Layout.preferredWidth: minimumWidth | 344 | Layout.preferredWidth: minimumWidth | ||
367 | 345 | | |||
368 | onClicked: { | 346 | onClicked: { | ||
369 | if (modelData.actionName === "inline-reply") { | 347 | if (modelData.actionName === "inline-reply") { | ||
370 | notificationItem.replying = true; | 348 | replyLoader.beginReply(); | ||
371 | | ||||
372 | plasmoid.nativeInterface.forceActivateWindow(notificationItem.Window.window); | | |||
373 | replyLoader.item.activate(); | | |||
374 | return; | 349 | return; | ||
375 | } | 350 | } | ||
376 | 351 | | |||
377 | notificationItem.actionInvoked(modelData.actionName); | 352 | notificationItem.actionInvoked(modelData.actionName); | ||
378 | } | 353 | } | ||
379 | } | 354 | } | ||
380 | } | 355 | } | ||
381 | } | 356 | } | ||
382 | 357 | | |||
383 | // inline reply field | 358 | // inline reply field | ||
384 | Loader { | 359 | Loader { | ||
385 | id: replyLoader | 360 | id: replyLoader | ||
386 | width: parent.width | 361 | width: parent.width | ||
387 | height: active ? item.implicitHeight : 0 | 362 | height: active ? item.implicitHeight : 0 | ||
388 | active: false | 363 | // When there is only one action and it is a reply action, show text field right away | ||
389 | visible: false | 364 | active: notificationItem.replying || (notificationItem.hasReplyAction && (notificationItem.actionNames || []).length === 0) | ||
390 | opacity: 0 | 365 | visible: active | ||
391 | x: parent.width | 366 | opacity: active ? 1 : 0 | ||
367 | x: active ? 0 : parent.width | ||||
368 | Behavior on x { | ||||
369 | NumberAnimation { | ||||
370 | duration: units.longDuration | ||||
371 | easing.type: Easing.InOutQuad | ||||
372 | } | ||||
373 | } | ||||
374 | Behavior on opacity { | ||||
375 | NumberAnimation { | ||||
376 | duration: units.longDuration | ||||
377 | easing.type: Easing.InOutQuad | ||||
378 | } | ||||
379 | } | ||||
380 | | ||||
381 | function beginReply() { | ||||
382 | notificationItem.replying = true; | ||||
383 | | ||||
384 | plasmoid.nativeInterface.forceActivateWindow(notificationItem.Window.window); | ||||
385 | replyLoader.item.activate(); | ||||
386 | } | ||||
387 | | ||||
392 | sourceComponent: NotificationReplyField { | 388 | sourceComponent: NotificationReplyField { | ||
393 | placeholderText: notificationItem.replyPlaceholderText | 389 | placeholderText: notificationItem.replyPlaceholderText | ||
394 | buttonIconName: notificationItem.replySubmitButtonIconName | 390 | buttonIconName: notificationItem.replySubmitButtonIconName | ||
395 | buttonText: notificationItem.replySubmitButtonText | 391 | buttonText: notificationItem.replySubmitButtonText | ||
396 | onReplied: notificationItem.replied(text) | 392 | onReplied: notificationItem.replied(text) | ||
393 | | ||||
394 | replying: notificationItem.replying | ||||
395 | onBeginReplyRequested: replyLoader.beginReply() | ||||
397 | } | 396 | } | ||
398 | } | 397 | } | ||
399 | } | 398 | } | ||
400 | 399 | | |||
401 | // thumbnails | 400 | // thumbnails | ||
402 | Loader { | 401 | Loader { | ||
403 | id: thumbnailStripLoader | 402 | id: thumbnailStripLoader | ||
404 | Layout.leftMargin: notificationItem.thumbnailLeftPadding | 403 | Layout.leftMargin: notificationItem.thumbnailLeftPadding | ||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |