From 667c02f6687efff505ffd3c11bc98acadd6fd76f Mon Sep 17 00:00:00 2001 From: Black Hat Date: Tue, 14 Aug 2018 14:45:32 +0800 Subject: [PATCH] Add server URL and username format indicator. Fixes #27. --- qml/Login.qml | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/qml/Login.qml b/qml/Login.qml index 4426654..215290e 100644 --- a/qml/Login.qml +++ b/qml/Login.qml @@ -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) } }