TextArea.qml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2021 The Qt Company Ltd.
  4. ** Contact: https://www.qt.io/licensing/
  5. **
  6. ** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
  7. **
  8. ** $QT_BEGIN_LICENSE:COMM$
  9. **
  10. ** Commercial License Usage
  11. ** Licensees holding valid commercial Qt licenses may use this file in
  12. ** accordance with the commercial license agreement provided with the
  13. ** Software or, alternatively, in accordance with the terms contained in
  14. ** a written agreement between you and The Qt Company. For licensing terms
  15. ** and conditions see https://www.qt.io/terms-conditions. For further
  16. ** information use the contact form at https://www.qt.io/contact-us.
  17. **
  18. ** $QT_END_LICENSE$
  19. **
  20. **
  21. **
  22. **
  23. **
  24. **
  25. **
  26. **
  27. **
  28. **
  29. **
  30. **
  31. **
  32. **
  33. **
  34. **
  35. ****************************************************************************/
  36. import QtQuick 2.12
  37. import QtQuick.Controls 2.12
  38. import QtQuick.Controls.impl 2.12
  39. import QtQuick.Templates 2.12 as T
  40. T.TextArea {
  41. id: control
  42. implicitWidth: Math.max(contentWidth + leftPadding + rightPadding,
  43. implicitBackgroundWidth + leftInset + rightInset,
  44. placeholder.implicitWidth + leftPadding + rightPadding)
  45. implicitHeight: Math.max(contentHeight + topPadding + bottomPadding,
  46. implicitBackgroundHeight + topInset + bottomInset,
  47. placeholder.implicitHeight + topPadding + bottomPadding)
  48. padding: 6
  49. leftPadding: padding + 4
  50. color: control.palette.text
  51. placeholderTextColor: Color.transparent(control.color, 0.5)
  52. selectionColor: control.palette.highlight
  53. selectedTextColor: control.palette.highlightedText
  54. PlaceholderText {
  55. id: placeholder
  56. x: control.leftPadding
  57. y: control.topPadding
  58. width: control.width - (control.leftPadding + control.rightPadding)
  59. height: control.height - (control.topPadding + control.bottomPadding)
  60. text: control.placeholderText
  61. font: control.font
  62. color: control.placeholderTextColor
  63. verticalAlignment: control.verticalAlignment
  64. visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
  65. elide: Text.ElideRight
  66. renderType: control.renderType
  67. }
  68. }