TextArea.qml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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.Universal
  8. T.TextArea {
  9. id: control
  10. implicitWidth: Math.max(contentWidth + leftPadding + rightPadding,
  11. implicitBackgroundWidth + leftInset + rightInset,
  12. placeholder.implicitWidth + leftPadding + rightPadding)
  13. implicitHeight: Math.max(contentHeight + topPadding + bottomPadding,
  14. implicitBackgroundHeight + topInset + bottomInset,
  15. placeholder.implicitHeight + topPadding + bottomPadding)
  16. // TextControlThemePadding + 2 (border)
  17. padding: 12
  18. topPadding: padding - 7
  19. rightPadding: padding - 4
  20. bottomPadding: padding - 5
  21. Universal.theme: activeFocus ? Universal.Light : undefined
  22. color: !enabled ? Universal.chromeDisabledLowColor : Universal.foreground
  23. selectionColor: Universal.accent
  24. selectedTextColor: Universal.chromeWhiteColor
  25. placeholderTextColor: !enabled ? Universal.chromeDisabledLowColor :
  26. activeFocus ? Universal.chromeBlackMediumLowColor :
  27. Universal.baseMediumColor
  28. PlaceholderText {
  29. id: placeholder
  30. x: control.leftPadding
  31. y: control.topPadding
  32. width: control.width - (control.leftPadding + control.rightPadding)
  33. height: control.height - (control.topPadding + control.bottomPadding)
  34. text: control.placeholderText
  35. font: control.font
  36. color: control.placeholderTextColor
  37. visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
  38. verticalAlignment: control.verticalAlignment
  39. elide: Text.ElideRight
  40. renderType: control.renderType
  41. }
  42. background: Rectangle {
  43. implicitWidth: 60 // TextControlThemeMinWidth - 4 (border)
  44. implicitHeight: 28 // TextControlThemeMinHeight - 4 (border)
  45. border.width: 2 // TextControlBorderThemeThickness
  46. border.color: !control.enabled ? control.Universal.baseLowColor :
  47. control.activeFocus ? control.Universal.accent :
  48. control.hovered ? control.Universal.baseMediumColor : control.Universal.chromeDisabledLowColor
  49. color: control.enabled ? control.Universal.background : control.Universal.baseLowColor
  50. }
  51. }