pantalaimon-ut/qml/Components/EditServerPage.qml
2020-07-13 17:59:16 -07:00

146 lines
3.8 KiB
QML

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: {
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: ""
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:')
}
TextField {
id: homeserver
text: ""
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();
}
}
}