Application.qml 4.6 KB

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