Advertisement
neochapay

Untitled

Nov 24th, 2021
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.36 KB | None | 0 0
  1. /* Copyright (C) 2018-2021 Chupligin Serhey <neochapay@gmail.com>
  2. * Copyright (C) 2012 John Brooks <john.brooks@dereferenced.net>
  3. * Copyright (C) 2011 Robin Burchell <robin+nemo@viroteck.net>
  4. *
  5. * You may use this file under the terms of the BSD license as follows:
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are
  9. * met:
  10. * * Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * * Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in
  14. * the documentation and/or other materials provided with the
  15. * distribution.
  16. * * Neither the name of Nemo Mobile nor the names of its contributors
  17. * may be used to endorse or promote products derived from this
  18. * software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. */
  32.  
  33. import QtQuick 2.6
  34.  
  35. import QtQuick.Controls 1.0
  36. import QtQuick.Controls.Nemo 1.0
  37. import QtQuick.Controls.Styles.Nemo 1.0
  38.  
  39. import org.nemomobile.qmlcontacts 1.0
  40.  
  41. ListViewItemWithActions {
  42. id: converstationListDelegate
  43. icon: getAvatar()
  44. showNext: true
  45. label: model.lastMessageText
  46. description: person ? person.displayLabel : model.remoteUids[0]
  47.  
  48. clip: true
  49.  
  50. property QtObject person: null
  51. property int contactId: model.contactIds.length > 0 ? model.contactIds[0] : -1
  52.  
  53. Connections {
  54. target: person ? null : peopleModel
  55. function onRowsInserted() { updatePerson() }
  56. function onModelReset() { updatePerson() }
  57. }
  58.  
  59. Component.onCompleted: updatePerson()
  60. onContactIdChanged: updatePerson()
  61.  
  62. function updatePerson() {
  63. person = peopleModel.personById(model.contactIds[0])
  64. }
  65.  
  66. actions: [
  67. ActionButton{
  68. id: markAsReadButton
  69. iconSource: "images://theme/check-double"
  70. onClicked: model.group.markAsRead()
  71. },
  72. ActionButton{
  73. id: deleteConverstationButton
  74. iconSource: "images://theme/trash"
  75. onClicked: model.group.deleteGroup()
  76. }
  77. ]
  78.  
  79. Rectangle{
  80. id: unreadCount
  81. visible: model.unreadMessages > 0
  82. width: Theme.itemHeightLarge/3
  83. height: width
  84. color: Theme.accentColor
  85. radius: height/2
  86.  
  87. Text {
  88. id: unreadCountText
  89. text: model.unreadMessages > 99 ? "99+" : model.unreadMessages
  90. font.pixelSize: parent.height*0.8
  91. color: Theme.textColor
  92. anchors.centerIn: parent
  93. }
  94.  
  95. anchors{
  96. bottom: converstationListDelegate.bottom
  97. bottomMargin: Theme.itemSpacingExtraSmall
  98. left: converstationListDelegate.left
  99. leftMargin: Theme.itemHeightLarge/4*3
  100. }
  101. }
  102.  
  103. Label {
  104. id: messageDate
  105. // XXX This should be something more natural/useful
  106. text: Qt.formatDateTime(model.lastModified, "M/d")
  107. anchors.left: parent.right
  108. anchors.verticalCenter: parent.verticalCenter
  109. }
  110.  
  111. function getAvatar() {
  112. var av_source;
  113. if (model.person == null || model.person.avatarPath == "image://theme/user" || model.person.avatarPath == "image://theme/icon-m-telephony-contact-avatar")
  114. {
  115. av_source = "image://theme/user"
  116. }
  117. else
  118. {
  119. av_source = model.person.avatarPath
  120. }
  121. return av_source;
  122. }
  123. }
  124.  
  125.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement