SettingsForm.qml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import QtQuick 2.0
  2. import QtQuick.Controls 2.2
  3. Page {
  4. id: root
  5. title: qsTr("Settings")
  6. ListModel {
  7. id: settingsModel
  8. ListElement {
  9. name: "serviceUrl"
  10. title: qsTr("nooLite service URL")
  11. inputMethodHint: Qt.ImhUrlCharactersOnly
  12. }
  13. }
  14. ListView {
  15. model: settingsModel
  16. anchors.fill: parent
  17. delegate: SubtitledItemDelegate {
  18. width: parent.width
  19. text: model.title
  20. subtitle: settings[model.name]
  21. onClicked: inputDialog.open()
  22. Dialog {
  23. id: inputDialog
  24. x: (parent.width - width) / 2
  25. y: (parent.height - height) / 2
  26. parent: ApplicationWindow.overlay
  27. focus: true
  28. modal: true
  29. title: model.title
  30. standardButtons: Dialog.Ok | Dialog.Cancel
  31. Column {
  32. spacing: 20
  33. anchors.fill: parent
  34. TextField {
  35. id: textField
  36. width: parent.width
  37. focus: true
  38. inputMethodHints: Qt.ImhNoAutoUppercase | model.inputMethodHint
  39. placeholderText: model.title
  40. text: settings[model.name]
  41. }
  42. }
  43. onAccepted: {
  44. settings[model.name] = textField.text
  45. }
  46. }
  47. }
  48. }
  49. }