2019-01-19 23:03:50 +01:00
|
|
|
/*
|
|
|
|
Fannyapp - Application to view the cover plan of the Fanny-Leicht-Gymnasium ins Stuttgart Vaihingen, Germany
|
|
|
|
Copyright (C) 2019 Itsblue Development <development@itsblue.de>
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published
|
|
|
|
by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-10-24 19:43:33 +02:00
|
|
|
import QtQuick 2.2
|
2018-12-30 20:58:52 +01:00
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import QtQuick.Controls 2.2
|
2019-10-24 19:43:33 +02:00
|
|
|
import QtQuick.Controls.Material 2.1
|
|
|
|
|
2018-12-30 20:58:52 +01:00
|
|
|
import "../Components"
|
|
|
|
|
|
|
|
Page {
|
|
|
|
id: root
|
|
|
|
objectName: "LoginPage";
|
|
|
|
|
|
|
|
header: AppToolBar {
|
|
|
|
Label {
|
|
|
|
text: "Anmeldung"
|
|
|
|
anchors.centerIn: parent
|
2019-03-10 12:54:35 +01:00
|
|
|
color: app.style.style.textColor
|
2018-12-30 20:58:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
Grid {
|
|
|
|
id: mainGrid
|
|
|
|
columns: app.landscape() ? 2:1
|
|
|
|
rows: app.landscape() ? 1:2
|
|
|
|
spacing: 0
|
2019-01-27 20:47:36 +01:00
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
anchors.fill: parent
|
2018-12-30 20:58:52 +01:00
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
2018-12-30 20:58:52 +01:00
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
Column {
|
|
|
|
id: logoInfoCol
|
2018-12-30 20:58:52 +01:00
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
width: app.landscape() ? root.width * 0.5:root.width
|
|
|
|
height: app.landscape() ? root.height:root.height * 0.3
|
2019-01-27 20:47:36 +01:00
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
Image {
|
|
|
|
id: bigLogo
|
2019-12-12 17:23:10 +01:00
|
|
|
source: "qrc:/graphics/favicon.png"
|
2019-02-16 22:38:13 +01:00
|
|
|
|
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
2019-12-12 17:23:10 +01:00
|
|
|
margins: height * 0.2
|
2019-02-16 22:38:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
height: parent.height * 0.6
|
|
|
|
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
smooth: true
|
|
|
|
}
|
2018-12-30 20:58:52 +01:00
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
Label {
|
|
|
|
id: infoText
|
2019-02-18 18:05:39 +01:00
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2019-02-18 18:05:39 +01:00
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
width: parent.width * 0.8
|
|
|
|
height: parent.height * 0.2
|
2019-02-18 18:05:39 +01:00
|
|
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
fontSizeMode: Text.Fit;
|
|
|
|
minimumPixelSize: 10;
|
|
|
|
font.pixelSize: 72
|
2019-02-18 18:05:39 +01:00
|
|
|
wrapMode: Text.Wrap
|
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
text: "<html>Bitte melde dich mit den Anmeldedaten der <a href='http://www.fanny-leicht.de/'>Fanny-Webseite</a> an.
|
|
|
|
<a href='http://www.fanny-leicht.de/j34/index.php/aktuelles/vertretungsplan'>Weitere Informationen</a></html>"
|
2019-02-18 18:05:39 +01:00
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
onLinkActivated: {
|
|
|
|
Qt.openUrlExternally(link)
|
|
|
|
}
|
2018-12-30 20:58:52 +01:00
|
|
|
}
|
2019-02-16 22:38:13 +01:00
|
|
|
|
2018-12-30 20:58:52 +01:00
|
|
|
}
|
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
Column {
|
|
|
|
id: formCol
|
2019-12-07 15:38:35 +01:00
|
|
|
spacing: height * 0.02
|
2018-12-30 20:58:52 +01:00
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
width: app.landscape() ? root.width * 0.5:root.width
|
|
|
|
height: app.landscape() ? root.height:root.height * 0.7
|
2018-12-30 20:58:52 +01:00
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
property int rowHeight: height / 6 - spacing * 2 > 60 ? 60: height / 6 - spacing * 2
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: spacer
|
|
|
|
height: formCol.spacing
|
|
|
|
color: "transparent"
|
2018-12-30 20:58:52 +01:00
|
|
|
}
|
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
TextField {
|
|
|
|
id: tiuname
|
|
|
|
|
2018-12-30 20:58:52 +01:00
|
|
|
anchors {
|
2019-02-16 22:38:13 +01:00
|
|
|
left: parent.left
|
|
|
|
leftMargin: root.width * 0.05
|
2018-12-30 20:58:52 +01:00
|
|
|
right: parent.right
|
2019-02-16 22:38:13 +01:00
|
|
|
rightMargin: root.width * 0.05
|
2018-12-30 20:58:52 +01:00
|
|
|
}
|
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
height: formCol.rowHeight
|
|
|
|
|
|
|
|
placeholderText: "Benutzername"
|
2019-12-07 15:38:35 +01:00
|
|
|
Keys.onReturnPressed: login(tiuname.text, tipasswd.text)
|
2019-02-16 22:38:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TextField {
|
|
|
|
id: tipasswd
|
|
|
|
placeholderText: "Passwort"
|
2019-12-07 15:38:35 +01:00
|
|
|
Keys.onReturnPressed: login(tiuname.text, tipasswd.text)
|
2019-02-16 22:38:13 +01:00
|
|
|
|
|
|
|
height: formCol.rowHeight
|
|
|
|
|
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
leftMargin: root.width * 0.05
|
|
|
|
right: parent.right
|
2020-01-25 11:15:37 +01:00
|
|
|
rightMargin: root.width * 0.05 + passwordHideShow.width * 1.1
|
2018-12-30 20:58:52 +01:00
|
|
|
}
|
|
|
|
|
2020-01-25 11:15:37 +01:00
|
|
|
rightPadding: passwordHideShow.width
|
|
|
|
|
2019-12-06 18:06:19 +01:00
|
|
|
CompatibleToolButton{
|
2019-02-16 22:38:13 +01:00
|
|
|
id: passwordHideShow
|
2020-01-25 11:15:37 +01:00
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
bottom: parent.bottom
|
|
|
|
right: parent.right
|
2020-01-25 11:15:37 +01:00
|
|
|
rightMargin: -width * 1.1
|
2019-02-16 22:38:13 +01:00
|
|
|
}
|
2019-11-06 22:02:48 +01:00
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
onClicked: {
|
|
|
|
if(state === "visible"){
|
|
|
|
state = "invisible"
|
2018-12-30 20:58:52 +01:00
|
|
|
}
|
2019-02-16 22:38:13 +01:00
|
|
|
else {
|
|
|
|
state = "visible"
|
2018-12-30 20:58:52 +01:00
|
|
|
}
|
2019-02-16 22:38:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
state: "invisible"
|
|
|
|
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "invisible"
|
|
|
|
PropertyChanges {
|
2019-11-06 22:02:48 +01:00
|
|
|
target: passwordHideShow
|
2019-12-12 17:23:10 +01:00
|
|
|
text: "\u0081"
|
2019-02-16 22:38:13 +01:00
|
|
|
}
|
2019-11-06 22:02:48 +01:00
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
PropertyChanges {
|
|
|
|
target: tipasswd
|
|
|
|
echoMode: TextInput.Password
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "visible"
|
|
|
|
PropertyChanges {
|
2019-11-06 22:02:48 +01:00
|
|
|
target: passwordHideShow
|
2019-12-12 17:23:10 +01:00
|
|
|
text: "\u0080"
|
2019-02-16 22:38:13 +01:00
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: tipasswd
|
|
|
|
echoMode: TextInput.Normal
|
|
|
|
}
|
2018-12-30 20:58:52 +01:00
|
|
|
}
|
2019-02-16 22:38:13 +01:00
|
|
|
]
|
2018-12-30 20:58:52 +01:00
|
|
|
}
|
2019-11-06 22:02:48 +01:00
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
}
|
2018-12-30 20:58:52 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
Label {
|
|
|
|
id: laStatus
|
2019-02-18 18:05:39 +01:00
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2018-12-30 20:58:52 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
height: formCol.rowHeight * 0.5
|
|
|
|
width: parent.width
|
2019-02-18 18:05:39 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
fontSizeMode: Text.Fit
|
|
|
|
font.pixelSize: height
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
|
|
|
color: "red"
|
2019-02-18 18:05:39 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
text: qsTr("")
|
2019-02-16 22:38:13 +01:00
|
|
|
}
|
2018-12-30 20:58:52 +01:00
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
FancyButton {
|
|
|
|
id: loginButton
|
|
|
|
|
|
|
|
anchors {
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
left: parent.left
|
|
|
|
margins: root.width * 0.05
|
2018-12-30 20:58:52 +01:00
|
|
|
}
|
2019-02-16 22:38:13 +01:00
|
|
|
|
|
|
|
height: formCol.rowHeight
|
|
|
|
|
|
|
|
enabled: tiuname.length > 0 & tipasswd.length > 0
|
2019-02-18 18:05:39 +01:00
|
|
|
|
|
|
|
text: qsTr("Anmelden")
|
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
onClicked: root.login(tiuname.text, tipasswd.text)
|
2019-01-27 20:47:36 +01:00
|
|
|
}
|
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
Label {
|
2019-12-07 15:38:35 +01:00
|
|
|
id: registerAndForgotLa
|
2019-02-18 18:05:39 +01:00
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2019-02-18 18:05:39 +01:00
|
|
|
|
2020-01-25 11:15:37 +01:00
|
|
|
visible: Qt.platform.os !== "ios"
|
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
height: formCol.rowHeight
|
2019-02-18 18:05:39 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
2019-02-18 18:05:39 +01:00
|
|
|
font.pixelSize: height * 0.3
|
2019-12-07 15:38:35 +01:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
2019-02-18 18:05:39 +01:00
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
text: "<html><a href=\"http://www.fanny-leicht.de/j34/index.php/login?view=registration\">Registrieren</a><br><a href=\"http://www.fanny-leicht.de/j34/index.php/login?view=reset\">Passwort vergessen?</a><br><a href=\"http://www.fanny-leicht.de/j34/index.php/login?view=remind\">Benutzername vergessen?</a>"
|
|
|
|
|
|
|
|
onLinkActivated: {
|
|
|
|
Qt.openUrlExternally(link)
|
|
|
|
}
|
2019-02-18 18:05:39 +01:00
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
}
|
2018-12-30 20:58:52 +01:00
|
|
|
}
|
2019-02-16 22:38:13 +01:00
|
|
|
|
|
|
|
Dialog {
|
|
|
|
id: busyDialog
|
|
|
|
modal: true
|
|
|
|
closePolicy: "NoAutoClose"
|
|
|
|
focus: true
|
|
|
|
title: "Bitte warten..."
|
|
|
|
x: (app.width - width) / 2
|
|
|
|
y: (app.height - height) / 2
|
|
|
|
width: Math.min(window.width, window.height) / 3 * 2
|
|
|
|
height: 150
|
|
|
|
contentHeight: contentColumn.height
|
2019-03-10 12:54:35 +01:00
|
|
|
Material.theme: _cppAppSettings.loadSetting("theme") === "Dark" ? Material.Dark:Material.Light
|
|
|
|
|
2019-02-16 22:38:13 +01:00
|
|
|
Column {
|
|
|
|
id: contentColumn
|
|
|
|
spacing: 20
|
|
|
|
RowLayout {
|
|
|
|
width: parent.width
|
|
|
|
BusyIndicator {
|
|
|
|
id: busyIndicator
|
|
|
|
visible: true
|
|
|
|
x: 22
|
|
|
|
y: 38
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
width: busyDialog.availableWidth
|
|
|
|
text: "Anmelden..."
|
|
|
|
wrapMode: Label.Wrap
|
|
|
|
font.pixelSize: 12
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-12-30 20:58:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
function login(username, password){
|
2018-12-30 20:58:52 +01:00
|
|
|
// hide the keyboard
|
|
|
|
Qt.inputMethod.hide();
|
|
|
|
// open the busy dialog
|
|
|
|
busyDialog.open()
|
|
|
|
// disable the login button
|
|
|
|
loginButton.enabled = false
|
|
|
|
// change the text to "Anmelden.."
|
|
|
|
loginButton.text = "Anmelden.."
|
|
|
|
|
|
|
|
// trigger the login fucntion of the cpp backend and store the return code
|
2019-12-07 15:38:35 +01:00
|
|
|
var ret = serverConn.login(username, password, true);
|
2018-12-30 20:58:52 +01:00
|
|
|
|
|
|
|
// the request has finished
|
|
|
|
// close the busy dialog
|
|
|
|
busyDialog.close()
|
|
|
|
// enable the button
|
|
|
|
loginButton.enabled = true
|
|
|
|
// change the text of the login button back to "Anmelden"
|
|
|
|
loginButton.text = "Anmelden"
|
|
|
|
|
2019-12-07 15:38:35 +01:00
|
|
|
// chekc if the login was not successfull
|
|
|
|
if(ret !== 200){
|
|
|
|
// set the error label to the error short description of the retuned error code
|
2018-12-30 20:58:52 +01:00
|
|
|
laStatus.text = app.getErrorInfo(ret)[1]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|