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 property alias proxy: proxy.text property alias ssl: ssl.checked 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, proxy: proxy.text, ssl: ssl.checked } 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? proxy.text = ""; ssl.checked = true; } 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 { id: instanceLabel anchors.verticalCenter: parent.verticalCenter text: i18n.tr('InstanceName') font.bold: true } TextField { id: instance text: "my-homeserver" anchors.verticalCenter: parent.verticalCenter width: parent.width - units.gu(6) - instanceLabel.width } } Row { width: parent.width height: units.gu(6) leftPadding: units.gu(2) spacing: units.gu(1) Label { id: homeserverLabel anchors.verticalCenter: parent.verticalCenter text: i18n.tr('Homeserver') font.bold: true } TextField { id: homeserver text: "" placeholderText: "https://matrix.org" anchors.verticalCenter: parent.verticalCenter width: parent.width - units.gu(6) - homeserverLabel.width inputMethodHints: Qt.ImhUrlCharactersOnly } } Row { width: parent.width leftPadding: units.gu(2) spacing: units.gu(1) Label { horizontalAlignment: Text.AlignLeft text: i18n.tr("The URI of the homeserver that the pantalaimon proxy should forward requests to, without the matrix API path but including the http(s) schema.") wrapMode: Text.WordWrap width: parent.width - units.gu(4) font.italic: true } } Row { width: parent.width height: units.gu(6) leftPadding: units.gu(2) spacing: units.gu(1) Label { id: listenportLabel anchors.verticalCenter: parent.verticalCenter text: i18n.tr('ListenPort') font.bold: true } TextField { id: listenport text: "8009" anchors.verticalCenter: parent.verticalCenter width: parent.width - units.gu(6) - listenportLabel.width inputMethodHints: Qt.ImhDigitsOnly } } Row { width: parent.width leftPadding: units.gu(2) spacing: units.gu(1) Label { horizontalAlignment: Text.AlignLeft text: i18n.tr("The port where the daemon will listen to client connections for this homeserver. Note that the listen address/port combination needs to be unique between different homeservers. Defaults to '8009'.") wrapMode: Text.WordWrap width: parent.width - units.gu(4) font.italic: true } } Row { width: parent.width height: units.gu(6) leftPadding: units.gu(2) spacing: units.gu(1) Label { id: proxyLabel anchors.verticalCenter: parent.verticalCenter text: i18n.tr('Proxy') font.bold: true } TextField { id: proxy text: "" anchors.verticalCenter: parent.verticalCenter width: parent.width - units.gu(6) - proxyLabel.width inputMethodHints: Qt.ImhUrlCharactersOnly } } Row { width: parent.width leftPadding: units.gu(2) spacing: units.gu(1) Label { horizontalAlignment: Text.AlignLeft text: i18n.tr("The URI of a HTTP proxy that the daemon should use when making requests to the homeserver. pantalaimon only supports HTTP proxies. The default is to make a direct connection to the homeserver.") wrapMode: Text.WordWrap width: parent.width - units.gu(4) font.italic: true } } Row { width: parent.width height: units.gu(6) leftPadding: units.gu(2) spacing: units.gu(1) Label { id: sslLabel anchors.verticalCenter: parent.verticalCenter text: i18n.tr('SSL') font.bold: true } Label { text: " " width: parent.width - sslLabel.width - ssl.width - units.gu(8) } Switch { id: ssl checked: true anchors.verticalCenter: parent.verticalCenter } } Row { width: parent.width leftPadding: units.gu(2) spacing: units.gu(1) Label { horizontalAlignment: Text.AlignLeft text: i18n.tr("SSL verification for outgoing connections to the homeserver. Defaults to 'True'.") wrapMode: Text.WordWrap width: parent.width - units.gu(4) font.italic: true } } } } Connections { target: bottomEdge onCollapseCompleted: { resetdata(); } } }