Add server URL and username format indicator.

Fixes #27.
This commit is contained in:
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 anchors.fill: parent
source: "qrc:/asset/img/background.jpg" source: "qrc:/asset/img/background.jpg"
fillMode: Image.PreserveAspectCrop fillMode: Image.PreserveAspectCrop
cache: false
} }
ColorOverlay { ColorOverlay {
@ -130,10 +131,27 @@ Page {
text: "LOGIN" text: "LOGIN"
highlighted: true highlighted: true
ToolTip {
id: loginButtonTooltip
}
onClicked: { 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) if (matriqueController.isLogin) stackView.replace(roomPage)
}) matriqueController.isLoginChanged.disconnect(replaceViewFunction)
}
matriqueController.isLoginChanged.connect(replaceViewFunction)
controller.loginWithCredentials(serverField.text, usernameField.text, passwordField.text) controller.loginWithCredentials(serverField.text, usernameField.text, passwordField.text)
} }
} }