aboutsummaryrefslogtreecommitdiffstats
path: root/test_upscale_qt.py
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-30 19:46:12 +0100
committerDanilo M. <danix@danix.xyz>2026-10-30 19:46:12 +0100
commit1953399f9bf0cf18ba54961583632d703eeaa07e (patch)
treec25283c05705137b2926d4ad466922d53f8d8f12 /test_upscale_qt.py
parent27dc1b71ff62dd4e8d91de239bc5ad70c1bc7428 (diff)
downloadupscale-qt-1953399f9bf0cf18ba54961583632d703eeaa07e.tar.gz
upscale-qt-1953399f9bf0cf18ba54961583632d703eeaa07e.zip
Add Ctrl+Q and ask before quitting with an unsaved upscale
Quit and window close share closeEvent, so both ask. The unsaved check moves into discard_ok, used by Clear as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'test_upscale_qt.py')
-rw-r--r--test_upscale_qt.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/test_upscale_qt.py b/test_upscale_qt.py
index 66423e8..7175e92 100644
--- a/test_upscale_qt.py
+++ b/test_upscale_qt.py
@@ -114,6 +114,25 @@ def test_main_window():
assert not w.a_clear.isEnabled() and not w.a_up.isEnabled()
+def test_quit_asks_when_unsaved():
+ from PyQt6.QtWidgets import QMessageBox
+ w = uq.Main()
+ assert w.a_quit.shortcut().toString() == 'Ctrl+Q'
+ path = os.path.join(TMP, 'q.png')
+ QImage(4, 4, QImage.Format.Format_RGB32).save(path)
+ w.load(path)
+ w.jobs[0].result = QImage(16, 16, QImage.Format.Format_RGB32)
+ answers = []
+ real = QMessageBox.question
+ try:
+ QMessageBox.question = lambda *a: answers.append(a) or QMessageBox.StandardButton.No
+ 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
+ finally:
+ QMessageBox.question = real
+
+
if __name__ == '__main__':
for name, fn in list(globals().items()):
if name.startswith('test_'):