2
0

PwmFansTab.qml 3.2 KB

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