2
0

KCM.qml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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.3
  21. import QtQuick.Layouts 1.1
  22. import org.kde.kcm 1.0
  23. import "../scripts/arrayfunctions.js" as ArrayFunctions
  24. import "../scripts/units.js" as Units
  25. Item {
  26. property QtObject base: kcm.base
  27. property var locale: Qt.locale()
  28. property real textWidth: 0
  29. id: root
  30. implicitWidth: 1024
  31. implicitHeight: 768
  32. ColumnLayout {
  33. id: noFansInfo
  34. width: parent.width
  35. anchors.verticalCenter: parent.verticalCenter
  36. spacing: 20
  37. visible: kcm.loader.allPwmFans.length == 0
  38. Label {
  39. Layout.alignment: Qt.AlignCenter
  40. text: i18n("There are no pwm capable fans in your system.")
  41. font.pointSize: 14
  42. font.bold: true
  43. }
  44. Button {
  45. Layout.alignment: Qt.AlignCenter
  46. text: i18n("Detect fans")
  47. onClicked: kcm.loader.detectSensors()
  48. }
  49. }
  50. CheckBox {
  51. id: enabledBox
  52. visible: kcm.loader.allPwmFans.length > 0
  53. Layout.alignment: Qt.AlignLeft | Qt.AlignTop
  54. text: i18n("Control fans manually")
  55. checked: kcm.manualControl
  56. onCheckedChanged: kcm.manualControl = checked
  57. Connections {
  58. target: kcm
  59. onManualControlChanged: enabledBox.checked = kcm.manualControl
  60. }
  61. }
  62. ColumnLayout {
  63. width: parent.width
  64. anchors.bottom: parent.bottom
  65. anchors.top: enabledBox.bottom
  66. visible: enabledBox.checked
  67. RowLayout {
  68. visible: enabledBox.checked && kcm.loader.allPwmFans.length > 0
  69. Label {
  70. text: i18n("Fan:")
  71. Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
  72. renderType: Text.NativeRendering
  73. }
  74. ComboBox {
  75. id: fanCombobox
  76. model: ArrayFunctions.namesWithPaths(kcm.loader.allPwmFans)
  77. Layout.fillWidth: true
  78. Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
  79. }
  80. Button {
  81. Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
  82. text: i18n("Detect fans")
  83. iconName: kcm.needsAuthorization ? "dialog-password" : ""
  84. onClicked: kcm.loader.detectSensors()
  85. }
  86. }
  87. Loader {
  88. Layout.fillWidth: true
  89. Layout.fillHeight: true
  90. active: !!kcm.loader.allPwmFans[fanCombobox.currentIndex]
  91. sourceComponent: PwmFan {
  92. unit: kcm.base.unit
  93. fan: kcm.loader.allPwmFans[fanCombobox.currentIndex]
  94. loader: kcm.loader
  95. systemdCom: kcm.systemdCom
  96. minTemp: kcm.base.minTemp
  97. maxTemp: kcm.base.maxTemp
  98. }
  99. }
  100. Row {
  101. property bool expanded: false
  102. id: expand
  103. Image {
  104. id: arrow
  105. source: parent.expanded ? "image://icon/go-down" : "image://icon/go-next"
  106. fillMode: Image.PreserveAspectFit
  107. height: advancedLabel.implicitHeight
  108. }
  109. Label {
  110. id: advancedLabel
  111. text: i18n("Advanced settings")
  112. font.bold: true
  113. }
  114. }
  115. MouseArea {
  116. anchors.fill: expand
  117. onClicked: expand.expanded = expand.expanded ? false : true
  118. }
  119. RowLayout {
  120. visible: expand.expanded
  121. Label {
  122. Layout.preferredWidth: root.textWidth
  123. clip: true
  124. text: i18n("Interval:")
  125. horizontalAlignment: Text.AlignRight
  126. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  127. }
  128. SpinBox {
  129. Layout.minimumWidth: implicitWidth
  130. Layout.fillWidth: true
  131. value: base.loader ? base.loader.interval : 1
  132. suffix: " " + (value > 1 ? i18n("seconds") : i18n("second"))
  133. minimumValue: 1.0
  134. onValueChanged: base.loader.interval = value
  135. }
  136. }
  137. RowLayout {
  138. visible: expand.expanded
  139. Label {
  140. Layout.preferredWidth: root.textWidth
  141. clip: true
  142. text: i18n("Minimum temperature for fan graphs:")
  143. horizontalAlignment: Text.AlignRight
  144. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  145. }
  146. SpinBox {
  147. id: minTempBox
  148. Layout.minimumWidth: implicitWidth
  149. Layout.fillWidth: true
  150. decimals: 2
  151. maximumValue: maxTempBox.value
  152. minimumValue: Units.fromKelvin(0, base.unit)
  153. value: Units.fromCelsius(base.minTemp, base.unit)
  154. suffix: base.unit == 0 ? i18n("°C") : base.unit == 1 ? i18n("K") : i18n("°F")
  155. onValueChanged: base.minTemp = value
  156. }
  157. }
  158. RowLayout {
  159. visible: expand.expanded
  160. Label {
  161. Layout.preferredWidth: root.textWidth
  162. clip: true
  163. text: i18n("Maximum temperature for fan graphs:")
  164. horizontalAlignment: Text.AlignRight
  165. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  166. }
  167. SpinBox {
  168. id: maxTempBox
  169. Layout.minimumWidth: implicitWidth
  170. Layout.fillWidth: true
  171. decimals: 2
  172. maximumValue: Number.POSITIVE_INFINITY
  173. minimumValue: minTempBox.value
  174. value: Units.fromCelsius(base.maxTemp, base.unit)
  175. suffix: base.unit == 0 ? i18n("°C") : base.unit == 1 ? i18n("K") : i18n("°F")
  176. onValueChanged: base.maxTemp = value
  177. }
  178. }
  179. RowLayout {
  180. visible: expand.expanded
  181. Label {
  182. Layout.preferredWidth: root.textWidth
  183. clip: true
  184. text: i18n("Name of the fancontrol systemd service:")
  185. horizontalAlignment: Text.AlignRight
  186. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  187. }
  188. OptionInput {
  189. Layout.minimumWidth: implicitWidth
  190. Layout.fillWidth: true
  191. color: base.systemdCom.serviceExists ? "green" : "red"
  192. value: base.serviceName
  193. onTextChanged: base.serviceName = text
  194. }
  195. }
  196. }
  197. }