diff options
author | trilene <trilene@runbox.com> | 2020-07-23 17:20:32 -0400 |
---|---|---|
committer | trilene <trilene@runbox.com> | 2020-07-23 17:20:32 -0400 |
commit | 7377215d28df70ca365a843a6a05f4f28c6c403a (patch) | |
tree | ac5225c7b7b4de8d7202c821c16a533dc5b82610 /src/MainWindow.cpp | |
parent | Tweak ActiveCallBar (diff) | |
download | nheko-7377215d28df70ca365a843a6a05f4f28c6c403a.tar.xz |
Confirm logout/quit if active call in progress
Diffstat (limited to 'src/MainWindow.cpp')
-rw-r--r-- | src/MainWindow.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index cc1d868b..4dab3d26 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -17,6 +17,7 @@ #include <QApplication> #include <QLayout> +#include <QMessageBox> #include <QPluginLoader> #include <QSettings> #include <QShortcut> @@ -35,6 +36,7 @@ #include "TrayIcon.h" #include "UserSettingsPage.h" #include "Utils.h" +#include "WebRTCSession.h" #include "WelcomePage.h" #include "ui/LoadingIndicator.h" #include "ui/OverlayModal.h" @@ -285,6 +287,14 @@ MainWindow::showChatPage() void MainWindow::closeEvent(QCloseEvent *event) { + if (WebRTCSession::instance().state() != WebRTCSession::State::DISCONNECTED) { + if (QMessageBox::question(this, "nheko", "A call is in progress. Quit?") != + QMessageBox::Yes) { + event->ignore(); + return; + } + } + if (!qApp->isSavingSession() && isVisible() && pageSupportsTray() && userSettings_->tray()) { event->ignore(); @@ -433,8 +443,17 @@ void MainWindow::openLogoutDialog() { auto dialog = new dialogs::Logout(this); - connect( - dialog, &dialogs::Logout::loggingOut, this, [this]() { chat_page_->initiateLogout(); }); + connect(dialog, &dialogs::Logout::loggingOut, this, [this]() { + if (WebRTCSession::instance().state() != WebRTCSession::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); } |