SettingsForm.ui.qml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. import QtQuick 2.12
  2. import QtQuick.Layouts 1.3
  3. import QtQuick.Controls 2.5
  4. import QtQuick.Controls.Material 2.3
  5. import QtQuick.Dialogs 1.0
  6. Page {
  7. width: 1280
  8. height: 570
  9. id: settingsForm
  10. font.capitalization: Font.MixedCase
  11. Connections {
  12. target: _qmlHandler
  13. onCloseWindow: {
  14. window.close()
  15. }
  16. onLoadSettings: {
  17. settingsSaveIpSwitch.checked = saveIP
  18. settingsSaveUsernameSwitch.checked = saveUsername
  19. settingsCliPath.text = "CLI-Path: " + cliPath
  20. settingsKeyPath.text = " " + keyPath
  21. }
  22. onKeyfileStatus: {
  23. if (success) {
  24. settingsKeyStatus.text = "Keyfile: OK"
  25. settingsKeyStatus.color = "#00ad11"
  26. } else {
  27. settingsKeyStatus.text = "Keyfile: Error"
  28. settingsKeyStatus.color = "#df3f3f"
  29. settingsKeyPath.text = msg
  30. }
  31. }
  32. onKeyfileClosedOK: {
  33. settingsKeyStatus.text = "Keyfile:"
  34. settingsKeyStatus.color = "#000000"
  35. settingsKeyPath.text = " "
  36. }
  37. }
  38. ColumnLayout {
  39. anchors.fill: parent
  40. RowLayout {
  41. Layout.alignment: Qt.AlignCenter
  42. Layout.preferredWidth: parent.width
  43. Layout.preferredHeight: 400
  44. Layout.bottomMargin: 20
  45. ColumnLayout {
  46. Layout.alignment: Qt.AlignCenter
  47. Layout.preferredWidth: 500
  48. Layout.preferredHeight: parent.height
  49. Text {
  50. Layout.alignment: Qt.AlignCenter
  51. Layout.preferredWidth: 400
  52. Layout.preferredHeight: 50
  53. text: "Autofill default IP on start:"
  54. verticalAlignment: Text.AlignVCenter
  55. horizontalAlignment: Text.AlignLeft
  56. font.pixelSize: 20
  57. }
  58. Text {
  59. Layout.alignment: Qt.AlignCenter
  60. Layout.preferredWidth: 400
  61. Layout.preferredHeight: 50
  62. text: "Autofill default username on start:"
  63. verticalAlignment: Text.AlignVCenter
  64. horizontalAlignment: Text.AlignLeft
  65. font.pixelSize: 20
  66. }
  67. Text {
  68. id: settingsCliPath
  69. Layout.alignment: Qt.AlignCenter
  70. Layout.preferredWidth: 400
  71. Layout.preferredHeight: 50
  72. text: "CLI-Path: "
  73. verticalAlignment: Text.AlignVCenter
  74. horizontalAlignment: Text.AlignLeft
  75. font.pixelSize: 20
  76. }
  77. Text {
  78. id: settingsKeyStatus
  79. Layout.alignment: Qt.AlignCenter
  80. Layout.preferredWidth: 400
  81. Layout.preferredHeight: 50
  82. text: "Keyfile:"
  83. verticalAlignment: Text.AlignVCenter
  84. horizontalAlignment: Text.AlignLeft
  85. font.pixelSize: 20
  86. }
  87. Text {
  88. id: settingsKeyPath
  89. Layout.alignment: Qt.AlignCenter
  90. Layout.preferredWidth: 400
  91. Layout.preferredHeight: 50
  92. text: " "
  93. verticalAlignment: Text.AlignVCenter
  94. horizontalAlignment: Text.AlignLeft
  95. font.pixelSize: 20
  96. }
  97. Text {
  98. Layout.alignment: Qt.AlignCenter
  99. Layout.preferredWidth: 400
  100. Layout.preferredHeight: 50
  101. text: "Delete my account:"
  102. verticalAlignment: Text.AlignVCenter
  103. horizontalAlignment: Text.AlignLeft
  104. font.pixelSize: 20
  105. }
  106. }
  107. ColumnLayout {
  108. Layout.alignment: Qt.AlignCenter
  109. Layout.preferredWidth: 500
  110. Layout.preferredHeight: parent.height
  111. Switch {
  112. id: settingsSaveIpSwitch
  113. Layout.alignment: Qt.AlignCenter
  114. Layout.preferredHeight: 50
  115. Layout.preferredWidth: 400
  116. text: ""
  117. checked: false
  118. display: AbstractButton.IconOnly
  119. }
  120. Switch {
  121. id: settingsSaveUsernameSwitch
  122. Layout.alignment: Qt.AlignCenter
  123. Layout.preferredHeight: 50
  124. Layout.preferredWidth: 400
  125. text: ""
  126. checked: false
  127. display: AbstractButton.IconOnly
  128. }
  129. Button {
  130. id: settingsChangeCliPathButton
  131. Layout.alignment: Qt.AlignCenter
  132. Layout.preferredHeight: 50
  133. Layout.preferredWidth: 220
  134. text: "Change (req. restart)"
  135. font.pixelSize: 20
  136. // @disable-check M223
  137. onClicked: {
  138. // @disable-check M222
  139. settingsCliDialog.open()
  140. }
  141. }
  142. ColumnLayout {
  143. Layout.alignment: Qt.AlignCenter
  144. Button {
  145. id: settingsChangeKeyfilePathButton
  146. Layout.alignment: Qt.AlignCenter
  147. Layout.preferredHeight: 50
  148. Layout.preferredWidth: 220
  149. text: "Select"
  150. font.pixelSize: 20
  151. // @disable-check M223
  152. onClicked: {
  153. // @disable-check M222
  154. settingsKeyfileDialog.open()
  155. }
  156. }
  157. Button {
  158. id: settingsDisableKeyfile
  159. Layout.alignment: Qt.AlignCenter
  160. Layout.preferredHeight: 50
  161. Layout.preferredWidth: 220
  162. text: "Close Keyfile"
  163. font.pixelSize: 20
  164. // @disable-check M223
  165. onClicked: {
  166. // @disable-check M222
  167. _qmlHandler.onKeyfileClosed()
  168. }
  169. }
  170. }
  171. Button {
  172. id: settingsDeleteMeButton
  173. Layout.alignment: Qt.AlignCenter
  174. Layout.preferredHeight: 50
  175. Layout.preferredWidth: 150
  176. text: "Delete Me"
  177. font.pixelSize: 20
  178. // @disable-check M223
  179. onClicked: {
  180. // @disable-check M222
  181. deleteMePopup.open()
  182. }
  183. }
  184. }
  185. }
  186. Rectangle {
  187. Layout.alignment: Qt.AlignCenter
  188. Layout.preferredWidth: parent.width
  189. Layout.preferredHeight: 2
  190. color: Material.accent
  191. }
  192. RowLayout {
  193. Layout.alignment: Qt.AlignCenter
  194. Layout.preferredWidth: parent.width
  195. Layout.preferredHeight: 50
  196. Layout.bottomMargin: 20
  197. Button {
  198. id: settingsResetButton
  199. Layout.alignment: Qt.AlignCenter
  200. Layout.preferredWidth: 200
  201. Layout.preferredHeight: 50
  202. text: "Select defaults"
  203. font.pixelSize: 20
  204. // @disable-check M223
  205. onClicked: {
  206. // @disable-check M222
  207. _qmlHandler.onSettingsResetButton()
  208. }
  209. }
  210. Button {
  211. id: settingsSaveButton
  212. Layout.alignment: Qt.AlignCenter
  213. Layout.preferredWidth: 200
  214. Layout.preferredHeight: 50
  215. text: "Save Changes"
  216. font.pixelSize: 20
  217. // @disable-check M223
  218. onClicked: {
  219. // @disable-check M222
  220. _qmlHandler.onSettingsSaveButton(
  221. settingsSaveIpSwitch.checked,
  222. settingsSaveUsernameSwitch.checked,
  223. // @disable-check M222
  224. settingsCliPath.text.replace("CLI-Path: ",
  225. ""),
  226. // @disable-check M222
  227. settingsKeyPath.text.replace(" ", ""))
  228. }
  229. }
  230. Button {
  231. id: settingsRevertChangesButton
  232. Layout.alignment: Qt.AlignCenter
  233. Layout.preferredWidth: 200
  234. Layout.preferredHeight: 50
  235. text: "Revert Changes"
  236. font.pixelSize: 20
  237. // @disable-check M223
  238. onClicked: {
  239. // @disable-check M222
  240. _qmlHandler.onSettingsRevertChangesButton()
  241. }
  242. }
  243. }
  244. }
  245. FileDialog {
  246. id: settingsCliDialog
  247. nameFilters: ["CLI file (ccats-cli)"]
  248. title: "Please select the CLI File"
  249. folder: shortcuts.home
  250. // @disable-check M223
  251. onAccepted: {
  252. var path = settingsCliDialog.fileUrl.toString()
  253. // @disable-check M222
  254. path = path.replace(/^(file:\/{2})/, "")
  255. settingsCliPath.text = "CLI-Path: " + path
  256. }
  257. }
  258. FileDialog {
  259. id: settingsKeyfileDialog
  260. title: "Select keyfile to use"
  261. folder: shortcuts.home
  262. // @disable-check M223
  263. onAccepted: {
  264. var path = settingsKeyfileDialog.fileUrl.toString()
  265. // @disable-check M222
  266. path = path.replace(/^(file:\/{2})/, "")
  267. settingsKeyPath.text = " " + path
  268. // @disable-check M222
  269. _qmlHandler.onKeyfileSelected(path)
  270. }
  271. }
  272. DeleteMePopup {
  273. id: deleteMePopup
  274. }
  275. }