Skip to content
Snippets Groups Projects
Commit 838cf635 authored by Malte E's avatar Malte E
Browse files

direct chat creator can now create direct chats

parent 5384ab37
No related branches found
No related tags found
No related merge requests found
Pipeline #2888 failed
...@@ -8,29 +8,38 @@ import QtQuick 2.15 ...@@ -8,29 +8,38 @@ import QtQuick 2.15
import QtQuick.Window 2.13 import QtQuick.Window 2.13
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import QtQuick.Controls 2.3 import QtQuick.Controls 2.3
import QtQml.Models 2.15
import im.nheko 1.0 import im.nheko 1.0
ApplicationWindow { ApplicationWindow {
id: createDirectRoot id: createDirectRoot
title: qsTr("Create Direct Chat") title: qsTr("Create Direct Chat")
property var profile: null property var profile
property bool otherUserHasE2ee: profile? dMod.count > 0 : true
minimumHeight: layout.implicitHeight+2*layout.anchors.margins+footer.height minimumHeight: layout.implicitHeight+2*layout.anchors.margins+footer.height
minimumWidth: footer.width minimumWidth: footer.width
DelegateModel {
id: dMod
model: profile? profile.deviceList : undefined
}
ColumnLayout { ColumnLayout {
id: layout id: layout
anchors.fill: parent anchors.fill: parent
anchors.margins: Nheko.paddingSmall anchors.margins: Nheko.paddingSmall
MatrixTextField { MatrixTextField {
id: userID id: userID
property bool isValidMxid: text.match("@.+?:.{3,}")
Layout.fillWidth: true Layout.fillWidth: true
focus: true focus: true
placeholderText: qsTr("Name") placeholderText: qsTr("Name")
/*onTextChanged: { onTextChanged: {
if(isValidMxid(text)) if(isValidMxid) {
profile = getProfile(text); profile = TimelineManager.getGlobalUserProfile(text);
else } else
profile = null; profile = null;
}*/ }
} }
GridLayout { GridLayout {
...@@ -39,21 +48,20 @@ ApplicationWindow { ...@@ -39,21 +48,20 @@ ApplicationWindow {
columns: 2 columns: 2
rowSpacing: Nheko.paddingSmall rowSpacing: Nheko.paddingSmall
columnSpacing: Nheko.paddingMedium columnSpacing: Nheko.paddingMedium
anchors.centerIn: parent
Avatar { Avatar {
Layout.rowSpan: 2 Layout.rowSpan: 2
Layout.preferredWidth: Nheko.avatarSize Layout.preferredWidth: Nheko.avatarSize
Layout.preferredHeight: Nheko.avatarSize Layout.preferredHeight: Nheko.avatarSize
Layout.alignment: Qt.AlignLeft Layout.alignment: Qt.AlignLeft
userid: profile.mxid userid: profile? profile.mxid : ""
url: profile.avatarUrl.replace("mxc://", "image://MxcImage/") url: profile? profile.avatarUrl.replace("mxc://", "image://MxcImage/") : null
displayName: profile.displayName displayName: profile? profile.displayName : ""
enabled: false enabled: false
} }
Label { Label {
Layout.fillWidth: true Layout.fillWidth: true
text: "John Smith" //profile.displayName text: profile? profile.displayName : ""
color: TimelineManager.userColor(userID.text, Nheko.colors.window) color: TimelineManager.userColor(userID.text, Nheko.colors.window)
font.pointSize: fontMetrics.font.pointSize font.pointSize: fontMetrics.font.pointSize
} }
...@@ -76,7 +84,7 @@ ApplicationWindow { ...@@ -76,7 +84,7 @@ ApplicationWindow {
ToggleButton { ToggleButton {
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
id: encryption id: encryption
checked: true checked: otherUserHasE2ee
} }
} }
} }
...@@ -85,8 +93,12 @@ ApplicationWindow { ...@@ -85,8 +93,12 @@ ApplicationWindow {
Button { Button {
text: "Start Direct Chat" text: "Start Direct Chat"
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
enabled: userID.isValidMxid
} }
onRejected: createDirectRoot.close(); onRejected: createDirectRoot.close();
//onAccepted: createRoom(newRoomName.text, newRoomTopic.text, newRoomAlias.text, newRoomVisibility.index, newRoomPreset.index) onAccepted: {
profile.startChat()
createDirectRoot.close()
}
} }
} }
...@@ -199,6 +199,14 @@ TimelineViewManager::openGlobalUserProfile(QString userId) ...@@ -199,6 +199,14 @@ TimelineViewManager::openGlobalUserProfile(QString userId)
emit openProfile(profile); emit openProfile(profile);
} }
UserProfile*
TimelineViewManager::getGlobalUserProfile(QString userId)
{
UserProfile *profile = new UserProfile{QString{}, userId, this};
QQmlEngine::setObjectOwnership(profile, QQmlEngine::JavaScriptOwnership);
return(profile);
}
void void
TimelineViewManager::setVideoCallItem() TimelineViewManager::setVideoCallItem()
{ {
......
...@@ -67,6 +67,7 @@ public: ...@@ -67,6 +67,7 @@ public:
Q_INVOKABLE void openRoomSettings(QString room_id); Q_INVOKABLE void openRoomSettings(QString room_id);
Q_INVOKABLE void openInviteUsers(QString roomId); Q_INVOKABLE void openInviteUsers(QString roomId);
Q_INVOKABLE void openGlobalUserProfile(QString userId); Q_INVOKABLE void openGlobalUserProfile(QString userId);
Q_INVOKABLE UserProfile* getGlobalUserProfile(QString userId);
Q_INVOKABLE void focusMessageInput(); Q_INVOKABLE void focusMessageInput();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment