From c088e442e8699f9461e74a8c94697e8c8d37d6dc Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 30 Oct 2026 19:46:45 +0100 Subject: Ask before quitting while an upscale runs Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- test_upscale_qt.py | 4 ++++ upscale-qt | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 71ae4a0..81f322f 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Small PyQt6 app to upscale an image with an ESRGAN model through `sd-cli` (stabl - Save As (Ctrl+Shift+S) writes a new file. Overwrite replaces the original after a confirmation, in the same format. EXIF metadata is not kept. - Clear (Ctrl+W) empties the view and deletes the temp files. It asks first if the upscaled image was not saved. - Settings holds the upscalers folder. -- Ctrl+Q quits. Quitting or closing the window asks first if the upscaled image was not saved. +- Ctrl+Q quits. Quitting or closing the window asks first if an upscale is running or the upscaled image was not saved. ### Model descriptions diff --git a/test_upscale_qt.py b/test_upscale_qt.py index 7175e92..37e0484 100644 --- a/test_upscale_qt.py +++ b/test_upscale_qt.py @@ -129,6 +129,10 @@ def test_quit_asks_when_unsaved(): assert not w.close() and len(answers) == 1 # declined, stays open w.jobs[0].saved = True assert w.close() and len(answers) == 1 # saved, no question + w.what = 'upscale' # pretend sd-cli runs + assert not w.close() and len(answers) == 2 # declined, stays open + QMessageBox.question = lambda *a: answers.append(a) or QMessageBox.StandardButton.Yes + assert w.close() and len(answers) == 3 finally: QMessageBox.question = real diff --git a/upscale-qt b/upscale-qt index 3515a1b..5b7ffad 100755 --- a/upscale-qt +++ b/upscale-qt @@ -424,6 +424,11 @@ class Main(QMainWindow): self.reload_models() def closeEvent(self, e): + if self.what is not None and QMessageBox.question( + self, 'Quit', 'An upscale is still running. Stop it and quit?' + ) != QMessageBox.StandardButton.Yes: + e.ignore() + return if not self.discard_ok('Quit'): e.ignore() return -- cgit v1.2.3