SettingsForm.qml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import QtQuick 2.0
  2. import QtQuick.Controls 2.2
  3. import ru.ded.noolight 1.0
  4. import ru.ded.components 1.0
  5. Page {
  6. id: root
  7. title: qsTr("Settings")
  8. ListModel {
  9. id: settingsModel
  10. ListElement {
  11. name: "serviceUrl"
  12. title: qsTr("nooLite service URL")
  13. inputMethodHint: Qt.ImhUrlCharactersOnly
  14. }
  15. ListElement {
  16. name: "login"
  17. title: qsTr("Login")
  18. inputMethodHint: Qt.ImhLatinOnly
  19. }
  20. ListElement {
  21. name: "password"
  22. title: qsTr("Password")
  23. hideText: true
  24. }
  25. }
  26. ListView {
  27. model: settingsModel
  28. anchors.fill: parent
  29. delegate: SubtitledItemDelegate {
  30. width: parent.width
  31. text: model.title
  32. subtitle: model.hideText && Settings[model.name] ? qsTr("Hidden") : Settings[model.name]
  33. onClicked: inputDialog.open()
  34. Dialog {
  35. id: inputDialog
  36. anchors.centerIn: parent
  37. parent: ApplicationWindow.overlay
  38. focus: true
  39. modal: true
  40. title: model.title
  41. standardButtons: Dialog.Ok | Dialog.Cancel
  42. Column {
  43. spacing: 20
  44. anchors.fill: parent
  45. TextField {
  46. id: textField
  47. width: parent.width
  48. focus: true
  49. inputMethodHints: model.inputMethodHint
  50. echoMode: model.hideText ? TextInput.Password : TextInput.Normal
  51. placeholderText: model.title
  52. text: Settings[model.name]
  53. }
  54. }
  55. onAccepted: {
  56. Settings[model.name] = textField.text
  57. }
  58. }
  59. }
  60. }
  61. }