diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-30 19:46:45 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-30 19:46:45 +0100 |
| commit | c088e442e8699f9461e74a8c94697e8c8d37d6dc (patch) | |
| tree | 29b8aa42480daeb19dc9354093b42a510d77cb66 | |
| parent | 1953399f9bf0cf18ba54961583632d703eeaa07e (diff) | |
| download | upscale-qt-c088e442e8699f9461e74a8c94697e8c8d37d6dc.tar.gz upscale-qt-c088e442e8699f9461e74a8c94697e8c8d37d6dc.zip | |
Ask before quitting while an upscale runs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | test_upscale_qt.py | 4 | ||||
| -rwxr-xr-x | upscale-qt | 5 |
3 files changed, 10 insertions, 1 deletions
@@ -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 @@ -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 |
