From 17c342bf61292ed8d11cede11cc04a84dfc2fe5c Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sat, 7 Feb 2015 03:39:16 -0800 Subject: [PATCH] UI: If active, prompt user before exiting Precautionary measure to prevent the user from accidentally clicking the 'exit' buttons --- obs/data/locale/en-US.ini | 4 ++++ obs/window-basic-main.cpp | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/obs/data/locale/en-US.ini b/obs/data/locale/en-US.ini index df1f5a8e1..65e11e9ce 100644 --- a/obs/data/locale/en-US.ini +++ b/obs/data/locale/en-US.ini @@ -34,6 +34,10 @@ NameExists.Text="The name is already in use." NoNameEntered.Title="Please enter a valid name" NoNameEntered.Text="You cannot use empty names." +# confirm exit dialog box +ConfirmExit.Title="Exit OBS?" +ConfirmExit.Text="OBS is currently active. Are you sure you wish to exit?" + # confirm delete dialog box ConfirmRemove.Title="Confirm Remove" ConfirmRemove.Text="Are you sure you wish to remove '$1'?" diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp index af3054d8e..0e4473ee1 100644 --- a/obs/window-basic-main.cpp +++ b/obs/window-basic-main.cpp @@ -1543,6 +1543,17 @@ void OBSBasic::ResizePreview(uint32_t cx, uint32_t cy) void OBSBasic::closeEvent(QCloseEvent *event) { + if (outputHandler && outputHandler->Active()) { + QMessageBox::StandardButton button = QMessageBox::question( + this, QTStr("ConfirmExit.Title"), + QTStr("ConfirmExit.Text")); + + if (button == QMessageBox::No) { + event->ignore(); + return; + } + } + QWidget::closeEvent(event); if (!event->isAccepted()) return;