make lint
This commit is contained in:
parent
6c57fa6c5b
commit
e1acf5d324
@ -344,6 +344,7 @@ set(SRC_FILES
|
|||||||
src/CompletionProxyModel.cpp
|
src/CompletionProxyModel.cpp
|
||||||
src/DeviceVerificationFlow.cpp
|
src/DeviceVerificationFlow.cpp
|
||||||
src/EventAccessors.cpp
|
src/EventAccessors.cpp
|
||||||
|
src/InviteesModel.cpp
|
||||||
src/Logging.cpp
|
src/Logging.cpp
|
||||||
src/LoginPage.cpp
|
src/LoginPage.cpp
|
||||||
src/MainWindow.cpp
|
src/MainWindow.cpp
|
||||||
@ -550,6 +551,7 @@ qt5_wrap_cpp(MOC_HEADERS
|
|||||||
src/Clipboard.h
|
src/Clipboard.h
|
||||||
src/CompletionProxyModel.h
|
src/CompletionProxyModel.h
|
||||||
src/DeviceVerificationFlow.h
|
src/DeviceVerificationFlow.h
|
||||||
|
src/InviteesModel.h
|
||||||
src/LoginPage.h
|
src/LoginPage.h
|
||||||
src/MainWindow.h
|
src/MainWindow.h
|
||||||
src/MemberList.h
|
src/MemberList.h
|
||||||
|
@ -2,50 +2,28 @@ import QtQuick 2.12
|
|||||||
import QtQuick.Controls 2.12
|
import QtQuick.Controls 2.12
|
||||||
import QtQuick.Layouts 1.12
|
import QtQuick.Layouts 1.12
|
||||||
import im.nheko 1.0
|
import im.nheko 1.0
|
||||||
import "./types"
|
|
||||||
|
|
||||||
ApplicationWindow {
|
ApplicationWindow {
|
||||||
id: inviteDialogRoot
|
id: inviteDialogRoot
|
||||||
|
|
||||||
property string roomId
|
property string roomId
|
||||||
property string roomName
|
property string roomName
|
||||||
property list<Invitee> invitees
|
property InviteesModel invitees
|
||||||
|
|
||||||
function addInvite() {
|
function addInvite() {
|
||||||
if (inviteeEntry.text.match("@.+?:.{3,}"))
|
if (inviteeEntry.text.match("@.+?:.{3,}"))
|
||||||
{
|
{
|
||||||
invitees.push(inviteeComponent.createObject(
|
invitees.addUser(inviteeEntry.text);
|
||||||
inviteDialogRoot, {
|
|
||||||
"invitee": inviteeEntry.text
|
|
||||||
}));
|
|
||||||
inviteeEntry.clear();
|
inviteeEntry.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function accept() {
|
|
||||||
if (inviteeEntry.text !== "")
|
|
||||||
addInvite();
|
|
||||||
|
|
||||||
var inviteeStringList = ["temp"]; // the "temp" element exists to declare this as a string array
|
|
||||||
for (var i = 0; i < invitees.length; ++i)
|
|
||||||
inviteeStringList.push(invitees[i].invitee);
|
|
||||||
inviteeStringList.shift(); // remove the first item
|
|
||||||
|
|
||||||
TimelineManager.inviteUsers(inviteDialogRoot.roomId, inviteeStringList);
|
|
||||||
}
|
|
||||||
|
|
||||||
title: qsTr("Invite users to ") + roomName
|
title: qsTr("Invite users to ") + roomName
|
||||||
x: MainWindow.x + (MainWindow.width / 2) - (width / 2)
|
x: MainWindow.x + (MainWindow.width / 2) - (width / 2)
|
||||||
y: MainWindow.y + (MainWindow.height / 2) - (height / 2)
|
y: MainWindow.y + (MainWindow.height / 2) - (height / 2)
|
||||||
height: 380
|
height: 380
|
||||||
width: 340
|
width: 340
|
||||||
|
|
||||||
Component {
|
|
||||||
id: inviteeComponent
|
|
||||||
|
|
||||||
Invitee {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: make this work in the TextField
|
// TODO: make this work in the TextField
|
||||||
Shortcut {
|
Shortcut {
|
||||||
sequence: "Ctrl+Enter"
|
sequence: "Ctrl+Enter"
|
||||||
@ -74,7 +52,7 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
text: qsTr("Invite")
|
text: qsTr("Add")
|
||||||
onClicked: if (inviteeEntry.text !== "") addInvite()
|
onClicked: if (inviteeEntry.text !== "") addInvite()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,9 +63,53 @@ ApplicationWindow {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
model: invitees
|
model: invitees
|
||||||
delegate: Label {
|
|
||||||
text: model.invitee
|
delegate: RowLayout {
|
||||||
|
spacing: 10
|
||||||
|
|
||||||
|
Avatar {
|
||||||
|
width: avatarSize
|
||||||
|
height: avatarSize
|
||||||
|
userid: model.mxid
|
||||||
|
url: model.avatarUrl.replace("mxc://", "image://MxcImage/")
|
||||||
|
displayName: model.displayName
|
||||||
|
onClicked: TimelineManager.timeline.openUserProfile(model.mxid)
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
spacing: 5
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: model.displayName
|
||||||
|
color: TimelineManager.userColor(model ? model.mxid : "", colors.window)
|
||||||
|
font.pointSize: 12
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: model.mxid
|
||||||
|
color: colors.buttonText
|
||||||
|
font.pointSize: 10
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// delegate: RowLayout {
|
||||||
|
// spacing: 10
|
||||||
|
|
||||||
|
// Avatar {
|
||||||
|
// url: model.avatarUrl
|
||||||
|
// width: 20
|
||||||
|
// height: width
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Label {
|
||||||
|
// text: model.displayName + " (" + model.mxid + ")"
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +120,7 @@ ApplicationWindow {
|
|||||||
text: qsTr("Invite")
|
text: qsTr("Invite")
|
||||||
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
|
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
|
||||||
onClicked: {
|
onClicked: {
|
||||||
inviteDialogRoot.accept();
|
invitees.accept();
|
||||||
inviteDialogRoot.close();
|
inviteDialogRoot.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,15 @@ ApplicationWindow {
|
|||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImageButton {
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
image: ":/icons/icons/ui/add-square-button.png"
|
||||||
|
hoverEnabled: true
|
||||||
|
ToolTip.visible: hovered
|
||||||
|
ToolTip.text: qsTr("Invite more people")
|
||||||
|
onClicked: TimelineManager.timeline.openInviteUsersDialog()
|
||||||
|
}
|
||||||
|
|
||||||
ScrollView {
|
ScrollView {
|
||||||
clip: false
|
clip: false
|
||||||
palette: colors
|
palette: colors
|
||||||
|
@ -89,6 +89,12 @@ Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Component {
|
||||||
|
id: inviteDialog
|
||||||
|
|
||||||
|
InviteDialog {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: TimelineManager
|
target: TimelineManager
|
||||||
@ -116,6 +122,38 @@ Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: TimelineManager.timeline
|
||||||
|
onOpenRoomMembersDialog: {
|
||||||
|
var membersDialog = roomMembersComponent.createObject(timelineRoot, {
|
||||||
|
"members": members,
|
||||||
|
"roomName": TimelineManager.timeline.roomName
|
||||||
|
});
|
||||||
|
membersDialog.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: TimelineManager.timeline
|
||||||
|
onOpenRoomSettingsDialog: {
|
||||||
|
var roomSettings = roomSettingsComponent.createObject(timelineRoot, {
|
||||||
|
"roomSettings": settings
|
||||||
|
});
|
||||||
|
roomSettings.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: TimelineManager.timeline
|
||||||
|
onOpenInviteUsersDialog: {
|
||||||
|
var dialog = inviteDialog.createObject(timelineRoot, {
|
||||||
|
"roomId": TimelineManager.timeline.roomId,
|
||||||
|
"roomName": TimelineManager.timeline.roomName
|
||||||
|
});
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ChatPage {
|
ChatPage {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,6 @@ Item {
|
|||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
enabled: false
|
enabled: false
|
||||||
}
|
}
|
||||||
|
|
||||||
MatrixText {
|
MatrixText {
|
||||||
text: parent.roomName
|
text: parent.roomName
|
||||||
font.pixelSize: 24
|
font.pixelSize: 24
|
||||||
|
@ -21,12 +21,6 @@ Rectangle {
|
|||||||
z: 3
|
z: 3
|
||||||
color: Nheko.colors.window
|
color: Nheko.colors.window
|
||||||
|
|
||||||
Component {
|
|
||||||
id: inviteDialog
|
|
||||||
|
|
||||||
InviteDialog {}
|
|
||||||
}
|
|
||||||
|
|
||||||
TapHandler {
|
TapHandler {
|
||||||
onSingleTapped: {
|
onSingleTapped: {
|
||||||
if (room)
|
if (room)
|
||||||
@ -117,13 +111,7 @@ Rectangle {
|
|||||||
Platform.MenuItem {
|
Platform.MenuItem {
|
||||||
visible: room ? room.permissions.canInvite() : false
|
visible: room ? room.permissions.canInvite() : false
|
||||||
text: qsTr("Invite users")
|
text: qsTr("Invite users")
|
||||||
onTriggered: {
|
onTriggered: TimelineManager.timeline.openInviteUsers()
|
||||||
var dialog = inviteDialog.createObject(topBar, {
|
|
||||||
"roomId": room.roomId,
|
|
||||||
"roomName": room.roomName
|
|
||||||
});
|
|
||||||
dialog.show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Platform.MenuItem {
|
Platform.MenuItem {
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
import QtQuick 2.12
|
|
||||||
|
|
||||||
Item {
|
|
||||||
property string invitee
|
|
||||||
}
|
|
@ -176,7 +176,6 @@
|
|||||||
<file>qml/components/FlatButton.qml</file>
|
<file>qml/components/FlatButton.qml</file>
|
||||||
<file>qml/RoomMembers.qml</file>
|
<file>qml/RoomMembers.qml</file>
|
||||||
<file>qml/InviteDialog.qml</file>
|
<file>qml/InviteDialog.qml</file>
|
||||||
<file>qml/types/Invitee.qml</file>
|
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="/media">
|
<qresource prefix="/media">
|
||||||
<file>media/ring.ogg</file>
|
<file>media/ring.ogg</file>
|
||||||
|
@ -116,32 +116,31 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
|||||||
|
|
||||||
connect(this, &ChatPage::loggedOut, this, &ChatPage::logout);
|
connect(this, &ChatPage::loggedOut, this, &ChatPage::logout);
|
||||||
|
|
||||||
connect(view_manager_, &TimelineViewManager::inviteUsers, this, [this](QStringList users) {
|
// TODO: once this signal is moved, reenable this
|
||||||
const auto room_id = currentRoom().toStdString();
|
// connect(view_manager_, &TimelineViewManager::inviteUsers, this, [this](QStringList users) {
|
||||||
|
// const auto room_id = currentRoom().toStdString();
|
||||||
|
|
||||||
for (int ii = 0; ii < users.size(); ++ii) {
|
// for (int ii = 0; ii < users.size(); ++ii) {
|
||||||
QTimer::singleShot(ii * 500, this, [this, room_id, ii, users]() {
|
// QTimer::singleShot(ii * 500, this, [this, room_id, ii, users]() {
|
||||||
const auto user = users.at(ii);
|
// const auto user = users.at(ii);
|
||||||
|
|
||||||
http::client()->invite_user(
|
// http::client()->invite_user(
|
||||||
room_id,
|
// room_id,
|
||||||
user.toStdString(),
|
// user.toStdString(),
|
||||||
[this, user](const mtx::responses::RoomInvite &,
|
// [this, user](const mtx::responses::RoomInvite &,
|
||||||
mtx::http::RequestErr err) {
|
// mtx::http::RequestErr err) {
|
||||||
if (err) {
|
// if (err) {
|
||||||
emit showNotification(
|
// emit showNotification(
|
||||||
tr("Failed to invite user: %1").arg(user));
|
// tr("Failed to invite user: %1").arg(user));
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
emit showNotification(tr("Invited user: %1").arg(user));
|
// emit showNotification(tr("Invited user: %1").arg(user));
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
connect(
|
|
||||||
view_manager_, &TimelineViewManager::showRoomList, splitter, &Splitter::showFullRoomList);
|
|
||||||
connect(
|
connect(
|
||||||
view_manager_,
|
view_manager_,
|
||||||
&TimelineViewManager::inviteUsers,
|
&TimelineViewManager::inviteUsers,
|
||||||
|
77
src/InviteesModel.cpp
Normal file
77
src/InviteesModel.cpp
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#include "InviteesModel.h"
|
||||||
|
|
||||||
|
#include "Cache.h"
|
||||||
|
#include "Logging.h"
|
||||||
|
#include "MatrixClient.h"
|
||||||
|
#include "mtx/responses/profile.hpp"
|
||||||
|
|
||||||
|
InviteesModel::InviteesModel(QObject *parent)
|
||||||
|
: QAbstractListModel{parent}
|
||||||
|
{}
|
||||||
|
|
||||||
|
void
|
||||||
|
InviteesModel::addUser(QString mxid)
|
||||||
|
{
|
||||||
|
beginInsertRows(QModelIndex(), invitees_.count(), invitees_.count());
|
||||||
|
|
||||||
|
auto invitee = new Invitee{mxid, this};
|
||||||
|
connect(invitee, &Invitee::userInfoLoaded, this, [this]() {
|
||||||
|
emit dataChanged(QModelIndex{}, QModelIndex{});
|
||||||
|
});
|
||||||
|
|
||||||
|
invitees_.push_back(invitee);
|
||||||
|
|
||||||
|
endInsertRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
QHash<int, QByteArray>
|
||||||
|
InviteesModel::roleNames() const
|
||||||
|
{
|
||||||
|
return {{Mxid, "mxid"}, {DisplayName, "displayName"}, {AvatarUrl, "avatarUrl"}};
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant
|
||||||
|
InviteesModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
if (!index.isValid() || index.row() >= (int)invitees_.size() || index.row() < 0)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
switch (role) {
|
||||||
|
case Mxid:
|
||||||
|
return invitees_[index.row()]->mxid_;
|
||||||
|
case DisplayName:
|
||||||
|
return invitees_[index.row()]->displayName_;
|
||||||
|
case AvatarUrl:
|
||||||
|
return invitees_[index.row()]->avatarUrl_;
|
||||||
|
default:
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList
|
||||||
|
InviteesModel::mxids()
|
||||||
|
{
|
||||||
|
QStringList mxidList;
|
||||||
|
for (int i = 0; i < invitees_.length(); ++i)
|
||||||
|
mxidList.push_back(invitees_[i]->mxid_);
|
||||||
|
return mxidList;
|
||||||
|
}
|
||||||
|
|
||||||
|
Invitee::Invitee(const QString &mxid, QObject *parent)
|
||||||
|
: QObject{parent}
|
||||||
|
, mxid_{mxid}
|
||||||
|
{
|
||||||
|
http::client()->get_profile(
|
||||||
|
mxid_.toStdString(),
|
||||||
|
[this](const mtx::responses::Profile &res, mtx::http::RequestErr err) {
|
||||||
|
if (err) {
|
||||||
|
nhlog::net()->warn("failed to retrieve own profile info");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
displayName_ = QString::fromStdString(res.display_name);
|
||||||
|
avatarUrl_ = QString::fromStdString(res.avatar_url);
|
||||||
|
|
||||||
|
emit userInfoLoaded();
|
||||||
|
});
|
||||||
|
}
|
56
src/InviteesModel.h
Normal file
56
src/InviteesModel.h
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#ifndef INVITEESMODEL_H
|
||||||
|
#define INVITEESMODEL_H
|
||||||
|
|
||||||
|
#include <QAbstractListModel>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
class Invitee : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
Invitee(const QString &mxid, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void userInfoLoaded();
|
||||||
|
|
||||||
|
private:
|
||||||
|
const QString mxid_;
|
||||||
|
QString displayName_;
|
||||||
|
QString avatarUrl_;
|
||||||
|
|
||||||
|
friend class InviteesModel;
|
||||||
|
};
|
||||||
|
|
||||||
|
class InviteesModel : public QAbstractListModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum Roles
|
||||||
|
{
|
||||||
|
Mxid,
|
||||||
|
DisplayName,
|
||||||
|
AvatarUrl,
|
||||||
|
};
|
||||||
|
|
||||||
|
InviteesModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
Q_INVOKABLE void addUser(QString mxid);
|
||||||
|
|
||||||
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
int rowCount(const QModelIndex & = QModelIndex()) const override
|
||||||
|
{
|
||||||
|
return (int)invitees_.size();
|
||||||
|
}
|
||||||
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
|
QStringList mxids();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void accept();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVector<Invitee *> invitees_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // INVITEESMODEL_H
|
@ -43,7 +43,8 @@ MemberList::MemberList(const QString &room_id, QWidget *parent)
|
|||||||
void
|
void
|
||||||
MemberList::addUsers(const std::vector<RoomMember> &members)
|
MemberList::addUsers(const std::vector<RoomMember> &members)
|
||||||
{
|
{
|
||||||
beginInsertRows(QModelIndex{}, m_memberList.count(), m_memberList.count() + members.size() - 1);
|
beginInsertRows(
|
||||||
|
QModelIndex{}, m_memberList.count(), m_memberList.count() + members.size() - 1);
|
||||||
|
|
||||||
for (const auto &member : members)
|
for (const auto &member : members)
|
||||||
m_memberList.push_back(
|
m_memberList.push_back(
|
||||||
@ -78,10 +79,11 @@ MemberList::data(const QModelIndex &index, int role) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MemberList::canFetchMore(const QModelIndex &) const
|
bool
|
||||||
|
MemberList::canFetchMore(const QModelIndex &) const
|
||||||
{
|
{
|
||||||
const size_t numMembers = rowCount();
|
const size_t numMembers = rowCount();
|
||||||
return (numMembers > 1 && numMembers < info_.member_count);
|
return (numMembers > 1 && numMembers < info_.member_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1076,6 +1076,16 @@ TimelineModel::openRoomSettings(QString room_id)
|
|||||||
openRoomSettingsDialog(settings);
|
openRoomSettingsDialog(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TimelineModel::openInviteUsers(QString room_id)
|
||||||
|
{
|
||||||
|
InviteesModel *model = new InviteesModel{this};
|
||||||
|
connect(model, &InviteesModel::accept, this, [this, model, room_id]() {
|
||||||
|
manager_->inviteUsers(room_id, model->mxids());
|
||||||
|
});
|
||||||
|
openInviteUsersDialog(model);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TimelineModel::replyAction(QString id)
|
TimelineModel::replyAction(QString id)
|
||||||
{
|
{
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "CacheStructs.h"
|
#include "CacheStructs.h"
|
||||||
#include "EventStore.h"
|
#include "EventStore.h"
|
||||||
#include "InputBar.h"
|
#include "InputBar.h"
|
||||||
|
#include "InviteesModel.h"
|
||||||
#include "MemberList.h"
|
#include "MemberList.h"
|
||||||
#include "Permissions.h"
|
#include "Permissions.h"
|
||||||
#include "ui/RoomSettings.h"
|
#include "ui/RoomSettings.h"
|
||||||
@ -239,6 +240,7 @@ public:
|
|||||||
Q_INVOKABLE void openUserProfile(QString userid);
|
Q_INVOKABLE void openUserProfile(QString userid);
|
||||||
Q_INVOKABLE void openRoomMembers();
|
Q_INVOKABLE void openRoomMembers();
|
||||||
Q_INVOKABLE void openRoomSettings(QString room_id = QString());
|
Q_INVOKABLE void openRoomSettings(QString room_id = QString());
|
||||||
|
Q_INVOKABLE void openInviteUsers(QString room_id = QString());
|
||||||
Q_INVOKABLE void editAction(QString id);
|
Q_INVOKABLE void editAction(QString id);
|
||||||
Q_INVOKABLE void replyAction(QString id);
|
Q_INVOKABLE void replyAction(QString id);
|
||||||
Q_INVOKABLE void readReceiptsAction(QString id) const;
|
Q_INVOKABLE void readReceiptsAction(QString id) const;
|
||||||
@ -357,6 +359,7 @@ signals:
|
|||||||
|
|
||||||
void openRoomMembersDialog(MemberList *members);
|
void openRoomMembersDialog(MemberList *members);
|
||||||
void openRoomSettingsDialog(RoomSettings *settings);
|
void openRoomSettingsDialog(RoomSettings *settings);
|
||||||
|
void openInviteUsersDialog(InviteesModel *invitees);
|
||||||
|
|
||||||
void newMessageToSend(mtx::events::collections::TimelineEvents event);
|
void newMessageToSend(mtx::events::collections::TimelineEvents event);
|
||||||
void addPendingMessageToStore(mtx::events::collections::TimelineEvents event);
|
void addPendingMessageToStore(mtx::events::collections::TimelineEvents event);
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "DeviceVerificationFlow.h"
|
#include "DeviceVerificationFlow.h"
|
||||||
#include "EventAccessors.h"
|
#include "EventAccessors.h"
|
||||||
#include "ImagePackModel.h"
|
#include "ImagePackModel.h"
|
||||||
|
#include "InviteesModel.h"
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "MatrixClient.h"
|
#include "MatrixClient.h"
|
||||||
@ -184,6 +185,12 @@ TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *par
|
|||||||
"Room Settings needs to be instantiated on the C++ side");
|
"Room Settings needs to be instantiated on the C++ side");
|
||||||
qmlRegisterUncreatableType<TimelineModel>(
|
qmlRegisterUncreatableType<TimelineModel>(
|
||||||
"im.nheko", 1, 0, "Room", "Room needs to be instantiated on the C++ side");
|
"im.nheko", 1, 0, "Room", "Room needs to be instantiated on the C++ side");
|
||||||
|
qmlRegisterUncreatableType<InviteesModel>(
|
||||||
|
"im.nheko",
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
"InviteesModel",
|
||||||
|
"InviteesModel needs to be instantiated on the C++ side");
|
||||||
|
|
||||||
static auto self = this;
|
static auto self = this;
|
||||||
qmlRegisterSingletonType<MainWindow>(
|
qmlRegisterSingletonType<MainWindow>(
|
||||||
@ -423,62 +430,13 @@ TimelineViewManager::openImageOverlayInternal(QString eventId, QImage img)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
//void
|
||||||
TimelineViewManager::openInviteUsersDialog()
|
//TimelineViewManager::openInviteUsersDialog()
|
||||||
{
|
//{
|
||||||
MainWindow::instance()->openInviteUsersDialog(
|
// TODO: move this somewhere where it will actually work (probably Rooms)
|
||||||
[this](const QStringList &invitees) { emit inviteUsers(invitees); });
|
// MainWindow::instance()->openInviteUsersDialog(
|
||||||
}
|
// [this](const QStringList &invitees) { emit inviteUsers(invitees); });
|
||||||
|
//}
|
||||||
void
|
|
||||||
TimelineViewManager::openLink(QString link) const
|
|
||||||
{
|
|
||||||
QUrl url(link);
|
|
||||||
if (url.scheme() == "https" && url.host() == "matrix.to") {
|
|
||||||
// handle matrix.to links internally
|
|
||||||
QString p = url.fragment(QUrl::FullyEncoded);
|
|
||||||
if (p.startsWith("/"))
|
|
||||||
p.remove(0, 1);
|
|
||||||
|
|
||||||
auto temp = p.split("?");
|
|
||||||
QString query;
|
|
||||||
if (temp.size() >= 2)
|
|
||||||
query = QUrl::fromPercentEncoding(temp.takeAt(1).toUtf8());
|
|
||||||
|
|
||||||
temp = temp.first().split("/");
|
|
||||||
auto identifier = QUrl::fromPercentEncoding(temp.takeFirst().toUtf8());
|
|
||||||
QString eventId = QUrl::fromPercentEncoding(temp.join('/').toUtf8());
|
|
||||||
if (!identifier.isEmpty()) {
|
|
||||||
if (identifier.startsWith("@")) {
|
|
||||||
QByteArray uri =
|
|
||||||
"matrix:u/" + QUrl::toPercentEncoding(identifier.remove(0, 1));
|
|
||||||
if (!query.isEmpty())
|
|
||||||
uri.append("?" + query.toUtf8());
|
|
||||||
ChatPage::instance()->handleMatrixUri(QUrl::fromEncoded(uri));
|
|
||||||
} else if (identifier.startsWith("#")) {
|
|
||||||
QByteArray uri =
|
|
||||||
"matrix:r/" + QUrl::toPercentEncoding(identifier.remove(0, 1));
|
|
||||||
if (!eventId.isEmpty())
|
|
||||||
uri.append("/e/" +
|
|
||||||
QUrl::toPercentEncoding(eventId.remove(0, 1)));
|
|
||||||
if (!query.isEmpty())
|
|
||||||
uri.append("?" + query.toUtf8());
|
|
||||||
ChatPage::instance()->handleMatrixUri(QUrl::fromEncoded(uri));
|
|
||||||
} else if (identifier.startsWith("!")) {
|
|
||||||
QByteArray uri = "matrix:roomid/" +
|
|
||||||
QUrl::toPercentEncoding(identifier.remove(0, 1));
|
|
||||||
if (!eventId.isEmpty())
|
|
||||||
uri.append("/e/" +
|
|
||||||
QUrl::toPercentEncoding(eventId.remove(0, 1)));
|
|
||||||
if (!query.isEmpty())
|
|
||||||
uri.append("?" + query.toUtf8());
|
|
||||||
ChatPage::instance()->handleMatrixUri(QUrl::fromEncoded(uri));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
QDesktopServices::openUrl(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TimelineViewManager::openLeaveRoomDialog(QString roomid) const
|
TimelineViewManager::openLeaveRoomDialog(QString roomid) const
|
||||||
|
Loading…
Reference in New Issue
Block a user