summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalte E <malte.e@mailbox.org>2022-03-26 22:25:48 +0100
committerMalte E <malte.e@mailbox.org>2022-03-26 22:25:48 +0100
commit838cf63578d2145e9264bd37e68993f6e6e8d132 (patch)
tree897580b5679beec1af1de68298b356721bf94217
parent5384ab377c5a6e9dc12b9b536935f22cffbff6e9 (diff)
direct chat creator can now create direct chats
-rw-r--r--resources/qml/dialogs/CreateDirect.qml38
-rw-r--r--src/timeline/TimelineViewManager.cpp8
-rw-r--r--src/timeline/TimelineViewManager.h1
3 files changed, 34 insertions, 13 deletions
diff --git a/resources/qml/dialogs/CreateDirect.qml b/resources/qml/dialogs/CreateDirect.qml
index bbb758e3..b76e728a 100644
--- a/resources/qml/dialogs/CreateDirect.qml
+++ b/resources/qml/dialogs/CreateDirect.qml
@@ -8,29 +8,38 @@ import QtQuick 2.15
import QtQuick.Window 2.13
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.3
+import QtQml.Models 2.15
import im.nheko 1.0
ApplicationWindow {
id: createDirectRoot
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
minimumWidth: footer.width
+
+ DelegateModel {
+ id: dMod
+ model: profile? profile.deviceList : undefined
+ }
+
ColumnLayout {
id: layout
anchors.fill: parent
anchors.margins: Nheko.paddingSmall
MatrixTextField {
id: userID
+ property bool isValidMxid: text.match("@.+?:.{3,}")
Layout.fillWidth: true
focus: true
placeholderText: qsTr("Name")
- /*onTextChanged: {
- if(isValidMxid(text))
- profile = getProfile(text);
- else
+ onTextChanged: {
+ if(isValidMxid) {
+ profile = TimelineManager.getGlobalUserProfile(text);
+ } else
profile = null;
- }*/
+ }
}
GridLayout {
@@ -39,21 +48,20 @@ ApplicationWindow {
columns: 2
rowSpacing: Nheko.paddingSmall
columnSpacing: Nheko.paddingMedium
- anchors.centerIn: parent
Avatar {
Layout.rowSpan: 2
Layout.preferredWidth: Nheko.avatarSize
Layout.preferredHeight: Nheko.avatarSize
Layout.alignment: Qt.AlignLeft
- userid: profile.mxid
- url: profile.avatarUrl.replace("mxc://", "image://MxcImage/")
- displayName: profile.displayName
+ userid: profile? profile.mxid : ""
+ url: profile? profile.avatarUrl.replace("mxc://", "image://MxcImage/") : null
+ displayName: profile? profile.displayName : ""
enabled: false
}
Label {
Layout.fillWidth: true
- text: "John Smith" //profile.displayName
+ text: profile? profile.displayName : ""
color: TimelineManager.userColor(userID.text, Nheko.colors.window)
font.pointSize: fontMetrics.font.pointSize
}
@@ -76,7 +84,7 @@ ApplicationWindow {
ToggleButton {
Layout.alignment: Qt.AlignRight
id: encryption
- checked: true
+ checked: otherUserHasE2ee
}
}
}
@@ -85,8 +93,12 @@ ApplicationWindow {
Button {
text: "Start Direct Chat"
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
+ enabled: userID.isValidMxid
}
onRejected: createDirectRoot.close();
- //onAccepted: createRoom(newRoomName.text, newRoomTopic.text, newRoomAlias.text, newRoomVisibility.index, newRoomPreset.index)
+ onAccepted: {
+ profile.startChat()
+ createDirectRoot.close()
+ }
}
}
diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp
index a18f3ee2..72f89fd4 100644
--- a/src/timeline/TimelineViewManager.cpp
+++ b/src/timeline/TimelineViewManager.cpp
@@ -199,6 +199,14 @@ TimelineViewManager::openGlobalUserProfile(QString userId)
emit openProfile(profile);
}
+UserProfile*
+TimelineViewManager::getGlobalUserProfile(QString userId)
+{
+ UserProfile *profile = new UserProfile{QString{}, userId, this};
+ QQmlEngine::setObjectOwnership(profile, QQmlEngine::JavaScriptOwnership);
+ return(profile);
+}
+
void
TimelineViewManager::setVideoCallItem()
{
diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h
index 393b1479..807fe76f 100644
--- a/src/timeline/TimelineViewManager.h
+++ b/src/timeline/TimelineViewManager.h
@@ -67,6 +67,7 @@ public:
Q_INVOKABLE void openRoomSettings(QString room_id);
Q_INVOKABLE void openInviteUsers(QString roomId);
Q_INVOKABLE void openGlobalUserProfile(QString userId);
+ Q_INVOKABLE UserProfile* getGlobalUserProfile(QString userId);
Q_INVOKABLE void focusMessageInput();