mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-10-30 09:30:47 +03:00
commit
7eb9071b50
7 changed files with 42 additions and 23 deletions
|
@ -111,6 +111,13 @@ Page {
|
|||
|
||||
}
|
||||
|
||||
Component {
|
||||
id: logoutDialog
|
||||
|
||||
LogoutDialog {
|
||||
}
|
||||
}
|
||||
|
||||
Shortcut {
|
||||
sequence: "Ctrl+K"
|
||||
onActivated: {
|
||||
|
@ -135,6 +142,15 @@ Page {
|
|||
onActivated: Rooms.previousRoom()
|
||||
}
|
||||
|
||||
Connections {
|
||||
function onOpenLogoutDialog() {
|
||||
var dialog = logoutDialog.createObject(timelineRoot);
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
target: Nheko
|
||||
}
|
||||
|
||||
Connections {
|
||||
function onNewDeviceVerificationRequest(flow) {
|
||||
var dialog = deviceVerificationDialog.createObject(timelineRoot, {
|
||||
|
|
19
resources/qml/dialogs/LogoutDialog.qml
Normal file
19
resources/qml/dialogs/LogoutDialog.qml
Normal file
|
@ -0,0 +1,19 @@
|
|||
// 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: logoutRoot
|
||||
|
||||
title: qsTr("Log out")
|
||||
text: CallManager.isOnCall ? qsTr("A call is in progress. Log out?") : qsTr("Are you sure you want to log out?")
|
||||
modality: Qt.WindowModal
|
||||
flags: Qt.Tool | Qt.WindowStaysOnTopHint | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
|
||||
buttons: Dialog.Ok | Dialog.Cancel
|
||||
onAccepted: Nheko.logout()
|
||||
}
|
|
@ -184,6 +184,7 @@
|
|||
<file>qml/dialogs/RoomMembers.qml</file>
|
||||
<file>qml/dialogs/RoomSettings.qml</file>
|
||||
<file>qml/dialogs/UserProfile.qml</file>
|
||||
<file>qml/dialogs/LogoutDialog.qml</file>
|
||||
</qresource>
|
||||
<qresource prefix="/media">
|
||||
<file>media/ring.ogg</file>
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "dialogs/CreateRoom.h"
|
||||
#include "dialogs/JoinRoom.h"
|
||||
#include "dialogs/LeaveRoom.h"
|
||||
#include "dialogs/Logout.h"
|
||||
|
||||
MainWindow *MainWindow::instance_ = nullptr;
|
||||
|
||||
|
@ -372,24 +371,6 @@ MainWindow::showSolidOverlayModal(QWidget *content, QFlags<Qt::AlignmentFlag> fl
|
|||
modal_->show();
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::openLogoutDialog()
|
||||
{
|
||||
auto dialog = new dialogs::Logout(this);
|
||||
connect(dialog, &dialogs::Logout::loggingOut, this, [this]() {
|
||||
if (WebRTCSession::instance().state() != webrtc::State::DISCONNECTED) {
|
||||
if (QMessageBox::question(this, "nheko", "A call is in progress. Log out?") !=
|
||||
QMessageBox::Yes) {
|
||||
return;
|
||||
}
|
||||
WebRTCSession::instance().end();
|
||||
}
|
||||
chat_page_->initiateLogout();
|
||||
});
|
||||
|
||||
showDialog(dialog);
|
||||
}
|
||||
|
||||
bool
|
||||
MainWindow::hasActiveDialogs() const
|
||||
{
|
||||
|
|
|
@ -64,7 +64,6 @@ public:
|
|||
void openCreateRoomDialog(
|
||||
std::function<void(const mtx::requests::CreateRoom &request)> callback);
|
||||
void openJoinRoomDialog(std::function<void(const QString &room_id)> callback);
|
||||
void openLogoutDialog();
|
||||
|
||||
void hideOverlay();
|
||||
void showSolidOverlayModal(QWidget *content, QFlags<Qt::AlignmentFlag> flags = Qt::AlignCenter);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "MainWindow.h"
|
||||
#include "UserSettingsPage.h"
|
||||
#include "Utils.h"
|
||||
#include "WebRTCSession.h"
|
||||
|
||||
Nheko::Nheko()
|
||||
{
|
||||
|
@ -83,9 +84,9 @@ Nheko::showUserSettingsPage() const
|
|||
}
|
||||
|
||||
void
|
||||
Nheko::openLogoutDialog() const
|
||||
Nheko::logout() const
|
||||
{
|
||||
MainWindow::instance()->openLogoutDialog();
|
||||
ChatPage::instance()->initiateLogout();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
Q_INVOKABLE void openLink(QString link) const;
|
||||
Q_INVOKABLE void setStatusMessage(QString msg) const;
|
||||
Q_INVOKABLE void showUserSettingsPage() const;
|
||||
Q_INVOKABLE void openLogoutDialog() const;
|
||||
Q_INVOKABLE void logout() const;
|
||||
Q_INVOKABLE void openCreateRoomDialog() const;
|
||||
Q_INVOKABLE void openJoinRoomDialog() const;
|
||||
Q_INVOKABLE void reparent(QWindow *win) const;
|
||||
|
@ -60,6 +60,8 @@ signals:
|
|||
void colorsChanged();
|
||||
void profileChanged();
|
||||
|
||||
void openLogoutDialog();
|
||||
|
||||
private:
|
||||
QScopedPointer<UserProfile> currentUser_;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue