OptionInput.qml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (C) 2015 Malte Veerman <maldela@halloarsch.de>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU Lesser General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. *
  18. */
  19. import QtQuick 2.4
  20. import QtQuick.Layouts 1.1
  21. FocusScope {
  22. property alias text: textField.text
  23. property alias font: textField.font
  24. property alias inputMethodHints: textField.inputMethodHints
  25. property alias validator: textField.validator
  26. property alias color: textField.color
  27. property real margin: 6
  28. property var value
  29. property var locale: Qt.locale()
  30. id: root
  31. implicitHeight: textField.implicitHeight + margin*2
  32. implicitWidth: textField.implicitWidth + margin*2
  33. onValueChanged: {
  34. if (textField.text != value) {
  35. textField.text = value;
  36. }
  37. }
  38. Rectangle {
  39. id: rect
  40. anchors.fill: parent
  41. border.width: 1
  42. radius: 2
  43. border.color: enabled ? palette.text : disabledPalette.text
  44. TextInput {
  45. id: textField
  46. anchors.fill: parent
  47. anchors.leftMargin: margin
  48. horizontalAlignment: TextEdit.AlignLeft
  49. verticalAlignment: TextEdit.AlignVCenter
  50. renderType: Text.NativeRendering
  51. selectByMouse: true
  52. color: enabled ? palette.text : disabledPalette.text
  53. MouseArea {
  54. anchors.fill: parent
  55. cursorShape: Qt.IBeamCursor
  56. acceptedButtons: Qt.NoButton
  57. }
  58. }
  59. SystemPalette {
  60. id: palette
  61. }
  62. SystemPalette {
  63. id: disabledPalette
  64. colorGroup: SystemPalette.Disabled
  65. }
  66. }
  67. }