update configs and settings

This commit is contained in:
Vxrtrauter
2026-01-31 03:54:38 +01:00
parent 8f9f77d63f
commit a19cf469f6
4 changed files with 49 additions and 10 deletions
+39 -2
View File
@@ -22,7 +22,7 @@ def settings_dialog(self):
consoleLog("Settings dialog opened")
dialog = QDialog(self)
dialog.setWindowTitle("Settings")
dialog.setFixedSize(800, 400)
dialog.setFixedSize(800, 550)
dialog.setLayout(QVBoxLayout())
dialog.layout().addWidget(QLabel("Settings"))
@@ -156,6 +156,43 @@ def settings_dialog(self):
up_speed_limit.setFixedHeight(30)
dialog.layout().addWidget(up_speed_limit_container)
######################
# CONNECTION CONFIGS #
######################
max_connections_container = QWidget()
max_connections_layout = QHBoxLayout()
max_connections_layout.addWidget(QLabel("Max Connections: "))
max_connections = QSpinBox()
max_connections.setMinimum(0)
max_connections.setMaximum(10000000)
max_connections.setValue(state.max_connections)
max_connections_container.setLayout(max_connections_layout)
max_connections_layout.addWidget(max_connections)
max_connections.setFixedWidth(180)
max_connections.setFixedHeight(30)
dialog.layout().addWidget(max_connections_container)
####################
# DOWNLOAD CONFIGS #
####################
max_downloads_container = QWidget()
max_downloads_layout = QHBoxLayout()
max_downloads_layout.addWidget(QLabel("Max Downloads: "))
max_downloads = QSpinBox()
max_downloads.setMinimum(0)
max_downloads.setMaximum(10000000)
max_downloads.setValue(state.max_downloads)
max_downloads_container.setLayout(max_downloads_layout)
max_downloads_layout.addWidget(max_downloads)
max_downloads.setFixedWidth(180)
max_downloads.setFixedHeight(30)
dialog.layout().addWidget(max_downloads_container)
###############
# IMAGE PATH #
###############
@@ -188,7 +225,7 @@ def settings_dialog(self):
save_btn = QPushButton("Save")
cancel_btn = QPushButton("Cancel")
save_btn.clicked.connect(lambda: save_settings(thread_box.value(), close_settings, api_url.text(), download_path.text(), down_speed_limit.value(), up_speed_limit.value(), image_path.text()))
save_btn.clicked.connect(lambda: save_settings(close_settings, api_url.text(), download_path.text(), down_speed_limit.value(), up_speed_limit.value(), image_path.text(), None, max_connections.value(), max_downloads.value()))
cancel_btn.clicked.connect(dialog.reject)
layout.addWidget(cancel_btn)
+1 -1
View File
@@ -1,5 +1,5 @@
from core.utils.general.logs import consoleLog
from core.network.libtorrent_int import add_download, dl_status_loop
from core.network.libtorrent_int import add_download
def add_magnet(uri):
if uri is not None and uri.startswith("magnet:?"):
+4 -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"download_speed_limit": f"{state.down_speed_limit}", f"upload_speed_limit": f"{state.up_speed_limit}",
"ignore_updates": f"{state.ignore_updates}", "image_path": f"{state.image_path}", "autoresume": f"{state.autoresume}"}
config["General"] = {"debug": True, "api_url": f"{state.api_url}", "download_path": f"{state.download_path}", f"download_speed_limit": f"{state.down_speed_limit}", f"upload_speed_limit": f"{state.up_speed_limit}",
"ignore_updates": f"{state.ignore_updates}", "image_path": f"{state.image_path}", "autoresume": f"{state.autoresume}", "max_connections": f"{state.max_connections}", "max_downloads": f"{state.max_downloads}"}
if platform.system() == "Windows":
config_dir = os.environ.get("APPDATA", os.path.expanduser("~\\AppData\\Roaming"))
@@ -40,12 +40,13 @@ def read_config():
state.debug = config.getboolean("General", "debug", fallback=state.debug)
state.api_url = config.get("General", "api_url", fallback=state.api_url)
state.aria2_threads = config.getint("General", "aria2_threads", fallback=state.aria2_threads)
state.download_path = config.get("General", "download_path", fallback=state.download_path)
state.down_speed_limit = config.getint("General", "download_speed_limit", fallback=state.down_speed_limit)
state.up_speed_limit = config.getint("General", "upload_speed_limit", fallback=state.up_speed_limit)
state.ignore_updates = config.getboolean("General", "ignore_updates", fallback=state.ignore_updates)
state.image_path = config.get("General", "image_path", fallback=state.image_path)
state.autoresume = config.getboolean("General", "autoresume", fallback=state.autoresume)
state.max_connections = config.getint("General", "max_connections", fallback=state.max_connections)
state.max_downloads = config.getint("General", "max_downloads", fallback=state.max_downloads)
create_config()
+5 -4
View File
@@ -2,9 +2,7 @@ from core.utils.data.state import state
from .config import create_config
def save_settings(thread_count=None, close=lambda: None, apiurl=None, download_path=None, down_speed_limit=None, up_speed_limit=None, image_path=None, autoresume=None):
if thread_count is not None:
state.aria2_threads = thread_count
def save_settings(close=lambda: None, apiurl=None, download_path=None, down_speed_limit=None, up_speed_limit=None, image_path=None, autoresume=None, max_connections=None, max_downloads=None):
if apiurl is not None:
state.api_url = apiurl
if download_path is not None:
@@ -17,7 +15,10 @@ def save_settings(thread_count=None, close=lambda: None, apiurl=None, download_p
state.image_path = image_path
if autoresume is not None:
state.autoresume = autoresume
if max_connections is not None:
state.max_connections = max_connections
if max_downloads is not None:
state.max_downloads = max_downloads
create_config()
close()