2
0

SettingsTab.qml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. OptionInput {
  50. id: intervalValue
  51. Layout.minimumWidth: implicitWidth
  52. Layout.fillWidth: true
  53. inputMethodHints: Qt.ImhDigitsOnly
  54. text: Number(gui ? gui.interval : 1).toLocaleString(locale, 'f', 0)
  55. onTextChanged: if (text && text != "0") gui.interval = parseInt(Number.fromLocaleString(root.locale, text))
  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. OptionInput {
  68. id: minTempValue
  69. Layout.minimumWidth: implicitWidth
  70. Layout.fillWidth: true
  71. inputMethodHints: Qt.ImhDigitsOnly
  72. onTextChanged: if (activeFocus) gui.minTemp = Units.toCelsius(Number.fromLocaleString(locale, text), gui.unit)
  73. Component.onCompleted: text = Units.fromCelsius(gui.minTemp, gui.unit)
  74. Connections {
  75. target: gui
  76. onUnitChanged: minTempValue.text = Units.fromCelsius(gui.minTemp, gui.unit)
  77. }
  78. }
  79. }
  80. RowLayout {
  81. width: parent.width
  82. Label {
  83. Layout.preferredWidth: root.textWidth
  84. clip: true
  85. text: i18n("Maximum temperature for fan graphs:")
  86. horizontalAlignment: Text.AlignRight
  87. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  88. }
  89. OptionInput {
  90. id: maxTempValue
  91. Layout.minimumWidth: implicitWidth
  92. Layout.fillWidth: true
  93. inputMethodHints: Qt.ImhDigitsOnly
  94. onTextChanged: if (activeFocus) gui.maxTemp = Units.toCelsius(Number.fromLocaleString(locale, text), gui.unit)
  95. Component.onCompleted: text = Units.fromCelsius(gui.maxTemp, gui.unit)
  96. Connections {
  97. target: gui
  98. onUnitChanged: maxTempValue.text = Units.fromCelsius(gui.maxTemp, gui.unit)
  99. }
  100. }
  101. }
  102. Loader {
  103. active: systemdCom
  104. sourceComponent: RowLayout {
  105. width: column.width
  106. Label {
  107. Layout.preferredWidth: root.textWidth
  108. clip: true
  109. text: i18n("Name of the fancontrol systemd service:")
  110. horizontalAlignment: Text.AlignRight
  111. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  112. }
  113. OptionInput {
  114. id: serviceName
  115. Layout.minimumWidth: implicitWidth
  116. Layout.fillWidth: true
  117. color: systemdCom.serviceExists ? "green" : "red"
  118. text: gui.serviceName
  119. onTextChanged: gui.serviceName = text
  120. }
  121. }
  122. }
  123. Loader {
  124. active: systemdCom
  125. sourceComponent: RowLayout {
  126. width: column.width
  127. Label {
  128. Layout.preferredWidth: root.textWidth
  129. clip: true
  130. text: i18n("Fancontrol systemd service autostart:")
  131. horizontalAlignment: Text.AlignRight
  132. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  133. }
  134. CheckBox {
  135. id: autostartBox
  136. Layout.minimumWidth: implicitWidth
  137. Layout.fillWidth: true
  138. checked: systemdCom.serviceEnabled
  139. onCheckedChanged: systemdCom.serviceEnabled = checked
  140. }
  141. }
  142. }
  143. Button {
  144. x: maxTempValue.x
  145. text: i18n("Detect fans")
  146. onClicked: loader.detectSensors()
  147. }
  148. }
  149. }