Compare commits

...

6 Commits

Author SHA1 Message Date
KeksNino 87c974f124 add build_info.json to workflow for win updater 2025-10-19 15:58:16 +02:00
KeksNino 95a687ddd9 fix updater 2025-10-19 04:07:41 +02:00
KeksNino 813d2b31c4 add setting to ignore updates on windows 2025-10-19 04:05:57 +02:00
Vxrtrauter deb5ce5b88 fixed aria2 killing issues on settings close 2025-10-19 03:53:52 +02:00
Vxrtrauter a11c1d7129 added dev release for version check 2025-10-19 03:23:37 +02:00
Vxrtrauter dcc78ade44 fixed qtablewidget colors 2025-10-19 03:13:08 +02:00
7 changed files with 69 additions and 56 deletions
+5 -1
View File
@@ -66,8 +66,12 @@ jobs:
pip install -r requirements.txt
pip install pyinstaller
- name: Inject commit hash into code
run: |
echo "version = '${GITHUB_SHA}'" > build_info.json
- 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)
if: runner.os != 'Windows'
+16 -5
View File
@@ -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()
dialog.exec()
+30 -16
View File
@@ -16,9 +16,10 @@ from PySide6.QtWidgets import (
QHeaderView,
QMessageBox,
QTableWidget,
QTableWidgetItem,
QTableWidgetItem
)
from PySide6.QtGui import QIcon, QAction, QCloseEvent
from PySide6.QtGui import QIcon, QAction, QCloseEvent, QPalette
import darkdetect
import threading
import platform
@@ -27,6 +28,7 @@ import os
import subprocess
import time
import sys
import json
from core.utils.config.settings import save_settings
from core.utils.general.wrappers import run_thread
from core.utils.data.state import state
@@ -52,29 +54,34 @@ def download_update(latest_version):
raise FileNotFoundError(f"Executable not found")
subprocess.Popen([filename], shell=True)
time.sleep(0.5)
save_settings(version=latest_version)
sys.exit(0)
class MainWindow(QtWidgets.QMainWindow, QWidget):
def __init__(self):
super().__init__()
build_info_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "build_info.json")
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
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)
@@ -109,6 +116,9 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
self.qtablewidget.verticalHeader().setVisible(False)
self.qtablewidget.setHorizontalHeaderLabels(["Post Title", "Author"])
self.qtablewidget.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch)
self.qtablewidget.setAttribute(Qt.WA_TranslucentBackground)
self.qtablewidget.viewport().setAttribute(Qt.WA_TranslucentBackground)
header = self.qtablewidget.horizontalHeader()
header.setSectionResizeMode(1, QHeaderView.Fixed)
header.resizeSection(1, 500)
@@ -158,6 +168,8 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
self.downloadList.horizontalHeader().setStretchLastSection(False)
self.downloadList.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch)
self.downloadList.setSelectionBehavior(QTableView.SelectRows)
self.downloadList.setAttribute(Qt.WA_TranslucentBackground)
self.downloadList.viewport().setAttribute(Qt.WA_TranslucentBackground)
# download button triggers
self.dlbutton.clicked.connect(lambda: run_thread(threading.Thread(target=download_selected, args=(self.qtablewidget.currentItem(), state.posts, state.post_titles))))
@@ -175,6 +187,8 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
self.tab1 = create_tab("Search", self.searchbar, self.qtablewidget, self.tabs, self.dlbutton, self.horizontal_layout)
self.tab2 = create_tab("Library", self.emptyLibrary, self.libraryList, self.tabs, None, None)
self.tab3 = create_tab("Downloads", self.emptyDownload, self.downloadList, self.tabs, None, None)
containerLayout.addWidget(self.tabs)
+3 -3
View File
@@ -6,8 +6,8 @@ from core.utils.data.state import state
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}"}
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}",
"ignore_updates": f"{state.ignore_updates}"}
if platform.system() == "Windows":
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.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")
+8 -30
View File
@@ -1,39 +1,19 @@
from core.utils.data.state import state
from core.utils.general.shutdown import kill_aria2server
from .config import create_config
def restart_aria2c():
import main # had to do this because of circle import :(
import signal
import atexit
import time
kill_aria2server()
state.aria2process.wait()
state.aria2process = main.run_aria2server()
signal.signal(signal.SIGINT, main.keyboardinterrupthandler)
atexit.unregister(kill_aria2server)
atexit.register(kill_aria2server)
try:
main.kill_aria2server()
except Exception as e:
print(f"Warning: aria2server kill failed: {e}")
try:
if state.aria2process:
state.aria2process.wait(timeout=3)
except Exception as e:
print(f"Warning: aria2process wait failed: {e}")
time.sleep(0.5)
try:
state.aria2process = main.run_aria2server()
except Exception as e:
print(f"Error: failed to restart aria2server: {e}")
return
try:
signal.signal(signal.SIGINT, main.keyboardinterrupthandler)
atexit.unregister(main.kill_aria2server)
atexit.register(main.kill_aria2server)
except Exception as e:
print(f"Warning: signal/atexit setup failed: {e}")
def save_settings(thread_count=None, close=lambda: None, apiurl=None, download_path=None, speed_limit=None, version=None):
def save_settings(thread_count=None, close=lambda: None, apiurl=None, download_path=None, speed_limit=None):
if thread_count is not None:
state.aria2_threads = thread_count
if apiurl is not None:
@@ -42,8 +22,6 @@ def save_settings(thread_count=None, close=lambda: None, apiurl=None, download_p
state.download_path = download_path
if speed_limit is not None:
state.speed_limit = speed_limit
if version is not None:
state.version = version
create_config()
restart_aria2c()
+1
View File
@@ -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"
+6 -1
View File
@@ -16,7 +16,12 @@ def check_for_updates():
latest_version = latest_release["name"]
assets = latest_release["assets"]
if latest_version != state.version:
if state.version == "dev":
if state.debug:
print("Dev release detected, skipping version check")
return None, None
elif latest_version != state.version:
if state.debug:
print(f"New release available: {latest_version}")
if assets: