diff --git a/src/qml/AccountTransferPage.qml b/src/qml/AccountTransferPage.qml index 93845a6..cc9bd16 100644 --- a/src/qml/AccountTransferPage.qml +++ b/src/qml/AccountTransferPage.qml @@ -1,153 +1,153 @@ /* * Kaidan - A user-friendly XMPP client for every device! * * Copyright (C) 2016-2020 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.12 import QtQuick.Controls 2.12 as Controls import QtQuick.Layouts 1.12 import org.kde.kirigami 2.8 as Kirigami import im.kaidan.kaidan 1.0 import "elements" /** * This page shows the user's credentials as a QR code or as cleartext, which allows the user to log in on another device. */ Kirigami.Page { id: root title: qsTr("Transfer account to another device") leftPadding: 0 rightPadding: 0 topPadding: 0 bottomPadding: 0 QrCodeGenerator { id: qrCodeGenerator } ColumnLayout { z: 1 anchors.margins: 18 anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom CenteredAdaptiveText { id: explanation text: qsTr("Scan the QR code or enter the credentials as text on another device to log in on it.\n\nAttention:\nNever show this QR code to anyone else. It would allow unlimited access to your account!") width: parent.width Layout.topMargin: 10 - scaleFactor: 2 + scaleFactor: 1.5 } // placeholder Item { Layout.fillHeight: true } Kirigami.Icon { id: qrCode width: parent.width height: width visible: false source: visible ? qrCodeGenerator.generateLoginUriQrCode(width) : "" Layout.fillWidth: true Layout.fillHeight: true } Kirigami.FormLayout { id: cleartext visible: false Controls.Label { text: Kaidan.jid Kirigami.FormData.label: qsTr("Chat address:") } Controls.Label { text: Kaidan.password Kirigami.FormData.label: qsTr("Password:") } } // placeholder Item { Layout.fillHeight: true } ColumnLayout { Layout.alignment: Qt.AlignHCenter Layout.maximumWidth: largeButtonWidth // button for showing or hiding the credentials as a QR code CenteredAdaptiveHighlightedButton { label.text: checked ? qsTr("Hide QR code") : qsTr("Show as QR code") checkable: true // If that was not used, this button would change its label text but not its checked state when the button for showing the cleartext is clicked right after it. checked: qrCode.visible onClicked: { if (qrCode.visible) { qrCode.visible = false cleartext.visible = false explanation.visible = true } else { qrCode.visible = true cleartext.visible = false explanation.visible = false } } } // button for showing or hiding the credentials as cleartext CenteredAdaptiveButton { label.text: checked ? qsTr("Hide text") : qsTr("Show as text") checkable: true // If that was not used, this button would change its label text but not its checked state when the button for showing the QR code is clicked right after it. checked: cleartext.visible onClicked: { if (cleartext.visible) { cleartext.visible = false qrCode.visible = false explanation.visible = true } else { cleartext.visible = true qrCode.visible = false explanation.visible = false } } } } } } diff --git a/src/qml/QrCodeScannerPage.qml b/src/qml/QrCodeScannerPage.qml index b357c01..8e3fded 100644 --- a/src/qml/QrCodeScannerPage.qml +++ b/src/qml/QrCodeScannerPage.qml @@ -1,234 +1,234 @@ /* * Kaidan - A user-friendly XMPP client for every device! * * Copyright (C) 2016-2020 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.12 import QtQuick.Layouts 1.12 import QtQuick.Controls 2.12 as Controls import QtQuick.Controls.Material 2.12 as Material import QtGraphicalEffects 1.12 import QtMultimedia 5.12 import org.kde.kirigami 2.8 as Kirigami import im.kaidan.kaidan 1.0 import "elements" /** * This page is used for logging in by scanning a QR code which contains an XMPP login URI. */ Kirigami.Page { id: root title: qsTr("Scan QR code") leftPadding: 0 rightPadding: 0 topPadding: 0 bottomPadding: 0 property bool cameraEnabled: false property bool loggingIn: false // hint for camera issues Kirigami.InlineMessage { visible: cameraEnabled && text !== "" anchors.centerIn: parent width: 300 height: 60 text: { switch (camera.availability) { case Camera.Unavailable: case Camera.ResourceMissing: // message to be shown if no camera can be found return qsTr("There is no camera available.") case Camera.Busy: // message to be shown if the found camera is not usable return qsTr("Your camera is busy.\nTry to close other applications using the camera.") default: // no message if no issue could be found return "" } } } // camera with continuous focus in the center of the video Camera { id: camera focus.focusMode: Camera.FocusContinuous focus.focusPointMode: Camera.FocusPointCenter // Show camera output if this page is visible and the camera enabled. cameraState: { if (visible && cameraEnabled) return Camera.ActiveState return Camera.LoadedState } Component.onCompleted: { scannerFilter.setCameraDefaultVideoFormat(camera); } } // filter which converts the video frames to images and decodes a containing QR code QrCodeScannerFilter { id: scannerFilter onScanningSucceeded: { if (!loggingIn) { // Login by the data from the decoded QR code. loggingIn = Kaidan.logInByUri(result) } } onUnsupportedFormatReceived: { pageStack.layers.pop() passiveNotification(qsTr("The camera format '%1' is not supported.").arg(format)) } } // video output from the camera which is shown on the screen and decoded by a filter VideoOutput { anchors.fill: parent fillMode: VideoOutput.PreserveAspectCrop source: camera autoOrientation: true filters: [scannerFilter] } ColumnLayout { id: loadingArea z: 2 anchors.centerIn: parent visible: loggingIn Controls.BusyIndicator { Layout.alignment: Qt.AlignHCenter } Controls.Label { text: "" + qsTr("Logging in…") + "" color: Kirigami.Theme.textColor } Connections { target: Kaidan onConnectionStateChanged: { if (loggingIn) { switch (Kaidan.connectionState) { case Enums.StateConnected: popAllLayers() break case Enums.StateDisconnected: showPassiveNotificationForConnectionError() loggingIn = false break } } } } } Rectangle { z: 1 anchors.fill: loadingArea anchors.margins: -8 radius: 3 opacity: 0.90 color: Kirigami.Theme.backgroundColor visible: loadingArea.visible } ColumnLayout { id: explanationArea z: 1 anchors.margins: 18 anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom CenteredAdaptiveText { id: explanation text: qsTr("Scan the QR code from your existing device to transfer your account.") width: parent.width Layout.topMargin: 10 - scaleFactor: 2 + scaleFactor: 1.5 } Image { source: Utils.getResourcePath("images/onboarding/account-transfer.svg") sourceSize.height: parent.height visible: explanation.visible fillMode: Image.PreserveAspectFit Layout.fillWidth: true Layout.fillHeight: true } // placeholder for the explanation text and image when they are invisible Item { Layout.fillHeight: true } ColumnLayout { Layout.alignment: Qt.AlignHCenter Layout.maximumWidth: largeButtonWidth // button for showing or hiding the explanation CenteredAdaptiveHighlightedButton { label.text: checked ? qsTr("Show explanation") : qsTr("Scan") checkable: true onClicked: { if (!cameraEnabled) { camera.start() cameraEnabled = true } explanation.visible = !explanation.visible } } // button for skipping the scanning CenteredAdaptiveButton { label.text: qsTr("Continue without QR code") onClicked: pageStack.layers.push(registrationLoginDecisionPage) } } } // background of the explanation area Rectangle { anchors.fill: explanationArea anchors.margins: -8 visible: explanation.visible radius: roundedCornersRadius opacity: 0.90 color: Kirigami.Theme.backgroundColor } } diff --git a/src/qml/elements/CenteredAdaptiveText.qml b/src/qml/elements/CenteredAdaptiveText.qml index a70e66c..742d631 100644 --- a/src/qml/elements/CenteredAdaptiveText.qml +++ b/src/qml/elements/CenteredAdaptiveText.qml @@ -1,48 +1,48 @@ /* * Kaidan - A user-friendly XMPP client for every device! * * Copyright (C) 2016-2020 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.12 import QtQuick.Layouts 1.12 import org.kde.kirigami 2.8 as Kirigami /** * This is a centered and adaptive text. */ Text { // factor to scale the text - property int scaleFactor: 1 + property double scaleFactor: 1 Layout.fillWidth: true horizontalAlignment: Text.AlignHCenter wrapMode: Text.WordWrap elide: Text.ElideRight - font.pointSize: Kirigami.Theme.defaultFont.pointSize * scaleFactor + font.pixelSize: Kirigami.Theme.defaultFont.pixelSize * scaleFactor color: Kirigami.Theme.textColor } diff --git a/src/qml/registration/ResultView.qml b/src/qml/registration/ResultView.qml index ede7396..f849566 100644 --- a/src/qml/registration/ResultView.qml +++ b/src/qml/registration/ResultView.qml @@ -1,62 +1,62 @@ /* * Kaidan - A user-friendly XMPP client for every device! * * Copyright (C) 2016-2020 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.12 import QtQuick.Layouts 1.12 import im.kaidan.kaidan 1.0 import "../elements" /** * This view is used for presenting the result of the registration process and confirming the registration. */ View { descriptionText: jid ? qsTr("Your chat address is used to chat with you, like your email address is used to exchange email messages.\n\nYour chat address will be:") : "" imageSource: "result" property alias registrationButton: registrationButton property string jid: username && server ? username + "@" + server : "" ColumnLayout { parent: contentArea spacing: 40 CenteredAdaptiveText { text: jid - scaleFactor: 2 + scaleFactor: 1.5 } RegistrationButton { id: registrationButton } } }