Add auto-update feature with Gitea release checking

- Add UpdateChecker class to query Gitea API for latest releases
- Show update dialog with release notes when new version available
- Open browser to release page for download (handles large files)
- Allow users to skip specific versions or defer updates
- Add "Check for Updates Now" button in settings
- Check automatically on startup (respects 24-hour interval)
- Pre-configured for repo.anhonesthost.net/streamer-tools

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-22 17:40:13 -08:00
parent 89819f5d1b
commit b7ab57f21f
7 changed files with 425 additions and 4 deletions

View File

@@ -528,6 +528,27 @@ class SettingsDialog(QDialog):
remote_group.setLayout(remote_layout)
content_layout.addWidget(remote_group)
# Updates Group
updates_group = QGroupBox("Software Updates")
updates_layout = QFormLayout()
updates_layout.setSpacing(10)
self.update_auto_check = QCheckBox("Enable")
self.update_auto_check.setToolTip(
"Automatically check for updates when the application starts"
)
updates_layout.addRow("Check on Startup:", self.update_auto_check)
self.check_updates_button = QPushButton("Check for Updates Now")
self.check_updates_button.setToolTip(
"Manually check for available updates"
)
self.check_updates_button.clicked.connect(self._check_for_updates_now)
updates_layout.addRow("", self.check_updates_button)
updates_group.setLayout(updates_layout)
content_layout.addWidget(updates_group)
# Add stretch to push everything to the top
content_layout.addStretch()
@@ -779,6 +800,9 @@ class SettingsDialog(QDialog):
self.remote_api_key_input.setText(self.config.get('remote_processing.api_key', ''))
self.remote_fallback_check.setChecked(self.config.get('remote_processing.fallback_to_local', True))
# Update settings
self.update_auto_check.setChecked(self.config.get('updates.auto_check', True))
def _save_settings(self):
"""Save settings to config."""
try:
@@ -851,6 +875,9 @@ class SettingsDialog(QDialog):
self.config.set('remote_processing.api_key', self.remote_api_key_input.text())
self.config.set('remote_processing.fallback_to_local', self.remote_fallback_check.isChecked())
# Update settings
self.config.set('updates.auto_check', self.update_auto_check.isChecked())
# Call save callback (which will show the success message)
if self.on_save:
self.on_save()
@@ -864,3 +891,54 @@ class SettingsDialog(QDialog):
QMessageBox.critical(self, "Invalid Input", f"Please check your input values:\n{e}")
except Exception as e:
QMessageBox.critical(self, "Error", f"Failed to save settings:\n{e}")
def _check_for_updates_now(self):
"""Manually check for updates."""
from version import __version__
from client.update_checker import UpdateChecker
# Get settings from config (hardcoded defaults)
gitea_url = self.config.get('updates.gitea_url', 'https://repo.anhonesthost.net')
owner = self.config.get('updates.owner', 'streamer-tools')
repo = self.config.get('updates.repo', 'local-transcription')
# Disable button during check
self.check_updates_button.setEnabled(False)
self.check_updates_button.setText("Checking...")
try:
checker = UpdateChecker(
current_version=__version__,
gitea_url=gitea_url,
owner=owner,
repo=repo
)
release_info, error = checker.check_for_update()
if error:
QMessageBox.warning(self, "Update Check Failed", f"Could not check for updates:\n{error}")
elif release_info:
# Update available
msg = QMessageBox(self)
msg.setWindowTitle("Update Available")
msg.setIcon(QMessageBox.Information)
msg.setText(f"A new version is available!\n\nCurrent: {__version__}\nNew: {release_info.version}")
if release_info.release_notes:
msg.setDetailedText(release_info.release_notes)
msg.setStandardButtons(QMessageBox.Ok)
msg.exec()
else:
QMessageBox.information(
self,
"No Updates",
f"You are running the latest version ({__version__})."
)
except Exception as e:
QMessageBox.critical(self, "Error", f"Error checking for updates:\n{e}")
finally:
# Re-enable button
self.check_updates_button.setEnabled(True)
self.check_updates_button.setText("Check for Updates Now")