SettingsTab.qml 5.8 KB

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