Cleanup DevicesPage
This commit is contained in:
committed by
Tobias Fella
parent
f3c37e4304
commit
cbde14d58b
@@ -19,6 +19,8 @@ FormCard.AbstractFormDelegate {
|
|||||||
required property string displayName
|
required property string displayName
|
||||||
required property int type
|
required property int type
|
||||||
|
|
||||||
|
required property DevicesModel devicesModel
|
||||||
|
|
||||||
property bool editDeviceName: false
|
property bool editDeviceName: false
|
||||||
property bool showVerifyButton
|
property bool showVerifyButton
|
||||||
|
|
||||||
@@ -77,12 +79,12 @@ FormCard.AbstractFormDelegate {
|
|||||||
icon.name: "checkmark"
|
icon.name: "checkmark"
|
||||||
visible: nameField.text !== root.displayName
|
visible: nameField.text !== root.displayName
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
devicesModel.setName(root.id, nameField.text);
|
root.devicesModel.setName(root.id, nameField.text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
onAccepted: devicesModel.setName(root.id, nameField.text)
|
onAccepted: root.devicesModel.setName(root.id, nameField.text)
|
||||||
}
|
}
|
||||||
QQC2.ToolButton {
|
QQC2.ToolButton {
|
||||||
display: QQC2.AbstractButton.IconOnly
|
display: QQC2.AbstractButton.IconOnly
|
||||||
@@ -98,7 +100,7 @@ FormCard.AbstractFormDelegate {
|
|||||||
visible: root.showVerifyButton && (root.type !== DevicesModel.Verified || NeoChatConfig.alwaysVerifyDevice)
|
visible: root.showVerifyButton && (root.type !== DevicesModel.Verified || NeoChatConfig.alwaysVerifyDevice)
|
||||||
text: i18nc("@action:button", "Verify device")
|
text: i18nc("@action:button", "Verify device")
|
||||||
icon.name: "security-low-symbolic"
|
icon.name: "security-low-symbolic"
|
||||||
onClicked: devicesModel.connection.startKeyVerificationSession(devicesModel.connection.localUserId, root.id)
|
onClicked: root.devicesModel.connection.startKeyVerificationSession(root.devicesModel.connection.localUserId, root.id)
|
||||||
|
|
||||||
QQC2.ToolTip.text: text
|
QQC2.ToolTip.text: text
|
||||||
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
||||||
@@ -133,4 +135,35 @@ FormCard.AbstractFormDelegate {
|
|||||||
QQC2.ToolTip.visible: hovered
|
QQC2.ToolTip.visible: hovered
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Kirigami.Dialog {
|
||||||
|
id: passwordSheet
|
||||||
|
|
||||||
|
property string deviceId
|
||||||
|
|
||||||
|
preferredWidth: Kirigami.Units.gridUnit * 24
|
||||||
|
|
||||||
|
title: i18nc("@title:dialog", "Remove device")
|
||||||
|
|
||||||
|
standardButtons: QQC2.Dialog.Cancel
|
||||||
|
|
||||||
|
Component.onCompleted: passwordField.forceActiveFocus()
|
||||||
|
|
||||||
|
contentItem: FormCard.FormTextFieldDelegate {
|
||||||
|
id: passwordField
|
||||||
|
label: i18n("Password:")
|
||||||
|
echoMode: TextInput.Password
|
||||||
|
}
|
||||||
|
customFooterActions: [
|
||||||
|
Kirigami.Action {
|
||||||
|
text: i18nc("@action:button As in 'Remove this device'", "Remove")
|
||||||
|
icon.name: "delete"
|
||||||
|
onTriggered: {
|
||||||
|
root.devicesModel.logout(passwordSheet.deviceId, passwordField.text);
|
||||||
|
passwordField.text = "";
|
||||||
|
passwordSheet.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 James Graham <james.h.graham@protonmail.com>
|
// SPDX-FileCopyrightText: 2022 James Graham <james.h.graham@protonmail.com>
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
|
||||||
@@ -17,6 +19,7 @@ ColumnLayout {
|
|||||||
required property string title
|
required property string title
|
||||||
required property var type
|
required property var type
|
||||||
required property bool showVerifyButton
|
required property bool showVerifyButton
|
||||||
|
required property DevicesModel devicesModel
|
||||||
|
|
||||||
visible: deviceRepeater.count > 0
|
visible: deviceRepeater.count > 0
|
||||||
|
|
||||||
@@ -30,17 +33,13 @@ ColumnLayout {
|
|||||||
Repeater {
|
Repeater {
|
||||||
id: deviceRepeater
|
id: deviceRepeater
|
||||||
model: DevicesProxyModel {
|
model: DevicesProxyModel {
|
||||||
sourceModel: devicesModel
|
sourceModel: root.devicesModel
|
||||||
type: root.type
|
type: root.type
|
||||||
}
|
}
|
||||||
|
|
||||||
Kirigami.LoadingPlaceholder {
|
|
||||||
visible: deviceModel.count === 0 // We can assume 0 means loading since there is at least one device
|
|
||||||
anchors.centerIn: parent
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: DeviceDelegate {
|
delegate: DeviceDelegate {
|
||||||
showVerifyButton: root.showVerifyButton
|
showVerifyButton: root.showVerifyButton
|
||||||
|
devicesModel: root.devicesModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ FormCard.FormCardPage {
|
|||||||
title: i18nc("@info:group", "This Device")
|
title: i18nc("@info:group", "This Device")
|
||||||
type: DevicesModel.This
|
type: DevicesModel.This
|
||||||
showVerifyButton: false
|
showVerifyButton: false
|
||||||
|
devicesModel: root.devicesModel
|
||||||
|
|
||||||
FormCard.FormButtonDelegate {
|
FormCard.FormButtonDelegate {
|
||||||
icon.name: "security-low"
|
icon.name: "security-low"
|
||||||
@@ -57,16 +58,19 @@ FormCard.FormCardPage {
|
|||||||
title: i18nc("@info:group", "Verified Devices")
|
title: i18nc("@info:group", "Verified Devices")
|
||||||
type: DevicesModel.Verified
|
type: DevicesModel.Verified
|
||||||
showVerifyButton: true
|
showVerifyButton: true
|
||||||
|
devicesModel: root.devicesModel
|
||||||
}
|
}
|
||||||
DevicesCard {
|
DevicesCard {
|
||||||
title: i18nc("@info:group", "Unverified Devices")
|
title: i18nc("@info:group", "Unverified Devices")
|
||||||
type: DevicesModel.Unverified
|
type: DevicesModel.Unverified
|
||||||
showVerifyButton: true
|
showVerifyButton: true
|
||||||
|
devicesModel: root.devicesModel
|
||||||
}
|
}
|
||||||
DevicesCard {
|
DevicesCard {
|
||||||
title: i18nc("@info:group", "Devices without Encryption Support")
|
title: i18nc("@info:group", "Devices without Encryption Support")
|
||||||
type: DevicesModel.Unencrypted
|
type: DevicesModel.Unencrypted
|
||||||
showVerifyButton: false
|
showVerifyButton: false
|
||||||
|
devicesModel: root.devicesModel
|
||||||
}
|
}
|
||||||
|
|
||||||
FormCard.AbstractFormDelegate {
|
FormCard.AbstractFormDelegate {
|
||||||
@@ -83,37 +87,4 @@ FormCard.FormCardPage {
|
|||||||
type: Kirigami.MessageType.Information
|
type: Kirigami.MessageType.Information
|
||||||
visible: !root.connection
|
visible: !root.connection
|
||||||
}
|
}
|
||||||
|
|
||||||
property Kirigami.Dialog passwordSheet: Kirigami.Dialog {
|
|
||||||
id: passwordSheet
|
|
||||||
|
|
||||||
property string deviceId
|
|
||||||
|
|
||||||
preferredWidth: Kirigami.Units.gridUnit * 24
|
|
||||||
|
|
||||||
title: i18n("Remove device")
|
|
||||||
|
|
||||||
standardButtons: QQC2.Dialog.Cancel
|
|
||||||
|
|
||||||
Component.onCompleted: passwordField.forceActiveFocus()
|
|
||||||
|
|
||||||
FormCard.FormCard {
|
|
||||||
FormCard.FormTextFieldDelegate {
|
|
||||||
id: passwordField
|
|
||||||
label: i18n("Password:")
|
|
||||||
echoMode: TextInput.Password
|
|
||||||
}
|
|
||||||
}
|
|
||||||
customFooterActions: [
|
|
||||||
Kirigami.Action {
|
|
||||||
text: i18nc("As in 'Remove this device'", "Remove")
|
|
||||||
icon.name: "delete"
|
|
||||||
onTriggered: {
|
|
||||||
devicesModel.logout(passwordSheet.deviceId, passwordField.text);
|
|
||||||
passwordField.text = "";
|
|
||||||
passwordSheet.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user