diff --git a/src/qml/LoginPage.qml b/src/qml/LoginPage.qml index 65f67be..ec5b973 100644 --- a/src/qml/LoginPage.qml +++ b/src/qml/LoginPage.qml @@ -1,163 +1,164 @@ /* * Kaidan - A user-friendly XMPP client for every device! * * Copyright (C) 2016-2019 Kaidan developers and contributors * (see the LICENSE file for a full list of copyright authors) * * Kaidan is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * In addition, as a special exception, the author of Kaidan gives * permission to link the code of its release with the OpenSSL * project's "OpenSSL" library (or with modified versions of it that * use the same license as the "OpenSSL" library), and distribute the * linked executables. You must obey the GNU General Public License in * all respects for all of the code used other than "OpenSSL". If you * modify this file, you may extend this exception to your version of * the file, but you are not obligated to do so. If you do not wish to * do so, delete this exception statement from your version. * * Kaidan 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Kaidan. If not, see . */ import QtQuick 2.7 import QtQuick.Controls 2.0 as Controls import QtQuick.Controls.Material 2.0 import QtQuick.Layouts 1.2 import org.kde.kirigami 2.5 as Kirigami import im.kaidan.kaidan 1.0 Kirigami.Page { title: qsTr("Log in") ColumnLayout { anchors.fill: parent Kirigami.Heading { text: qsTr("Log in to your XMPP account") wrapMode: Text.WordWrap Layout.fillWidth: true horizontalAlignment: Qt.AlignHCenter } ColumnLayout { width: parent.width Layout.fillWidth: true // For desktop or tablet devices Layout.alignment: Qt.AlignCenter Layout.maximumWidth: Kirigami.Units.gridUnit * 25 // JID field Controls.Label { id: jidLabel text: qsTr("Your Jabber-ID:") } Controls.TextField { id: jidField text: kaidan.jid placeholderText: qsTr("user@example.org") Layout.fillWidth: true selectByMouse: true + inputMethodHints: Qt.ImhEmailCharactersOnly } // Password field Controls.Label { text: qsTr("Your Password:") } Controls.TextField { id: passField text: kaidan.password echoMode: TextInput.Password selectByMouse: true Layout.fillWidth: true } // Connect button Controls.Button { id: connectButton Layout.fillWidth: true Kirigami.Theme.backgroundColor: Material.accent text: qsTr("Connect") states: [ State { name: "connecting" PropertyChanges { target: connectButton enabled: false text: "" + qsTr("Connecting…") + "" } } ] onClicked: { // connect to given account data kaidan.jid = jidField.text.toLowerCase() kaidan.password = passField.text kaidan.mainConnect() } } // connect when return was pressed Keys.onPressed: { if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) { connectButton.clicked() } } } // placeholder Item { Layout.preferredHeight: Kirigami.Units.gridUnit * 3 } } function handleConnectionState(state) { if (state === Enums.StateConnecting) { connectButton.state = "connecting" } else { connectButton.state = "" } } function handleConnectionError() { var error = kaidan.disconnReason if (error === Enums.ConnAuthenticationFailed) { passiveNotification(qsTr("Invalid username or password.")) } else if (error === Enums.ConnNotConnected) { passiveNotification(qsTr("Cannot connect to the server. Please check your internet connection.")) } else if (error === Enums.ConnTlsNotAvailable) { passiveNotification(qsTr("The server doesn't support secure connections.")) } else if (error === Enums.ConnTlsFailed) { passiveNotification(qsTr("Error while trying to connect securely.")) } else if (error === Enums.ConnDnsError) { passiveNotification(qsTr("Could not resolve the server's address. Please check your JID again.")) } else if (error === Enums.ConnConnectionRefused) { passiveNotification(qsTr("Could not connect to the server.")) } else if (error === Enums.ConnNoSupportedAuth) { passiveNotification(qsTr("Authentification protocol not supported by the server.")) } else { passiveNotification(qsTr("An unknown error occured; see log for details.")) } } Component.onCompleted: { kaidan.connectionStateChanged.connect(handleConnectionState) kaidan.disconnReasonChanged.connect(handleConnectionError) } Component.onDestruction: { kaidan.connectionStateChanged.disconnect(handleConnectionState) kaidan.disconnReasonChanged.disconnect(handleConnectionError) } } diff --git a/src/qml/RosterPage.qml b/src/qml/RosterPage.qml index d4f46fb..7d40372 100644 --- a/src/qml/RosterPage.qml +++ b/src/qml/RosterPage.qml @@ -1,133 +1,132 @@ /* * Kaidan - A user-friendly XMPP client for every device! * * Copyright (C) 2016-2019 Kaidan developers and contributors * (see the LICENSE file for a full list of copyright authors) * * Kaidan is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * In addition, as a special exception, the author of Kaidan gives * permission to link the code of its release with the OpenSSL * project's "OpenSSL" library (or with modified versions of it that * use the same license as the "OpenSSL" library), and distribute the * linked executables. You must obey the GNU General Public License in * all respects for all of the code used other than "OpenSSL". If you * modify this file, you may extend this exception to your version of * the file, but you are not obligated to do so. If you do not wish to * do so, delete this exception statement from your version. * * Kaidan 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Kaidan. If not, see . */ -import QtQuick 2.0 +import QtQuick 2.7 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.0 as Controls import org.kde.kirigami 2.0 as Kirigami import im.kaidan.kaidan 1.0 import "elements" Kirigami.ScrollablePage { title: { kaidan.connectionState === Enums.StateConnecting ? qsTr("Connecting…") : kaidan.connectionState === Enums.StateDisconnected ? qsTr("Offline") : qsTr("Contacts") } RosterAddContactSheet { id: addContactSheet jid: "" } RosterRemoveContactSheet { id: removeContactSheet jid: "" } mainAction: Kirigami.Action { text: qsTr("Add new contact") iconName: "contact-new" onTriggered: { if (addContactSheet.sheetOpen) addContactSheet.close() else addContactSheet.open() } } ListView { verticalLayoutDirection: ListView.TopToBottom - focus: true model: kaidan.rosterModel delegate: RosterListItem { id: rosterItem name: model.name ? model.name : model.jid jid: model.jid lastMessage: model.lastMessage presenceType: kaidan.presenceCache.getPresenceType(model.jid) statusMsg: kaidan.presenceCache.getStatusText(model.jid) unreadMessages: model.unreadMessages avatarImagePath: kaidan.avatarStorage.getAvatarUrl(model.jid) backgroundColor: { - if (!Kirigami.Settings.isMobile && kaidan.chatPartner == model.jid) { + if (!Kirigami.Settings.isMobile && kaidan.chatPartner === model.jid) { Kirigami.Theme.highlightColor } else { Kirigami.Theme.backgroundColor } } onClicked: { // first push the chat page pageStack.push(chatPage, { "chatName": (model.name ? model.name : model.jid), "recipientJid": model.jid }) // then set the message filter for this jid // this will update the unread message count, // which will update the roster and will reset the // model variable kaidan.chatPartner = model.jid } actions: [ Kirigami.Action { iconName: "bookmark-remove" onTriggered: { removeContactSheet.jid = model.jid; removeContactSheet.open(); } } ] function newPresenceArrived(jid) { if (jid === model.jid) { rosterItem.presenceType = kaidan.presenceCache. getPresenceType(model.jid) rosterItem.statusMsg = kaidan.presenceCache. getStatusText(model.jid) } } function xmppUriReceived(uri) { // 'xmpp:' has length of 5 addContactSheet.jid = uri.substr(5) addContactSheet.open() } Component.onCompleted: { kaidan.presenceCache.presenceChanged.connect(newPresenceArrived) kaidan.xmppUriReceived.connect(xmppUriReceived) } Component.onDestruction: { kaidan.presenceCache.presenceChanged.disconnect(newPresenceArrived) kaidan.xmppUriReceived.disconnect(xmppUriReceived) } } } }