SettingsTab.qml 5.9 KB

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