Add server URL and username format indicator.

Fixes #27.
square-messages
Black Hat 2018-08-14 14:45:32 +08:00
parent 09fdd52524
commit 667c02f668
1 changed files with 20 additions and 2 deletions

View File

@ -22,6 +22,7 @@ Page {
anchors.fill: parent
source: "qrc:/asset/img/background.jpg"
fillMode: Image.PreserveAspectCrop
cache: false
}
ColorOverlay {
@ -130,10 +131,27 @@ Page {
text: "LOGIN"
highlighted: true
ToolTip {
id: loginButtonTooltip
}
onClicked: {
matriqueController.isLoginChanged.connect( function() {
if (!serverField.text.startsWith("http")) {
loginButtonTooltip.text = "Server address should start with http(s)://"
loginButtonTooltip.open()
return
}
if (!(usernameField.text.startsWith("@") && usernameField.text.includes(":"))) {
loginButtonTooltip.text = "Username should be in format of @example:example.com"
loginButtonTooltip.open()
return
}
var replaceViewFunction = function() {
if (matriqueController.isLogin) stackView.replace(roomPage)
})
matriqueController.isLoginChanged.disconnect(replaceViewFunction)
}
matriqueController.isLoginChanged.connect(replaceViewFunction)
controller.loginWithCredentials(serverField.text, usernameField.text, passwordField.text)
}
}