Application.qml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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.Controls 1.3
  21. import QtQuick.Window 2.2
  22. import QtQuick.Dialogs 1.2
  23. import QtQuick.Layouts 1.1
  24. ApplicationWindow {
  25. id: window
  26. title: i18n("Fancontrol-GUI")
  27. width: 1024
  28. height: 768
  29. visible: true
  30. menuBar: MenuBar {
  31. Menu {
  32. title: i18n("File")
  33. MenuItem {
  34. text: i18n("Load configuration file")
  35. onTriggered: openFileDialog.open()
  36. }
  37. MenuItem {
  38. text: i18n("Save configuration file")
  39. onTriggered: gui.loader.save()
  40. }
  41. MenuItem {
  42. text: i18n("Save configuration file as")
  43. onTriggered: saveFileDialog.open()
  44. }
  45. MenuItem {
  46. text: i18n("Exit")
  47. onTriggered: Qt.quit()
  48. }
  49. }
  50. }
  51. toolBar: ToolBar {
  52. RowLayout {
  53. anchors.fill: parent
  54. ToolButton {
  55. iconName: "document-open"
  56. onClicked: openFileDialog.open()
  57. ToolTip {
  58. text: i18n("Load configuration file")
  59. }
  60. }
  61. ToolButton {
  62. iconName: "document-save"
  63. onClicked: gui.loader.save()
  64. ToolTip {
  65. text: i18n("Save configuration file")
  66. }
  67. }
  68. Loader {
  69. active: gui.hasSystemdCommunicator()
  70. sourceComponent: ToolButton {
  71. iconName: gui.systemdCom.serviceActive ? "system-reboot" : "system-run"
  72. onClicked: gui.systemdCom.serviceActive ? gui.systemdCom.restartService() : gui.systemdCom.serviceActive = true;
  73. ToolTip {
  74. text: gui.systemdCom.serviceActive ? i18n("Restart fancontrol") : i18n("Start fancontrol")
  75. }
  76. }
  77. }
  78. Loader {
  79. active: gui.hasSystemdCommunicator()
  80. sourceComponent: ToolButton {
  81. iconName: "system-shutdown"
  82. enabled: gui.systemdCom.serviceActive
  83. onClicked: gui.systemdCom.serviceActive = false;
  84. ToolTip {
  85. text: i18n("Stop fancontrol")
  86. }
  87. }
  88. }
  89. Item {
  90. Layout.fillWidth: true
  91. }
  92. Slider {
  93. id: sizeSlider
  94. Layout.alignment: Qt.AlignRight
  95. Layout.preferredWidth: 200
  96. value: 0.4
  97. visible: tabView.currentIndex == 1
  98. }
  99. }
  100. }
  101. TabView {
  102. property real minTemp: 30.0
  103. property real maxTemp: 90.0
  104. property string unit: i18n("Celsius")
  105. id: tabView
  106. anchors.fill: parent
  107. anchors.topMargin: 5
  108. frameVisible: true
  109. Tab {
  110. title: i18n("Sensors")
  111. SensorsTab {
  112. loader: gui.loader
  113. }
  114. }
  115. Tab {
  116. title: i18n("PwmFans")
  117. PwmFansTab {
  118. size: sizeSlider.value
  119. minTemp: tabView.minTemp
  120. maxTemp: tabView.maxTemp
  121. unit: tabView.unit
  122. loader: gui.loader
  123. }
  124. }
  125. Tab {
  126. title: i18n("Configfile")
  127. ConfigfileTab {
  128. loader: gui.loader
  129. }
  130. }
  131. Tab {
  132. title: i18n("Settings")
  133. SettingsTab {
  134. id: settingsTab
  135. interval: gui.loader.interval
  136. minTemp: tabView.minTemp
  137. maxTemp: tabView.maxTemp
  138. onMinTempChanged: tabView.minTemp = minTemp
  139. onMaxTempChanged: tabView.maxTemp = maxTemp
  140. onUnitChanged: tabView.unit = unit
  141. loader: gui.loader
  142. systemdCom: gui.hasSystemdCommunicator() ? gui.systemdCom : null
  143. }
  144. }
  145. }
  146. statusBar: StatusBar {
  147. Text {
  148. property string systemdError: gui.hasSystemdCommunicator() ? gui.systemdCom.error : ""
  149. property string loaderError: gui.loader.error
  150. color: "red"
  151. onSystemdErrorChanged: {
  152. if (systemdError !== "Success" && systemdError.search("succeeded") == -1)
  153. text = systemdError;
  154. else if (loaderError === "Success" || loaderError === "")
  155. text = ""
  156. }
  157. onLoaderErrorChanged: {
  158. if (loaderError !== "Success")
  159. text = loaderError;
  160. else if (systemdError === "Success" || systemdError === "")
  161. text = ""
  162. }
  163. }
  164. }
  165. FileDialog {
  166. id: openFileDialog
  167. title: i18n("Please choose a configuration file")
  168. folder: "file:///etc"
  169. selectExisting: true
  170. selectMultiple: false
  171. modality: Qt.NonModal
  172. onAccepted: {
  173. gui.loader.load(fileUrl);
  174. }
  175. }
  176. FileDialog {
  177. id: saveFileDialog
  178. title: i18n("Save configuration file as")
  179. folder: "file:///etc"
  180. selectExisting: false
  181. selectMultiple: false
  182. modality: Qt.NonModal
  183. onAccepted: {
  184. gui.loader.save(fileUrl);
  185. }
  186. }
  187. }