Добавил форму настроек

This commit is contained in:
2018-07-11 20:44:50 +02:00
parent f2f55a2830
commit 34637319ba
3 changed files with 58 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ Page {
title: qsTr("Home") title: qsTr("Home")
Label { Label {
text: qsTr("You are on the home page.") text: qsTr("You are on the home page. " + settings.serviceUrl)
anchors.centerIn: parent anchors.centerIn: parent
} }
} }

View File

@@ -2,10 +2,56 @@ import QtQuick 2.0
import QtQuick.Controls 2.2 import QtQuick.Controls 2.2
Page { Page {
id: root
title: qsTr("Settings") title: qsTr("Settings")
ListModel {
id: settingsModel
ListElement {
name: "serviceUrl"
title: qsTr("NooLite service URL:")
inputHint: Qt.ImhUrlCharactersOnly
}
}
ListView {
model: settingsModel
anchors.fill: parent
anchors.margins: 8
delegate: Item {
id: settingsItem
width: parent.width
height: childrenRect.height
Label { Label {
text: qsTr("You are on Settings Page") id: titleLabel
anchors.centerIn: parent
anchors.left: settingsItem.left
anchors.verticalCenter: valueField.verticalCenter
text: model.title
}
TextField {
id: valueField
anchors.right: settingsItem.right
anchors.left: titleLabel.right
anchors.leftMargin: 8
inputMethodHints: model.inputHint
text: settings[model.name]
onTextChanged: {
settings[model.name] = text
}
}
}
} }
} }

View File

@@ -1,13 +1,21 @@
import QtQuick 2.9 import QtQuick 2.9
import QtQuick.Controls 2.2 import QtQuick.Controls 2.2
import Qt.labs.settings 1.0
ApplicationWindow { ApplicationWindow {
id: window id: window
visible: true visible: true
width: 640 width: 640
height: 480 height: 480
title: qsTr("Stack") title: qsTr("Stack")
Settings {
id: settings
property string serviceUrl: ""
}
header: ToolBar { header: ToolBar {
contentHeight: 36 contentHeight: 36