SensorsTab.qml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Copyright (C) 2015 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. import Fancontrol.Qml 1.0 as Fancontrol
  24. Kirigami.ScrollablePage {
  25. id: root
  26. readonly property QtObject loader: Fancontrol.Base.loader
  27. spacing: Kirigami.Units.smallSpacing
  28. ListView {
  29. id: listView
  30. width: root.width
  31. topMargin: spacing
  32. spacing: Kirigami.Units.largeSpacing * 2
  33. headerPositioning: ListView.OverlayHeader
  34. model: loader.hwmons.length
  35. delegate: Rectangle {
  36. property QtObject hwmon: loader.hwmons[index]
  37. height: childrenRect.height
  38. width: listView.width - listView.spacing * 2
  39. x: listView.spacing
  40. clip: true
  41. color: Kirigami.Theme.backgroundColor
  42. Column {
  43. id: column
  44. width: parent.width
  45. padding: root.spacing
  46. Label {
  47. anchors.horizontalCenter: parent.horizontalCenter
  48. text: hwmon.name
  49. font.pointSize: 12
  50. horizontalAlignment: Text.horizontalCenter
  51. }
  52. Repeater {
  53. model: hwmon.fans.length
  54. RowLayout {
  55. width: parent.width - parent.padding * 2
  56. Label {
  57. anchors.leftMargin: root.spacing
  58. Layout.maximumWidth: parent.width - rpmValue.width - root.spacing*2
  59. Layout.alignment: Qt.AlignLeft
  60. clip: true
  61. text: "Fan " + (index+1) + ":"
  62. }
  63. Label {
  64. id: rpmValue
  65. Layout.alignment: Qt.AlignRight
  66. anchors.rightMargin: root.spacing
  67. text: hwmon.fans[index].rpm + " " + i18n("rpm")
  68. }
  69. }
  70. }
  71. Repeater {
  72. model: hwmon.temps.length
  73. RowLayout {
  74. width: parent.width - parent.padding * 2
  75. Label {
  76. anchors.leftMargin: root.spacing
  77. text: hwmon.temps[index].name + ": "
  78. Layout.maximumWidth: parent.width - tempValue.width - root.spacing*2
  79. Layout.alignment: Qt.AlignLeft
  80. clip: true
  81. }
  82. Label {
  83. id: tempValue
  84. Layout.alignment: Qt.AlignRight
  85. anchors.rightMargin: root.spacing
  86. text: Units.fromCelsius(hwmon.temps[index].value, Fancontrol.Base.unit) + " " + i18n(Fancontrol.Base.unit)
  87. }
  88. }
  89. }
  90. }
  91. }
  92. }
  93. }