Refactor: streamline update notification logic and enhance settings dialog for cross-platform compatibility

This commit is contained in:
Vxrtrauter
2026-04-24 10:20:26 +02:00
parent 6b45c40aad
commit 468faff16b
2 changed files with 49 additions and 16 deletions
+2 -3
View File
@@ -79,9 +79,8 @@ def settings_dialog(self):
# Ignore Updates checkbox
update_checkbox_container, update_checkbox = create_widget(QCheckBox, "Ignore Updates: ")
if platform.system() == "Windows":
update_checkbox.setChecked(state.ignore_updates)
update_checkbox.toggled.connect(lambda checked: setattr(state, 'ignore_updates', checked))
update_checkbox.setChecked(state.ignore_updates)
update_checkbox.toggled.connect(lambda checked: setattr(state, 'ignore_updates', checked))
# Autoresume Container Checkbox
autoresume_container, autoresume_checkbox = create_widget(QCheckBox, "Auto-Resume Downloads: ")
+47 -13
View File
@@ -1,13 +1,17 @@
from utils.network.update_checker import get_updates
from PySide6.QtWidgets import QDialog, QMessageBox
from PySide6.QtWidgets import QDialog, QMessageBox, QCheckBox, QDialogButtonBox, QVBoxLayout, QLabel
from utils.network.updater import download_update
from utils.config.config import create_config
from utils.logging.logs import consoleLog
from utils.data.state import state
from pathlib import Path
import webbrowser
import platform
import json
import os
RELEASES_URL = "https://github.com/KeksPirates/SoftwareManager/releases/latest"
def _get_build_info_path() -> (Path | None):
current_dir = Path(__file__).resolve().parent
@@ -31,19 +35,49 @@ def get_version() -> None:
else:
consoleLog(f"Could not find build info file (Path: {build_info_path})")
def _show_notify_dialog(latest: str) -> None:
msg = QMessageBox()
msg.setIcon(QMessageBox.Icon.Information)
msg.setWindowTitle("Update Available")
msg.setText(f"A new version is available: <b>{latest}</b>")
msg.setInformativeText("Visit the releases page to download it.")
dont_show = QCheckBox("Don't show again")
msg.setCheckBox(dont_show)
open_btn = msg.addButton("Open Releases Page", QMessageBox.ButtonRole.AcceptRole)
msg.addButton("Dismiss", QMessageBox.ButtonRole.RejectRole)
msg.exec()
if dont_show.isChecked():
state.ignore_updates = True
create_config()
if msg.clickedButton() == open_btn:
webbrowser.open(RELEASES_URL)
class UpdateDialog(QDialog):
def __init__(self, parent=None):
if state.ignore_updates is False and platform.system() == "Windows":
if state.ignore_updates:
return
assets, latest = get_updates()
if assets != None:
msg = QMessageBox()
msg.setIcon(QMessageBox.Icon.Information)
msg.setWindowTitle("Update Available")
msg.setText(f"A new version is available\n({latest})")
msg.setInformativeText("Press Ok to download.")
msg.setStandardButtons(QMessageBox.StandardButton.Ok | QMessageBox.StandardButton.Ignore)
response = msg.exec_()
if response == QMessageBox.StandardButton.Ok:
download_update(assets)
assets, latest = get_updates()
if assets is None:
return
if platform.system() == "Windows":
msg = QMessageBox()
msg.setIcon(QMessageBox.Icon.Information)
msg.setWindowTitle("Update Available")
msg.setText(f"A new version is available\n({latest})")
msg.setInformativeText("Press Ok to download.")
msg.setStandardButtons(QMessageBox.StandardButton.Ok | QMessageBox.StandardButton.Ignore)
response = msg.exec_()
if response == QMessageBox.StandardButton.Ok:
download_update(assets)
else:
_show_notify_dialog(latest)