SettingsTab.qml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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 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: gui.loader ? gui.loader.interval : 1
  52. suffix: " " + (value > 1 ? i18n("seconds") : i18n("second"))
  53. minimumValue: 1.0
  54. onValueChanged: gui.loader.interval = value
  55. }
  56. }
  57. RowLayout {
  58. width: parent.width
  59. Label {
  60. Layout.preferredWidth: root.textWidth
  61. clip: true
  62. text: i18n("Minimum temperature for fan graphs:")
  63. horizontalAlignment: Text.AlignRight
  64. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  65. }
  66. SpinBox {
  67. id: minTempBox
  68. Layout.minimumWidth: implicitWidth
  69. Layout.fillWidth: true
  70. decimals: 2
  71. maximumValue: maxTempBox.value
  72. minimumValue: Units.fromKelvin(0, gui.unit)
  73. value: Units.fromCelsius(gui.minTemp, gui.unit)
  74. suffix: gui.unit == 0 ? i18n("°C") : gui.unit == 1 ? i18n("K") : i18n("°F")
  75. onValueChanged: gui.minTemp = value
  76. }
  77. }
  78. RowLayout {
  79. width: parent.width
  80. Label {
  81. Layout.preferredWidth: root.textWidth
  82. clip: true
  83. text: i18n("Maximum temperature for fan graphs:")
  84. horizontalAlignment: Text.AlignRight
  85. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  86. }
  87. SpinBox {
  88. id: maxTempBox
  89. Layout.minimumWidth: implicitWidth
  90. Layout.fillWidth: true
  91. decimals: 2
  92. maximumValue: Number.POSITIVE_INFINITY
  93. minimumValue: minTempBox.value
  94. value: Units.fromCelsius(gui.maxTemp, gui.unit)
  95. suffix: gui.unit == 0 ? i18n("°C") : gui.unit == 1 ? i18n("K") : i18n("°F")
  96. onValueChanged: gui.maxTemp = value
  97. }
  98. }
  99. Loader {
  100. active: systemdCom
  101. sourceComponent: RowLayout {
  102. width: column.width
  103. Label {
  104. Layout.preferredWidth: root.textWidth
  105. clip: true
  106. text: i18n("Name of the fancontrol systemd service:")
  107. horizontalAlignment: Text.AlignRight
  108. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  109. }
  110. OptionInput {
  111. Layout.minimumWidth: implicitWidth
  112. Layout.fillWidth: true
  113. color: systemdCom.serviceExists ? "green" : "red"
  114. value: gui.serviceName
  115. onTextChanged: gui.serviceName = text
  116. }
  117. }
  118. }
  119. Loader {
  120. active: systemdCom
  121. sourceComponent: RowLayout {
  122. width: column.width
  123. Label {
  124. Layout.preferredWidth: root.textWidth
  125. clip: true
  126. text: i18n("Fancontrol systemd service autostart:")
  127. horizontalAlignment: Text.AlignRight
  128. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  129. }
  130. CheckBox {
  131. id: autostartBox
  132. Layout.minimumWidth: implicitWidth
  133. Layout.fillWidth: true
  134. checked: systemdCom.serviceEnabled
  135. onCheckedChanged: systemdCom.serviceEnabled = checked
  136. }
  137. }
  138. }
  139. }
  140. }