ComboBoxMenuItem.qml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
  4. ** All rights reserved.
  5. ** Contact: Nokia Corporation (qt-info@nokia.com)
  6. **
  7. ** This file is part of the Qt Components project.
  8. **
  9. ** $QT_BEGIN_LICENSE:BSD$
  10. ** You may use this file under the terms of the BSD license as follows:
  11. **
  12. ** "Redistribution and use in source and binary forms, with or without
  13. ** modification, are permitted provided that the following conditions are
  14. ** met:
  15. ** * Redistributions of source code must retain the above copyright
  16. ** notice, this list of conditions and the following disclaimer.
  17. ** * Redistributions in binary form must reproduce the above copyright
  18. ** notice, this list of conditions and the following disclaimer in
  19. ** the documentation and/or other materials provided with the
  20. ** distribution.
  21. ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
  22. ** the names of its contributors may be used to endorse or promote
  23. ** products derived from this software without specific prior written
  24. ** permission.
  25. **
  26. ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  27. ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  28. ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  29. ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  30. ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  31. ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  32. ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  33. ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  34. ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  35. ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  36. ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
  37. ** $QT_END_LICENSE$
  38. **
  39. ****************************************************************************/
  40. // MenuItem is a component that is used in menus.
  41. import QtQuick 1.1
  42. import "." 1.0
  43. import "UIConstants.js" as UI
  44. Item {
  45. id: root
  46. // Common API
  47. property string text
  48. property string selectionText
  49. signal clicked
  50. property alias pressed: mouseArea.pressed
  51. width: parent ? parent.width: 0
  52. height: 80
  53. /*
  54. Rectangle {
  55. id: backgroundRec
  56. // ToDo: remove hardcoded values
  57. color: pressed ? "darkgray" : "transparent"
  58. anchors.fill : root
  59. opacity : 0.5
  60. }
  61. */
  62. BorderImage {
  63. id: backgroundImage
  64. // ToDo: remove hardcoded values
  65. source: root.parent.children.length == 1 ? (pressed ? "image://theme/meegotouch-list-background-pressed" : "image://theme/meegotouch-list-background")
  66. : root.parent.children[0] == root ? (pressed ? "image://theme/meegotouch-list-background-pressed-vertical-top" : "image://theme/meegotouch-list-background-vertical-top")
  67. : root.parent.children[root.parent.children.length-1] == root ? (pressed ? "image://theme/meegotouch-list-background-pressed-vertical-bottom" : "image://theme/meegotouch-list-background-vertical-bottom")
  68. : (pressed ? "image://theme/meegotouch-list-background-pressed-vertical-center" : "image://theme/meegotouch-list-background-vertical-center")
  69. anchors.fill : root
  70. border { left: 22; top: 22;
  71. right: 22; bottom: 22 }
  72. }
  73. Text {
  74. id: menuText
  75. anchors.left: parent.left
  76. anchors.right: filterIndicator.left
  77. anchors.leftMargin: UI.PADDING_XXLARGE
  78. anchors.rightMargin: UI.PADDING_XXLARGE
  79. anchors.bottom: parent.verticalCenter
  80. text: root.text
  81. elide: Text.ElideRight
  82. font.family : UI.FONT_FAMILY
  83. font.pixelSize : UI.FONT_SLARGE
  84. font.weight: Font.Bold
  85. color: "black"
  86. }
  87. Text {
  88. id: filterText
  89. anchors.left: parent.left
  90. anchors.right: filterIndicator.left
  91. anchors.leftMargin: UI.PADDING_XXLARGE
  92. anchors.rightMargin: UI.PADDING_XXLARGE
  93. anchors.top: parent.verticalCenter
  94. text: root.selectionText
  95. elide: Text.ElideRight
  96. font.family : UI.FONT_FAMILY_LIGHT
  97. font.pixelSize : UI.FONT_LSMALL
  98. font.weight: Font.Normal
  99. color: "black"
  100. }
  101. Image {
  102. id: filterIndicator
  103. anchors.right: parent.right
  104. anchors.rightMargin: UI.PADDING_XXLARGE
  105. anchors.verticalCenter: parent.verticalCenter
  106. width: 32
  107. height: 32
  108. source: "qrc:/shared/images/filter_indicator_inverted.png"
  109. }
  110. MouseArea {
  111. id: mouseArea
  112. anchors.fill: parent
  113. onClicked: { if (parent.enabled) parent.clicked();}
  114. }
  115. onClicked: if (parent) parent.closeLayout();
  116. }