Warning, /network/neochat/src/qml/DevicesPage.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2020 - 2023 Tobias Fella <tobias.fella@kde.org>
0002 // SPDX-FileCopyrightText: 2022 James Graham <james.h.graham@protonmail.com>
0003 // SPDX-License-Identifier: GPL-2.0-or-later
0004
0005 import QtQuick
0006 import QtQuick.Controls as QQC2
0007 import QtQuick.Layouts
0008
0009 import org.kde.kirigami as Kirigami
0010 import org.kde.kirigamiaddons.formcard as FormCard
0011
0012 import org.kde.neochat
0013
0014 FormCard.FormCardPage {
0015 id: root
0016
0017 title: i18n("Devices")
0018
0019 background: Kirigami.PlaceholderMessage {
0020 text: i18n("Loading…")
0021 visible: !thisDeviceCard.visible
0022 }
0023
0024 required property NeoChatConnection connection
0025
0026 property DevicesModel devicesModel: DevicesModel {
0027 id: devicesModel
0028 connection: root.connection
0029 }
0030
0031 DevicesCard {
0032 id: thisDeviceCard
0033 title: i18n("This Device")
0034 type: DevicesModel.This
0035 showVerifyButton: false
0036 }
0037 DevicesCard {
0038 title: i18n("Verified Devices")
0039 type: DevicesModel.Verified
0040 showVerifyButton: true
0041 }
0042 DevicesCard {
0043 title: i18n("Unverified Devices")
0044 type: DevicesModel.Unverified
0045 showVerifyButton: true
0046 }
0047 DevicesCard {
0048 title: i18n("Devices without Encryption Support")
0049 type: DevicesModel.Unencrypted
0050 showVerifyButton: false
0051 }
0052
0053 FormCard.AbstractFormDelegate {
0054 Layout.fillWidth: true
0055 visible: root.connection && devicesModel.count === 0 // We can assume 0 means loading since there is at least one device
0056 contentItem: Kirigami.LoadingPlaceholder {}
0057 }
0058
0059 Kirigami.InlineMessage {
0060 Layout.fillWidth: true
0061 Layout.maximumWidth: Kirigami.Units.gridUnit * 30
0062 Layout.alignment: Qt.AlignHCenter
0063 text: i18n("Please login to view the signed-in devices for your account.")
0064 type: Kirigami.MessageType.Information
0065 visible: !root.connection
0066 }
0067
0068 property Kirigami.Dialog passwordSheet: Kirigami.Dialog {
0069 id: passwordSheet
0070
0071 property string deviceId
0072
0073 preferredWidth: Kirigami.Units.gridUnit * 24
0074
0075 title: i18n("Remove device")
0076
0077 standardButtons: QQC2.Dialog.Cancel
0078 FormCard.FormCard {
0079 FormCard.FormTextFieldDelegate {
0080 id: passwordField
0081 label: i18n("Password:")
0082 echoMode: TextInput.Password
0083 }
0084 }
0085 customFooterActions: [
0086 Kirigami.Action {
0087 text: i18nc("As in 'Remove this device'", "Remove")
0088 icon.name: "delete"
0089 onTriggered: {
0090 devicesModel.logout(passwordSheet.deviceId, passwordField.text);
0091 passwordField.text = "";
0092 passwordSheet.close();
0093 }
0094 }
0095 ]
0096 }
0097 }