VideoInformationView.qml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /**
  2. * Copyright (c) 2012 Nokia Corporation.
  3. */
  4. import QtQuick 1.1
  5. import "util.js" as Util
  6. Item {
  7. id: videoInformationView
  8. property string videoTitle: ""
  9. property int numLikes: 0
  10. property int numDislikes: 0
  11. property int viewCount: 0
  12. // Prepends forward zeros to a text (e.g. 41 -> 0041)
  13. function __prependToLength(text, len, fill) {
  14. text = text.toString();
  15. fill = fill.toString();
  16. var diff = len - text.length;
  17. for (var index = 0; index < diff; index++) {
  18. text = fill.concat(text);
  19. }
  20. return text;
  21. }
  22. anchors.margins: visual.informationViewMargins
  23. // Bundle each text label & image as a pair.
  24. Item {
  25. id: views
  26. height: childrenRect.height
  27. width: childrenRect.width
  28. anchors {
  29. top: parent.top
  30. topMargin: visual.inPortrait ? visual.margins * 10 : 0
  31. horizontalCenter: parent.horizontalCenter
  32. }
  33. VideoInfoTextLabel {
  34. id: viewCount
  35. // The forward zeros aren't prepended at the time being.
  36. //text: videoInformationView.__prependToLength(videoInformationView.viewCount, 4, 0)
  37. text: videoInformationView.viewCount
  38. font.pixelSize: visual.ultraLargeFontSize
  39. }
  40. VideoInfoTextLabel {
  41. anchors {
  42. top: viewCount.bottom
  43. horizontalCenter: visual.inPortrait ? viewCount.horizontalCenter : undefined
  44. left: visual.inPortrait ? undefined : viewCount.left
  45. }
  46. text: qsTr("views")
  47. }
  48. }
  49. Loader {
  50. id: likesAndDislikesLoader
  51. width: parent.width
  52. anchors {
  53. top: views.bottom
  54. topMargin: visual.margins * 2
  55. horizontalCenter: visual.inPortrait ? parent.horizontalCenter : undefined
  56. left: visual.inPortrait ? undefined : views.left
  57. }
  58. sourceComponent: visual.inPortrait ? likesAndDislikes : likesAndDislikesLS
  59. }
  60. Component {
  61. id: likesAndDislikes
  62. // Item bundling the likes & dislikes amounts + strings together.
  63. Item {
  64. // Two Text elements on top of each other,
  65. // amount of likes + "likes" string.
  66. VideoInfoTextLabel {
  67. id: likesCount
  68. anchors.left: parent.left
  69. font.pixelSize: visual.extraLargeFontSize
  70. // The forward zeros aren't prepended at the time being.
  71. //text: videoInformationView.__prependToLength(videoInformationView.numLikes, 4, 0)
  72. text: videoInformationView.numLikes
  73. }
  74. VideoInfoTextLabel {
  75. id: likesLabel
  76. anchors {
  77. top: likesCount.bottom
  78. horizontalCenter: likesCount.horizontalCenter
  79. }
  80. text: qsTr("likes")
  81. }
  82. // Two Text elements on top of each other,
  83. // amount of dislikes + "dislikes" string.
  84. VideoInfoTextLabel {
  85. id: dislikesCount
  86. anchors {
  87. right: parent.right
  88. rightMargin: visual.margins
  89. }
  90. font.pixelSize: visual.extraLargeFontSize
  91. // The forward zeros aren't prepended at the time being.
  92. //text: videoInformationView.__prependToLength(videoInformationView.numDislikes, 4, 0)
  93. text: videoInformationView.numDislikes
  94. }
  95. VideoInfoTextLabel {
  96. id: dislikesLabel
  97. anchors {
  98. horizontalCenter: dislikesCount.horizontalCenter
  99. top: dislikesCount.bottom
  100. }
  101. text: qsTr("dislikes")
  102. }
  103. }
  104. }
  105. Component {
  106. id: likesAndDislikesLS
  107. // Item bundling the likes & dislikes amounts + strings together.
  108. Item {
  109. // Two Text elements on top of each other,
  110. // amount of likes + "likes" string.
  111. VideoInfoTextLabel {
  112. id: likesCount
  113. //anchors.horizontalCenter: parent.horizontalCenter
  114. anchors.left: parent.left
  115. font.pixelSize: visual.extraLargeFontSize
  116. // The forward zeros aren't prepended at the time being.
  117. //text: videoInformationView.__prependToLength(videoInformationView.numLikes, 4, 0)
  118. text: videoInformationView.numLikes
  119. }
  120. VideoInfoTextLabel {
  121. id: likesLabel
  122. anchors {
  123. top: likesCount.bottom
  124. //horizontalCenter: likesCount.horizontalCenter
  125. left: likesCount.left
  126. }
  127. text: qsTr("likes")
  128. }
  129. // Two Text elements on top of each other,
  130. // amount of dislikes + "dislikes" string.
  131. VideoInfoTextLabel {
  132. id: dislikesCount
  133. anchors {
  134. //horizontalCenter: parent.horizontalCenter
  135. left: parent.left
  136. top: likesLabel.bottom
  137. topMargin: visual.margins
  138. }
  139. font.pixelSize: visual.extraLargeFontSize
  140. // The forward zeros aren't prepended at the time being.
  141. //text: videoInformationView.__prependToLength(videoInformationView.numDislikes, 4, 0)
  142. text: videoInformationView.numDislikes
  143. }
  144. VideoInfoTextLabel {
  145. id: dislikesLabel
  146. anchors {
  147. //horizontalCenter: dislikesCount.horizontalCenter
  148. left: dislikesCount.left
  149. top: dislikesCount.bottom
  150. }
  151. text: qsTr("dislikes")
  152. }
  153. }
  154. }
  155. }