SettingsTab.qml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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 "../scripts/arrayfunctions.js" as ArrayFunctions
  23. import "../scripts/units.js" as Units
  24. Item {
  25. property QtObject loader
  26. property QtObject systemdCom
  27. property real minTemp: 30.0
  28. property real maxTemp: 90.0
  29. property int interval: loader ? loader.interval : 1
  30. property int padding: 10
  31. property string unit: i18n("Celsius")
  32. property real textWidth: 0
  33. id: root
  34. anchors.fill: parent
  35. anchors.topMargin: 5
  36. Column {
  37. id: column
  38. anchors.fill: parent
  39. anchors.margins: padding
  40. spacing: 5
  41. RowLayout {
  42. width: parent.width
  43. Label {
  44. Layout.preferredWidth: root.textWidth
  45. clip: true
  46. text: i18n("Interval:")
  47. horizontalAlignment: Text.AlignRight
  48. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  49. }
  50. OptionInput {
  51. id: intervalValue
  52. Layout.minimumWidth: implicitWidth
  53. Layout.fillWidth: true
  54. inputMethodHints: Qt.ImhDigitsOnly
  55. text: interval
  56. onTextChanged: if (text && text != "0") loader.interval = parseInt(text)
  57. }
  58. }
  59. RowLayout {
  60. width: parent.width
  61. Label {
  62. Layout.preferredWidth: root.textWidth
  63. clip: true
  64. text: i18n("Minimum temperature for fan graphs:")
  65. horizontalAlignment: Text.AlignRight
  66. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  67. }
  68. OptionInput {
  69. id: minTempValue
  70. Layout.minimumWidth: implicitWidth
  71. Layout.fillWidth: true
  72. inputMethodHints: Qt.ImhDigitsOnly
  73. onTextChanged: if (activeFocus) minTemp = Units.toCelsius(text, unit)
  74. Component.onCompleted: text = Units.fromCelsius(minTemp, unit)
  75. }
  76. }
  77. RowLayout {
  78. width: parent.width
  79. Label {
  80. Layout.preferredWidth: root.textWidth
  81. clip: true
  82. text: i18n("Maximum temperature for fan graphs:")
  83. horizontalAlignment: Text.AlignRight
  84. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  85. }
  86. OptionInput {
  87. id: maxTempValue
  88. Layout.minimumWidth: implicitWidth
  89. Layout.fillWidth: true
  90. inputMethodHints: Qt.ImhDigitsOnly
  91. text: Units.fromCelsius(maxTemp, unit.currentText)
  92. onTextChanged: if (activeFocus) maxTemp = Units.toCelsius(text, unit)
  93. Component.onCompleted: text = Units.fromCelsius(maxTemp, unit)
  94. }
  95. }
  96. RowLayout {
  97. width: parent.width
  98. Label {
  99. Layout.preferredWidth: root.textWidth
  100. clip: true
  101. text: i18n("Unit:")
  102. horizontalAlignment: Text.AlignRight
  103. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  104. }
  105. ComboBox {
  106. id: unitBox
  107. Layout.minimumWidth: implicitWidth
  108. Layout.fillWidth: true
  109. model: [i18n("Celsius"), i18n("Kelvin"), i18n("Fahrenheit")]
  110. currentIndex: find(root.unit)
  111. onCurrentIndexChanged: {
  112. minTempValue.text = Units.fromCelsius(minTemp, currentIndex);
  113. maxTempValue.text = Units.fromCelsius(maxTemp, currentIndex);
  114. }
  115. }
  116. }
  117. Loader {
  118. active: systemdCom
  119. sourceComponent: RowLayout {
  120. width: column.width
  121. Label {
  122. Layout.preferredWidth: root.textWidth
  123. clip: true
  124. text: i18n("Name of the fancontrol systemd service:")
  125. horizontalAlignment: Text.AlignRight
  126. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  127. }
  128. OptionInput {
  129. id: serviceName
  130. Layout.minimumWidth: implicitWidth
  131. Layout.fillWidth: true
  132. color: systemdCom.serviceExists ? "green" : "red"
  133. text: systemdCom.serviceName
  134. onTextChanged: systemdCom.serviceName = text
  135. }
  136. }
  137. }
  138. Loader {
  139. active: systemdCom
  140. sourceComponent: RowLayout {
  141. width: column.width
  142. Label {
  143. Layout.preferredWidth: root.textWidth
  144. clip: true
  145. text: i18n("Fancontrol systemd service autostart:")
  146. horizontalAlignment: Text.AlignRight
  147. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  148. }
  149. ComboBox {
  150. id: autostartBox
  151. Layout.minimumWidth: implicitWidth
  152. Layout.fillWidth: true
  153. model: [i18n("disabled") , i18n("enabled")]
  154. currentIndex: systemdCom.serviceEnabled ? 1 : 0
  155. onCurrentIndexChanged: systemdCom.serviceEnabled = (currentIndex == 1) ? true : false
  156. }
  157. }
  158. }
  159. }
  160. }