Application.qml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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.Dialogs 1.2
  22. import QtQuick.Layouts 1.1
  23. ApplicationWindow {
  24. id: window
  25. title: i18n("Fancontrol-GUI")
  26. width: 1024
  27. height: 768
  28. visible: true
  29. menuBar: MenuBar {
  30. Menu {
  31. title: i18n("File")
  32. MenuItem { action: loadAction }
  33. MenuItem { action: saveAction }
  34. MenuItem {
  35. text: i18n("Save configuration file as")
  36. onTriggered: saveFileDialog.open()
  37. shortcut: StandardKey.SaveAs
  38. }
  39. MenuItem {
  40. text: i18n("Exit")
  41. onTriggered: Qt.quit()
  42. shortcut: StandardKey.Quit
  43. }
  44. }
  45. }
  46. toolBar: ToolBar {
  47. RowLayout {
  48. anchors.fill: parent
  49. ToolButton { action: loadAction }
  50. ToolButton { action: saveAction }
  51. Loader {
  52. active: base.hasSystemdCommunicator()
  53. sourceComponent: ToolButton {
  54. iconName: base.systemdCom.serviceActive ? "system-reboot" : "system-run"
  55. onClicked: {
  56. base.loader.abortTestingFans();
  57. base.systemdCom.serviceActive ? base.systemdCom.restartService() : base.systemdCom.serviceActive = true;
  58. }
  59. tooltip: base.systemdCom.serviceActive ? i18n("Restart fancontrol") : i18n("Start fancontrol")
  60. }
  61. }
  62. Loader {
  63. active: base.hasSystemdCommunicator()
  64. sourceComponent: ToolButton {
  65. iconName: "system-shutdown"
  66. enabled: base.systemdCom.serviceActive
  67. onClicked: base.systemdCom.serviceActive = false;
  68. tooltip: i18n("Stop fancontrol")
  69. }
  70. }
  71. Item {
  72. Layout.fillWidth: true
  73. }
  74. }
  75. }
  76. TabView {
  77. id: tabView
  78. anchors.fill: parent
  79. anchors.topMargin: 5
  80. frameVisible: true
  81. Tab {
  82. title: i18n("Sensors")
  83. SensorsTab {
  84. loader: base.loader
  85. }
  86. }
  87. Tab {
  88. title: i18n("PwmFans")
  89. PwmFansTab {
  90. baseObject: base
  91. }
  92. }
  93. Tab {
  94. title: i18n("Configfile")
  95. ConfigfileTab {
  96. loader: base.loader
  97. }
  98. }
  99. Tab {
  100. id: settingsTab
  101. title: i18n("Settings")
  102. SettingsTab {
  103. gui: base
  104. }
  105. }
  106. }
  107. ErrorDialog {
  108. id: errorDialog
  109. visible: !!base.loader.error
  110. modality: Qt.ApplicationModal
  111. text: base.loader.error
  112. onTextChanged: show()
  113. }
  114. Action {
  115. id: loadAction
  116. text: i18n("Load configuration file")
  117. iconName: "document-open"
  118. onTriggered: openFileDialog.open()
  119. tooltip: i18n("Load configuration file")
  120. shortcut: StandardKey.Open
  121. }
  122. Action {
  123. id: saveAction
  124. text: i18n("Save configuration file")
  125. onTriggered: base.loader.save()
  126. iconName: "document-save"
  127. tooltip: i18n("Save configuration file") + " (" + base.loader.configUrl.toString() + ")"
  128. shortcut: StandardKey.Save
  129. }
  130. FileDialog {
  131. id: openFileDialog
  132. title: i18n("Please choose a configuration file")
  133. folder: "file:///etc"
  134. selectExisting: true
  135. selectMultiple: false
  136. modality: Qt.NonModal
  137. onAccepted: {
  138. base.loader.load(fileUrl);
  139. }
  140. }
  141. FileDialog {
  142. id: saveFileDialog
  143. title: i18n("Save configuration file as")
  144. folder: "file:///etc"
  145. selectExisting: false
  146. selectMultiple: false
  147. modality: Qt.NonModal
  148. onAccepted: {
  149. base.loader.save(fileUrl);
  150. }
  151. }
  152. }