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. onClosing: base.save()
  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: {
  57. base.loader.abortTestingFans();
  58. base.systemdCom.serviceActive ? base.systemdCom.restartService() : base.systemdCom.serviceActive = true;
  59. }
  60. tooltip: base.systemdCom.serviceActive ? i18n("Restart fancontrol") : i18n("Start fancontrol")
  61. }
  62. }
  63. Loader {
  64. active: base.hasSystemdCommunicator()
  65. sourceComponent: ToolButton {
  66. iconName: "system-shutdown"
  67. enabled: base.systemdCom.serviceActive
  68. onClicked: base.systemdCom.serviceActive = false;
  69. tooltip: i18n("Stop fancontrol")
  70. }
  71. }
  72. Item {
  73. Layout.fillWidth: true
  74. }
  75. }
  76. }
  77. TabView {
  78. id: tabView
  79. anchors.fill: parent
  80. anchors.topMargin: 5
  81. frameVisible: true
  82. Tab {
  83. title: i18n("Sensors")
  84. SensorsTab {
  85. loader: base.loader
  86. }
  87. }
  88. Tab {
  89. title: i18n("PwmFans")
  90. PwmFansTab {
  91. baseObject: base
  92. }
  93. }
  94. Tab {
  95. title: i18n("Configfile")
  96. ConfigfileTab {
  97. loader: base.loader
  98. }
  99. }
  100. Tab {
  101. id: settingsTab
  102. title: i18n("Settings")
  103. SettingsTab {
  104. gui: base
  105. }
  106. }
  107. }
  108. ErrorDialog {
  109. id: errorDialog
  110. visible: !!base.loader.error
  111. modality: Qt.ApplicationModal
  112. text: base.loader.error
  113. onTextChanged: show()
  114. }
  115. Action {
  116. id: loadAction
  117. text: i18n("Load configuration file")
  118. iconName: "document-open"
  119. onTriggered: openFileDialog.open()
  120. tooltip: i18n("Load configuration file")
  121. shortcut: StandardKey.Open
  122. }
  123. Action {
  124. id: saveAction
  125. text: i18n("Save configuration file")
  126. onTriggered: base.save(true)
  127. iconName: "document-save"
  128. tooltip: i18n("Save configuration file") + " (" + base.loader.configUrl.toString() + ")"
  129. shortcut: StandardKey.Save
  130. }
  131. FileDialog {
  132. id: openFileDialog
  133. title: i18n("Please choose a configuration file")
  134. folder: "file:///etc"
  135. selectExisting: true
  136. selectMultiple: false
  137. modality: Qt.NonModal
  138. onAccepted: base.configUrl = fileUrl;
  139. }
  140. FileDialog {
  141. id: saveFileDialog
  142. title: i18n("Save configuration file as")
  143. folder: "file:///etc"
  144. selectExisting: false
  145. selectMultiple: false
  146. modality: Qt.NonModal
  147. onAccepted: base.save(true, fileUrl);
  148. }
  149. }