ClassifierButton.qml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2012 Róbert Márki
  4. **
  5. ** This file is part of Web Feeds.
  6. **
  7. ** Web Feeds is free software: you can redistribute it and/or modify
  8. ** it under the terms of the GNU General Public License as published by
  9. ** the Free Software Foundation, either version 3 of the License, or
  10. ** (at your option) any later version.
  11. **
  12. ** Web Feeds is distributed in the hope that it will be useful,
  13. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ** GNU General Public License for more details.
  16. **
  17. ** You should have received a copy of the GNU General Public License
  18. ** along with Web Feeds. If not, see <http://www.gnu.org/licenses/>.
  19. ****************************************************************************/
  20. import QtQuick 1.1
  21. import com.nokia.meego 1.0
  22. import WebFeeds 1.0
  23. import NewsBlur 1.0
  24. import "../../../../shared/qml" as Shared
  25. import "../../../../shared/qml/UIConstants.js" as UIConstants
  26. Item {
  27. id: root
  28. property alias text: label.text
  29. property string position: ""
  30. property int classification: 0
  31. property string __classificationText: !(root.classification > 0) ? (!(root.classification < 0) ? "neutral" : "negative") : "positive"
  32. signal classificationSet(int newClassification);
  33. width: 300
  34. height: UIConstants.DEFAULT_DELEGATE_HEIGHT
  35. Item {
  36. id: dislikeItem
  37. anchors.left: parent.left
  38. height: parent.height
  39. width: parent.height
  40. BorderImage {
  41. id: leftBackground
  42. anchors.fill: parent
  43. border { left: UIConstants.CORNER_MARGINS; top: UIConstants.CORNER_MARGINS;
  44. right: UIConstants.CORNER_MARGINS; bottom: UIConstants.CORNER_MARGINS }
  45. source: "qrc:/plugins/newsblur/images/classifier_button/" + (root.position ? (root.position + "-") : "")
  46. + "left" + (dislikeMouseArea.pressed ? "-pressed" :
  47. ((root.classification < 0) ? "-selected" : ""))
  48. + ".png"
  49. // source: "qrc:/plugins/newsblur/images/classifier_button/" + root.__classificationText + "-" + (root.position ? (root.position + "-") : "")
  50. // + "left" + (dislikeMouseArea.pressed ? "-pressed" : "")
  51. // + ".png"
  52. }
  53. Image {
  54. id: dislikeImage
  55. anchors.centerIn: parent
  56. source: "qrc:/plugins/newsblur/images/dislike_icon" + ((root.classification < 0) ? "-inverted" : "") + ".png"
  57. // source: "qrc:/plugins/newsblur/images/dislike_icon-inverted.png"
  58. }
  59. MouseArea {
  60. id: dislikeMouseArea
  61. anchors.fill: parent
  62. onClicked: {
  63. if(root.classification >= 0)
  64. root.classificationSet(-1);
  65. }
  66. }
  67. }
  68. Item {
  69. id: centerItem
  70. anchors.left: dislikeItem.right
  71. anchors.right: likeItem.left
  72. height: parent.height
  73. BorderImage {
  74. id: centerBackground
  75. anchors.fill: parent
  76. border { left: UIConstants.CORNER_MARGINS; top: UIConstants.CORNER_MARGINS;
  77. right: UIConstants.CORNER_MARGINS; bottom: UIConstants.CORNER_MARGINS }
  78. source: "qrc:/plugins/newsblur/images/classifier_button/" + (root.position ? (root.position + "-") : "")
  79. + "center" + (centerMouseArea.pressed ? "-pressed" :
  80. ((root.classification == 0) ? "-selected" : ""))
  81. + ".png"
  82. // source: "qrc:/plugins/newsblur/images/classifier_button/" + root.__classificationText + "-" + (root.position ? (root.position + "-") : "")
  83. // + "center" + (dislikeMouseArea.pressed ? "-pressed" : "")
  84. // + ".png"
  85. }
  86. Label {
  87. id: label
  88. anchors.fill: parent
  89. anchors.leftMargin: UIConstants.BUTTON_SPACING
  90. anchors.rightMargin: UIConstants.BUTTON_SPACING
  91. anchors.topMargin: UIConstants.BUTTON_SPACING
  92. anchors.bottomMargin: UIConstants.BUTTON_SPACING
  93. horizontalAlignment: Text.AlignHCenter
  94. verticalAlignment: Text.AlignVCenter
  95. text: modelData
  96. elide: Text.ElideRight
  97. wrapMode: Text.Wrap
  98. maximumLineCount: 2
  99. textFormat: Text.PlainText
  100. color: (root.classification == 0) ? "white" : "black"
  101. }
  102. MouseArea {
  103. id: centerMouseArea
  104. anchors.fill: parent
  105. onClicked: {
  106. if(root.classification != 0)
  107. root.classificationSet(0);
  108. }
  109. }
  110. }
  111. Item {
  112. id: likeItem
  113. anchors.right: parent.right
  114. height: parent.height
  115. width: parent.height
  116. BorderImage {
  117. id: rightBackground
  118. anchors.fill: parent
  119. border { left: UIConstants.CORNER_MARGINS; top: UIConstants.CORNER_MARGINS;
  120. right: UIConstants.CORNER_MARGINS; bottom: UIConstants.CORNER_MARGINS }
  121. source: "qrc:/plugins/newsblur/images/classifier_button/" + (root.position ? (root.position + "-") : "")
  122. + "right" + (likeMouseArea.pressed ? "-pressed" :
  123. ((root.classification > 0) ? "-selected" : ""))
  124. + ".png"
  125. // source: "qrc:/plugins/newsblur/images/classifier_button/" + root.__classificationText + "-" + (root.position ? (root.position + "-") : "")
  126. // + "right" + (dislikeMouseArea.pressed ? "-pressed" : "")
  127. // + ".png"
  128. }
  129. Image {
  130. id: likeImage
  131. anchors.centerIn: parent
  132. source: "qrc:/plugins/newsblur/images/like_icon" + ((root.classification > 0) ? "-inverted" : "") + ".png"
  133. // source: "qrc:/plugins/newsblur/images/like_icon-inverted.png"
  134. }
  135. MouseArea {
  136. id: likeMouseArea
  137. anchors.fill: parent
  138. onClicked: {
  139. if(root.classification <= 0)
  140. root.classificationSet(1);
  141. }
  142. }
  143. }
  144. }