RadioDelegate.qml 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright (C) 2017 The Qt Company Ltd.
  2. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
  3. // Qt-Security score:significant reason:default
  4. import QtQuick
  5. import QtQuick.Templates as T
  6. import QtQuick.Controls.impl
  7. import QtQuick.Controls.Imagine
  8. import QtQuick.Controls.Imagine.impl
  9. T.RadioDelegate {
  10. id: control
  11. implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
  12. implicitContentWidth + leftPadding + rightPadding)
  13. implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
  14. implicitContentHeight + topPadding + bottomPadding,
  15. implicitIndicatorHeight + topPadding + bottomPadding)
  16. spacing: 12 // ###
  17. topPadding: background ? background.topPadding : 0
  18. leftPadding: background ? background.leftPadding : 0
  19. rightPadding: background ? background.rightPadding : 0
  20. bottomPadding: background ? background.bottomPadding : 0
  21. topInset: background ? -background.topInset || 0 : 0
  22. leftInset: background ? -background.leftInset || 0 : 0
  23. rightInset: background ? -background.rightInset || 0 : 0
  24. bottomInset: background ? -background.bottomInset || 0 : 0
  25. icon.width: 24
  26. icon.height: 24
  27. icon.color: control.palette.text
  28. indicator: Image {
  29. x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding
  30. y: control.topPadding + (control.availableHeight - height) / 2
  31. source: Imagine.url + "radiodelegate-indicator"
  32. ImageSelector on source {
  33. states: [
  34. {"disabled": !control.enabled},
  35. {"pressed": control.down},
  36. {"checked": control.checked},
  37. {"focused": control.visualFocus},
  38. {"highlighted": control.highlighted},
  39. {"mirrored": control.mirrored},
  40. {"hovered": control.enabled && control.hovered}
  41. ]
  42. }
  43. }
  44. contentItem: IconLabel {
  45. leftPadding: control.mirrored ? control.indicator.width + control.spacing : 0
  46. rightPadding: !control.mirrored ? control.indicator.width + control.spacing : 0
  47. spacing: control.spacing
  48. mirrored: control.mirrored
  49. display: control.display
  50. alignment: control.display === IconLabel.IconOnly || control.display === IconLabel.TextUnderIcon ? Qt.AlignCenter : Qt.AlignLeft
  51. icon: control.icon
  52. text: control.text
  53. font: control.font
  54. color: control.palette.text
  55. }
  56. background: NinePatchImage {
  57. source: Imagine.url + "radiodelegate-background"
  58. NinePatchImageSelector on source {
  59. states: [
  60. {"disabled": !control.enabled},
  61. {"pressed": control.down},
  62. {"checked": control.checked},
  63. {"focused": control.visualFocus},
  64. {"highlighted": control.highlighted},
  65. {"mirrored": control.mirrored},
  66. {"hovered": control.enabled && control.hovered}
  67. ]
  68. }
  69. }
  70. }