Always open the invite dialog properly from the member list

This commit is contained in:
Loren Burkholder 2023-02-25 23:19:15 -05:00
parent f3ab0abadf
commit 24d401365e
5 changed files with 12 additions and 9 deletions

View file

@ -268,8 +268,6 @@ Pane {
var component = Qt.createComponent("qrc:/qml/dialogs/InviteDialog.qml") var component = Qt.createComponent("qrc:/qml/dialogs/InviteDialog.qml")
if (component.status == Component.Ready) { if (component.status == Component.Ready) {
var dialog = component.createObject(timelineRoot, { var dialog = component.createObject(timelineRoot, {
"roomId": Rooms.currentRoom.roomId,
"plainRoomName": Rooms.currentRoom.plainRoomName,
"invitees": invitees "invitees": invitees
}); });
dialog.show(); dialog.show();

View file

@ -12,8 +12,6 @@ import im.nheko 1.0
ApplicationWindow { ApplicationWindow {
id: inviteDialogRoot id: inviteDialogRoot
property string roomId
property string plainRoomName
property InviteesModel invitees property InviteesModel invitees
property var friendsCompleter property var friendsCompleter
property var profile property var profile
@ -39,7 +37,7 @@ ApplicationWindow {
close(); close();
} }
title: qsTr("Invite users to %1").arg(plainRoomName) title: qsTr("Invite users to %1").arg(invitees.room.plainRoomName)
height: 380 height: 380
width: 340 width: 340
palette: Nheko.colors palette: Nheko.colors

View file

@ -9,8 +9,9 @@
#include "MatrixClient.h" #include "MatrixClient.h"
#include "mtx/responses/profile.hpp" #include "mtx/responses/profile.hpp"
InviteesModel::InviteesModel(QObject *parent) InviteesModel::InviteesModel(TimelineModel *room, QObject *parent)
: QAbstractListModel{parent} : QAbstractListModel{parent},
room_{room}
{ {
} }

View file

@ -8,6 +8,8 @@
#include <QAbstractListModel> #include <QAbstractListModel>
#include <QVector> #include <QVector>
class TimelineModel;
class Invitee final : public QObject class Invitee final : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -34,6 +36,7 @@ class InviteesModel final : public QAbstractListModel
Q_OBJECT Q_OBJECT
Q_PROPERTY(int count READ rowCount NOTIFY countChanged) Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
Q_PROPERTY(TimelineModel * room READ room CONSTANT)
public: public:
enum Roles enum Roles
@ -43,7 +46,9 @@ public:
AvatarUrl, AvatarUrl,
}; };
InviteesModel(QObject *parent = nullptr); InviteesModel(TimelineModel *room, QObject *parent = nullptr);
TimelineModel *room() const { return room_; }
Q_INVOKABLE void addUser(QString mxid, QString displayName = "", QString avatarUrl = ""); Q_INVOKABLE void addUser(QString mxid, QString displayName = "", QString avatarUrl = "");
Q_INVOKABLE void removeUser(QString mxid); Q_INVOKABLE void removeUser(QString mxid);
@ -63,6 +68,7 @@ signals:
private: private:
QVector<Invitee *> invitees_; QVector<Invitee *> invitees_;
TimelineModel *room_;
}; };
#endif // INVITEESMODEL_H #endif // INVITEESMODEL_H

View file

@ -180,7 +180,7 @@ TimelineViewManager::openRoomSettings(QString room_id)
void void
TimelineViewManager::openInviteUsers(QString roomId) TimelineViewManager::openInviteUsers(QString roomId)
{ {
InviteesModel *model = new InviteesModel{}; InviteesModel *model = new InviteesModel{rooms_->getRoomById(roomId).data()};
connect(model, &InviteesModel::accept, this, [this, model, roomId]() { connect(model, &InviteesModel::accept, this, [this, model, roomId]() {
emit inviteUsers(roomId, model->mxids()); emit inviteUsers(roomId, model->mxids());
}); });