From 34637319ba6be870f448c5de513e380f01193ab6 Mon Sep 17 00:00:00 2001 From: "Denis V. Dedkov" Date: Wed, 11 Jul 2018 20:44:50 +0200 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=84=D0=BE=D1=80=D0=BC=D1=83=20=D0=BD=D0=B0=D1=81=D1=82=D1=80?= =?UTF-8?q?=D0=BE=D0=B5=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HomeForm.qml | 2 +- SettingsForm.qml | 52 +++++++++++++++++++++++++++++++++++++++++++++--- main.qml | 8 ++++++++ 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/HomeForm.qml b/HomeForm.qml index 29d484b..4d8b3a6 100644 --- a/HomeForm.qml +++ b/HomeForm.qml @@ -5,7 +5,7 @@ Page { title: qsTr("Home") Label { - text: qsTr("You are on the home page.") + text: qsTr("You are on the home page. " + settings.serviceUrl) anchors.centerIn: parent } } diff --git a/SettingsForm.qml b/SettingsForm.qml index ee384c9..c926550 100644 --- a/SettingsForm.qml +++ b/SettingsForm.qml @@ -2,10 +2,56 @@ import QtQuick 2.0 import QtQuick.Controls 2.2 Page { + id: root + title: qsTr("Settings") - Label { - text: qsTr("You are on Settings Page") - anchors.centerIn: parent + 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 { + id: titleLabel + + 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 + } + } + } } } diff --git a/main.qml b/main.qml index 392db4a..027061a 100644 --- a/main.qml +++ b/main.qml @@ -1,13 +1,21 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 +import Qt.labs.settings 1.0 ApplicationWindow { id: window + visible: true width: 640 height: 480 title: qsTr("Stack") + Settings { + id: settings + + property string serviceUrl: "" + } + header: ToolBar { contentHeight: 36