SettingsTab.qml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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/units.js" as Units
  23. Item {
  24. property QtObject gui
  25. property QtObject systemdCom: !!gui && gui.hasSystemdCommunicator() ? gui.systemdCom : null
  26. property QtObject loader : !!gui ? gui.loader : null
  27. property int padding: 10
  28. property int unit: !!gui ? gui.unit : 0
  29. property real textWidth: 0
  30. property var locale: Qt.locale()
  31. id: root
  32. anchors.fill: parent
  33. anchors.topMargin: 5
  34. Column {
  35. id: column
  36. anchors.fill: parent
  37. anchors.margins: padding
  38. spacing: 5
  39. RowLayout {
  40. width: parent.width
  41. Label {
  42. Layout.preferredWidth: root.textWidth
  43. clip: true
  44. text: i18n("Interval:")
  45. horizontalAlignment: Text.AlignRight
  46. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  47. }
  48. SpinBox {
  49. Layout.minimumWidth: implicitWidth
  50. Layout.fillWidth: true
  51. value: !!loader ? loader.interval : 1
  52. suffix: !!loader ? " " + i18np("second", "seconds", loader.interval): ""
  53. minimumValue: 1.0
  54. onValueChanged: {
  55. if (!!loader) {
  56. loader.interval = value;
  57. }
  58. }
  59. }
  60. }
  61. RowLayout {
  62. width: parent.width
  63. Label {
  64. Layout.preferredWidth: root.textWidth
  65. clip: true
  66. text: i18n("Minimum temperature for fan graphs:")
  67. horizontalAlignment: Text.AlignRight
  68. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  69. }
  70. SpinBox {
  71. id: minTempBox
  72. Layout.minimumWidth: implicitWidth
  73. Layout.fillWidth: true
  74. decimals: 2
  75. maximumValue: maxTempBox.value
  76. minimumValue: Units.fromKelvin(0, unit)
  77. value: !!gui ? Units.fromCelsius(gui.minTemp, unit) : 0
  78. suffix: unit == 0 ? i18n("°C") : unit == 1 ? i18n("K") : i18n("°F")
  79. onValueChanged: {
  80. if (!!gui) {
  81. gui.minTemp = value;
  82. }
  83. }
  84. }
  85. }
  86. RowLayout {
  87. width: parent.width
  88. Label {
  89. Layout.preferredWidth: root.textWidth
  90. clip: true
  91. text: i18n("Maximum temperature for fan graphs:")
  92. horizontalAlignment: Text.AlignRight
  93. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  94. }
  95. SpinBox {
  96. id: maxTempBox
  97. Layout.minimumWidth: implicitWidth
  98. Layout.fillWidth: true
  99. decimals: 2
  100. maximumValue: Number.POSITIVE_INFINITY
  101. minimumValue: minTempBox.value
  102. value: !!gui ? Units.fromCelsius(gui.maxTemp, unit) : 0
  103. suffix: unit == 0 ? i18n("°C") : unit == 1 ? i18n("K") : i18n("°F")
  104. onValueChanged: {
  105. if (!!gui) {
  106. gui.maxTemp = value;
  107. }
  108. }
  109. }
  110. }
  111. Loader {
  112. active: !!systemdCom
  113. sourceComponent: RowLayout {
  114. width: column.width
  115. Label {
  116. Layout.preferredWidth: root.textWidth
  117. clip: true
  118. text: i18n("Name of the fancontrol systemd service:")
  119. horizontalAlignment: Text.AlignRight
  120. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  121. }
  122. OptionInput {
  123. Layout.minimumWidth: implicitWidth
  124. Layout.fillWidth: true
  125. color: !!systemdCom && systemdCom.serviceExists ? "green" : "red"
  126. value: !!gui ? gui.serviceName : ""
  127. onTextChanged: {
  128. if (!!gui) {
  129. gui.serviceName = text;
  130. }
  131. }
  132. }
  133. }
  134. }
  135. Loader {
  136. active: !!systemdCom
  137. sourceComponent: RowLayout {
  138. width: column.width
  139. Label {
  140. Layout.preferredWidth: root.textWidth
  141. clip: true
  142. text: i18n("Fancontrol systemd service autostart:")
  143. horizontalAlignment: Text.AlignRight
  144. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  145. }
  146. CheckBox {
  147. id: autostartBox
  148. Layout.minimumWidth: implicitWidth
  149. Layout.fillWidth: true
  150. checked: !!systemdCom ? systemdCom.serviceEnabled : false
  151. onCheckedChanged: {
  152. if (!!systemdCom) {
  153. systemdCom.serviceEnabled = checked;
  154. }
  155. }
  156. }
  157. }
  158. }
  159. }
  160. }