2
0

SettingsTab.qml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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/arrayfunctions.js" as ArrayFunctions
  24. import "../scripts/units.js" as Units
  25. Item {
  26. property QtObject gui
  27. property QtObject systemdCom: gui && gui.hasSystemdCommunicator() ? gui.systemdCom : null
  28. property QtObject loader : gui ? gui.loader : null
  29. property int padding: 10
  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: gui.loader ? gui.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, gui.unit)
  74. value: Units.fromCelsius(gui.minTemp, gui.unit)
  75. suffix: gui.unit == 0 ? i18n("°C") : gui.unit == 1 ? i18n("K") : i18n("°F")
  76. onValueChanged: gui.minTemp = value
  77. }
  78. }
  79. RowLayout {
  80. width: parent.width
  81. Label {
  82. Layout.preferredWidth: root.textWidth
  83. clip: true
  84. text: i18n("Maximum temperature for fan graphs:")
  85. horizontalAlignment: Text.AlignRight
  86. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  87. }
  88. SpinBox {
  89. id: maxTempBox
  90. Layout.minimumWidth: implicitWidth
  91. Layout.fillWidth: true
  92. decimals: 2
  93. maximumValue: Number.POSITIVE_INFINITY
  94. minimumValue: minTempBox.value
  95. value: Units.fromCelsius(gui.maxTemp, gui.unit)
  96. suffix: gui.unit == 0 ? i18n("°C") : gui.unit == 1 ? i18n("K") : i18n("°F")
  97. onValueChanged: gui.maxTemp = value
  98. }
  99. }
  100. Loader {
  101. active: systemdCom
  102. sourceComponent: RowLayout {
  103. width: column.width
  104. Label {
  105. Layout.preferredWidth: root.textWidth
  106. clip: true
  107. text: i18n("Name of the fancontrol systemd service:")
  108. horizontalAlignment: Text.AlignRight
  109. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  110. }
  111. OptionInput {
  112. Layout.minimumWidth: implicitWidth
  113. Layout.fillWidth: true
  114. color: systemdCom.serviceExists ? "green" : "red"
  115. value: gui.serviceName
  116. onTextChanged: gui.serviceName = text
  117. }
  118. }
  119. }
  120. Loader {
  121. active: systemdCom
  122. sourceComponent: RowLayout {
  123. width: column.width
  124. Label {
  125. Layout.preferredWidth: root.textWidth
  126. clip: true
  127. text: i18n("Fancontrol systemd service autostart:")
  128. horizontalAlignment: Text.AlignRight
  129. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  130. }
  131. CheckBox {
  132. id: autostartBox
  133. Layout.minimumWidth: implicitWidth
  134. Layout.fillWidth: true
  135. checked: systemdCom.serviceEnabled
  136. onCheckedChanged: systemdCom.serviceEnabled = checked
  137. }
  138. }
  139. }
  140. }
  141. }