2022-03-26 19:28:44 +03:00
|
|
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
|
|
|
// SPDX-FileCopyrightText: 2022 Nheko Contributors
|
2023-01-02 06:25:33 +03:00
|
|
|
// SPDX-FileCopyrightText: 2023 Nheko Contributors
|
2022-03-26 19:28:44 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
import ".."
|
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Window 2.13
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import QtQuick.Controls 2.3
|
2022-03-27 00:25:48 +03:00
|
|
|
import QtQml.Models 2.15
|
2022-03-26 19:28:44 +03:00
|
|
|
import im.nheko 1.0
|
|
|
|
|
|
|
|
ApplicationWindow {
|
|
|
|
id: createDirectRoot
|
|
|
|
title: qsTr("Create Direct Chat")
|
2022-03-27 00:25:48 +03:00
|
|
|
property var profile
|
2022-03-29 05:50:25 +03:00
|
|
|
property bool otherUserHasE2ee: profile? profile.deviceList.rowCount() > 0 : true
|
|
|
|
minimumHeight: layout.implicitHeight + footer.implicitHeight + Nheko.paddingLarge*2
|
|
|
|
minimumWidth: Math.max(footer.implicitWidth, layout.implicitWidth)
|
|
|
|
modality: Qt.NonModal
|
|
|
|
flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
|
|
|
|
|
|
|
|
onVisibilityChanged: {
|
|
|
|
userID.forceActiveFocus();
|
|
|
|
}
|
2022-03-27 00:25:48 +03:00
|
|
|
|
2022-03-27 23:32:29 +03:00
|
|
|
Shortcut {
|
|
|
|
sequence: StandardKey.Cancel
|
2022-03-29 05:50:25 +03:00
|
|
|
onActivated: createDirectRoot.close()
|
2022-03-27 00:25:48 +03:00
|
|
|
}
|
|
|
|
|
2022-03-26 19:28:44 +03:00
|
|
|
ColumnLayout {
|
|
|
|
id: layout
|
|
|
|
anchors.fill: parent
|
2022-03-29 05:50:25 +03:00
|
|
|
anchors.margins: Nheko.paddingLarge
|
|
|
|
spacing: userID.height/4
|
2022-03-26 19:28:44 +03:00
|
|
|
|
|
|
|
GridLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
rows: 2
|
|
|
|
columns: 2
|
|
|
|
rowSpacing: Nheko.paddingSmall
|
|
|
|
columnSpacing: Nheko.paddingMedium
|
|
|
|
|
|
|
|
Avatar {
|
|
|
|
Layout.rowSpan: 2
|
|
|
|
Layout.preferredWidth: Nheko.avatarSize
|
|
|
|
Layout.preferredHeight: Nheko.avatarSize
|
|
|
|
Layout.alignment: Qt.AlignLeft
|
2022-03-29 05:50:25 +03:00
|
|
|
userid: profile? profile.userid : ""
|
2022-03-27 00:25:48 +03:00
|
|
|
url: profile? profile.avatarUrl.replace("mxc://", "image://MxcImage/") : null
|
|
|
|
displayName: profile? profile.displayName : ""
|
2022-03-26 19:28:44 +03:00
|
|
|
enabled: false
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
Layout.fillWidth: true
|
2022-03-27 00:25:48 +03:00
|
|
|
text: profile? profile.displayName : ""
|
2022-03-26 19:28:44 +03:00
|
|
|
color: TimelineManager.userColor(userID.text, Nheko.colors.window)
|
|
|
|
font.pointSize: fontMetrics.font.pointSize
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
text: userID.text
|
|
|
|
color: Nheko.colors.buttonText
|
|
|
|
font.pointSize: fontMetrics.font.pointSize * 0.9
|
|
|
|
}
|
|
|
|
}
|
2022-03-29 05:50:25 +03:00
|
|
|
|
|
|
|
MatrixTextField {
|
|
|
|
id: userID
|
|
|
|
property bool isValidMxid: text.match("@.+?:.{3,}")
|
|
|
|
Layout.fillWidth: true
|
|
|
|
focus: true
|
|
|
|
label: qsTr("User to invite")
|
|
|
|
placeholderText: qsTr("@user:server.tld")
|
|
|
|
onTextChanged: {
|
|
|
|
if(isValidMxid) {
|
|
|
|
profile = TimelineManager.getGlobalUserProfile(text);
|
|
|
|
} else
|
|
|
|
profile = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-26 19:28:44 +03:00
|
|
|
RowLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Label {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.alignment: Qt.AlignLeft
|
|
|
|
text: qsTr("Encryption")
|
|
|
|
color: Nheko.colors.text
|
|
|
|
}
|
|
|
|
ToggleButton {
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
id: encryption
|
2022-03-27 00:25:48 +03:00
|
|
|
checked: otherUserHasE2ee
|
2022-03-26 19:28:44 +03:00
|
|
|
}
|
|
|
|
}
|
2022-03-29 05:50:25 +03:00
|
|
|
|
|
|
|
Item {Layout.fillHeight: true}
|
2022-03-26 19:28:44 +03:00
|
|
|
}
|
|
|
|
footer: DialogButtonBox {
|
|
|
|
standardButtons: DialogButtonBox.Cancel
|
|
|
|
Button {
|
|
|
|
text: "Start Direct Chat"
|
|
|
|
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
|
2022-03-27 00:25:48 +03:00
|
|
|
enabled: userID.isValidMxid
|
2022-03-26 19:28:44 +03:00
|
|
|
}
|
|
|
|
onRejected: createDirectRoot.close();
|
2022-03-27 00:25:48 +03:00
|
|
|
onAccepted: {
|
2022-03-29 05:50:25 +03:00
|
|
|
profile.startChat(encryption.checked)
|
2022-03-27 00:25:48 +03:00
|
|
|
createDirectRoot.close()
|
|
|
|
}
|
2022-03-26 19:28:44 +03:00
|
|
|
}
|
|
|
|
}
|