PwmFansTab.qml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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.6
  20. import QtQuick.Controls 2.1
  21. import org.kde.kirigami 2.3 as Kirigami
  22. import Fancontrol.Qml 1.0 as Fancontrol
  23. Kirigami.Page {
  24. readonly property QtObject loader: Fancontrol.Base.loader
  25. readonly property QtObject systemdCom: Fancontrol.Base.hasSystemdCommunicator ? Fancontrol.Base.systemdCom : null
  26. readonly property QtObject pwmFanModel: Fancontrol.Base.pwmFanModel
  27. readonly property QtObject profileModel: Fancontrol.Base.profileModel
  28. property QtObject fan: applicationWindow().fan
  29. id: root
  30. header: Fancontrol.FanHeader {
  31. fan: root.fan
  32. }
  33. contextualActions: [
  34. Kirigami.Action {
  35. text: i18n("Manage profiles")
  36. onTriggered: profilesDialog.open()
  37. },
  38. Kirigami.Action {
  39. text: i18n("Service")
  40. visible: Fancontrol.Base.hasSystemdCommunicator
  41. tooltip: i18n("Control the systemd service")
  42. Kirigami.Action {
  43. text: !!systemdCom && systemdCom.serviceActive ? i18n("Stop service") : i18n("Start service")
  44. icon.name: !!systemdCom && systemdCom.serviceActive ? "media-playback-stop" : "media-playback-start"
  45. onTriggered: systemdCom.serviceActive = !systemdCom.serviceActive
  46. }
  47. Kirigami.Action {
  48. text: !!systemdCom && systemdCom.serviceEnabled ? i18n("Disable service") : i18n("Enable service")
  49. tooltip: !!systemdCom && systemdCom.serviceEnabled ? i18n("Disable service autostart at boot") : i18n("Enable service autostart at boot")
  50. onTriggered: systemdCom.serviceEnabled = !systemdCom.serviceEnabled
  51. }
  52. },
  53. Kirigami.Action {
  54. visible: !!systemdCom && !!fan
  55. text: !!fan ? fan.testing ? i18n("Abort test") : i18n("Test start and stop values") : ""
  56. icon.name: "dialog-password"
  57. onTriggered: {
  58. if (fan.testing) {
  59. fan.abortTest();
  60. } else {
  61. fan.test();
  62. }
  63. }
  64. }
  65. ]
  66. mainAction: Kirigami.Action {
  67. text: i18n("Apply")
  68. enabled: Fancontrol.Base.needsApply
  69. icon.name: "dialog-ok-apply"
  70. tooltip: i18n("Apply changes")
  71. shortcut: StandardKey.Apply
  72. onTriggered: Fancontrol.Base.apply()
  73. }
  74. rightAction: Kirigami.Action {
  75. text: i18n("Reset")
  76. enabled: Fancontrol.Base.needsApply
  77. icon.name: "edit-undo"
  78. tooltip: i18n("Revert changes")
  79. onTriggered: Fancontrol.Base.reset()
  80. }
  81. Loader {
  82. anchors.fill: parent
  83. active: !!root.fan
  84. sourceComponent: Fancontrol.FanItem {
  85. fan: root.fan
  86. }
  87. }
  88. Loader {
  89. anchors.centerIn: parent
  90. active: pwmFanModel.length === 0
  91. sourceComponent: Label {
  92. text: i18n("There are no pwm capable fans in your system.\nTry running 'sensors-detect' in a terminal and restart this application.")
  93. horizontalAlignment: Text.AlignHCenter
  94. font.pointSize: 14
  95. font.bold: true
  96. }
  97. }
  98. Fancontrol.ProfilesDialog {
  99. id: profilesDialog
  100. visible: false
  101. modal: true
  102. anchors.centerIn: parent
  103. }
  104. }