SettingsTab.qml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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 "../scripts/arrayfunctions.js" as ArrayFunctions
  23. import "../scripts/units.js" as Units
  24. Item {
  25. property QtObject baseObject
  26. property QtObject loader: baseObject ? baseObject.loader : null
  27. property QtObject systemdCom: baseObject ? baseObject.hasSystemdCommunicator() ? baseObject.systemdCom : null : null
  28. property int interval: loader ? loader.interval : 1
  29. property int padding: 10
  30. property real textWidth: 0
  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: interval
  54. onTextChanged: if (text && text != "0") loader.interval = parseInt(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) baseObject.minTemp = Units.toCelsius(text, baseObject.unit)
  72. Component.onCompleted: text = Units.fromCelsius(baseObject.minTemp, baseObject.unit)
  73. Connections {
  74. target: baseObject
  75. onUnitChanged: minTempValue.text = Units.fromCelsius(baseObject.minTemp, baseObject.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) baseObject.maxTemp = Units.toCelsius(text, baseObject.unit)
  94. Component.onCompleted: text = Units.fromCelsius(baseObject.maxTemp, baseObject.unit)
  95. Connections {
  96. target: baseObject
  97. onUnitChanged: maxTempValue.text = Units.fromCelsius(baseObject.maxTemp, baseObject.unit)
  98. }
  99. }
  100. }
  101. RowLayout {
  102. width: parent.width
  103. Label {
  104. Layout.preferredWidth: root.textWidth
  105. clip: true
  106. text: i18n("Unit:")
  107. horizontalAlignment: Text.AlignRight
  108. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  109. }
  110. ComboBox {
  111. id: unitBox
  112. Layout.minimumWidth: implicitWidth
  113. Layout.fillWidth: true
  114. model: [i18n("Celsius"), i18n("Kelvin"), i18n("Fahrenheit")]
  115. currentIndex: baseObject.unit
  116. onCurrentIndexChanged: {
  117. baseObject.unit = currentIndex;
  118. }
  119. }
  120. }
  121. Loader {
  122. active: systemdCom
  123. sourceComponent: RowLayout {
  124. width: column.width
  125. Label {
  126. Layout.preferredWidth: root.textWidth
  127. clip: true
  128. text: i18n("Name of the fancontrol systemd service:")
  129. horizontalAlignment: Text.AlignRight
  130. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  131. }
  132. OptionInput {
  133. id: serviceName
  134. Layout.minimumWidth: implicitWidth
  135. Layout.fillWidth: true
  136. color: systemdCom.serviceExists ? "green" : "red"
  137. text: systemdCom.serviceName
  138. onTextChanged: systemdCom.serviceName = text
  139. }
  140. }
  141. }
  142. Loader {
  143. active: systemdCom
  144. sourceComponent: RowLayout {
  145. width: column.width
  146. Label {
  147. Layout.preferredWidth: root.textWidth
  148. clip: true
  149. text: i18n("Fancontrol systemd service autostart:")
  150. horizontalAlignment: Text.AlignRight
  151. Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
  152. }
  153. ComboBox {
  154. id: autostartBox
  155. Layout.minimumWidth: implicitWidth
  156. Layout.fillWidth: true
  157. model: [i18n("disabled") , i18n("enabled")]
  158. currentIndex: systemdCom.serviceEnabled ? 1 : 0
  159. onCurrentIndexChanged: systemdCom.serviceEnabled = (currentIndex == 1) ? true : false
  160. }
  161. }
  162. }
  163. }
  164. }