SettingsTab.qml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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.Layouts 1.1
  21. import QtQuick.Controls 1.2
  22. import "../javascript/arrayfunctions.js" as ArrayFunctions
  23. import "../javascript/units.js" as Units
  24. Item {
  25. property real minTemp: 30.0
  26. property real maxTemp: 90.0
  27. property int interval: 1
  28. property int padding: 10
  29. property string unit: "Celsius"
  30. id: root
  31. anchors.fill: parent
  32. anchors.topMargin: 5
  33. onIntervalChanged: {
  34. var fans = ArrayFunctions.allPwmFans(loader.hwmons);
  35. for (var i=0; i<fans.length; i++) {
  36. fans[i].interval = interval;
  37. }
  38. }
  39. Rectangle {
  40. width: 600
  41. height: parent.height
  42. border.width: 1
  43. border.color: "black"
  44. radius: 5
  45. Column {
  46. anchors.fill: parent
  47. anchors.topMargin: padding
  48. spacing: 5
  49. RowLayout {
  50. width: parent.width
  51. Text {
  52. anchors.left: parent.left
  53. anchors.leftMargin: padding
  54. Layout.maximumWidth: parent.width - intervalValue.width - padding*2
  55. clip: true
  56. text: "Interval:"
  57. }
  58. OptionInput {
  59. id: intervalValue
  60. anchors.right: parent.right
  61. anchors.rightMargin: padding
  62. width: 100
  63. inputMethodHints: Qt.ImhDigitsOnly
  64. text: interval
  65. onTextChanged: if (text != "") loader.interval = parseInt(text)
  66. }
  67. }
  68. RowLayout {
  69. width: parent.width
  70. Text {
  71. anchors.left: parent.left
  72. anchors.leftMargin: padding
  73. Layout.maximumWidth: parent.width - minTempValue.width - padding*2
  74. clip: true
  75. text: "Minimum temperature for fan graphs:"
  76. }
  77. OptionInput {
  78. id: minTempValue
  79. anchors.right: parent.right
  80. anchors.rightMargin: padding
  81. width: 100
  82. inputMethodHints: Qt.ImhDigitsOnly
  83. onTextChanged: if (activeFocus) minTemp = Units.toCelsius(text, unit)
  84. Component.onCompleted: text = Units.fromCelsius(minTemp, unit)
  85. }
  86. }
  87. RowLayout {
  88. width: parent.width
  89. Text {
  90. anchors.left: parent.left
  91. anchors.leftMargin: padding
  92. Layout.maximumWidth: parent.width - maxTempValue.width - padding*2
  93. clip: true
  94. text: "Maximum temperature for fan graphs:"
  95. }
  96. OptionInput {
  97. id: maxTempValue
  98. anchors.right: parent.right
  99. anchors.rightMargin: padding
  100. width: 100
  101. inputMethodHints: Qt.ImhDigitsOnly
  102. text: Units.fromCelsius(maxTemp, unit.currentText)
  103. onTextChanged: if (activeFocus) maxTemp = Units.toCelsius(text, unit)
  104. Component.onCompleted: text = Units.fromCelsius(maxTemp, unit)
  105. }
  106. }
  107. RowLayout {
  108. width: parent.width
  109. Text {
  110. anchors.left: parent.left
  111. anchors.leftMargin: padding
  112. Layout.maximumWidth: parent.width - maxTempValue.width - padding*2
  113. clip: true
  114. text: "Unit:"
  115. }
  116. ComboBox {
  117. id: unitBox
  118. anchors.right: parent.right
  119. anchors.rightMargin: padding
  120. model: ["Celsius", "Kelvin", "Fahrenheit"]
  121. currentIndex: find(root.unit)
  122. onCurrentIndexChanged: {
  123. unit = currentText;
  124. minTempValue.text = Units.fromCelsius(minTemp, unit);
  125. maxTempValue.text = Units.fromCelsius(maxTemp, unit);
  126. }
  127. }
  128. }
  129. RowLayout {
  130. width: parent.width
  131. visible: typeof systemdCom != "undefined"
  132. Text {
  133. anchors.left: parent.left
  134. anchors.leftMargin: padding
  135. Layout.maximumWidth: parent.width - maxTempValue.width - padding*2
  136. clip: true
  137. text: "Name of the fancontrol systemd service:"
  138. }
  139. OptionInput {
  140. id: serviceName
  141. anchors.right: parent.right
  142. anchors.rightMargin: padding
  143. color: systemdCom.serviceExists ? "green" : "red"
  144. width: 100
  145. text: systemdCom.serviceName
  146. onTextChanged: systemdCom.serviceName = text
  147. }
  148. }
  149. RowLayout {
  150. width: parent.width
  151. visible: typeof systemdCom != "undefined"
  152. Text {
  153. anchors.left: parent.left
  154. anchors.leftMargin: padding
  155. Layout.maximumWidth: parent.width - maxTempValue.width - padding*2
  156. clip: true
  157. text: "Fancontrol systemd service autostart:"
  158. }
  159. ComboBox {
  160. id: autostartBox
  161. anchors.right: parent.right
  162. anchors.rightMargin: padding
  163. model: ["disabled" , "enabled"]
  164. currentIndex: systemdCom.serviceEnabled ? 1 : 0
  165. onCurrentIndexChanged: {
  166. systemdCom.serviceEnabled = (currentIndex == 1) ? true : false;
  167. }
  168. }
  169. }
  170. }
  171. }
  172. }