PwmFansTab.qml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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.Controls 1.4
  21. import QtQuick.Layouts 1.2
  22. import "../scripts/arrayfunctions.js" as ArrayFunctions
  23. ColumnLayout {
  24. property QtObject baseObject
  25. property QtObject loader: baseObject ? baseObject.loader : null
  26. property QtObject systemdCom: baseObject && baseObject.hasSystemdCommunicator() ? baseObject.systemdCom : null
  27. id: root
  28. anchors.fill: parent
  29. anchors.topMargin: 5
  30. RowLayout {
  31. width: parent.width
  32. visible: loader && loader.allPwmFans.length > 0
  33. Label {
  34. text: i18n("Fan:")
  35. Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
  36. renderType: Text.NativeRendering
  37. }
  38. ComboBox {
  39. id: fanComboBox
  40. model: ListModel {
  41. property var fans: loader.allPwmFans
  42. id: fanList
  43. Component.onCompleted: {
  44. for (var i=0; i<fans.length; i++) {
  45. fanList.append({"text": ArrayFunctions.nameWithPath(fans[i])});
  46. }
  47. }
  48. }
  49. Layout.fillWidth: true
  50. Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
  51. }
  52. Button {
  53. Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
  54. action: detectFansAction
  55. }
  56. }
  57. Loader {
  58. Layout.fillHeight: true
  59. Layout.fillWidth: true
  60. active: !!baseObject.loader.allPwmFans[fanComboBox.currentIndex]
  61. sourceComponent: PwmFan {
  62. unit: baseObject.unit
  63. fan: loader.allPwmFans[fanComboBox.currentIndex]
  64. loader: root.loader
  65. systemdCom: baseObject.systemdCom
  66. minTemp: baseObject.minTemp
  67. maxTemp: baseObject.maxTemp
  68. onNameChanged: {
  69. if (fanComboBox.currentText != ArrayFunctions.nameWithPath(fan)) {
  70. fanList.setProperty(fanComboBox.currentIndex, "text", ArrayFunctions.nameWithPath(fan));
  71. }
  72. }
  73. }
  74. }
  75. ColumnLayout {
  76. id: noFansInfo
  77. anchors.centerIn: parent
  78. spacing: 20
  79. visible: loader.allPwmFans.length == 0
  80. Label {
  81. Layout.alignment: Qt.AlignCenter
  82. text: i18n("There are no pwm capable fans in your system.")
  83. font.pointSize: 14
  84. font.bold: true
  85. }
  86. Button {
  87. Layout.alignment: Qt.AlignCenter
  88. action: detectFansAction
  89. }
  90. }
  91. Action {
  92. id: detectFansAction
  93. text: i18n("Detect fans")
  94. iconName: "dialog-password"
  95. onTriggered: loader.detectSensors()
  96. }
  97. }