Fix progress bar estimation and GUI responsiveness during copy stage

Progress Estimation Improvements:
- Changed re-estimation interval from 10 seconds to 5 seconds for more frequent updates
- Multiplied initial time estimation by 4 to make it more conservative and realistic
- Better accuracy for long-running copy operations with more frequent recalculations

GUI Responsiveness Fix:
- Added QApplication.processEvents() calls in the copy loop to keep GUI responsive
- Exit button and other UI elements now remain interactive during copy operations
- Prevents blocking calls that would freeze the interface during file copying

Technical Details:
- Re-estimation now occurs every 5 seconds instead of 10 seconds
- Initial estimation multiplied by 4 for more conservative time prediction
- GUI event processing integrated into copy loop to maintain responsiveness
- Progress text now shows '5-second estimation' instead of '10-second estimation'
parent 1e71d54c
......@@ -749,9 +749,9 @@ class InstallerWorker(QThread):
self.log(f"Estimated total size to copy: {total_bytes} bytes ({total_bytes // (1024*1024)} MB)")
# Estimate copy time based on typical speeds (50-200 MB/s for modern systems)
# Use conservative estimate of 100 MB/s
estimated_copy_time = total_bytes / (100 * 1024 * 1024) # seconds
self.log(f"Estimated copy time: {estimated_copy_time:.1f} seconds")
# Use conservative estimate of 100 MB/s, multiplied by 4 for more realistic estimation
estimated_copy_time = (total_bytes / (100 * 1024 * 1024)) * 4 # seconds
self.log(f"Estimated copy time: {estimated_copy_time:.1f} seconds (conservative estimate)")
except (subprocess.CalledProcessError, ValueError, IndexError):
# Fallback to time-based estimation if du fails
......@@ -847,8 +847,8 @@ class InstallerWorker(QThread):
current_time = time.time()
elapsed_time = current_time - start_time
# Re-estimate progress every 10 seconds based on actual transfer rate
if current_time - last_reestimate_time >= 10.0 and bytes_copied > last_reestimate_bytes:
# Re-estimate progress every 5 seconds based on actual transfer rate
if current_time - last_reestimate_time >= 5.0 and bytes_copied > last_reestimate_bytes:
bytes_since_last = bytes_copied - last_reestimate_bytes
time_since_last = current_time - last_reestimate_time
......@@ -859,7 +859,7 @@ class InstallerWorker(QThread):
new_estimated_time = remaining_bytes / current_rate
estimated_copy_time = elapsed_time + new_estimated_time
# Update progress text with 10-second estimation
# Update progress text with 5-second estimation
rate_mb_s = current_rate / (1024 * 1024)
remaining_mb = remaining_bytes / (1024 * 1024)
eta_minutes = int(new_estimated_time // 60)
......@@ -911,6 +911,15 @@ class InstallerWorker(QThread):
# Allow GUI event processing by yielding control
time.sleep(0.01)
# Process GUI events to keep interface responsive during copy
try:
from PyQt6.QtWidgets import QApplication
app = QApplication.instance()
if app:
app.processEvents()
except ImportError:
pass
# Check return code
if process.returncode != 0:
raise subprocess.CalledProcessError(process.returncode, cmd)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment