FluMultilineTextBox.qml 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import QtQuick
  2. import QtQuick.Controls
  3. import QtQuick.Controls.Basic
  4. import FluentUI
  5. TextArea{
  6. property int fontStyle: FluText.Body
  7. property int pixelSize : FluTheme.textSize
  8. property bool disabled: false
  9. property color normalColor: FluTheme.dark ? Qt.rgba(255/255,255/255,255/255,1) : Qt.rgba(27/255,27/255,27/255,1)
  10. property color disableColor: FluTheme.dark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
  11. property color placeholderNormalColor: FluTheme.dark ? Qt.rgba(210/255,210/255,210/255,1) : Qt.rgba(96/255,96/255,96/255,1)
  12. property color placeholderFocusColor: FluTheme.dark ? Qt.rgba(152/255,152/255,152/255,1) : Qt.rgba(141/255,141/255,141/255,1)
  13. property color placeholderDisableColor: FluTheme.dark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
  14. id:control
  15. width: 300
  16. enabled: !disabled
  17. color: {
  18. if(disabled){
  19. return disableColor
  20. }
  21. return normalColor
  22. }
  23. wrapMode: Text.WrapAnywhere
  24. renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering
  25. selectionColor: FluTheme.primaryColor.lightest
  26. placeholderTextColor: {
  27. if(disabled){
  28. return placeholderDisableColor
  29. }
  30. if(focus){
  31. return placeholderFocusColor
  32. }
  33. return placeholderNormalColor
  34. }
  35. font.bold: {
  36. switch (fontStyle) {
  37. case FluText.Display:
  38. return true
  39. case FluText.TitleLarge:
  40. return true
  41. case FluText.Title:
  42. return true
  43. case FluText.SubTitle:
  44. return true
  45. case FluText.BodyStrong:
  46. return true
  47. case FluText.Body:
  48. return false
  49. case FluText.Caption:
  50. return false
  51. default:
  52. return false
  53. }
  54. }
  55. font.pixelSize: {
  56. switch (fontStyle) {
  57. case FluText.Display:
  58. return text.pixelSize * 4.857
  59. case FluText.TitleLarge:
  60. return text.pixelSize * 2.857
  61. case FluText.Title:
  62. return text.pixelSize * 2
  63. case FluText.SubTitle:
  64. return text.pixelSize * 1.428
  65. case FluText.Body:
  66. return text.pixelSize * 1.0
  67. case FluText.BodyStrong:
  68. return text.pixelSize * 1.0
  69. case FluText.Caption:
  70. return text.pixelSize * 0.857
  71. default:
  72. return text.pixelSize * 1.0
  73. }
  74. }
  75. selectByMouse: true
  76. background: FluTextBoxBackground{ inputItem: control }
  77. TapHandler {
  78. acceptedButtons: Qt.RightButton
  79. onTapped: control.echoMode !== TextInput.Password && menu.popup()
  80. }
  81. FluTextBoxMenu{
  82. id:menu
  83. inputItem: control
  84. }
  85. }