PwmFansTab.qml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 Fancontrol.Qml 1.0
  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. property QtObject pwmFanModel: baseObject ? baseObject.pwmFanModel : null
  28. property QtObject tempModel: baseObject ? baseObject.tempModel : null
  29. property var pwmFans: pwmFanModel ? pwmFanModel.fans : []
  30. id: root
  31. anchors.fill: parent
  32. anchors.margins: 10
  33. RowLayout {
  34. width: parent.width
  35. visible: !!pwmFanModel && pwmFans.length > 0
  36. Label {
  37. text: i18n("Fan:")
  38. Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
  39. renderType: Text.NativeRendering
  40. }
  41. ComboBox {
  42. id: fanComboBox
  43. model: pwmFanModel
  44. textRole: "display"
  45. Layout.fillWidth: true
  46. Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
  47. }
  48. Button {
  49. Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
  50. action: detectFansAction
  51. }
  52. }
  53. Loader {
  54. Layout.fillHeight: true
  55. Layout.fillWidth: true
  56. active: !!tempModel && !!systemdCom && pwmFans.length > fanComboBox.currentIndex
  57. sourceComponent: PwmFan {
  58. unit: !!baseObject ? baseObject.unit : 0
  59. fan: pwmFans[fanComboBox.currentIndex]
  60. tempModel: root.tempModel
  61. systemdCom: root.systemdCom
  62. minTemp: !!baseObject ? baseObject.minTemp : 30
  63. maxTemp: !!baseObject ? baseObject.maxTemp : 100
  64. }
  65. }
  66. ColumnLayout {
  67. id: noFansInfo
  68. anchors.centerIn: parent
  69. spacing: 20
  70. visible: pwmFans.length === 0
  71. Label {
  72. Layout.alignment: Qt.AlignCenter
  73. text: i18n("There are no pwm capable fans in your system.")
  74. font.pointSize: 14
  75. font.bold: true
  76. }
  77. Button {
  78. Layout.alignment: Qt.AlignCenter
  79. action: detectFansAction
  80. }
  81. }
  82. Action {
  83. id: detectFansAction
  84. text: loader.sensorsDetected ? i18n("Detect fans again") : i18n("Detect fans")
  85. iconName: "dialog-password"
  86. onTriggered: loader.detectSensors()
  87. }
  88. }