2
0

Application.qml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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: {
  30. base.save();
  31. windowConfig.save(window);
  32. }
  33. Component.onCompleted: windowConfig.restore(window)
  34. menuBar: MenuBar {
  35. Menu {
  36. title: i18n("File")
  37. MenuItem { action: loadAction }
  38. MenuItem { action: saveAction }
  39. MenuItem {
  40. text: i18n("Save configuration file as")
  41. onTriggered: saveFileDialog.open()
  42. shortcut: StandardKey.SaveAs
  43. }
  44. MenuItem {
  45. text: i18n("Exit")
  46. onTriggered: Qt.quit()
  47. shortcut: StandardKey.Quit
  48. }
  49. }
  50. }
  51. toolBar: ToolBar {
  52. RowLayout {
  53. anchors.fill: parent
  54. ToolButton { action: loadAction }
  55. ToolButton { action: saveAction }
  56. Loader {
  57. active: base.hasSystemdCommunicator()
  58. sourceComponent: ToolButton {
  59. iconName: base.systemdCom.serviceActive ? "system-reboot" : "system-run"
  60. onClicked: {
  61. base.loader.abortTestingFans();
  62. base.systemdCom.serviceActive ? base.systemdCom.restartService() : base.systemdCom.serviceActive = true;
  63. }
  64. tooltip: base.systemdCom.serviceActive ? i18n("Restart fancontrol") : i18n("Start fancontrol")
  65. }
  66. }
  67. Loader {
  68. active: base.hasSystemdCommunicator()
  69. sourceComponent: ToolButton {
  70. iconName: "system-shutdown"
  71. enabled: base.systemdCom.serviceActive
  72. onClicked: base.systemdCom.serviceActive = false;
  73. tooltip: i18n("Stop fancontrol")
  74. }
  75. }
  76. Item {
  77. Layout.fillWidth: true
  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. baseObject: base
  96. }
  97. }
  98. Tab {
  99. title: i18n("Configfile")
  100. ConfigfileTab {
  101. loader: base.loader
  102. }
  103. }
  104. Tab {
  105. id: settingsTab
  106. title: i18n("Settings")
  107. SettingsTab {
  108. gui: base
  109. }
  110. }
  111. }
  112. ErrorDialog {
  113. id: errorDialog
  114. visible: !!base.loader.error
  115. modality: Qt.ApplicationModal
  116. text: base.loader.error
  117. onTextChanged: show()
  118. }
  119. Action {
  120. id: loadAction
  121. text: i18n("Load configuration file")
  122. iconName: "document-open"
  123. onTriggered: openFileDialog.open()
  124. tooltip: i18n("Load configuration file")
  125. shortcut: StandardKey.Open
  126. }
  127. Action {
  128. id: saveAction
  129. text: i18n("Save configuration file")
  130. onTriggered: base.save(true)
  131. iconName: "document-save"
  132. tooltip: i18n("Save configuration file") + " (" + base.loader.configUrl.toString() + ")"
  133. shortcut: StandardKey.Save
  134. }
  135. FileDialog {
  136. id: openFileDialog
  137. title: i18n("Please choose a configuration file")
  138. folder: "file:///etc"
  139. selectExisting: true
  140. selectMultiple: false
  141. modality: Qt.NonModal
  142. onAccepted: base.configUrl = fileUrl;
  143. }
  144. FileDialog {
  145. id: saveFileDialog
  146. title: i18n("Save configuration file as")
  147. folder: "file:///etc"
  148. selectExisting: false
  149. selectMultiple: false
  150. modality: Qt.NonModal
  151. onAccepted: base.save(true, fileUrl);
  152. }
  153. }