mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 03:00:46 +03:00
direct chat creator can now create direct chats
This commit is contained in:
parent
5384ab377c
commit
838cf63578
3 changed files with 34 additions and 13 deletions
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue