Fix UI sizing and progress estimation issues

- Reduce UI element sizes to fit within screen bounds in fullscreen mode
- Add margins to fullscreen geometry to prevent window overflow
- Make log and copy progress text areas more compact
- Improve progress estimation to prevent jumping to 82% too quickly
- Use more conservative time estimates (50 MB/s instead of 100 MB/s)
- Cap data-based progress at 75% initially to prevent premature completion
- Add gradual progress completion at the end to avoid sudden jumps
- Reduce spacing and margins in layout for better screen fit

This ensures the fullscreen window fits properly on screen and provides
more accurate, gradual progress updates during the copy operation.
parent fb22c36f
......@@ -750,8 +750,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, multiplied by 10 for more realistic estimation
estimated_copy_time = (total_bytes / (100 * 1024 * 1024)) * 10 # seconds
# Use very conservative estimate of 50 MB/s for more realistic estimation
# This accounts for slower USB drives and system overhead
estimated_copy_time = total_bytes / (50 * 1024 * 1024) # seconds
self.log(f"Estimated copy time: {estimated_copy_time:.1f} seconds (conservative estimate)")
except (subprocess.CalledProcessError, ValueError, IndexError):
......@@ -881,23 +882,25 @@ class InstallerWorker(QThread):
# Calculate progress based on actual bytes copied vs total bytes
if total_bytes and bytes_copied > 0:
# Use actual data transfer progress for more accurate calculation
data_progress = min(bytes_copied / total_bytes, 0.95) # Cap at 95% to leave room for final steps
# Be more conservative - don't let it reach 82% too quickly
data_progress = min(bytes_copied / total_bytes, 0.75) # Cap at 75% initially
current_progress = copy_progress_start + (data_progress * copy_progress_range)
else:
# Fallback to time-based estimation when we don't have byte information
if estimated_copy_time > 0:
# Use the re-estimated copy time for more accurate progression
time_progress = min(elapsed_time / estimated_copy_time, 0.95)
# Be more conservative with time-based estimation too
time_progress = min(elapsed_time / estimated_copy_time, 0.7) # Cap at 70%
else:
# Fallback to adaptive time-based estimation
if elapsed_time < 60: # First minute: 0-40% of copy progress
time_progress = (elapsed_time / 60) * 0.4
elif elapsed_time < 120: # Next minute: 40-70% of copy progress
time_progress = 0.4 + ((elapsed_time - 60) / 60) * 0.3
elif elapsed_time < 240: # Next 2 minutes: 70-90% of copy progress
time_progress = 0.7 + ((elapsed_time - 120) / 120) * 0.2
else: # After 4 minutes: 90-95% of copy progress
time_progress = 0.9 + min((elapsed_time - 240) / 120, 0.05)
if elapsed_time < 60: # First minute: 0-30% of copy progress
time_progress = (elapsed_time / 60) * 0.3
elif elapsed_time < 120: # Next minute: 30-55% of copy progress
time_progress = 0.3 + ((elapsed_time - 60) / 60) * 0.25
elif elapsed_time < 240: # Next 2 minutes: 55-75% of copy progress
time_progress = 0.55 + ((elapsed_time - 120) / 120) * 0.2
else: # After 4 minutes: 75-80% of copy progress
time_progress = 0.75 + min((elapsed_time - 240) / 120, 0.05)
current_progress = copy_progress_start + (time_progress * copy_progress_range)
......@@ -942,6 +945,16 @@ class InstallerWorker(QThread):
raise subprocess.CalledProcessError(process.returncode, cmd)
# Ensure we reach the end of copy progress range
# Gradually increase to 85% to avoid sudden jumps
if hasattr(self, '_last_progress') and self._last_progress < copy_progress_end:
# Fill in the remaining progress gradually
remaining_progress = copy_progress_end - self._last_progress
steps = 5
for i in range(1, steps + 1):
intermediate_progress = self._last_progress + (remaining_progress * i / steps)
self.progress_updated.emit(int(intermediate_progress))
time.sleep(0.1) # Small delay for visual effect
self.progress_updated.emit(copy_progress_end)
self.log("System copy completed successfully")
......@@ -1241,7 +1254,11 @@ class AutoInstallerGUI(QMainWindow):
central_widget = QWidget()
scroll_area.setWidget(central_widget)
self.setCentralWidget(scroll_area)
# Use a more compact layout to fit within screen bounds
layout = QVBoxLayout(central_widget)
layout.setSpacing(5) # Reduce spacing between elements
layout.setContentsMargins(10, 10, 10, 10) # Add some margins
# Header
header = QLabel("MBetter Offline Automatic Installer")
......@@ -1329,19 +1346,20 @@ class AutoInstallerGUI(QMainWindow):
self.progress_bar.setRange(0, 100)
layout.addWidget(self.progress_bar)
# Log Output
# Log Output - make it more compact
self.log_text = QTextEdit()
self.log_text.setReadOnly(True)
self.log_text.setMaximumHeight(150)
self.log_text.setMaximumHeight(120) # Reduced from 150
layout.addWidget(self.log_text)
# Copy Progress Output (small text area for rsync details)
# Copy Progress Output (small text area for rsync details) - make it more compact
copy_group = QGroupBox("Copy Progress Details")
copy_layout = QVBoxLayout(copy_group)
copy_layout.setContentsMargins(5, 5, 5, 5) # Reduce margins
self.copy_progress_text = QTextEdit()
self.copy_progress_text.setReadOnly(True)
self.copy_progress_text.setMaximumHeight(60)
self.copy_progress_text.setFont(QFont("Monospace", 8))
self.copy_progress_text.setMaximumHeight(50) # Reduced from 60
self.copy_progress_text.setFont(QFont("Monospace", 7)) # Smaller font
copy_layout.addWidget(self.copy_progress_text)
layout.addWidget(copy_group)
......@@ -1680,8 +1698,13 @@ def main():
screen = app.primaryScreen()
available_geometry = screen.availableGeometry()
# Set window geometry to available screen space (excluding taskbars/panels)
window.setGeometry(available_geometry)
# Ensure window fits within screen bounds by using a slightly smaller size
# Leave some margin to account for window decorations and ensure it fits
margin = 20 # pixels to leave as margin
adjusted_geometry = available_geometry.adjusted(margin, margin, -margin, -margin)
# Set window geometry to adjusted screen space
window.setGeometry(adjusted_geometry)
window.showFullScreen()
else:
window.show()
......
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