2020-07-14 00:59:16 +00:00
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
2020-09-03 22:04:34 +00:00
property alias proxy: proxy . text
property alias ssl: ssl . checked
2020-07-14 00:59:16 +00:00
signal save ( )
header: PageHeader {
id: header
title: i18n . tr ( 'Homeserver Configuration' )
trailingActionBar.actions: [
Action {
iconName: 'ok'
text: i18n . tr ( 'Save' )
onTriggered: {
2020-08-09 23:01:00 +00:00
if ( homeserver . text . length == 0 ) {
homeserver . text = "https://matrix.org"
}
if ( ! /^https?:\/\//i . test ( homeserver . text ) ) {
homeserver . text = "https://" + homeserver . text
}
2020-07-14 00:59:16 +00:00
var data = {
name: instance . text ,
homeserver: homeserver . text ,
2020-09-03 22:04:34 +00:00
listenport: listenport . text ,
proxy: proxy . text ,
ssl: ssl . checked
2020-07-14 00:59:16 +00:00
}
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?
2020-09-03 22:04:34 +00:00
proxy . text = "" ;
ssl . checked = true ;
2020-07-14 00:59:16 +00:00
}
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 {
2020-09-03 22:04:34 +00:00
id: instanceLabel
2020-07-14 00:59:16 +00:00
anchors.verticalCenter: parent . verticalCenter
2020-09-03 22:04:34 +00:00
text: i18n . tr ( 'InstanceName' )
font.bold: true
2020-07-14 00:59:16 +00:00
}
TextField {
id: instance
2020-08-09 23:01:00 +00:00
text: "my-homeserver"
2020-07-14 00:59:16 +00:00
anchors.verticalCenter: parent . verticalCenter
2020-09-03 22:04:34 +00:00
width: parent . width - units . gu ( 6 ) - instanceLabel . width
2020-07-14 00:59:16 +00:00
}
}
2020-09-08 03:23:50 +00:00
// Homeserver
2020-07-14 00:59:16 +00:00
Row {
width: parent . width
height: units . gu ( 6 )
leftPadding: units . gu ( 2 )
spacing: units . gu ( 1 )
Label {
2020-09-03 22:04:34 +00:00
id: homeserverLabel
2020-07-14 00:59:16 +00:00
anchors.verticalCenter: parent . verticalCenter
2020-09-03 22:04:34 +00:00
text: i18n . tr ( 'Homeserver' )
font.bold: true
2020-07-14 00:59:16 +00:00
}
TextField {
id: homeserver
text: ""
2020-08-09 23:01:00 +00:00
placeholderText: "https://matrix.org"
2020-07-14 00:59:16 +00:00
anchors.verticalCenter: parent . verticalCenter
2020-09-03 22:04:34 +00:00
width: parent . width - units . gu ( 6 ) - homeserverLabel . width
2020-07-14 00:59:16 +00:00
inputMethodHints: Qt . ImhUrlCharactersOnly
}
}
2020-09-03 22:04:34 +00:00
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
}
}
2020-09-08 03:23:50 +00:00
// ListenPort
2020-07-14 00:59:16 +00:00
Row {
width: parent . width
height: units . gu ( 6 )
leftPadding: units . gu ( 2 )
spacing: units . gu ( 1 )
Label {
2020-09-03 22:04:34 +00:00
id: listenportLabel
2020-07-14 00:59:16 +00:00
anchors.verticalCenter: parent . verticalCenter
2020-09-03 22:04:34 +00:00
text: i18n . tr ( 'ListenPort' )
font.bold: true
2020-07-14 00:59:16 +00:00
}
TextField {
id: listenport
text: "8009"
anchors.verticalCenter: parent . verticalCenter
2020-09-03 22:04:34 +00:00
width: parent . width - units . gu ( 6 ) - listenportLabel . width
2020-07-14 00:59:16 +00:00
inputMethodHints: Qt . ImhDigitsOnly
}
}
2020-09-03 22:04:34 +00:00
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
}
}
2020-09-08 03:23:50 +00:00
// Proxy
2020-09-03 22:04:34 +00:00
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
}
}
2020-09-08 03:23:50 +00:00
// SSL
2020-09-03 22:04:34 +00:00
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
}
}
2020-09-08 03:23:50 +00:00
// END
2020-07-14 00:59:16 +00:00
}
}
Connections {
target: bottomEdge
onCollapseCompleted: {
resetdata ( ) ;
}
}
}