Application.qml 5.9 KB

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