PwmFansTab.qml 3.1 KB

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