mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
QML the invite dialog
This also adds a property `roomId` to TimelineModel.
This commit is contained in:
parent
77a0c574bf
commit
6c57fa6c5b
14 changed files with 215 additions and 293 deletions
|
@ -281,7 +281,6 @@ set(SRC_FILES
|
||||||
src/dialogs/CreateRoom.cpp
|
src/dialogs/CreateRoom.cpp
|
||||||
src/dialogs/FallbackAuth.cpp
|
src/dialogs/FallbackAuth.cpp
|
||||||
src/dialogs/ImageOverlay.cpp
|
src/dialogs/ImageOverlay.cpp
|
||||||
src/dialogs/InviteUsers.cpp
|
|
||||||
src/dialogs/JoinRoom.cpp
|
src/dialogs/JoinRoom.cpp
|
||||||
src/dialogs/LeaveRoom.cpp
|
src/dialogs/LeaveRoom.cpp
|
||||||
src/dialogs/Logout.cpp
|
src/dialogs/Logout.cpp
|
||||||
|
@ -345,7 +344,6 @@ set(SRC_FILES
|
||||||
src/CompletionProxyModel.cpp
|
src/CompletionProxyModel.cpp
|
||||||
src/DeviceVerificationFlow.cpp
|
src/DeviceVerificationFlow.cpp
|
||||||
src/EventAccessors.cpp
|
src/EventAccessors.cpp
|
||||||
src/InviteeItem.cpp
|
|
||||||
src/Logging.cpp
|
src/Logging.cpp
|
||||||
src/LoginPage.cpp
|
src/LoginPage.cpp
|
||||||
src/MainWindow.cpp
|
src/MainWindow.cpp
|
||||||
|
@ -492,7 +490,6 @@ qt5_wrap_cpp(MOC_HEADERS
|
||||||
src/dialogs/CreateRoom.h
|
src/dialogs/CreateRoom.h
|
||||||
src/dialogs/FallbackAuth.h
|
src/dialogs/FallbackAuth.h
|
||||||
src/dialogs/ImageOverlay.h
|
src/dialogs/ImageOverlay.h
|
||||||
src/dialogs/InviteUsers.h
|
|
||||||
src/dialogs/JoinRoom.h
|
src/dialogs/JoinRoom.h
|
||||||
src/dialogs/LeaveRoom.h
|
src/dialogs/LeaveRoom.h
|
||||||
src/dialogs/Logout.h
|
src/dialogs/Logout.h
|
||||||
|
@ -553,7 +550,6 @@ qt5_wrap_cpp(MOC_HEADERS
|
||||||
src/Clipboard.h
|
src/Clipboard.h
|
||||||
src/CompletionProxyModel.h
|
src/CompletionProxyModel.h
|
||||||
src/DeviceVerificationFlow.h
|
src/DeviceVerificationFlow.h
|
||||||
src/InviteeItem.h
|
|
||||||
src/LoginPage.h
|
src/LoginPage.h
|
||||||
src/MainWindow.h
|
src/MainWindow.h
|
||||||
src/MemberList.h
|
src/MemberList.h
|
||||||
|
|
112
resources/qml/InviteDialog.qml
Normal file
112
resources/qml/InviteDialog.qml
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
import QtQuick 2.12
|
||||||
|
import QtQuick.Controls 2.12
|
||||||
|
import QtQuick.Layouts 1.12
|
||||||
|
import im.nheko 1.0
|
||||||
|
import "./types"
|
||||||
|
|
||||||
|
ApplicationWindow {
|
||||||
|
id: inviteDialogRoot
|
||||||
|
|
||||||
|
property string roomId
|
||||||
|
property string roomName
|
||||||
|
property list<Invitee> invitees
|
||||||
|
|
||||||
|
function addInvite() {
|
||||||
|
if (inviteeEntry.text.match("@.+?:.{3,}"))
|
||||||
|
{
|
||||||
|
invitees.push(inviteeComponent.createObject(
|
||||||
|
inviteDialogRoot, {
|
||||||
|
"invitee": inviteeEntry.text
|
||||||
|
}));
|
||||||
|
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
|
||||||
|
x: MainWindow.x + (MainWindow.width / 2) - (width / 2)
|
||||||
|
y: MainWindow.y + (MainWindow.height / 2) - (height / 2)
|
||||||
|
height: 380
|
||||||
|
width: 340
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: inviteeComponent
|
||||||
|
|
||||||
|
Invitee {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: make this work in the TextField
|
||||||
|
Shortcut {
|
||||||
|
sequence: "Ctrl+Enter"
|
||||||
|
onActivated: inviteDialogRoot.accept()
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: 10
|
||||||
|
spacing: 10
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr("User ID to invite")
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
spacing: 10
|
||||||
|
|
||||||
|
TextField {
|
||||||
|
id: inviteeEntry
|
||||||
|
|
||||||
|
placeholderText: qsTr("@joe:matrix.org", "Example user id. The name 'joe' can be localized however you want.")
|
||||||
|
Layout.fillWidth: true
|
||||||
|
onAccepted: if (text !== "") addInvite()
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
text: qsTr("Invite")
|
||||||
|
onClicked: if (inviteeEntry.text !== "") addInvite()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ListView {
|
||||||
|
id: inviteesList
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
model: invitees
|
||||||
|
delegate: Label {
|
||||||
|
text: model.invitee
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
footer: DialogButtonBox {
|
||||||
|
id: buttons
|
||||||
|
|
||||||
|
Button {
|
||||||
|
text: qsTr("Invite")
|
||||||
|
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
|
||||||
|
onClicked: {
|
||||||
|
inviteDialogRoot.accept();
|
||||||
|
inviteDialogRoot.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
text: qsTr("Cancel")
|
||||||
|
DialogButtonBox.buttonRole: DialogButtonBox.DestructiveRole
|
||||||
|
onClicked: inviteDialogRoot.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,6 +21,12 @@ 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)
|
||||||
|
@ -111,7 +117,13 @@ 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: TimelineManager.openInviteUsersDialog()
|
onTriggered: {
|
||||||
|
var dialog = inviteDialog.createObject(topBar, {
|
||||||
|
"roomId": room.roomId,
|
||||||
|
"roomName": room.roomName
|
||||||
|
});
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Platform.MenuItem {
|
Platform.MenuItem {
|
||||||
|
|
5
resources/qml/types/Invitee.qml
Normal file
5
resources/qml/types/Invitee.qml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import QtQuick 2.12
|
||||||
|
|
||||||
|
Item {
|
||||||
|
property string invitee
|
||||||
|
}
|
|
@ -9,7 +9,6 @@
|
||||||
<file>icons/ui/do-not-disturb-rounded-sign@2x.png</file>
|
<file>icons/ui/do-not-disturb-rounded-sign@2x.png</file>
|
||||||
<file>icons/ui/round-remove-button.png</file>
|
<file>icons/ui/round-remove-button.png</file>
|
||||||
<file>icons/ui/round-remove-button@2x.png</file>
|
<file>icons/ui/round-remove-button@2x.png</file>
|
||||||
|
|
||||||
<file>icons/ui/double-tick-indicator.png</file>
|
<file>icons/ui/double-tick-indicator.png</file>
|
||||||
<file>icons/ui/double-tick-indicator@2x.png</file>
|
<file>icons/ui/double-tick-indicator@2x.png</file>
|
||||||
<file>icons/ui/lock.png</file>
|
<file>icons/ui/lock.png</file>
|
||||||
|
@ -55,22 +54,17 @@
|
||||||
<file>icons/ui/pause-symbol@2x.png</file>
|
<file>icons/ui/pause-symbol@2x.png</file>
|
||||||
<file>icons/ui/remove-symbol.png</file>
|
<file>icons/ui/remove-symbol.png</file>
|
||||||
<file>icons/ui/remove-symbol@2x.png</file>
|
<file>icons/ui/remove-symbol@2x.png</file>
|
||||||
|
|
||||||
<file>icons/ui/world.png</file>
|
<file>icons/ui/world.png</file>
|
||||||
<file>icons/ui/world@2x.png</file>
|
<file>icons/ui/world@2x.png</file>
|
||||||
|
|
||||||
<file>icons/ui/tag.png</file>
|
<file>icons/ui/tag.png</file>
|
||||||
<file>icons/ui/tag@2x.png</file>
|
<file>icons/ui/tag@2x.png</file>
|
||||||
<file>icons/ui/star.png</file>
|
<file>icons/ui/star.png</file>
|
||||||
<file>icons/ui/star@2x.png</file>
|
<file>icons/ui/star@2x.png</file>
|
||||||
<file>icons/ui/lowprio.png</file>
|
<file>icons/ui/lowprio.png</file>
|
||||||
<file>icons/ui/lowprio@2x.png</file>
|
<file>icons/ui/lowprio@2x.png</file>
|
||||||
|
|
||||||
<file>icons/ui/edit.png</file>
|
<file>icons/ui/edit.png</file>
|
||||||
<file>icons/ui/edit@2x.png</file>
|
<file>icons/ui/edit@2x.png</file>
|
||||||
|
|
||||||
<file>icons/ui/mail-reply.png</file>
|
<file>icons/ui/mail-reply.png</file>
|
||||||
|
|
||||||
<file>icons/ui/place-call.png</file>
|
<file>icons/ui/place-call.png</file>
|
||||||
<file>icons/ui/end-call.png</file>
|
<file>icons/ui/end-call.png</file>
|
||||||
<file>icons/ui/microphone-mute.png</file>
|
<file>icons/ui/microphone-mute.png</file>
|
||||||
|
@ -78,7 +72,6 @@
|
||||||
<file>icons/ui/screen-share.png</file>
|
<file>icons/ui/screen-share.png</file>
|
||||||
<file>icons/ui/toggle-camera-view.png</file>
|
<file>icons/ui/toggle-camera-view.png</file>
|
||||||
<file>icons/ui/video-call.png</file>
|
<file>icons/ui/video-call.png</file>
|
||||||
|
|
||||||
<file>icons/emoji-categories/people.png</file>
|
<file>icons/emoji-categories/people.png</file>
|
||||||
<file>icons/emoji-categories/people@2x.png</file>
|
<file>icons/emoji-categories/people@2x.png</file>
|
||||||
<file>icons/emoji-categories/nature.png</file>
|
<file>icons/emoji-categories/nature.png</file>
|
||||||
|
@ -99,16 +92,12 @@
|
||||||
<qresource prefix="/logos">
|
<qresource prefix="/logos">
|
||||||
<file>nheko.png</file>
|
<file>nheko.png</file>
|
||||||
<file>nheko.svg</file>
|
<file>nheko.svg</file>
|
||||||
|
|
||||||
<file>splash.png</file>
|
<file>splash.png</file>
|
||||||
<file>splash@2x.png</file>
|
<file>splash@2x.png</file>
|
||||||
|
|
||||||
<file>register.png</file>
|
<file>register.png</file>
|
||||||
<file>register@2x.png</file>
|
<file>register@2x.png</file>
|
||||||
|
|
||||||
<file>login.png</file>
|
<file>login.png</file>
|
||||||
<file>login@2x.png</file>
|
<file>login@2x.png</file>
|
||||||
|
|
||||||
<file>nheko-512.png</file>
|
<file>nheko-512.png</file>
|
||||||
<file>nheko-256.png</file>
|
<file>nheko-256.png</file>
|
||||||
<file>nheko-128.png</file>
|
<file>nheko-128.png</file>
|
||||||
|
@ -186,6 +175,8 @@
|
||||||
<file>qml/components/AdaptiveLayoutElement.qml</file>
|
<file>qml/components/AdaptiveLayoutElement.qml</file>
|
||||||
<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/types/Invitee.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="/media">
|
<qresource prefix="/media">
|
||||||
<file>media/ring.ogg</file>
|
<file>media/ring.ogg</file>
|
||||||
|
|
|
@ -140,6 +140,34 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(
|
||||||
|
view_manager_, &TimelineViewManager::showRoomList, splitter, &Splitter::showFullRoomList);
|
||||||
|
connect(
|
||||||
|
view_manager_,
|
||||||
|
&TimelineViewManager::inviteUsers,
|
||||||
|
this,
|
||||||
|
[this](QString roomId, QStringList users) {
|
||||||
|
for (int ii = 0; ii < users.size(); ++ii) {
|
||||||
|
QTimer::singleShot(ii * 500, this, [this, roomId, ii, users]() {
|
||||||
|
const auto user = users.at(ii);
|
||||||
|
|
||||||
|
http::client()->invite_user(
|
||||||
|
roomId.toStdString(),
|
||||||
|
user.toStdString(),
|
||||||
|
[this, user](const mtx::responses::RoomInvite &,
|
||||||
|
mtx::http::RequestErr err) {
|
||||||
|
if (err) {
|
||||||
|
emit showNotification(
|
||||||
|
tr("Failed to invite user: %1").arg(user));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit showNotification(tr("Invited user: %1").arg(user));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
connect(this, &ChatPage::leftRoom, this, &ChatPage::removeRoom);
|
connect(this, &ChatPage::leftRoom, this, &ChatPage::removeRoom);
|
||||||
connect(this, &ChatPage::newRoom, this, &ChatPage::changeRoom, Qt::QueuedConnection);
|
connect(this, &ChatPage::newRoom, this, &ChatPage::changeRoom, Qt::QueuedConnection);
|
||||||
connect(this, &ChatPage::notificationsRetrieved, this, &ChatPage::sendNotifications);
|
connect(this, &ChatPage::notificationsRetrieved, this, &ChatPage::sendNotifications);
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QPushButton>
|
|
||||||
|
|
||||||
#include "InviteeItem.h"
|
|
||||||
|
|
||||||
constexpr int SidePadding = 10;
|
|
||||||
|
|
||||||
InviteeItem::InviteeItem(mtx::identifiers::User user, QWidget *parent)
|
|
||||||
: QWidget{parent}
|
|
||||||
, user_{QString::fromStdString(user.to_string())}
|
|
||||||
{
|
|
||||||
auto topLayout_ = new QHBoxLayout(this);
|
|
||||||
topLayout_->setSpacing(0);
|
|
||||||
topLayout_->setContentsMargins(SidePadding, 0, 3 * SidePadding, 0);
|
|
||||||
|
|
||||||
name_ = new QLabel(user_, this);
|
|
||||||
removeUserBtn_ = new QPushButton(tr("Remove"), this);
|
|
||||||
|
|
||||||
topLayout_->addWidget(name_);
|
|
||||||
topLayout_->addWidget(removeUserBtn_, 0, Qt::AlignRight);
|
|
||||||
|
|
||||||
connect(removeUserBtn_, &QPushButton::clicked, this, &InviteeItem::removeItem);
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
#include <mtx/identifiers.hpp>
|
|
||||||
|
|
||||||
class QPushButton;
|
|
||||||
class QLabel;
|
|
||||||
|
|
||||||
class InviteeItem : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
InviteeItem(mtx::identifiers::User user, QWidget *parent = nullptr);
|
|
||||||
|
|
||||||
QString userID() { return user_; }
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void removeItem();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString user_;
|
|
||||||
|
|
||||||
QLabel *name_;
|
|
||||||
QPushButton *removeUserBtn_;
|
|
||||||
};
|
|
|
@ -33,7 +33,6 @@
|
||||||
#include "ui/SnackBar.h"
|
#include "ui/SnackBar.h"
|
||||||
|
|
||||||
#include "dialogs/CreateRoom.h"
|
#include "dialogs/CreateRoom.h"
|
||||||
#include "dialogs/InviteUsers.h"
|
|
||||||
#include "dialogs/JoinRoom.h"
|
#include "dialogs/JoinRoom.h"
|
||||||
#include "dialogs/LeaveRoom.h"
|
#include "dialogs/LeaveRoom.h"
|
||||||
#include "dialogs/Logout.h"
|
#include "dialogs/Logout.h"
|
||||||
|
@ -333,18 +332,6 @@ MainWindow::showOverlayProgressBar()
|
||||||
showSolidOverlayModal(spinner_);
|
showSolidOverlayModal(spinner_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
MainWindow::openInviteUsersDialog(std::function<void(const QStringList &invitees)> callback)
|
|
||||||
{
|
|
||||||
auto dialog = new dialogs::InviteUsers(this);
|
|
||||||
connect(dialog, &dialogs::InviteUsers::sendInvites, this, [callback](QStringList invitees) {
|
|
||||||
if (!invitees.isEmpty())
|
|
||||||
callback(invitees);
|
|
||||||
});
|
|
||||||
|
|
||||||
showDialog(dialog);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MainWindow::openJoinRoomDialog(std::function<void(const QString &room_id)> callback)
|
MainWindow::openJoinRoomDialog(std::function<void(const QString &room_id)> callback)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,158 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QIcon>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QListWidget>
|
|
||||||
#include <QListWidgetItem>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QStyleOption>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
|
|
||||||
#include "dialogs/InviteUsers.h"
|
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
#include "InviteeItem.h"
|
|
||||||
#include "ui/TextField.h"
|
|
||||||
|
|
||||||
#include <mtx/identifiers.hpp>
|
|
||||||
|
|
||||||
using namespace dialogs;
|
|
||||||
|
|
||||||
InviteUsers::InviteUsers(QWidget *parent)
|
|
||||||
: QFrame(parent)
|
|
||||||
{
|
|
||||||
setAutoFillBackground(true);
|
|
||||||
setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint);
|
|
||||||
setWindowModality(Qt::WindowModal);
|
|
||||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
|
||||||
|
|
||||||
setMinimumWidth(conf::window::minModalWidth);
|
|
||||||
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
|
||||||
|
|
||||||
auto layout = new QVBoxLayout(this);
|
|
||||||
layout->setSpacing(conf::modals::WIDGET_SPACING);
|
|
||||||
layout->setMargin(conf::modals::WIDGET_MARGIN);
|
|
||||||
|
|
||||||
auto buttonLayout = new QHBoxLayout();
|
|
||||||
buttonLayout->setSpacing(0);
|
|
||||||
buttonLayout->setMargin(0);
|
|
||||||
|
|
||||||
confirmBtn_ = new QPushButton("Invite", this);
|
|
||||||
confirmBtn_->setDefault(true);
|
|
||||||
cancelBtn_ = new QPushButton(tr("Cancel"), this);
|
|
||||||
|
|
||||||
buttonLayout->addStretch(1);
|
|
||||||
buttonLayout->setSpacing(15);
|
|
||||||
buttonLayout->addWidget(cancelBtn_);
|
|
||||||
buttonLayout->addWidget(confirmBtn_);
|
|
||||||
|
|
||||||
inviteeInput_ = new TextField(this);
|
|
||||||
inviteeInput_->setLabel(tr("User ID to invite"));
|
|
||||||
|
|
||||||
inviteeList_ = new QListWidget;
|
|
||||||
inviteeList_->setFrameStyle(QFrame::NoFrame);
|
|
||||||
inviteeList_->setSelectionMode(QAbstractItemView::NoSelection);
|
|
||||||
inviteeList_->setAttribute(Qt::WA_MacShowFocusRect, 0);
|
|
||||||
inviteeList_->setSpacing(5);
|
|
||||||
|
|
||||||
errorLabel_ = new QLabel(this);
|
|
||||||
errorLabel_->setAlignment(Qt::AlignCenter);
|
|
||||||
|
|
||||||
layout->addWidget(inviteeInput_);
|
|
||||||
layout->addWidget(errorLabel_);
|
|
||||||
layout->addWidget(inviteeList_);
|
|
||||||
layout->addLayout(buttonLayout);
|
|
||||||
|
|
||||||
connect(inviteeInput_, &TextField::returnPressed, this, &InviteUsers::addUser);
|
|
||||||
connect(confirmBtn_, &QPushButton::clicked, [this]() {
|
|
||||||
if (!inviteeInput_->text().trimmed().isEmpty()) {
|
|
||||||
addUser();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit sendInvites(invitedUsers());
|
|
||||||
|
|
||||||
inviteeInput_->clear();
|
|
||||||
inviteeList_->clear();
|
|
||||||
errorLabel_->hide();
|
|
||||||
|
|
||||||
emit close();
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(cancelBtn_, &QPushButton::clicked, [this]() {
|
|
||||||
inviteeInput_->clear();
|
|
||||||
inviteeList_->clear();
|
|
||||||
errorLabel_->hide();
|
|
||||||
|
|
||||||
emit close();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
InviteUsers::addUser()
|
|
||||||
{
|
|
||||||
auto user_id = inviteeInput_->text();
|
|
||||||
|
|
||||||
try {
|
|
||||||
namespace ids = mtx::identifiers;
|
|
||||||
auto user = ids::parse<ids::User>(user_id.toStdString());
|
|
||||||
|
|
||||||
auto item = new QListWidgetItem(inviteeList_);
|
|
||||||
auto invitee = new InviteeItem(user, this);
|
|
||||||
|
|
||||||
item->setSizeHint(invitee->minimumSizeHint());
|
|
||||||
item->setFlags(Qt::NoItemFlags);
|
|
||||||
item->setTextAlignment(Qt::AlignCenter);
|
|
||||||
|
|
||||||
inviteeList_->setItemWidget(item, invitee);
|
|
||||||
|
|
||||||
connect(invitee, &InviteeItem::removeItem, this, [this, item]() {
|
|
||||||
emit removeInvitee(item);
|
|
||||||
});
|
|
||||||
|
|
||||||
errorLabel_->hide();
|
|
||||||
inviteeInput_->clear();
|
|
||||||
} catch (std::exception &e) {
|
|
||||||
errorLabel_->setText(e.what());
|
|
||||||
errorLabel_->show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
InviteUsers::removeInvitee(QListWidgetItem *item)
|
|
||||||
{
|
|
||||||
int row = inviteeList_->row(item);
|
|
||||||
auto widget = inviteeList_->takeItem(row);
|
|
||||||
|
|
||||||
inviteeList_->removeItemWidget(widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList
|
|
||||||
InviteUsers::invitedUsers() const
|
|
||||||
{
|
|
||||||
QStringList users;
|
|
||||||
|
|
||||||
for (int ii = 0; ii < inviteeList_->count(); ++ii) {
|
|
||||||
auto item = inviteeList_->item(ii);
|
|
||||||
auto widget = inviteeList_->itemWidget(item);
|
|
||||||
auto invitee = qobject_cast<InviteeItem *>(widget);
|
|
||||||
|
|
||||||
if (invitee)
|
|
||||||
users << invitee->userID();
|
|
||||||
else
|
|
||||||
qDebug() << "Cast InviteeItem failed";
|
|
||||||
}
|
|
||||||
|
|
||||||
return users;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
InviteUsers::showEvent(QShowEvent *event)
|
|
||||||
{
|
|
||||||
inviteeInput_->setFocus();
|
|
||||||
|
|
||||||
QFrame::showEvent(event);
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QFrame>
|
|
||||||
#include <QStringList>
|
|
||||||
|
|
||||||
class QPushButton;
|
|
||||||
class QLabel;
|
|
||||||
class TextField;
|
|
||||||
class QListWidget;
|
|
||||||
class QListWidgetItem;
|
|
||||||
|
|
||||||
namespace dialogs {
|
|
||||||
|
|
||||||
class InviteUsers : public QFrame
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit InviteUsers(QWidget *parent = nullptr);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void showEvent(QShowEvent *event) override;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void sendInvites(QStringList invitees);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void removeInvitee(QListWidgetItem *item);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void addUser();
|
|
||||||
QStringList invitedUsers() const;
|
|
||||||
|
|
||||||
QPushButton *confirmBtn_;
|
|
||||||
QPushButton *cancelBtn_;
|
|
||||||
|
|
||||||
TextField *inviteeInput_;
|
|
||||||
QLabel *errorLabel_;
|
|
||||||
|
|
||||||
QListWidget *inviteeList_;
|
|
||||||
};
|
|
||||||
} // dialogs
|
|
|
@ -159,6 +159,7 @@ class TimelineModel : public QAbstractListModel
|
||||||
Q_PROPERTY(QString edit READ edit WRITE setEdit NOTIFY editChanged RESET resetEdit)
|
Q_PROPERTY(QString edit READ edit WRITE setEdit NOTIFY editChanged RESET resetEdit)
|
||||||
Q_PROPERTY(
|
Q_PROPERTY(
|
||||||
bool paginationInProgress READ paginationInProgress NOTIFY paginationInProgressChanged)
|
bool paginationInProgress READ paginationInProgress NOTIFY paginationInProgressChanged)
|
||||||
|
Q_PROPERTY(QString roomId READ roomId CONSTANT)
|
||||||
Q_PROPERTY(QString roomName READ roomName NOTIFY roomNameChanged)
|
Q_PROPERTY(QString roomName READ roomName NOTIFY roomNameChanged)
|
||||||
Q_PROPERTY(QString roomAvatarUrl READ roomAvatarUrl NOTIFY roomAvatarUrlChanged)
|
Q_PROPERTY(QString roomAvatarUrl READ roomAvatarUrl NOTIFY roomAvatarUrlChanged)
|
||||||
Q_PROPERTY(QString roomTopic READ roomTopic NOTIFY roomTopicChanged)
|
Q_PROPERTY(QString roomTopic READ roomTopic NOTIFY roomTopicChanged)
|
||||||
|
|
|
@ -429,6 +429,57 @@ TimelineViewManager::openInviteUsersDialog()
|
||||||
MainWindow::instance()->openInviteUsersDialog(
|
MainWindow::instance()->openInviteUsersDialog(
|
||||||
[this](const QStringList &invitees) { emit inviteUsers(invitees); });
|
[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
|
||||||
{
|
{
|
||||||
|
|
|
@ -65,7 +65,6 @@ public:
|
||||||
Q_INVOKABLE QString userStatus(QString id) const;
|
Q_INVOKABLE QString userStatus(QString id) const;
|
||||||
|
|
||||||
Q_INVOKABLE void focusMessageInput();
|
Q_INVOKABLE void focusMessageInput();
|
||||||
Q_INVOKABLE void openInviteUsersDialog();
|
|
||||||
Q_INVOKABLE void openLeaveRoomDialog(QString roomid) const;
|
Q_INVOKABLE void openLeaveRoomDialog(QString roomid) const;
|
||||||
Q_INVOKABLE void removeVerificationFlow(DeviceVerificationFlow *flow);
|
Q_INVOKABLE void removeVerificationFlow(DeviceVerificationFlow *flow);
|
||||||
|
|
||||||
|
@ -80,7 +79,9 @@ signals:
|
||||||
void replyingEventChanged(QString replyingEvent);
|
void replyingEventChanged(QString replyingEvent);
|
||||||
void replyClosed();
|
void replyClosed();
|
||||||
void newDeviceVerificationRequest(DeviceVerificationFlow *flow);
|
void newDeviceVerificationRequest(DeviceVerificationFlow *flow);
|
||||||
void inviteUsers(QStringList users);
|
void inviteUsers(QString roomId, QStringList users);
|
||||||
|
void showRoomList();
|
||||||
|
void narrowViewChanged();
|
||||||
void focusChanged();
|
void focusChanged();
|
||||||
void focusInput();
|
void focusInput();
|
||||||
void openImageOverlayInternalCb(QString eventId, QImage img);
|
void openImageOverlayInternalCb(QString eventId, QImage img);
|
||||||
|
|
Loading…
Reference in a new issue