FanHeader.qml 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (C) 2019 Malte Veerman <malte.veerman@gmail.com>
  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.6
  20. import QtQuick.Controls 2.1
  21. import QtQuick.Layouts 1.2
  22. import org.kde.kirigami 2.3 as Kirigami
  23. Item {
  24. property QtObject fan
  25. implicitHeight: layout.childrenRect.height
  26. RowLayout {
  27. id: layout
  28. anchors.fill: parent
  29. anchors.leftMargin: Kirigami.Units.smallSpacing
  30. anchors.rightMargin: Kirigami.Units.smallSpacing
  31. TextEdit {
  32. id: nameField
  33. Layout.alignment: Qt.AlignLeft
  34. text: !!fan ? fan.name : ""
  35. color: Kirigami.Theme.textColor
  36. horizontalAlignment: TextEdit.AlignLeft
  37. wrapMode: TextEdit.Wrap
  38. font.bold: true
  39. font.pointSize: Kirigami.Theme.defaultFont.pointSize + 2
  40. selectByMouse: true
  41. onTextChanged: if (!!fan && fan.name != text) fan.name = text
  42. Connections {
  43. target: !!fan ? fan : null
  44. onNameChanged: if (fan.name != nameField.text) nameField.text = fan.name
  45. }
  46. MouseArea {
  47. anchors.fill: parent
  48. cursorShape: Qt.IBeamCursor
  49. acceptedButtons: Qt.NoButton
  50. }
  51. }
  52. Label {
  53. Layout.alignment: Qt.AlignRight
  54. text: !!fan ? fan.path : ""
  55. horizontalAlignment: Text.AlignRight
  56. }
  57. }
  58. }