SelectionDialogIconDelegate.qml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 "UIConstants.js" as UI
  23. Item {
  24. id: delegateItem
  25. property bool selected: index == selectedIndex;
  26. property Style platformStyle: SelectionDialogStyle {}
  27. height: root.platformStyle.itemHeight
  28. anchors.left: parent.left
  29. anchors.right: parent.right
  30. MouseArea {
  31. id: delegateMouseArea
  32. anchors.fill: parent;
  33. onPressed: selectedIndex = index;
  34. onClicked: accept();
  35. }
  36. Rectangle {
  37. id: backgroundRect
  38. anchors.fill: parent
  39. color: delegateItem.selected ? root.platformStyle.itemSelectedBackgroundColor : root.platformStyle.itemBackgroundColor
  40. }
  41. BorderImage {
  42. id: background
  43. anchors.fill: parent
  44. border { left: UI.CORNER_MARGINS; top: UI.CORNER_MARGINS; right: UI.CORNER_MARGINS; bottom: UI.CORNER_MARGINS }
  45. source: delegateMouseArea.pressed ? root.platformStyle.itemPressedBackground :
  46. delegateItem.selected ? root.platformStyle.itemSelectedBackground :
  47. root.platformStyle.itemBackground
  48. }
  49. Image {
  50. id: image
  51. anchors.verticalCenter: delegateItem.verticalCenter
  52. anchors.left: parent.left
  53. anchors.leftMargin: root.platformStyle.itemLeftMargin
  54. source: icon
  55. }
  56. Text {
  57. id: itemText
  58. elide: Text.ElideRight
  59. color: delegateItem.selected ? root.platformStyle.itemSelectedTextColor : root.platformStyle.itemTextColor
  60. anchors.verticalCenter: delegateItem.verticalCenter
  61. anchors.left: image.right
  62. anchors.right: parent.right
  63. anchors.leftMargin: root.platformStyle.itemLeftMargin
  64. anchors.rightMargin: root.platformStyle.itemRightMargin
  65. text: name;
  66. font: root.platformStyle.itemFont
  67. }
  68. }