refactor: update progress dialog and tidy UI

This commit is contained in:
Vxrtrauter
2026-03-21 00:27:56 +01:00
parent c0f5060451
commit 0a591e1cda
6 changed files with 28 additions and 37 deletions
+12 -29
View File
@@ -46,7 +46,7 @@ def settings_dialog(self):
update_checkbox_container = QWidget() update_checkbox_container = QWidget()
update_checkbox_layout = QHBoxLayout() update_checkbox_layout = QHBoxLayout()
# ignore updates checkbox # Ignore updates checkbox
if platform.system() == "Windows": if platform.system() == "Windows":
update_checkbox = QCheckBox() update_checkbox = QCheckBox()
@@ -57,7 +57,7 @@ def settings_dialog(self):
update_checkbox.toggled.connect(lambda checked: setattr(state, 'ignore_updates', checked)) update_checkbox.toggled.connect(lambda checked: setattr(state, 'ignore_updates', checked))
update_checkbox_layout.addWidget(update_checkbox) update_checkbox_layout.addWidget(update_checkbox)
# auto-resume downloads checkbox # Auto-resume downloads checkbox
autoresume_container = QWidget() autoresume_container = QWidget()
autoresume_layout = QHBoxLayout() autoresume_layout = QHBoxLayout()
@@ -71,7 +71,7 @@ def settings_dialog(self):
autoresume_layout.addWidget(autoresume_checkbox) autoresume_layout.addWidget(autoresume_checkbox)
# transparent window checkbox # Transparent window checkbox
transparent_window_container = QWidget() transparent_window_container = QWidget()
transparent_window_layout = QHBoxLayout() transparent_window_layout = QHBoxLayout()
@@ -84,10 +84,8 @@ def settings_dialog(self):
transparent_window_checkbox.toggled.connect(lambda checked: setattr(state, 'window_transparency', checked)) transparent_window_checkbox.toggled.connect(lambda checked: setattr(state, 'window_transparency', checked))
transparent_window_layout.addWidget(transparent_window_checkbox) transparent_window_layout.addWidget(transparent_window_checkbox)
##################
# SERVER SETTING #
##################
# API Server Setting
api_url_container = QWidget() api_url_container = QWidget()
api_url_layout = QHBoxLayout() api_url_layout = QHBoxLayout()
@@ -98,10 +96,8 @@ def settings_dialog(self):
api_url_container.setLayout(api_url_layout) api_url_container.setLayout(api_url_layout)
api_url.setText(state.api_url) api_url.setText(state.api_url)
#################
# DOWNLOAD PATH #
#################
# Download Path
download_path_container = QWidget() download_path_container = QWidget()
download_path_layout = QHBoxLayout() download_path_layout = QHBoxLayout()
@@ -133,10 +129,8 @@ def settings_dialog(self):
download_path_layout.addWidget(browse_button) download_path_layout.addWidget(browse_button)
browse_button.clicked.connect(browse_download_path) browse_button.clicked.connect(browse_download_path)
###############
# IMAGE PATH #
###############
# Image Path
image_path_container = QWidget() image_path_container = QWidget()
image_path_layout = QHBoxLayout() image_path_layout = QHBoxLayout()
@@ -167,10 +161,8 @@ def settings_dialog(self):
image_path_layout.addWidget(browse_button) image_path_layout.addWidget(browse_button)
browse_button.clicked.connect(browse_image_path) browse_button.clicked.connect(browse_image_path)
##################
# SPEED LIMITING #
##################
# Speed Limiting
down_speed_limit_container = QWidget() down_speed_limit_container = QWidget()
down_speed_limit_layout = QHBoxLayout() down_speed_limit_layout = QHBoxLayout()
@@ -197,10 +189,8 @@ def settings_dialog(self):
up_speed_limit.setFixedWidth(180) up_speed_limit.setFixedWidth(180)
up_speed_limit.setFixedHeight(30) up_speed_limit.setFixedHeight(30)
######################
# CONNECTION CONFIGS # # Connection Configs
######################
max_connections_container = QWidget() max_connections_container = QWidget()
max_connections_layout = QHBoxLayout() max_connections_layout = QHBoxLayout()
@@ -214,10 +204,8 @@ def settings_dialog(self):
max_connections.setFixedWidth(180) max_connections.setFixedWidth(180)
max_connections.setFixedHeight(30) max_connections.setFixedHeight(30)
####################
# DOWNLOAD CONFIGS #
####################
# Download Configs
max_downloads_container = QWidget() max_downloads_container = QWidget()
max_downloads_layout = QHBoxLayout() max_downloads_layout = QHBoxLayout()
@@ -231,10 +219,8 @@ def settings_dialog(self):
max_downloads.setFixedWidth(180) max_downloads.setFixedWidth(180)
max_downloads.setFixedHeight(30) max_downloads.setFixedHeight(30)
#####################
# INTERFACE BINDING #
#####################
# Interface Binding
interface_container = QWidget() interface_container = QWidget()
interface_layout = QHBoxLayout() interface_layout = QHBoxLayout()
@@ -257,10 +243,7 @@ def settings_dialog(self):
interface_container.setLayout(interface_layout) interface_container.setLayout(interface_layout)
############### # Save / Cancel buttons
# SAVE/CANCEL #
###############
layout = QHBoxLayout() layout = QHBoxLayout()
save_btn = QPushButton("Save") save_btn = QPushButton("Save")
+15 -1
View File
@@ -1,8 +1,10 @@
from PySide6.QtWidgets import QDialog, QMessageBox, QProgressDialog
from utils.network.update_checker import get_updates from utils.network.update_checker import get_updates
from PySide6.QtWidgets import QDialog, QMessageBox
from utils.network.updater import download_update from utils.network.updater import download_update
from utils.logging.logs import consoleLog from utils.logging.logs import consoleLog
from utils.data.state import state from utils.data.state import state
from PySide6 import QtWidgets
from PySide6.QtCore import Qt
from pathlib import Path from pathlib import Path
import platform import platform
import json import json
@@ -47,3 +49,15 @@ class UpdateDialog(QDialog):
if response == QMessageBox.StandardButton.Ok: if response == QMessageBox.StandardButton.Ok:
download_update(assets) download_update(assets)
class UpdateProgressDialog(QProgressDialog):
def __init__(self, parent=None):
self.progress = QtWidgets.QProgressDialog("Downloading update... (0.0 MB/s)", None, 0, 100)
self.progress.setWindowTitle("Updating")
self.progress.setWindowModality(Qt.WindowModality.ApplicationModal)
self.progress.setCancelButton(None)
self.progress.setMinimumDuration(0)
self.progress.setAutoClose(False)
self.progress.setAutoReset(False)
self.progress.setValue(0)
self.progress.show()
QtWidgets.QApplication.processEvents()
+1 -1
View File
@@ -232,7 +232,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
self.statusbar.addPermanentWidget(self.version, Qt.AlignmentFlag.AlignLeft) self.statusbar.addPermanentWidget(self.version, Qt.AlignmentFlag.AlignLeft)
# (\u2193) Arrow down, (\u2191) Arrow up # (\u2193) Arrow down, (\u2191) Arrow up
self.speed_label = QLabel("\u2193 0.0 kB/s \u2191 0.0 kB/s") self.speed_label = QLabel(" 0.0 kB/s 0.0 kB/s")
self.speed_label.setStyleSheet("padding-right: 6px;") self.speed_label.setStyleSheet("padding-right: 6px;")
self.statusbar.addPermanentWidget(self.speed_label) self.statusbar.addPermanentWidget(self.speed_label)
-2
View File
@@ -60,7 +60,6 @@ def add_download(magnet_uri):
state.active_downloads = {} state.active_downloads = {}
init_session() init_session()
free_space = get_free_space_mb(state.download_path) free_space = get_free_space_mb(state.download_path)
if magnet_uri in state.active_downloads: if magnet_uri in state.active_downloads:
@@ -91,7 +90,6 @@ def add_download(magnet_uri):
params.save_path = state.download_path params.save_path = state.download_path
handle = state.dl_session.add_torrent(params) handle = state.dl_session.add_torrent(params)
while not handle.has_metadata(): while not handle.has_metadata():
time.sleep(1) time.sleep(1)
-3
View File
@@ -17,9 +17,6 @@ def cleanup_session():
state.dl_session = None state.dl_session = None
state.active_downloads.clear() state.active_downloads.clear()
def send_notification(shutdown_event): def send_notification(shutdown_event):
notified = set() notified = set()
while not shutdown_event.is_set(): while not shutdown_event.is_set():
-1
View File
@@ -3,7 +3,6 @@ from utils.data.state import state
import requests import requests
def get_updates(): def get_updates():
url = f"https://api.github.com/repos/KeksPirates/SoftwareManager/releases/latest" url = f"https://api.github.com/repos/KeksPirates/SoftwareManager/releases/latest"
try: try: