mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 28cffe59f5 | |||
| b7ca895aeb |
+41
-6
@@ -273,13 +273,14 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
status = magnetdl.status()
|
status = magnetdl.status()
|
||||||
|
|
||||||
if status.state == lt.torrent_status.seeding:
|
if status.state == lt.torrent_status.seeding:
|
||||||
if state.download_path and os.path.exists(state.download_path):
|
save_path = magnetdl.save_path()
|
||||||
|
if save_path and os.path.exists(save_path):
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
os.startfile(os.path.normpath(state.download_path))
|
os.startfile(os.path.normpath(save_path))
|
||||||
elif platform.system() == "Linux":
|
elif platform.system() == "Linux":
|
||||||
subprocess.Popen(["xdg-open", state.download_path])
|
subprocess.Popen(["xdg-open", save_path])
|
||||||
elif platform.system() == "Darwin":
|
elif platform.system() == "Darwin":
|
||||||
subprocess.Popen(["open", state.download_path])
|
subprocess.Popen(["open", save_path])
|
||||||
return
|
return
|
||||||
|
|
||||||
if status.paused:
|
if status.paused:
|
||||||
@@ -460,7 +461,8 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
self.context_menu = QtWidgets.QMenu(self)
|
self.context_menu = QtWidgets.QMenu(self)
|
||||||
self.context_menu.addAction("Open Containing Folder", self.openFolderAction)
|
self.context_menu.addAction("Open Containing Folder", self.openFolderAction)
|
||||||
self.context_menu.addAction("Copy Magnet URI", self.copyMagnetURIAction)
|
self.context_menu.addAction("Copy Magnet URI", self.copyMagnetURIAction)
|
||||||
self.context_menu.addAction("Cancel Download", self.cancelDownload)
|
self.context_menu.addAction("Cancel Download", self.cancelDownloadAction)
|
||||||
|
self.context_menu.addAction("Delete File", self.deleteFileAction)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def add_log(text):
|
def add_log(text):
|
||||||
@@ -565,7 +567,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
clipboard = QtWidgets.QApplication.clipboard()
|
clipboard = QtWidgets.QApplication.clipboard()
|
||||||
clipboard.setText(magnet_link)
|
clipboard.setText(magnet_link)
|
||||||
|
|
||||||
def cancelDownload(self):
|
def cancelDownloadAction(self):
|
||||||
if not hasattr(self, '_context_menu_row'):
|
if not hasattr(self, '_context_menu_row'):
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -581,3 +583,36 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
del state.active_downloads[magnet_link]
|
del state.active_downloads[magnet_link]
|
||||||
remove_download_log(magnet_link)
|
remove_download_log(magnet_link)
|
||||||
consoleLog(f"Cancelled download: {magnetdl.status().name}", True)
|
consoleLog(f"Cancelled download: {magnetdl.status().name}", True)
|
||||||
|
|
||||||
|
def deleteFileAction(self):
|
||||||
|
if not hasattr(self, '_context_menu_row'):
|
||||||
|
return
|
||||||
|
|
||||||
|
row = self._context_menu_row
|
||||||
|
if row < 0 or row >= len(state.active_downloads):
|
||||||
|
return
|
||||||
|
|
||||||
|
magnet_link = list(state.active_downloads.keys())[row]
|
||||||
|
magnetdl = state.active_downloads[magnet_link]
|
||||||
|
status = magnetdl.status()
|
||||||
|
save_path = status.save_path
|
||||||
|
torrent_name = status.name
|
||||||
|
download_path = os.path.join(save_path, torrent_name)
|
||||||
|
|
||||||
|
confirm = QMessageBox.question(self, "Delete Files", f"Are you sure you want to delete the downloaded files of '{magnetdl.status().name}'? This action cannot be undone.", QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)
|
||||||
|
if confirm == QMessageBox.StandardButton.Yes:
|
||||||
|
if download_path and os.path.exists(download_path):
|
||||||
|
try:
|
||||||
|
if os.path.isfile(download_path):
|
||||||
|
os.remove(download_path)
|
||||||
|
del state.active_downloads[magnet_link]
|
||||||
|
remove_download_log(magnet_link)
|
||||||
|
consoleLog(f"Deleted files for: {magnetdl.status().name}", True)
|
||||||
|
else:
|
||||||
|
import shutil
|
||||||
|
shutil.rmtree(download_path)
|
||||||
|
del state.active_downloads[magnet_link]
|
||||||
|
remove_download_log(magnet_link)
|
||||||
|
consoleLog(f"Deleted files for: {magnetdl.status().name}", True)
|
||||||
|
except Exception as e:
|
||||||
|
consoleLog(f"Error deleting files: {e}", True)
|
||||||
|
|||||||
Reference in New Issue
Block a user