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. Slider {
  72. id: sizeSlider
  73. Layout.alignment: Qt.AlignRight
  74. Layout.preferredWidth: 200
  75. value: 0.4
  76. visible: tabView.currentIndex == 1
  77. }
  78. }
  79. }
  80. TabView {
  81. id: tabView
  82. anchors.fill: parent
  83. anchors.topMargin: 5
  84. frameVisible: true
  85. Tab {
  86. title: i18n("Sensors")
  87. SensorsTab {
  88. loader: base.loader
  89. }
  90. }
  91. Tab {
  92. title: i18n("PwmFans")
  93. PwmFansTab {
  94. size: sizeSlider.value
  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. Action {
  113. id: loadAction
  114. text: i18n("Load configuration file")
  115. iconName: "document-open"
  116. onTriggered: openFileDialog.open()
  117. tooltip: i18n("Load configuration file")
  118. shortcut: StandardKey.Open
  119. }
  120. Action {
  121. id: saveAction
  122. text: i18n("Save configuration file")
  123. onTriggered: base.loader.save()
  124. iconName: "document-save"
  125. tooltip: i18n("Save configuration file")
  126. shortcut: StandardKey.Save
  127. }
  128. FileDialog {
  129. id: openFileDialog
  130. title: i18n("Please choose a configuration file")
  131. folder: "file:///etc"
  132. selectExisting: true
  133. selectMultiple: false
  134. modality: Qt.NonModal
  135. onAccepted: {
  136. base.loader.load(fileUrl);
  137. }
  138. }
  139. FileDialog {
  140. id: saveFileDialog
  141. title: i18n("Save configuration file as")
  142. folder: "file:///etc"
  143. selectExisting: false
  144. selectMultiple: false
  145. modality: Qt.NonModal
  146. onAccepted: {
  147. base.loader.save(fileUrl);
  148. }
  149. }
  150. }