mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Use the same leave room dialog everywhere
This ports the leave room dialog to QML, everywhere. There are now no differences between the various leave dialogs.
This commit is contained in:
parent
cd39e015d4
commit
14488a8fe7
12 changed files with 47 additions and 116 deletions
|
@ -281,7 +281,6 @@ set(SRC_FILES
|
|||
src/dialogs/CreateRoom.cpp
|
||||
src/dialogs/FallbackAuth.cpp
|
||||
src/dialogs/ImageOverlay.cpp
|
||||
src/dialogs/LeaveRoom.cpp
|
||||
src/dialogs/Logout.cpp
|
||||
src/dialogs/PreviewUploadOverlay.cpp
|
||||
src/dialogs/ReCaptcha.cpp
|
||||
|
@ -497,7 +496,6 @@ qt5_wrap_cpp(MOC_HEADERS
|
|||
src/dialogs/CreateRoom.h
|
||||
src/dialogs/FallbackAuth.h
|
||||
src/dialogs/ImageOverlay.h
|
||||
src/dialogs/LeaveRoom.h
|
||||
src/dialogs/Logout.h
|
||||
src/dialogs/PreviewUploadOverlay.h
|
||||
src/dialogs/ReCaptcha.h
|
||||
|
|
|
@ -71,19 +71,9 @@ Page {
|
|||
}
|
||||
}
|
||||
|
||||
Platform.MessageDialog {
|
||||
id: leaveRoomDialog
|
||||
|
||||
title: qsTr("Leave Room")
|
||||
text: qsTr("Are you sure you want to leave this room?")
|
||||
modality: Qt.ApplicationModal
|
||||
onAccepted: Rooms.leave(roomContextMenu.roomid)
|
||||
buttons: Dialog.Ok | Dialog.Cancel
|
||||
}
|
||||
|
||||
Platform.MenuItem {
|
||||
text: qsTr("Leave room")
|
||||
onTriggered: leaveRoomDialog.open()
|
||||
onTriggered: TimelineManager.openLeaveRoomDialog(roomContextMenu.roomid)
|
||||
}
|
||||
|
||||
Platform.MenuSeparator {
|
||||
|
|
|
@ -125,6 +125,13 @@ Page {
|
|||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: leaveRoomComponent
|
||||
|
||||
LeaveRoomDialog {
|
||||
}
|
||||
}
|
||||
|
||||
Shortcut {
|
||||
sequence: "Ctrl+K"
|
||||
onActivated: {
|
||||
|
@ -209,6 +216,13 @@ Page {
|
|||
dialog.show();
|
||||
}
|
||||
|
||||
function onOpenLeaveRoomDialog(roomid) {
|
||||
var dialog = leaveRoomComponent.createObject(timelineRoot, {
|
||||
"roomId": roomid
|
||||
});
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
target: TimelineManager
|
||||
}
|
||||
|
||||
|
|
20
resources/qml/dialogs/LeaveRoomDialog.qml
Normal file
20
resources/qml/dialogs/LeaveRoomDialog.qml
Normal file
|
@ -0,0 +1,20 @@
|
|||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import Qt.labs.platform 1.1
|
||||
import im.nheko 1.0
|
||||
|
||||
MessageDialog {
|
||||
id: leaveRoomRoot
|
||||
|
||||
required property string roomId
|
||||
|
||||
title: qsTr("Leave room")
|
||||
text: qsTr("Are you sure you want to leave?")
|
||||
modality: Qt.ApplicationModal
|
||||
buttons: Dialog.Ok | Dialog.Cancel
|
||||
onAccepted: Rooms.leave(roomId)
|
||||
}
|
|
@ -185,8 +185,16 @@
|
|||
<file>qml/voip/VideoCall.qml</file>
|
||||
<file>qml/components/AdaptiveLayout.qml</file>
|
||||
<file>qml/components/AdaptiveLayoutElement.qml</file>
|
||||
<file>qml/components/AvatarListTile.qml</file>
|
||||
<file>qml/components/FlatButton.qml</file>
|
||||
<file>qml/components/AvatarListTile.qml</file>
|
||||
<file>qml/components/FlatButton.qml</file>
|
||||
<file>qml/dialogs/InviteDialog.qml</file>
|
||||
<file>qml/dialogs/LeaveRoomDialog.qml</file>
|
||||
<file>qml/dialogs/RawMessageDialog.qml</file>
|
||||
<file>qml/dialogs/ReadReceipts.qml</file>
|
||||
<file>qml/dialogs/RoomDirectory.qml</file>
|
||||
<file>qml/dialogs/RoomMembers.qml</file>
|
||||
<file>qml/dialogs/RoomSettings.qml</file>
|
||||
<file>qml/dialogs/UserProfile.qml</file>
|
||||
</qresource>
|
||||
<qresource prefix="/media">
|
||||
<file>media/ring.ogg</file>
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "ui/SnackBar.h"
|
||||
|
||||
#include "dialogs/CreateRoom.h"
|
||||
#include "dialogs/LeaveRoom.h"
|
||||
|
||||
MainWindow *MainWindow::instance_ = nullptr;
|
||||
|
||||
|
@ -300,17 +299,6 @@ MainWindow::hasActiveUser()
|
|||
settings->contains(prefix + "auth/user_id");
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::openLeaveRoomDialog(const QString &room_id)
|
||||
{
|
||||
auto dialog = new dialogs::LeaveRoom(this);
|
||||
connect(dialog, &dialogs::LeaveRoom::leaving, this, [this, room_id]() {
|
||||
chat_page_->leaveRoom(room_id);
|
||||
});
|
||||
|
||||
showDialog(dialog);
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::showOverlayProgressBar()
|
||||
{
|
||||
|
|
|
@ -37,7 +37,6 @@ struct CreateRoom;
|
|||
namespace dialogs {
|
||||
class CreateRoom;
|
||||
class InviteUsers;
|
||||
class LeaveRoom;
|
||||
class Logout;
|
||||
class MemberList;
|
||||
class ReCaptcha;
|
||||
|
@ -58,7 +57,6 @@ public:
|
|||
static MainWindow *instance() { return instance_; }
|
||||
void saveCurrentWindowSize();
|
||||
|
||||
void openLeaveRoomDialog(const QString &room_id);
|
||||
void openCreateRoomDialog(
|
||||
std::function<void(const mtx::requests::CreateRoom &request)> callback);
|
||||
void openJoinRoomDialog(std::function<void(const QString &room_id)> callback);
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "dialogs/LeaveRoom.h"
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
using namespace dialogs;
|
||||
|
||||
LeaveRoom::LeaveRoom(QWidget *parent)
|
||||
: QFrame(parent)
|
||||
{
|
||||
setAutoFillBackground(true);
|
||||
setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint);
|
||||
setWindowModality(Qt::WindowModal);
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
|
||||
setMinimumWidth(conf::modals::MIN_WIDGET_WIDTH);
|
||||
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("Leave", this);
|
||||
cancelBtn_ = new QPushButton(tr("Cancel"), this);
|
||||
cancelBtn_->setDefault(true);
|
||||
|
||||
buttonLayout->addStretch(1);
|
||||
buttonLayout->setSpacing(15);
|
||||
buttonLayout->addWidget(cancelBtn_);
|
||||
buttonLayout->addWidget(confirmBtn_);
|
||||
|
||||
auto label = new QLabel(tr("Are you sure you want to leave?"), this);
|
||||
|
||||
layout->addWidget(label);
|
||||
layout->addLayout(buttonLayout);
|
||||
|
||||
connect(confirmBtn_, &QPushButton::clicked, this, [this]() {
|
||||
emit leaving();
|
||||
emit close();
|
||||
});
|
||||
connect(cancelBtn_, &QPushButton::clicked, this, &LeaveRoom::close);
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
class QPushButton;
|
||||
|
||||
namespace dialogs {
|
||||
|
||||
class LeaveRoom : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LeaveRoom(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void leaving();
|
||||
|
||||
private:
|
||||
QPushButton *confirmBtn_;
|
||||
QPushButton *cancelBtn_;
|
||||
};
|
||||
} // dialogs
|
|
@ -577,7 +577,7 @@ InputBar::command(QString command, QString args)
|
|||
} else if (command == "join") {
|
||||
ChatPage::instance()->joinRoom(args);
|
||||
} else if (command == "part" || command == "leave") {
|
||||
MainWindow::instance()->openLeaveRoomDialog(room->roomId());
|
||||
ChatPage::instance()->timelineManager()->openLeaveRoomDialog(room->roomId());
|
||||
} else if (command == "invite") {
|
||||
ChatPage::instance()->inviteUser(args.section(' ', 0, 0), args.section(' ', 1, -1));
|
||||
} else if (command == "kick") {
|
||||
|
|
|
@ -475,12 +475,6 @@ TimelineViewManager::openImageOverlayInternal(QString eventId, QImage img)
|
|||
});
|
||||
}
|
||||
|
||||
void
|
||||
TimelineViewManager::openLeaveRoomDialog(QString roomid) const
|
||||
{
|
||||
MainWindow::instance()->openLeaveRoomDialog(roomid);
|
||||
}
|
||||
|
||||
void
|
||||
TimelineViewManager::verifyUser(QString userid)
|
||||
{
|
||||
|
|
|
@ -73,7 +73,6 @@ public:
|
|||
Q_INVOKABLE void openGlobalUserProfile(QString userId);
|
||||
|
||||
Q_INVOKABLE void focusMessageInput();
|
||||
Q_INVOKABLE void openLeaveRoomDialog(QString roomid) const;
|
||||
Q_INVOKABLE void removeVerificationFlow(DeviceVerificationFlow *flow);
|
||||
|
||||
Q_INVOKABLE void fixImageRendering(QQuickTextDocument *t, QQuickItem *i);
|
||||
|
@ -98,6 +97,7 @@ signals:
|
|||
void openInviteUsersDialog(InviteesModel *invitees);
|
||||
void openProfile(UserProfile *profile);
|
||||
void showImagePackSettings(ImagePackListModel *packlist);
|
||||
void openLeaveRoomDialog(QString roomid);
|
||||
|
||||
public slots:
|
||||
void updateReadReceipts(const QString &room_id, const std::vector<QString> &event_ids);
|
||||
|
|
Loading…
Reference in a new issue