NotificationsForm.ui.qml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import QtQuick 2.12
  2. import QtQuick.Controls 2.5
  3. import QtQuick.Layouts 1.3
  4. import Qt.labs.platform 1.1
  5. Page {
  6. width: 1280
  7. height: 570
  8. id: notificationsForm
  9. font.capitalization: Font.MixedCase
  10. Connections {
  11. target: _qmlHandler
  12. onNotification: {
  13. notificationList.append({
  14. "notificationDate": new Date().toLocaleString(
  15. Qt.locale(
  16. "de_DE"),
  17. "[dd.MM.yyyy hh:mm:ss]"),
  18. "notificationMessage": message
  19. })
  20. }
  21. onDismissNotification: {
  22. notificationList.remove(index)
  23. }
  24. onShowDesktopNotification: {
  25. trayIcon.showMessage(title, message)
  26. }
  27. }
  28. ColumnLayout {
  29. anchors.fill: parent
  30. ScrollView {
  31. Layout.preferredWidth: parent.width
  32. Layout.preferredHeight: 370
  33. ListView {
  34. anchors.fill: parent
  35. model: notificationList
  36. clip: true
  37. delegate: NotificationTemplate {
  38. notificationDateText: notificationDate
  39. notificationMessageText: notificationMessage
  40. myIndex: index
  41. }
  42. }
  43. }
  44. ListModel {
  45. id: notificationList
  46. }
  47. Text {
  48. Layout.alignment: Qt.AlignCenter
  49. Layout.preferredWidth: parent.width
  50. Layout.preferredHeight: 30
  51. id: loginTitle
  52. text: qsTr("No new notifications!")
  53. horizontalAlignment: Text.AlignHCenter
  54. verticalAlignment: Text.AlignVCenter
  55. visible: notificationList.count == 0 ? true : false
  56. font.pixelSize: 20
  57. }
  58. Button {
  59. id: notificationsDismissAllButton
  60. Layout.preferredWidth: 180
  61. Layout.preferredHeight: 70
  62. Layout.alignment: Qt.AlignCenter
  63. text: qsTr("Dismiss all")
  64. enabled: notificationList.count != 0 ? true : false
  65. visible: enabled
  66. // @disable-check M223
  67. onClicked: {
  68. // @disable-check M222
  69. notificationList.clear()
  70. }
  71. }
  72. }
  73. SystemTrayIcon {
  74. id: trayIcon
  75. visible: true
  76. }
  77. }