2020-09-24 09:57:54 +10:00
|
|
|
// Copyright Mirage authors & contributors <https://github.com/mirukana/mirage>
|
2020-06-25 22:32:08 +10:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import "../../Base"
|
2020-07-12 12:52:14 +10:00
|
|
|
import "../../Base/Buttons"
|
2020-06-25 22:32:08 +10:00
|
|
|
import "../../Base/HTile"
|
|
|
|
|
|
|
|
HTile {
|
2020-06-26 16:09:59 +10:00
|
|
|
id: deviceTile
|
2020-06-25 22:32:08 +10:00
|
|
|
|
|
|
|
property HListView view
|
2020-06-26 16:09:59 +10:00
|
|
|
property string userId
|
2020-09-21 06:01:02 +10:00
|
|
|
property bool offline: false
|
2020-06-25 22:32:08 +10:00
|
|
|
|
2020-06-26 16:09:59 +10:00
|
|
|
signal verified()
|
2020-06-26 16:16:00 +10:00
|
|
|
signal blacklisted()
|
2020-06-26 16:09:59 +10:00
|
|
|
signal renameRequest(string name)
|
2020-06-26 18:30:47 +10:00
|
|
|
signal deleteRequest()
|
2020-06-26 02:11:11 +10:00
|
|
|
|
2020-06-25 22:32:08 +10:00
|
|
|
backgroundColor: "transparent"
|
|
|
|
compact: false
|
|
|
|
|
|
|
|
leftPadding: theme.spacing * 2
|
|
|
|
rightPadding: 0
|
|
|
|
|
|
|
|
contentItem: ContentRow {
|
2020-06-26 16:09:59 +10:00
|
|
|
tile: deviceTile
|
2020-06-25 22:32:08 +10:00
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
HCheckBox {
|
|
|
|
id: checkBox
|
2020-09-21 05:41:02 +10:00
|
|
|
activeFocusOnTab: false
|
2020-06-25 22:32:08 +10:00
|
|
|
checked: view.checked[model.id] || false
|
|
|
|
onClicked: view.toggleCheck(model.index)
|
|
|
|
}
|
|
|
|
|
|
|
|
HColumnLayout {
|
|
|
|
Layout.leftMargin: theme.spacing
|
|
|
|
|
|
|
|
HRowLayout {
|
|
|
|
spacing: theme.spacing
|
|
|
|
|
|
|
|
TitleLabel {
|
|
|
|
text: model.display_name || qsTr("Unnamed")
|
|
|
|
}
|
|
|
|
|
|
|
|
TitleRightInfoLabel {
|
2020-06-26 16:09:59 +10:00
|
|
|
tile: deviceTile
|
2020-06-25 22:32:08 +10:00
|
|
|
text: utils.smartFormatDate(model.last_seen_date)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SubtitleLabel {
|
2020-06-26 16:09:59 +10:00
|
|
|
tile: deviceTile
|
2020-06-25 22:32:08 +10:00
|
|
|
font.family: theme.fontFamily.mono
|
|
|
|
text:
|
|
|
|
model.last_seen_ip ?
|
|
|
|
model.id + " " + model.last_seen_ip :
|
|
|
|
model.id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HButton {
|
|
|
|
icon.name: "device-action-menu"
|
|
|
|
toolTip.text: qsTr("Rename, verify or sign out")
|
|
|
|
backgroundColor: "transparent"
|
2020-09-21 05:41:02 +10:00
|
|
|
activeFocusOnTab: false
|
2020-07-10 11:33:51 +10:00
|
|
|
onClicked: deviceTile.openMenu()
|
2020-06-25 22:32:08 +10:00
|
|
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
contextMenu: HMenu {
|
|
|
|
id: actionMenu
|
2020-06-26 02:36:36 +10:00
|
|
|
implicitWidth: Math.min(360 * theme.uiScale, window.width)
|
2020-06-25 22:32:08 +10:00
|
|
|
onOpened: nameField.forceActiveFocus()
|
|
|
|
|
|
|
|
HLabeledItem {
|
|
|
|
width: parent.width
|
|
|
|
label.topPadding: theme.spacing / 2
|
|
|
|
label.text: qsTr("Public display name:")
|
|
|
|
label.horizontalAlignment: Qt.AlignHCenter
|
|
|
|
|
2020-06-26 02:36:36 +10:00
|
|
|
HRowLayout {
|
2020-09-21 06:01:02 +10:00
|
|
|
enabled: ! deviceTile.offline
|
2020-06-25 22:32:08 +10:00
|
|
|
width: parent.width
|
2020-06-26 02:36:36 +10:00
|
|
|
|
|
|
|
HTextField {
|
|
|
|
id: nameField
|
|
|
|
defaultText: model.display_name
|
2020-06-26 02:37:05 +10:00
|
|
|
maximumLength: 255
|
2020-06-26 02:36:36 +10:00
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
2020-06-26 18:30:47 +10:00
|
|
|
onAccepted: deviceTile.renameRequest(text)
|
2020-06-26 02:36:36 +10:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
HButton {
|
|
|
|
icon.name: "apply"
|
|
|
|
icon.color: theme.colors.positiveBackground
|
2020-06-26 18:30:47 +10:00
|
|
|
onClicked: deviceTile.renameRequest(nameField.text)
|
2020-06-26 02:36:36 +10:00
|
|
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
2020-06-25 22:32:08 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HMenuSeparator {}
|
|
|
|
|
2020-06-26 06:10:44 +10:00
|
|
|
HLabel {
|
|
|
|
id: noKeysLabel
|
|
|
|
visible: model.type === "no_keys"
|
|
|
|
width: parent.width
|
|
|
|
height: visible ? implicitHeight : 0 // avoid empty space
|
|
|
|
|
|
|
|
wrapMode: HLabel.Wrap
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
|
|
|
textFormat: HLabel.RichText
|
|
|
|
color: theme.colors.warningText
|
|
|
|
text: qsTr(
|
|
|
|
"This session doesn't support encryption or " +
|
|
|
|
"failed to upload a verification key"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
HMenuSeparator {
|
|
|
|
visible: noKeysLabel.visible
|
|
|
|
height: visible ? implicitHeight : 0
|
|
|
|
}
|
|
|
|
|
2020-06-25 22:32:08 +10:00
|
|
|
HLabeledItem {
|
|
|
|
width: parent.width
|
|
|
|
label.text: qsTr("Actions:")
|
|
|
|
label.horizontalAlignment: Qt.AlignHCenter
|
|
|
|
|
2020-07-12 12:52:14 +10:00
|
|
|
AutoDirectionLayout {
|
2020-06-25 22:32:08 +10:00
|
|
|
width: parent.width
|
|
|
|
|
2020-07-12 12:52:14 +10:00
|
|
|
PositiveButton {
|
2020-06-26 16:09:59 +10:00
|
|
|
enabled: model.type !== "no_keys"
|
2020-06-25 22:32:08 +10:00
|
|
|
icon.name: "device-verify"
|
2020-06-26 16:09:59 +10:00
|
|
|
text:
|
|
|
|
model.type === "current" ? qsTr("Get verified") :
|
|
|
|
model.type === "verified" ? qsTr("Reverify") :
|
|
|
|
qsTr("Verify")
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
actionMenu.focusOnClosed = null
|
|
|
|
|
2020-08-03 15:26:35 +10:00
|
|
|
window.makePopup(
|
2020-06-26 16:09:59 +10:00
|
|
|
"Popups/KeyVerificationPopup.qml",
|
|
|
|
{
|
|
|
|
focusOnClosed: nameField,
|
|
|
|
deviceOwner: deviceTile.userId,
|
|
|
|
deviceId: model.id,
|
|
|
|
deviceName: model.display_name,
|
|
|
|
ed25519Key: model.ed25519_key,
|
|
|
|
deviceIsCurrent: model.type === "current",
|
|
|
|
verifiedCallback: deviceTile.verified,
|
2020-06-26 16:16:00 +10:00
|
|
|
blacklistedCallback: deviceTile.blacklisted,
|
2020-06-26 16:09:59 +10:00
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|
2020-06-25 22:32:08 +10:00
|
|
|
}
|
|
|
|
|
2020-07-12 12:52:14 +10:00
|
|
|
NegativeButton {
|
2020-06-25 22:32:08 +10:00
|
|
|
text: qsTr("Sign out")
|
2020-09-21 06:01:02 +10:00
|
|
|
enabled: ! deviceTile.offline
|
2020-06-25 22:32:08 +10:00
|
|
|
icon.name: "device-delete"
|
2020-06-26 18:30:47 +10:00
|
|
|
onClicked: deviceTile.deleteRequest()
|
2020-06-25 22:32:08 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onLeftClicked: checkBox.clicked()
|
2020-09-23 09:12:13 +10:00
|
|
|
|
|
|
|
DelegateTransitionFixer {}
|
2020-06-25 22:32:08 +10:00
|
|
|
}
|