CommonSheet.qml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 com.nokia.extras 1.1
  23. import WebFeeds 1.0
  24. import "UIConstants.js" as UIConstants
  25. Sheet {
  26. id: root
  27. property PageItem pageItem: null
  28. property Button acceptButton
  29. property alias contentItem: contentParent.children
  30. property string busyText : qsTr("Busy")
  31. property string title: qsTr("Title")
  32. property bool multilineTitle: false
  33. property string iconSource
  34. property bool busy: false
  35. property bool titleEnabled: true
  36. Component.onCompleted: {
  37. root.acceptButton = root.getButton("acceptButton");
  38. root.acceptButton.enabled = false;
  39. root.acceptButton.platformStyle.background = "image://theme/" + UIConstants.COLOR_NAME +
  40. "meegotouch-sheet-button-accent"+root.acceptButton.platformStyle.__invertedString+"-background";
  41. root.acceptButton.platformStyle.pressedBackground = "image://theme/" + UIConstants.COLOR_NAME +
  42. "meegotouch-sheet-button-accent"+root.acceptButton.platformStyle.__invertedString+"-background-pressed";
  43. root.acceptButton.platformStyle.disabledBackground = "image://theme/" + UIConstants.COLOR_NAME +
  44. "meegotouch-sheet-button-accent"+root.acceptButton.platformStyle.__invertedString+"-background-disabled";
  45. }
  46. function showMessage(message) {
  47. infoBanner.text = message;
  48. infoBanner.show();
  49. }
  50. InfoBanner {
  51. id: infoBanner
  52. }
  53. content: Item {
  54. anchors.fill: parent
  55. Column {
  56. id: titleColumn
  57. visible: root.titleEnabled
  58. anchors.left: parent.left
  59. anchors.right: parent.right
  60. anchors.top: parent.top
  61. anchors.leftMargin: UIConstants.DEFAULT_MARGIN
  62. anchors.rightMargin: UIConstants.DEFAULT_MARGIN
  63. anchors.topMargin: UIConstants.DEFAULT_MARGIN
  64. spacing: UIConstants.DEFAULT_MARGIN
  65. Item {
  66. id: titleContents
  67. anchors.left: parent.left
  68. anchors.right: parent.right
  69. height: Math.max(icon.height, titleLabel.paintedHeight);
  70. Image {
  71. id: icon
  72. anchors.left: parent.left
  73. anchors.verticalCenter: parent.verticalCenter
  74. width: root.iconSource ? 64 : 0
  75. height: root.iconSource ? 64 : 0
  76. source: root.iconSource
  77. visible: root.iconSource
  78. }
  79. Label {
  80. id: titleLabel
  81. anchors.left: icon.right
  82. anchors.leftMargin: icon.visible ? UIConstants.DEFAULT_MARGIN : 0
  83. anchors.right: parent.right
  84. anchors.verticalCenter: parent.verticalCenter
  85. font.pointSize: UIConstants.FONT_DEFAULT
  86. font.family: UIConstants.FONT_FAMILY_LIGHT
  87. color: UIConstants.HEADER_TITLE_COLOR
  88. text: root.title
  89. wrapMode: root.multilineTitle ? Text.Wrap : Text.NoWrap
  90. maximumLineCount: root.multilineTitle ? 2 : 1
  91. elide: root.multilineTitle ? Text.ElideRight : Text.ElideNone
  92. }
  93. }
  94. Separator {}
  95. }
  96. Item {
  97. id: contentParent
  98. width: parent.width
  99. anchors.top: root.titleEnabled ? titleColumn.bottom : parent.top
  100. anchors.topMargin: UIConstants.DEFAULT_MARGIN
  101. anchors.bottom: parent.bottom
  102. }
  103. Column {
  104. id: busyItem
  105. visible: false
  106. width: parent.width
  107. spacing: UIConstants.DEFAULT_HALF_MARGIN
  108. anchors.centerIn: parent
  109. BusyIndicator {
  110. anchors.horizontalCenter: parent.horizontalCenter
  111. running: true
  112. platformStyle: BusyIndicatorStyle { size: "large" }
  113. }
  114. Label {
  115. anchors.horizontalCenter: parent.horizontalCenter
  116. text: root.busyText
  117. font.pointSize: UIConstants.FONT_SLARGE
  118. font.bold: true
  119. }
  120. }
  121. }
  122. Item {
  123. id: privateItem
  124. property Item originalParent: null
  125. states: [
  126. State {
  127. name: "BUSY"
  128. when: root.busy
  129. PropertyChanges {
  130. target: contentParent
  131. visible: false
  132. }
  133. PropertyChanges {
  134. target: busyItem
  135. visible: true
  136. }
  137. PropertyChanges {
  138. target: root.acceptButton
  139. enabled: false
  140. }
  141. }
  142. ]
  143. }
  144. }