NotificationsForm.ui.qml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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: 470
  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. color: "#ffffff"
  53. text: qsTr("No new notifications!")
  54. horizontalAlignment: Text.AlignHCenter
  55. verticalAlignment: Text.AlignVCenter
  56. visible: notificationList.count == 0 ? true : false
  57. font.pixelSize: 20
  58. }
  59. Button {
  60. id: notificationsDismissAllButton
  61. Layout.preferredWidth: 180
  62. Layout.preferredHeight: 70
  63. Layout.alignment: Qt.AlignCenter
  64. text: qsTr("Dismiss all")
  65. enabled: notificationList.count != 0 ? true : false
  66. visible: enabled
  67. // @disable-check M223
  68. onClicked: {
  69. // @disable-check M222
  70. notificationList.clear()
  71. }
  72. }
  73. }
  74. SystemTrayIcon {
  75. id: trayIcon
  76. visible: true
  77. icon.source: "qrc:/images/tray-icon.png"
  78. }
  79. }