Added Open processed file and Open input file options for items in the queue manager

This commit is contained in:
Deniz Şafak
2025-10-27 17:24:23 +03:00
parent eedf347866
commit 9d2e8bed00
2 changed files with 55 additions and 32 deletions
+1
View File
@@ -1,6 +1,7 @@
# 1.2.1 (pre-release) # 1.2.1 (pre-release)
- Upgraded Abogen's interface from PyQt5 to PyQt6 for better compatibility and long-term support. - Upgraded Abogen's interface from PyQt5 to PyQt6 for better compatibility and long-term support.
- Added tooltip indicators in queue manager to display book handler options (`Save chapters separately` and `Merge chapters at the end`) for queued items. - Added tooltip indicators in queue manager to display book handler options (`Save chapters separately` and `Merge chapters at the end`) for queued items.
- Added `Open processed file` and `Open input file` options for items in the queue manager, instead of just `Open file` option.
- Added loading gif animation to book handler window. - Added loading gif animation to book handler window.
- Fixed subtitle word-count splitting logic for more accurate segmentation. - Fixed subtitle word-count splitting logic for more accurate segmentation.
+54 -32
View File
@@ -513,38 +513,7 @@ class QueueManager(QDialog):
remove_action.triggered.connect(self.remove_item) remove_action.triggered.connect(self.remove_item)
menu.addAction(remove_action) menu.addAction(remove_action)
# Add Open file action # Get paths for determining if it's a document input
open_file_action = QAction("Open file", self)
def open_file():
from PyQt6.QtWidgets import QMessageBox
item = selected_items[0]
paths = item.data(Qt.ItemDataRole.UserRole)
if isinstance(paths, dict):
file_path = paths.get('display_path', paths.get('processing_path', ''))
else:
file_path = paths # Fallback for old format
# Find the queue item
for q in self.queue:
if (getattr(q, "save_base_path", None) == file_path or
q.file_name == file_path):
target_path = getattr(q, "save_base_path", None) or q.file_name
if not os.path.exists(target_path):
QMessageBox.warning(
self, "File Not Found", f"The file does not exist."
)
return
QDesktopServices.openUrl(QUrl.fromLocalFile(target_path))
break
open_file_action.triggered.connect(open_file)
menu.addAction(open_file_action)
# Add Go to folder action
# If the queued item represents a converted document (markdown, pdf, epub)
# show two actions: Go to processed file (the cached .txt) and Go to input file (original source)
item = selected_items[0] item = selected_items[0]
paths = item.data(Qt.ItemDataRole.UserRole) paths = item.data(Qt.ItemDataRole.UserRole)
if isinstance(paths, dict): if isinstance(paths, dict):
@@ -561,6 +530,59 @@ class QueueManager(QDialog):
isinstance(processing_path, str) and processing_path.lower().endswith(doc_exts) isinstance(processing_path, str) and processing_path.lower().endswith(doc_exts)
) )
# Add Open file action(s)
def open_file_by_path(path_label: str):
from PyQt6.QtWidgets import QMessageBox
p = display_path if path_label == 'display' else processing_path
if not p:
QMessageBox.warning(self, "File Not Found", "Path is not available.")
return
# Find the queue item and resolve the target path
target_path = None
for q in self.queue:
if getattr(q, 'save_base_path', None) == display_path or q.file_name == display_path:
if path_label == 'display':
target_path = getattr(q, 'save_base_path', None) or q.file_name
else:
target_path = q.file_name
break
if getattr(q, 'save_base_path', None) == processing_path or q.file_name == processing_path:
if path_label == 'display':
target_path = getattr(q, 'save_base_path', None) or q.file_name
else:
target_path = q.file_name
break
# Fallback to the raw path if resolution failed
if not target_path:
target_path = p
if not os.path.exists(target_path):
QMessageBox.warning(self, "File Not Found", f"The file does not exist.")
return
QDesktopServices.openUrl(QUrl.fromLocalFile(target_path))
if is_document_input:
# For documents, show two open options
open_processed_action = QAction("Open processed file", self)
open_processed_action.triggered.connect(lambda: open_file_by_path('processing'))
menu.addAction(open_processed_action)
open_input_action = QAction("Open input file", self)
open_input_action.triggered.connect(lambda: open_file_by_path('display'))
menu.addAction(open_input_action)
else:
# For plain text files, show single open option
open_file_action = QAction("Open file", self)
open_file_action.triggered.connect(lambda: open_file_by_path('display'))
menu.addAction(open_file_action)
# Add Go to folder action
# If the queued item represents a converted document (markdown, pdf, epub)
# show two actions: Go to processed file (the cached .txt) and Go to input file (original source)
from PyQt6.QtWidgets import QMessageBox from PyQt6.QtWidgets import QMessageBox
def open_folder_for(path_label: str): def open_folder_for(path_label: str):