SettingsForm.ui.qml 11 KB

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