mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 03:00:46 +03:00
Always open the invite dialog properly from the member list
This commit is contained in:
parent
f3ab0abadf
commit
24d401365e
5 changed files with 12 additions and 9 deletions
|
@ -268,8 +268,6 @@ Pane {
|
|||
var component = Qt.createComponent("qrc:/qml/dialogs/InviteDialog.qml")
|
||||
if (component.status == Component.Ready) {
|
||||
var dialog = component.createObject(timelineRoot, {
|
||||
"roomId": Rooms.currentRoom.roomId,
|
||||
"plainRoomName": Rooms.currentRoom.plainRoomName,
|
||||
"invitees": invitees
|
||||
});
|
||||
dialog.show();
|
||||
|
|
|
@ -12,8 +12,6 @@ import im.nheko 1.0
|
|||
ApplicationWindow {
|
||||
id: inviteDialogRoot
|
||||
|
||||
property string roomId
|
||||
property string plainRoomName
|
||||
property InviteesModel invitees
|
||||
property var friendsCompleter
|
||||
property var profile
|
||||
|
@ -39,7 +37,7 @@ ApplicationWindow {
|
|||
close();
|
||||
}
|
||||
|
||||
title: qsTr("Invite users to %1").arg(plainRoomName)
|
||||
title: qsTr("Invite users to %1").arg(invitees.room.plainRoomName)
|
||||
height: 380
|
||||
width: 340
|
||||
palette: Nheko.colors
|
||||
|
|
|
@ -9,8 +9,9 @@
|
|||
#include "MatrixClient.h"
|
||||
#include "mtx/responses/profile.hpp"
|
||||
|
||||
InviteesModel::InviteesModel(QObject *parent)
|
||||
: QAbstractListModel{parent}
|
||||
InviteesModel::InviteesModel(TimelineModel *room, QObject *parent)
|
||||
: QAbstractListModel{parent},
|
||||
room_{room}
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#include <QAbstractListModel>
|
||||
#include <QVector>
|
||||
|
||||
class TimelineModel;
|
||||
|
||||
class Invitee final : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -34,6 +36,7 @@ class InviteesModel final : public QAbstractListModel
|
|||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
|
||||
Q_PROPERTY(TimelineModel * room READ room CONSTANT)
|
||||
|
||||
public:
|
||||
enum Roles
|
||||
|
@ -43,7 +46,9 @@ public:
|
|||
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 removeUser(QString mxid);
|
||||
|
@ -63,6 +68,7 @@ signals:
|
|||
|
||||
private:
|
||||
QVector<Invitee *> invitees_;
|
||||
TimelineModel *room_;
|
||||
};
|
||||
|
||||
#endif // INVITEESMODEL_H
|
||||
|
|
|
@ -180,7 +180,7 @@ TimelineViewManager::openRoomSettings(QString room_id)
|
|||
void
|
||||
TimelineViewManager::openInviteUsers(QString roomId)
|
||||
{
|
||||
InviteesModel *model = new InviteesModel{};
|
||||
InviteesModel *model = new InviteesModel{rooms_->getRoomById(roomId).data()};
|
||||
connect(model, &InviteesModel::accept, this, [this, model, roomId]() {
|
||||
emit inviteUsers(roomId, model->mxids());
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue