From 101012d9aad963397034988cf2921226bbe6b613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deniz=20=C5=9Eafak?= Date: Fri, 9 May 2025 01:50:09 +0300 Subject: [PATCH] Prevent cancellation if process is at 99% --- CHANGELOG.md | 1 + abogen/gui.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8f705a..0dcb9fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # v1.0.7 (pre-release) - Improve chaptered audio generation by outputting directly as `m4b` instead of converting from `wav`. - Ignore chapter markers and single newlines when calculating text length, improving the accuracy of the text length calculation. +- Prevent cancellation if process is at 99%, ensuring the process is not interrupted at the last moment. - Added `.opus` as output format for generated audio files. - Added "Playing..." indicator for "Preview" button in the voice mixer. diff --git a/abogen/gui.py b/abogen/gui.py index b7514af..7f1cd1d 100644 --- a/abogen/gui.py +++ b/abogen/gui.py @@ -1127,12 +1127,20 @@ class abogen(QWidget): QApplication.processEvents() def update_progress(self, value, etr_str): # Add etr_str parameter + # Ensure progress doesn't exceed 99% + if value >= 100: + value = 99 self.progress_bar.setValue(value) self.progress_bar.setFormat("%p%") # Keep format as percentage only self.etr_label.setText( f"Estimated time remaining: {etr_str}" ) # Update ETR label self.etr_label.show() # Show only when estimate is ready + + # Disable cancel button if progress is >= 98% + if value >= 98: + self.btn_cancel.setEnabled(False) + self.progress_bar.repaint() QApplication.processEvents()