Application.qml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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: base.hasSystemdCommunicator()
  54. sourceComponent: ToolButton {
  55. iconName: base.systemdCom.serviceActive ? "system-reboot" : "system-run"
  56. onClicked: base.systemdCom.serviceActive ? base.systemdCom.restartService() : base.systemdCom.serviceActive = true;
  57. tooltip: base.systemdCom.serviceActive ? i18n("Restart fancontrol") : i18n("Start fancontrol")
  58. }
  59. }
  60. Loader {
  61. active: base.hasSystemdCommunicator()
  62. sourceComponent: ToolButton {
  63. iconName: "system-shutdown"
  64. enabled: base.systemdCom.serviceActive
  65. onClicked: base.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. id: tabView
  83. anchors.fill: parent
  84. anchors.topMargin: 5
  85. frameVisible: true
  86. Tab {
  87. title: i18n("Sensors")
  88. SensorsTab {
  89. loader: base.loader
  90. }
  91. }
  92. Tab {
  93. title: i18n("PwmFans")
  94. PwmFansTab {
  95. size: sizeSlider.value
  96. baseObject: base
  97. }
  98. }
  99. Tab {
  100. title: i18n("Configfile")
  101. ConfigfileTab {
  102. loader: base.loader
  103. }
  104. }
  105. Tab {
  106. id: settingsTab
  107. title: i18n("Settings")
  108. SettingsTab {
  109. baseObject: base
  110. }
  111. }
  112. }
  113. statusBar: StatusBar {
  114. Label {
  115. property string systemdError: base.hasSystemdCommunicator() ? base.systemdCom.error : ""
  116. property string loaderError: base.loader.error
  117. color: "red"
  118. onSystemdErrorChanged: {
  119. if (systemdError !== "Success" && systemdError.search("succeeded") == -1)
  120. text = systemdError;
  121. else if (loaderError === "Success" || loaderError === "")
  122. text = ""
  123. }
  124. onLoaderErrorChanged: {
  125. if (loaderError !== "Success")
  126. text = loaderError;
  127. else if (systemdError === "Success" || systemdError === "")
  128. text = ""
  129. }
  130. }
  131. }
  132. Action {
  133. id: loadAction
  134. text: i18n("Load configuration file")
  135. iconName: "document-open"
  136. onTriggered: openFileDialog.open()
  137. tooltip: i18n("Load configuration file")
  138. shortcut: StandardKey.Open
  139. }
  140. Action {
  141. id: saveAction
  142. text: i18n("Save configuration file")
  143. onTriggered: base.loader.save()
  144. iconName: "document-save"
  145. tooltip: i18n("Save configuration file")
  146. shortcut: StandardKey.Save
  147. }
  148. FileDialog {
  149. id: openFileDialog
  150. title: i18n("Please choose a configuration file")
  151. folder: "file:///etc"
  152. selectExisting: true
  153. selectMultiple: false
  154. modality: Qt.NonModal
  155. onAccepted: {
  156. base.loader.load(fileUrl);
  157. }
  158. }
  159. FileDialog {
  160. id: saveFileDialog
  161. title: i18n("Save configuration file as")
  162. folder: "file:///etc"
  163. selectExisting: false
  164. selectMultiple: false
  165. modality: Qt.NonModal
  166. onAccepted: {
  167. base.loader.save(fileUrl);
  168. }
  169. }
  170. }