Compare commits

...

4 Commits

6 changed files with 56 additions and 29 deletions
+5 -1
View File
@@ -66,8 +66,12 @@ jobs:
pip install -r requirements.txt pip install -r requirements.txt
pip install pyinstaller pip install pyinstaller
- name: Inject commit hash into code
run: |
echo "version = '${GITHUB_SHA}'" > build_info.json
- name: Build executable with PyInstaller - name: Build executable with PyInstaller
run: pyinstaller --onefile --windowed --name ${{ env.APP_NAME }} main.py run: pyinstaller --onefile --windowed --add-data "build_info.json:." --name ${{ env.APP_NAME }} main.py
- name: Make executable (Unix) - name: Make executable (Unix)
if: runner.os != 'Windows' if: runner.os != 'Windows'
+16 -5
View File
@@ -10,12 +10,10 @@ from PySide6.QtWidgets import (
QLabel, QLabel,
QHBoxLayout, QHBoxLayout,
QSpinBox, QSpinBox,
QCheckBox,
) )
def settings_dialog(self): def settings_dialog(self):
if state.debug: if state.debug:
@@ -29,7 +27,20 @@ def settings_dialog(self):
def close_settings(): def close_settings():
dialog.reject() 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 # # THREAD SETTING #
################## ##################
@@ -119,4 +130,4 @@ def settings_dialog(self):
dialog.layout().addLayout(layout) dialog.layout().addLayout(layout)
dialog.exec() dialog.exec()
+22 -15
View File
@@ -28,6 +28,7 @@ import os
import subprocess import subprocess
import time import time
import sys import sys
import json
from core.utils.config.settings import save_settings from core.utils.config.settings import save_settings
from core.utils.general.wrappers import run_thread from core.utils.general.wrappers import run_thread
from core.utils.data.state import state from core.utils.data.state import state
@@ -39,7 +40,7 @@ from core.interface.utils.searchhelper import return_pressed
from core.interface.dialogs.settings import settings_dialog from core.interface.dialogs.settings import settings_dialog
from core.network.aria2_integration import dlprogress from core.network.aria2_integration import dlprogress
def download_update(latest_version): def download_update():
filename = "SoftwareManager-dev-windows.exe" filename = "SoftwareManager-dev-windows.exe"
url = "https://github.com/KeksPirates/SoftwareManager/releases/latest/download/SoftwareManager-dev-windows.exe" url = "https://github.com/KeksPirates/SoftwareManager/releases/latest/download/SoftwareManager-dev-windows.exe"
@@ -53,29 +54,35 @@ def download_update(latest_version):
raise FileNotFoundError(f"Executable not found") raise FileNotFoundError(f"Executable not found")
subprocess.Popen([filename], shell=True) subprocess.Popen([filename], shell=True)
time.sleep(0.5) time.sleep(0.5)
save_settings(version=latest_version)
sys.exit(0) sys.exit(0)
class MainWindow(QtWidgets.QMainWindow, QWidget): class MainWindow(QtWidgets.QMainWindow, QWidget):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
build_info_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "build_info.json")
if os.path.exists(build_info_path):
with open(build_info_path, "r") as f:
build_info = json.load(f)
state.version = build_info.get("version", "dev")
# Check for updates on Windows # Check for updates on Windows
if platform.system() == "Windows": if state.ignore_updates is False:
result = check_for_updates() if platform.system() == "Windows":
assets, latest_version = result result = check_for_updates()
assets, latest_version = result
if assets: if assets:
msg = QMessageBox() msg = QMessageBox()
msg.setIcon(QMessageBox.Information) msg.setIcon(QMessageBox.Information)
msg.setWindowTitle("Update Available") msg.setWindowTitle("Update Available")
msg.setText(f"A new version is available.") msg.setText(f"A new version is available.")
msg.setInformativeText("Please visit the GitHub releases page to download the latest version.") msg.setInformativeText("Please visit the GitHub releases page to download the latest version.")
msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Ignore) msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Ignore)
response = msg.exec_() response = msg.exec_()
if response == QMessageBox.Ok: if response == QMessageBox.Ok:
download_update(latest_version) download_update(latest_version)
self.setWindowTitle("Software Manager") self.setWindowTitle("Software Manager")
self.setGeometry(100, 100, 800, 600) self.setGeometry(100, 100, 800, 600)
+3 -3
View File
@@ -6,8 +6,8 @@ from core.utils.data.state import state
def create_config(): def create_config():
config = configparser.ConfigParser() 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}", 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}"} "ignore_updates": f"{state.ignore_updates}"}
if platform.system() == "Windows": if platform.system() == "Windows":
config_dir = os.environ.get("APPDATA", os.path.expanduser("~\\AppData\\Roaming")) config_dir = os.environ.get("APPDATA", os.path.expanduser("~\\AppData\\Roaming"))
@@ -42,4 +42,4 @@ def read_config():
state.aria2_threads = config.getint("General", "aria2_threads") state.aria2_threads = config.getint("General", "aria2_threads")
state.download_path = config.get("General", "download_path") state.download_path = config.get("General", "download_path")
state.speed_limit = config.getint("General", "speed_limit") state.speed_limit = config.getint("General", "speed_limit")
state.version = config.get("General", "version") state.ignore_updates = config.getboolean("General", "ignore_updates")
+9 -5
View File
@@ -13,11 +13,15 @@ def restart_aria2c():
atexit.unregister(kill_aria2server) atexit.unregister(kill_aria2server)
atexit.register(kill_aria2server) atexit.register(kill_aria2server)
def save_settings(thread_count, close, apiurl, download_path, speed_limit): def save_settings(thread_count=None, close=lambda: None, apiurl=None, download_path=None, speed_limit=None):
state.aria2_threads = thread_count if thread_count is not None:
state.api_url = apiurl state.aria2_threads = thread_count
state.download_path = download_path if apiurl is not None:
state.speed_limit = speed_limit state.api_url = apiurl
if download_path is not None:
state.download_path = download_path
if speed_limit is not None:
state.speed_limit = speed_limit
create_config() create_config()
restart_aria2c() restart_aria2c()
+1
View File
@@ -10,6 +10,7 @@ class AppState:
post_author: List[str] post_author: List[str]
downloads: List[str] downloads: List[str]
version: str version: str
ignore_updates: bool = False
debug: bool = False debug: bool = False
tracker: str = "rutracker" tracker: str = "rutracker"
api_url: str = "https://api.michijackson.xyz" api_url: str = "https://api.michijackson.xyz"