From a98d1c7277c1875a309a171bc58f29cc1315ed9e Mon Sep 17 00:00:00 2001 From: k4yt3x Date: Sun, 17 May 2020 10:51:17 -0400 Subject: [PATCH] added stopping confirmation --- src/video2x_gui.py | 36 +++++++++++++++++++++++++++++++----- src/video2x_gui.ui | 9 ++++++--- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/video2x_gui.py b/src/video2x_gui.py index fbcf943..e147d73 100755 --- a/src/video2x_gui.py +++ b/src/video2x_gui.py @@ -4,7 +4,7 @@ Creator: Video2X GUI Author: K4YT3X Date Created: May 5, 2020 -Last Modified: May 15, 2020 +Last Modified: May 17, 2020 """ # local imports @@ -1104,13 +1104,39 @@ You can [submit an issue on GitHub](https://github.com/k4yt3x/video2x/issues/new self.reset_progress_display() def stop(self): - with contextlib.suppress(AttributeError): - self.upscaler.running = False + + try: + # if upscaler is running, ask the user for confirmation + if self.upscaler.running is True: + confirmation = QMessageBox.question(self, + 'Stopping Confirmation', + 'Are you sure you want to want to stop the upscaling process?', + QMessageBox.Yes, + QMessageBox.No) + # if the user indeed wants to stop processing + if confirmation == QMessageBox.Yes: + with contextlib.suppress(AttributeError): + self.upscaler.running = False + return True + # if the user doesn't want ot stop processing + else: + return False + + # if the upscaler is not running + else: + return True + + # if an AttributeError happens + # that means the upscaler object haven't been created yet + except AttributeError: + return True def closeEvent(self, event): # try cleaning up temp directories - self.stop() - event.accept() + if self.stop(): + event.accept() + else: + event.ignore() # this file shouldn't be imported diff --git a/src/video2x_gui.ui b/src/video2x_gui.ui index 628bfaa..16a392c 100644 --- a/src/video2x_gui.ui +++ b/src/video2x_gui.ui @@ -6,7 +6,7 @@ 0 0 - 671 + 673 802 @@ -2103,8 +2103,11 @@ + + Copy streams without re-encoding + - Stream copy (-c copy) + Copy streams (-c copy) true @@ -2529,7 +2532,7 @@ 0 0 - 671 + 673 21