Merge pull request #743 from LorenDB/qmlLogout

QML the logout dialog
This commit is contained in:
DeepBlueV7.X 2021-10-09 20:57:38 +00:00 committed by GitHub
commit 7eb9071b50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 42 additions and 23 deletions

View file

@ -111,6 +111,13 @@ Page {
} }
Component {
id: logoutDialog
LogoutDialog {
}
}
Shortcut { Shortcut {
sequence: "Ctrl+K" sequence: "Ctrl+K"
onActivated: { onActivated: {
@ -135,6 +142,15 @@ Page {
onActivated: Rooms.previousRoom() onActivated: Rooms.previousRoom()
} }
Connections {
function onOpenLogoutDialog() {
var dialog = logoutDialog.createObject(timelineRoot);
dialog.open();
}
target: Nheko
}
Connections { Connections {
function onNewDeviceVerificationRequest(flow) { function onNewDeviceVerificationRequest(flow) {
var dialog = deviceVerificationDialog.createObject(timelineRoot, { var dialog = deviceVerificationDialog.createObject(timelineRoot, {

View 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()
}

View file

@ -184,6 +184,7 @@
<file>qml/dialogs/RoomMembers.qml</file> <file>qml/dialogs/RoomMembers.qml</file>
<file>qml/dialogs/RoomSettings.qml</file> <file>qml/dialogs/RoomSettings.qml</file>
<file>qml/dialogs/UserProfile.qml</file> <file>qml/dialogs/UserProfile.qml</file>
<file>qml/dialogs/LogoutDialog.qml</file>
</qresource> </qresource>
<qresource prefix="/media"> <qresource prefix="/media">
<file>media/ring.ogg</file> <file>media/ring.ogg</file>

View file

@ -35,7 +35,6 @@
#include "dialogs/CreateRoom.h" #include "dialogs/CreateRoom.h"
#include "dialogs/JoinRoom.h" #include "dialogs/JoinRoom.h"
#include "dialogs/LeaveRoom.h" #include "dialogs/LeaveRoom.h"
#include "dialogs/Logout.h"
MainWindow *MainWindow::instance_ = nullptr; MainWindow *MainWindow::instance_ = nullptr;
@ -372,24 +371,6 @@ MainWindow::showSolidOverlayModal(QWidget *content, QFlags<Qt::AlignmentFlag> fl
modal_->show(); 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 bool
MainWindow::hasActiveDialogs() const MainWindow::hasActiveDialogs() const
{ {

View file

@ -64,7 +64,6 @@ public:
void openCreateRoomDialog( void openCreateRoomDialog(
std::function<void(const mtx::requests::CreateRoom &request)> callback); std::function<void(const mtx::requests::CreateRoom &request)> callback);
void openJoinRoomDialog(std::function<void(const QString &room_id)> callback); void openJoinRoomDialog(std::function<void(const QString &room_id)> callback);
void openLogoutDialog();
void hideOverlay(); void hideOverlay();
void showSolidOverlayModal(QWidget *content, QFlags<Qt::AlignmentFlag> flags = Qt::AlignCenter); void showSolidOverlayModal(QWidget *content, QFlags<Qt::AlignmentFlag> flags = Qt::AlignCenter);

View file

@ -14,6 +14,7 @@
#include "MainWindow.h" #include "MainWindow.h"
#include "UserSettingsPage.h" #include "UserSettingsPage.h"
#include "Utils.h" #include "Utils.h"
#include "WebRTCSession.h"
Nheko::Nheko() Nheko::Nheko()
{ {
@ -83,9 +84,9 @@ Nheko::showUserSettingsPage() const
} }
void void
Nheko::openLogoutDialog() const Nheko::logout() const
{ {
MainWindow::instance()->openLogoutDialog(); ChatPage::instance()->initiateLogout();
} }
void void

View file

@ -48,7 +48,7 @@ public:
Q_INVOKABLE void openLink(QString link) const; Q_INVOKABLE void openLink(QString link) const;
Q_INVOKABLE void setStatusMessage(QString msg) const; Q_INVOKABLE void setStatusMessage(QString msg) const;
Q_INVOKABLE void showUserSettingsPage() const; Q_INVOKABLE void showUserSettingsPage() const;
Q_INVOKABLE void openLogoutDialog() const; Q_INVOKABLE void logout() const;
Q_INVOKABLE void openCreateRoomDialog() const; Q_INVOKABLE void openCreateRoomDialog() const;
Q_INVOKABLE void openJoinRoomDialog() const; Q_INVOKABLE void openJoinRoomDialog() const;
Q_INVOKABLE void reparent(QWindow *win) const; Q_INVOKABLE void reparent(QWindow *win) const;
@ -60,6 +60,8 @@ signals:
void colorsChanged(); void colorsChanged();
void profileChanged(); void profileChanged();
void openLogoutDialog();
private: private:
QScopedPointer<UserProfile> currentUser_; QScopedPointer<UserProfile> currentUser_;
}; };