mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 09:59:41 +02:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c1509f9172 | |||
| 5eca1a678e | |||
| 7e59fdc2d3 | |||
| ad6fa428a0 | |||
| 56e8fada4d |
@@ -231,6 +231,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
|
|
||||||
if darkdetect.isDark():
|
if darkdetect.isDark():
|
||||||
settings_action = QAction(QIcon("core/interface/assets/settings_black.png"), "Settings", self)
|
settings_action = QAction(QIcon("core/interface/assets/settings_black.png"), "Settings", self)
|
||||||
|
else:
|
||||||
settings_action = QAction(QIcon("core/interface/assets/settings_white.png"), "Settings", self)
|
settings_action = QAction(QIcon("core/interface/assets/settings_white.png"), "Settings", self)
|
||||||
|
|
||||||
settings_action.triggered.connect(lambda: settings_dialog(self))
|
settings_action.triggered.connect(lambda: settings_dialog(self))
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ def create_config():
|
|||||||
else:
|
else:
|
||||||
config_dir = os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config"))
|
config_dir = os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config"))
|
||||||
|
|
||||||
settings_path = os.path.join(config_dir, "SoftwareManager")
|
state.settings_path = os.path.join(config_dir, "SoftwareManager")
|
||||||
os.makedirs(settings_path, exist_ok=True)
|
os.makedirs(state.settings_path, exist_ok=True)
|
||||||
|
|
||||||
with open(os.path.join(settings_path, "config.yml"), 'w') as cf:
|
with open(os.path.join(state.settings_path, "config.yml"), 'w') as cf:
|
||||||
config.write(cf)
|
config.write(cf)
|
||||||
|
|
||||||
|
|
||||||
@@ -29,8 +29,8 @@ def read_config():
|
|||||||
config_dir = os.environ.get("APPDATA", os.path.expanduser("~\\AppData\\Roaming"))
|
config_dir = os.environ.get("APPDATA", os.path.expanduser("~\\AppData\\Roaming"))
|
||||||
else:
|
else:
|
||||||
config_dir = os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config"))
|
config_dir = os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config"))
|
||||||
settings_path = os.path.join(config_dir, "SoftwareManager")
|
state.settings_path = os.path.join(config_dir, "SoftwareManager")
|
||||||
config_file = os.path.join(settings_path, "config.yml")
|
config_file = os.path.join(state.settings_path, "config.yml")
|
||||||
|
|
||||||
if not os.path.exists(config_file):
|
if not os.path.exists(config_file):
|
||||||
create_config()
|
create_config()
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
from dataclasses import dataclass
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Download:
|
||||||
|
title: str
|
||||||
|
url: str
|
||||||
|
magnet_uri: str
|
||||||
|
completed: bool
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class DownloadList:
|
||||||
|
count: int
|
||||||
|
data: List[Download]
|
||||||
@@ -24,6 +24,7 @@ class AppState(QObject):
|
|||||||
self.aria2: Any = None
|
self.aria2: Any = None
|
||||||
self.aria2p: Any = None
|
self.aria2p: Any = None
|
||||||
self.aria2_threads: int = 4
|
self.aria2_threads: int = 4
|
||||||
|
self.settings_path: str = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def image_path(self) -> str:
|
def image_path(self) -> str:
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
from core.utils.data.models import Download, DownloadList
|
||||||
|
from core.utils.data.state import state
|
||||||
|
from dataclasses import asdict
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def add_download_log(title, url, magnet_uri, completed) -> DownloadList:
|
||||||
|
downloads_file = os.path.join(state.settings_path, "downloads.json")
|
||||||
|
|
||||||
|
if os.path.exists(downloads_file) and os.path.getsize(downloads_file) > 0:
|
||||||
|
try:
|
||||||
|
with open(downloads_file, "r") as file:
|
||||||
|
existing_data = json.load(file)
|
||||||
|
downloads = [Download(**d) for d in existing_data.get("data", [])]
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
downloads = []
|
||||||
|
else:
|
||||||
|
downloads = []
|
||||||
|
|
||||||
|
downloads.append(Download(
|
||||||
|
title=title,
|
||||||
|
url=url,
|
||||||
|
magnet_uri=magnet_uri,
|
||||||
|
completed=completed
|
||||||
|
))
|
||||||
|
|
||||||
|
download_list = DownloadList(data=downloads, count=len(downloads))
|
||||||
|
with open(downloads_file, "w") as file:
|
||||||
|
json.dump(asdict(download_list), file, indent=4)
|
||||||
|
|
||||||
|
return download_list
|
||||||
@@ -12,7 +12,6 @@ def download_selected(item, posts, post_titles):
|
|||||||
if state.debug:
|
if state.debug:
|
||||||
print(f"Downloading {item.text()}")
|
print(f"Downloading {item.text()}")
|
||||||
run_thread(threading.Thread(target=run_download, args=(item.text(), posts, post_titles)))
|
run_thread(threading.Thread(target=run_download, args=(item.text(), posts, post_titles)))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if state.debug:
|
if state.debug:
|
||||||
print("No item selected for download.")
|
print("No item selected for download.")
|
||||||
|
|||||||
Reference in New Issue
Block a user