diff --git a/CMakeLists.txt b/CMakeLists.txt
index dad34349..8ff3ca26 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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
diff --git a/resources/qml/RoomList.qml b/resources/qml/RoomList.qml
index addbf571..85087bc4 100644
--- a/resources/qml/RoomList.qml
+++ b/resources/qml/RoomList.qml
@@ -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 {
diff --git a/resources/qml/Root.qml b/resources/qml/Root.qml
index c73d1f1d..18130469 100644
--- a/resources/qml/Root.qml
+++ b/resources/qml/Root.qml
@@ -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
}
diff --git a/resources/qml/dialogs/LeaveRoomDialog.qml b/resources/qml/dialogs/LeaveRoomDialog.qml
new file mode 100644
index 00000000..1341ad72
--- /dev/null
+++ b/resources/qml/dialogs/LeaveRoomDialog.qml
@@ -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)
+}
diff --git a/resources/res.qrc b/resources/res.qrc
index 9303ab5f..ffbadd91 100644
--- a/resources/res.qrc
+++ b/resources/res.qrc
@@ -185,8 +185,16 @@
qml/voip/VideoCall.qml
qml/components/AdaptiveLayout.qml
qml/components/AdaptiveLayoutElement.qml
- qml/components/AvatarListTile.qml
- qml/components/FlatButton.qml
+ qml/components/AvatarListTile.qml
+ qml/components/FlatButton.qml
+ qml/dialogs/InviteDialog.qml
+ qml/dialogs/LeaveRoomDialog.qml
+ qml/dialogs/RawMessageDialog.qml
+ qml/dialogs/ReadReceipts.qml
+ qml/dialogs/RoomDirectory.qml
+ qml/dialogs/RoomMembers.qml
+ qml/dialogs/RoomSettings.qml
+ qml/dialogs/UserProfile.qml
media/ring.ogg
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 777b5b22..c8eb2d24 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -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()
{
diff --git a/src/MainWindow.h b/src/MainWindow.h
index 64606412..b9d2fe5f 100644
--- a/src/MainWindow.h
+++ b/src/MainWindow.h
@@ -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 callback);
void openJoinRoomDialog(std::function callback);
diff --git a/src/dialogs/LeaveRoom.cpp b/src/dialogs/LeaveRoom.cpp
deleted file mode 100644
index 9eb431da..00000000
--- a/src/dialogs/LeaveRoom.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-// SPDX-FileCopyrightText: 2021 Nheko Contributors
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include
-#include
-#include
-
-#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);
-}
diff --git a/src/dialogs/LeaveRoom.h b/src/dialogs/LeaveRoom.h
deleted file mode 100644
index edf88282..00000000
--- a/src/dialogs/LeaveRoom.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// SPDX-FileCopyrightText: 2021 Nheko Contributors
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#pragma once
-
-#include
-
-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
diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp
index f518248b..f33d1dfd 100644
--- a/src/timeline/InputBar.cpp
+++ b/src/timeline/InputBar.cpp
@@ -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") {
diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp
index df8210d3..a30a145d 100644
--- a/src/timeline/TimelineViewManager.cpp
+++ b/src/timeline/TimelineViewManager.cpp
@@ -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)
{
diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h
index f7b01315..ab078aa7 100644
--- a/src/timeline/TimelineViewManager.h
+++ b/src/timeline/TimelineViewManager.h
@@ -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 &event_ids);