ClassificationCountBubble.qml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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 "../../../../shared/qml/UIConstants.js" as UIConstants
  22. import NewsBlur 1.0
  23. import WebFeeds 1.0
  24. Item
  25. {
  26. id:root
  27. property int negativeCount: 0
  28. property int neutralCount: 0
  29. property int positiveCount: 0
  30. property bool largeSized: false
  31. property bool vertical: false
  32. property int filterType: NewsBlurEnum.CfNoFilter
  33. property bool hideNullSegments: true
  34. width: row.width
  35. height: row.height
  36. Row {
  37. id: row
  38. // anchors.fill: parent
  39. visible: !root.vertical
  40. Item {
  41. id: leftBubble
  42. //width: visible ? internal.getBubbleWidth(root.negativeCount, leftText.paintedWidth) : 0
  43. width: visible ? leftText.paintedWidth + 13 : 0
  44. visible: root.hideNullSegments ? (root.negativeCount > 0) : true
  45. height: 24
  46. BorderImage {
  47. source: {
  48. if(root.hideNullSegments) {
  49. if(middleBubble.visible || rightBubble.visible)
  50. return "qrc:/plugins/newsblur/images/count_bubble/red_horizontal_left.png";
  51. else
  52. return "qrc:/plugins/newsblur/images/count_bubble/red.png";
  53. } else {
  54. if(root.filterType == NewsBlurEnum.CfNoFilter)
  55. return "qrc:/plugins/newsblur/images/count_bubble/red_horizontal_left.png"
  56. else
  57. return "qrc:/plugins/newsblur/images/count_bubble/gray_horizontal_left.png"
  58. }
  59. }
  60. anchors.fill: parent
  61. border { left: 10; top: 10; right: 10; bottom: 10 }
  62. }
  63. Text {
  64. id: leftText
  65. height: parent.height
  66. y:1
  67. color: "white"
  68. font.family: UIConstants.FONT_FAMILY_BOLD
  69. anchors.horizontalCenter: parent.horizontalCenter
  70. verticalAlignment: Text.AlignVCenter
  71. font.pixelSize: 18
  72. text: root.negativeCount
  73. }
  74. }
  75. Item {
  76. id: middleBubble
  77. // width: visible ? internal.getBubbleWidth(root.neutralCount, middleText.paintedWidth) : 0
  78. width: visible ? middleText.paintedWidth + 13 : 0
  79. visible: root.hideNullSegments ? (root.neutralCount > 0) : true
  80. height: 24
  81. BorderImage {
  82. source: {
  83. if(root.hideNullSegments) {
  84. if(leftBubble.visible && rightBubble.visible)
  85. return "qrc:/plugins/newsblur/images/count_bubble/orange_horizontal_middle.png";
  86. else if(leftBubble.visible)
  87. return "qrc:/plugins/newsblur/images/count_bubble/orange_horizontal_right.png";
  88. else if(rightBubble.visible)
  89. return "qrc:/plugins/newsblur/images/count_bubble/orange_horizontal_left.png";
  90. else
  91. return "qrc:/plugins/newsblur/images/count_bubble/orange.png";
  92. } else {
  93. if(root.filterType != NewsBlurEnum.CfOnlyPositive)
  94. return "qrc:/plugins/newsblur/images/count_bubble/orange_horizontal_middle.png"
  95. else
  96. return "qrc:/plugins/newsblur/images/count_bubble/gray_horizontal_middle.png"
  97. }
  98. }
  99. anchors.fill: parent
  100. border { left: 10; top: 10; right: 10; bottom: 10 }
  101. }
  102. Text {
  103. id: middleText
  104. height: parent.height
  105. y:1
  106. color: "white"
  107. font.family: UIConstants.FONT_FAMILY_BOLD
  108. anchors.horizontalCenter: parent.horizontalCenter
  109. verticalAlignment: Text.AlignVCenter
  110. font.pixelSize: 18
  111. text: root.neutralCount
  112. }
  113. }
  114. Item {
  115. id: rightBubble
  116. // width: visible ? internal.getBubbleWidth(root.positiveCount, rightText.paintedWidth) : 0
  117. width: visible ? rightText.paintedWidth + 13 : 0
  118. visible: root.hideNullSegments ? (root.positiveCount > 0) : true
  119. height: 24
  120. BorderImage {
  121. source: {
  122. if(root.hideNullSegments) {
  123. if(middleBubble.visible || leftBubble.visible)
  124. return "qrc:/plugins/newsblur/images/count_bubble/green_horizontal_right.png";
  125. else
  126. return "qrc:/plugins/newsblur/images/count_bubble/green.png";
  127. } else {
  128. return "qrc:/plugins/newsblur/images/count_bubble/green_horizontal_right.png";
  129. }
  130. }
  131. anchors.fill: parent
  132. border { left: 10; top: 10; right: 10; bottom: 10 }
  133. }
  134. Text {
  135. id: rightText
  136. height: parent.height
  137. y:1
  138. color: "white"
  139. font.family: UIConstants.FONT_FAMILY_BOLD
  140. anchors.horizontalCenter: parent.horizontalCenter
  141. verticalAlignment: Text.AlignVCenter
  142. font.pixelSize: 18
  143. text: root.positiveCount
  144. }
  145. }
  146. }
  147. QtObject {
  148. id: internal
  149. function getBubbleWidth(value, paintedWidth) {
  150. if (value < 10)
  151. return 24;
  152. else if (value < 100)
  153. return 30;
  154. else if (value < 1000)
  155. return 40;
  156. else
  157. return paintedWidth+13
  158. }
  159. }
  160. }