add notification function (not working)

This commit is contained in:
2025-10-10 21:48:09 +02:00
parent 573889721f
commit 335845b9dd
4 changed files with 28 additions and 9 deletions
+3 -6
View File
@@ -14,7 +14,6 @@ from PySide6.QtWidgets import (
QSpinBox,
QTabWidget,
QProgressBar,
QTextEdit,
)
from PySide6.QtGui import QIcon, QAction
import darkdetect
@@ -173,7 +172,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
api_url_container = QWidget()
api_url_layout = QHBoxLayout()
api_url = QTextEdit()
api_url = QLineEdit()
api_url_layout.addWidget(QLabel("API Server URL:"))
api_url_layout.addWidget(api_url)
api_url_container.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
@@ -188,7 +187,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
download_path_container = QWidget()
download_path_layout = QHBoxLayout()
download_path = QTextEdit()
download_path = QLineEdit()
download_path_layout.addWidget(QLabel("Download Path:"))
download_path_layout.addWidget(download_path)
download_path_container.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
@@ -222,9 +221,8 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
save_btn = QPushButton("Save")
cancel_btn = QPushButton("Cancel")
save_btn.clicked.connect(lambda: save_settings(thread_box.value(), close_settings, api_url.toPlainText(), download_path.toPlainText(), speed_limit.value()))
save_btn.clicked.connect(lambda: save_settings(thread_box.value(), close_settings, api_url.text(), download_path.text(), speed_limit.value()))
cancel_btn.clicked.connect(dialog.reject)
print(thread_box.value())
layout.addWidget(cancel_btn)
@@ -234,7 +232,6 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
dialog.exec()
# this needs a cleanup
def return_pressed(self):
search_text = self.searchbar.text()
+20 -3
View File
@@ -1,6 +1,8 @@
import aria2p
import subprocess
from core.utils.data.state import state
from plyer import notification
import time
def run_aria2p():
global aria2
@@ -37,12 +39,27 @@ def aria2server():
def dlprogress():
try:
download2 = aria2.get_downloads()
if download2:
for download in download2:
downloads = aria2.get_downloads()
if downloads:
for download in downloads:
progress = download.progress_string(0)
progress_int = int(progress.strip('%'))
return progress_int
return 0
except:
return 0
def send_notification():
while True:
try:
downloads = aria2.get_downloads()
if downloads:
for download in downloads:
if download.is_complete:
# notification.notify("Download Complete"
print("yet")
time.sleep(5)
except Exception as e:
if state.debug:
print(f"Notification Error: {e}")
break