mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 01:49:42 +02:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d82008c9fe | |||
| 83ff2720c8 | |||
| 83adbb027f | |||
| 606c70efcc |
+20
-5
@@ -147,6 +147,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
self.downloadList = QTableView()
|
self.downloadList = QTableView()
|
||||||
self.emptyLibrary = QLabel("No items in library.")
|
self.emptyLibrary = QLabel("No items in library.")
|
||||||
self.emptyDownload = QLabel("No items in downloads.")
|
self.emptyDownload = QLabel("No items in downloads.")
|
||||||
|
self.emptyDownload.setAlignment(Qt.AlignCenter)
|
||||||
|
|
||||||
self.consoleLog = QTextEdit()
|
self.consoleLog = QTextEdit()
|
||||||
self.progressbar = QProgressBar()
|
self.progressbar = QProgressBar()
|
||||||
@@ -183,7 +184,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
|
|
||||||
def rowCount(self, parent=QModelIndex()):
|
def rowCount(self, parent=QModelIndex()):
|
||||||
return len(state.downloads)
|
return len(state.downloads)
|
||||||
|
|
||||||
def columnCount(self, parent=QModelIndex()):
|
def columnCount(self, parent=QModelIndex()):
|
||||||
return len(self.headers)
|
return len(self.headers)
|
||||||
|
|
||||||
@@ -199,7 +200,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
col = index.column()
|
col = index.column()
|
||||||
|
|
||||||
if col == 0:
|
if col == 0:
|
||||||
return "Resume" if download.is_paused else "Pause"
|
return "▶︎" if download.is_paused else "⏸︎"
|
||||||
elif col == 1:
|
elif col == 1:
|
||||||
return download.name
|
return download.name
|
||||||
elif col == 2:
|
elif col == 2:
|
||||||
@@ -239,7 +240,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
|
|
||||||
button = QStyleOptionButton()
|
button = QStyleOptionButton()
|
||||||
button.rect = option.rect
|
button.rect = option.rect
|
||||||
button.text = "Resume" if paused else "Pause"
|
button.text = "▶︎" if paused else "⏸︎"
|
||||||
button.state = QStyle.State_Enabled
|
button.state = QStyle.State_Enabled
|
||||||
|
|
||||||
QApplication.style().drawControl(
|
QApplication.style().drawControl(
|
||||||
@@ -255,7 +256,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
self.download_model = DownloadModel()
|
self.download_model = DownloadModel()
|
||||||
self.downloadList.setModel(self.download_model)
|
self.downloadList.setModel(self.download_model)
|
||||||
self.downloadList.horizontalHeader().setStretchLastSection(False)
|
self.downloadList.horizontalHeader().setStretchLastSection(False)
|
||||||
self.downloadList.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch)
|
self.downloadList.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch)
|
||||||
self.downloadList.setSelectionBehavior(QTableView.SelectRows)
|
self.downloadList.setSelectionBehavior(QTableView.SelectRows)
|
||||||
self.downloadList.setAttribute(Qt.WA_TranslucentBackground)
|
self.downloadList.setAttribute(Qt.WA_TranslucentBackground)
|
||||||
self.downloadList.viewport().setAttribute(Qt.WA_TranslucentBackground)
|
self.downloadList.viewport().setAttribute(Qt.WA_TranslucentBackground)
|
||||||
@@ -345,6 +346,10 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
self.download_timer.timeout.connect(lambda: run_thread(threading.Thread(target=self.download_list_update)))
|
self.download_timer.timeout.connect(lambda: run_thread(threading.Thread(target=self.download_list_update)))
|
||||||
self.download_timer.start(500)
|
self.download_timer.start(500)
|
||||||
|
|
||||||
|
self.active_timer = QTimer()
|
||||||
|
self.active_timer.timeout.connect(self.show_empty_downloads)
|
||||||
|
self.active_timer.start(500)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def add_log(text):
|
def add_log(text):
|
||||||
if MainWindow._instance:
|
if MainWindow._instance:
|
||||||
@@ -367,6 +372,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
if self.download_model:
|
if self.download_model:
|
||||||
self.download_model.layoutAboutToBeChanged.emit()
|
self.download_model.layoutAboutToBeChanged.emit()
|
||||||
self.download_model.layoutChanged.emit()
|
self.download_model.layoutChanged.emit()
|
||||||
|
|
||||||
|
|
||||||
def closeEvent(self, event: QCloseEvent):
|
def closeEvent(self, event: QCloseEvent):
|
||||||
closehelper()
|
closehelper()
|
||||||
@@ -384,8 +390,17 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
self.qtablewidget.hide()
|
self.qtablewidget.hide()
|
||||||
self.emptyResults.show()
|
self.emptyResults.show()
|
||||||
else:
|
else:
|
||||||
self.emptyResults.hide()
|
|
||||||
self.qtablewidget.show()
|
self.qtablewidget.show()
|
||||||
|
self.emptyResults.hide()
|
||||||
|
|
||||||
|
def show_empty_downloads(self):
|
||||||
|
if len(state.downloads) > 0:
|
||||||
|
self.emptyDownload.hide()
|
||||||
|
self.downloadList.show()
|
||||||
|
else:
|
||||||
|
self.emptyDownload.show()
|
||||||
|
self.downloadList.hide()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# thank you claude
|
# thank you claude
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from core.utils.data.state import state
|
|||||||
from core.utils.general.logs import update_download_completed_by_hash
|
from core.utils.general.logs import update_download_completed_by_hash
|
||||||
from core.utils.general.logs import consoleLog
|
from core.utils.general.logs import consoleLog
|
||||||
from plyer import notification
|
from plyer import notification
|
||||||
|
import socket
|
||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@@ -42,6 +43,21 @@ def aria2server():
|
|||||||
stderr=subprocess.DEVNULL,
|
stderr=subprocess.DEVNULL,
|
||||||
creationflags=subprocess.CREATE_NO_WINDOW if sys.platform == 'win32' else 0
|
creationflags=subprocess.CREATE_NO_WINDOW if sys.platform == 'win32' else 0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
max_checks = 50
|
||||||
|
for check in range(max_checks):
|
||||||
|
try:
|
||||||
|
sock = socket.socket()
|
||||||
|
sock.settimeout(0.1)
|
||||||
|
sock.connect(("localhost", 6800))
|
||||||
|
sock.close()
|
||||||
|
break
|
||||||
|
except(ConnectionRefusedError, socket.timeout):
|
||||||
|
time.sleep(0.1)
|
||||||
|
else:
|
||||||
|
raise RuntimeError("Aria2 Server failed to start")
|
||||||
|
|
||||||
|
consoleLog("Aria2 Server started")
|
||||||
return aria2server
|
return aria2server
|
||||||
|
|
||||||
def dlprogress():
|
def dlprogress():
|
||||||
|
|||||||
@@ -8,8 +8,11 @@ def start_client():
|
|||||||
consoleLog("Started Aria2p")
|
consoleLog("Started Aria2p")
|
||||||
|
|
||||||
def add_magnet(uri):
|
def add_magnet(uri):
|
||||||
aria2.add_magnet(uri)
|
if uri is not None and uri.startswith("magnet:?"):
|
||||||
consoleLog("Magnet URI added to Aria2")
|
aria2.add_magnet(uri)
|
||||||
|
consoleLog("Magnet URI added to Aria2")
|
||||||
|
else:
|
||||||
|
consoleLog(f"Invalid Magnet Link: {uri}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
from core.utils.data.state import state
|
|
||||||
from core.utils.general.logs import consoleLog
|
from core.utils.general.logs import consoleLog
|
||||||
from core.utils.network.download import run_download_direct
|
from core.utils.network.download import run_download_direct
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user