From 813d2b31c4375178145c01a4dba377a614f832b3 Mon Sep 17 00:00:00 2001 From: KeksNino Date: Sun, 19 Oct 2025 04:05:57 +0200 Subject: [PATCH] add setting to ignore updates on windows --- core/interface/dialogs/settings.py | 21 ++++++++++++++++----- core/interface/gui.py | 27 ++++++++++++++------------- core/utils/config/config.py | 3 ++- core/utils/data/state.py | 1 + 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/core/interface/dialogs/settings.py b/core/interface/dialogs/settings.py index cba35fc..038af6d 100644 --- a/core/interface/dialogs/settings.py +++ b/core/interface/dialogs/settings.py @@ -10,12 +10,10 @@ from PySide6.QtWidgets import ( QLabel, QHBoxLayout, QSpinBox, + QCheckBox, ) - - - def settings_dialog(self): if state.debug: @@ -29,7 +27,20 @@ def settings_dialog(self): def close_settings(): dialog.reject() - + + checkbox_container = QWidget() + checkbox_layout = QHBoxLayout() + + # ignore updates checkbox + checkbox = QCheckBox() + checkbox_container.setLayout(checkbox_layout) + checkbox_layout.addWidget(QLabel("Ignore Updates: ")) + checkbox_layout.addStretch() + checkbox.setChecked(state.ignore_updates) + checkbox.toggled.connect(lambda checked: setattr(state, 'ignore_updates', checked)) + checkbox_layout.addWidget(checkbox) + dialog.layout().addWidget(checkbox_container) + ################## # THREAD SETTING # ################## @@ -119,4 +130,4 @@ def settings_dialog(self): dialog.layout().addLayout(layout) - dialog.exec() \ No newline at end of file + dialog.exec() diff --git a/core/interface/gui.py b/core/interface/gui.py index 44ed640..d206c3d 100644 --- a/core/interface/gui.py +++ b/core/interface/gui.py @@ -61,21 +61,22 @@ class MainWindow(QtWidgets.QMainWindow, QWidget): super().__init__() # Check for updates on Windows - if platform.system() == "Windows": - result = check_for_updates() - assets, latest_version = result + if state.ignore_updates is False: + if platform.system() == "Windows": + result = check_for_updates() + assets, latest_version = result - if assets: - msg = QMessageBox() - msg.setIcon(QMessageBox.Information) - msg.setWindowTitle("Update Available") - msg.setText(f"A new version is available.") - msg.setInformativeText("Please visit the GitHub releases page to download the latest version.") - msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Ignore) + if assets: + msg = QMessageBox() + msg.setIcon(QMessageBox.Information) + msg.setWindowTitle("Update Available") + msg.setText(f"A new version is available.") + msg.setInformativeText("Please visit the GitHub releases page to download the latest version.") + msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Ignore) - response = msg.exec_() - if response == QMessageBox.Ok: - download_update(latest_version) + response = msg.exec_() + if response == QMessageBox.Ok: + download_update(latest_version) self.setWindowTitle("Software Manager") self.setGeometry(100, 100, 800, 600) diff --git a/core/utils/config/config.py b/core/utils/config/config.py index 0016fe8..c816d3e 100644 --- a/core/utils/config/config.py +++ b/core/utils/config/config.py @@ -7,7 +7,7 @@ def create_config(): config = configparser.ConfigParser() config["General"] = {"debug": True, "api_url": f"{state.api_url}", "aria2_threads": f"{state.aria2_threads}", "download_path": f"{state.download_path}", f"speed_limit": f"{state.speed_limit}", - "version": f"{state.version}"} + "version": f"{state.version}", "ignore_updates": f"{state.ignore_updates}"} if platform.system() == "Windows": config_dir = os.environ.get("APPDATA", os.path.expanduser("~\\AppData\\Roaming")) @@ -43,3 +43,4 @@ def read_config(): state.download_path = config.get("General", "download_path") state.speed_limit = config.getint("General", "speed_limit") state.version = config.get("General", "version") + state.ignore_updates = config.getboolean("General", "ignore_updates") diff --git a/core/utils/data/state.py b/core/utils/data/state.py index 17e7e3d..19159fe 100644 --- a/core/utils/data/state.py +++ b/core/utils/data/state.py @@ -10,6 +10,7 @@ class AppState: post_author: List[str] downloads: List[str] version: str + ignore_updates: bool = False debug: bool = False tracker: str = "rutracker" api_url: str = "https://api.michijackson.xyz"