PwmFansTab.qml 3.1 KB

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