import QtQuick 2.7 import QtQuick.Layouts 1.3 import Ubuntu.Components 1.3 import Ubuntu.Components.ListItems 1.3 Page { id: bottomEdgeComponent property int idx: 0 property bool editmode: false property alias instance: instance.text property alias homeserver: homeserver.text property alias listenport: listenport.text signal save() header: PageHeader { id: header title: i18n.tr('Homeserver Configuration') trailingActionBar.actions: [ Action { iconName: 'ok' text: i18n.tr('Save') onTriggered: { if (homeserver.text.length == 0) { homeserver.text = "https://matrix.org" } if (!/^https?:\/\//i.test(homeserver.text)) { homeserver.text = "https://" + homeserver.text } var data = { name: instance.text, homeserver: homeserver.text, listenport: listenport.text } if (editmode) { listModel.set(idx, data); pageStack.pop(); } else { listModel.append(data) bottomEdge.collapse(); } save(); } } ] } width: bottomEdge.width height: bottomEdge.height function resetdata() { console.log("debug: resetdata"); instance.text = ""; homeserver.text = ""; listenport.text = "8009"; // TODO: maybe autoincrement based on existing entries? } Flickable { clip: true anchors { top: header.bottom left: parent.left right: parent.right bottom: parent.bottom } contentHeight: contentColumn.height + units.gu(4) Column { id: contentColumn anchors { top: parent.top; left: parent.left; right: parent.right; } Row { width: parent.width height: units.gu(6) leftPadding: units.gu(2) spacing: units.gu(1) Label { anchors.verticalCenter: parent.verticalCenter text: i18n.tr('Description:') } TextField { id: instance text: "my-homeserver" anchors.verticalCenter: parent.verticalCenter Layout.fillWidth: true } } Row { width: parent.width height: units.gu(6) leftPadding: units.gu(2) spacing: units.gu(1) Label { anchors.verticalCenter: parent.verticalCenter text: i18n.tr('Homeserver URL:') } TextField { id: homeserver text: "" placeholderText: "https://matrix.org" anchors.verticalCenter: parent.verticalCenter Layout.fillWidth: true inputMethodHints: Qt.ImhUrlCharactersOnly } } Row { width: parent.width height: units.gu(6) leftPadding: units.gu(2) spacing: units.gu(1) Label { anchors.verticalCenter: parent.verticalCenter text: i18n.tr('Listen on 127.0.0.1:') } TextField { id: listenport text: "8009" anchors.verticalCenter: parent.verticalCenter Layout.fillWidth: true inputMethodHints: Qt.ImhDigitsOnly } } } } Connections { target: bottomEdge onCollapseCompleted: { resetdata(); } } }