set valid url for homeserver

fixes https://todo.sr.ht/~thrrgilag/pantalaimon-ut/3
This commit is contained in:
Morgan McMillian 2020-08-09 16:01:00 -07:00
parent 763fbf8e4f
commit b1f5450f58
4 changed files with 15 additions and 8 deletions

View file

@ -48,7 +48,7 @@ install(DIRECTORY src DESTINATION ${DATA_DIR})
install(DIRECTORY qml DESTINATION ${DATA_DIR}) install(DIRECTORY qml DESTINATION ${DATA_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/AboutPage.qml DESTINATION ${DATA_DIR}qml/) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/AboutPage.qml DESTINATION ${DATA_DIR}qml/)
# example config file for local testing # TODO: example config file for local testing
# install(FILES example.conf DESTINATION ${CMAKE_INSTALL_PREFIX} RENAME pantalaimon.conf) # install(FILES example.conf DESTINATION ${CMAKE_INSTALL_PREFIX} RENAME pantalaimon.conf)
# Translations # Translations

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: pantalaimon.thrrgilag\n" "Project-Id-Version: pantalaimon.thrrgilag\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-08-09 20:24+0000\n" "POT-Creation-Date: 2020-08-09 22:57+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -25,15 +25,15 @@ msgstr ""
msgid "Save" msgid "Save"
msgstr "" msgstr ""
#: ../qml/Components/EditServerPage.qml:83 #: ../qml/Components/EditServerPage.qml:89
msgid "Description:" msgid "Description:"
msgstr "" msgstr ""
#: ../qml/Components/EditServerPage.qml:103 #: ../qml/Components/EditServerPage.qml:109
msgid "Homeserver:" msgid "Homeserver URL:"
msgstr "" msgstr ""
#: ../qml/Components/EditServerPage.qml:124 #: ../qml/Components/EditServerPage.qml:131
msgid "Listen on 127.0.0.1:" msgid "Listen on 127.0.0.1:"
msgstr "" msgstr ""

View file

@ -23,6 +23,12 @@ Page {
iconName: 'ok' iconName: 'ok'
text: i18n.tr('Save') text: i18n.tr('Save')
onTriggered: { onTriggered: {
if (homeserver.text.length == 0) {
homeserver.text = "https://matrix.org"
}
if (!/^https?:\/\//i.test(homeserver.text)) {
homeserver.text = "https://" + homeserver.text
}
var data = { var data = {
name: instance.text, name: instance.text,
homeserver: homeserver.text, homeserver: homeserver.text,
@ -85,7 +91,7 @@ Page {
TextField { TextField {
id: instance id: instance
text: "" text: "my-homeserver"
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
Layout.fillWidth: true Layout.fillWidth: true
} }
@ -100,12 +106,13 @@ Page {
Label { Label {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
text: i18n.tr('Homeserver:') text: i18n.tr('Homeserver URL:')
} }
TextField { TextField {
id: homeserver id: homeserver
text: "" text: ""
placeholderText: "https://matrix.org"
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
Layout.fillWidth: true Layout.fillWidth: true
inputMethodHints: Qt.ImhUrlCharactersOnly inputMethodHints: Qt.ImhUrlCharactersOnly

Binary file not shown.