TextArea.qml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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.TextArea {
  10. id: control
  11. implicitWidth: Math.max(contentWidth + leftPadding + rightPadding,
  12. implicitBackgroundWidth + leftInset + rightInset,
  13. placeholder.implicitWidth + leftPadding + rightPadding)
  14. implicitHeight: Math.max(contentHeight + topPadding + bottomPadding,
  15. implicitBackgroundHeight + topInset + bottomInset,
  16. placeholder.implicitHeight + topPadding + bottomPadding)
  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. color: control.palette.text
  26. selectionColor: control.palette.highlight
  27. selectedTextColor: control.palette.highlightedText
  28. verticalAlignment: Qt.AlignVCenter
  29. placeholderTextColor: control.palette.placeholderText
  30. PlaceholderText {
  31. id: placeholder
  32. x: control.leftPadding
  33. y: control.topPadding
  34. width: control.width - (control.leftPadding + control.rightPadding)
  35. height: control.height - (control.topPadding + control.bottomPadding)
  36. text: control.placeholderText
  37. font: control.font
  38. color: control.placeholderTextColor
  39. verticalAlignment: control.verticalAlignment
  40. visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
  41. elide: Text.ElideRight
  42. renderType: control.renderType
  43. }
  44. background: NinePatchImage {
  45. source: Imagine.url + "textarea-background"
  46. NinePatchImageSelector on source {
  47. states: [
  48. {"disabled": !control.enabled},
  49. {"focused": control.activeFocus},
  50. {"mirrored": control.mirrored},
  51. {"hovered": control.enabled && control.hovered}
  52. ]
  53. }
  54. }
  55. }