Add 'Open Folder' button after download completion

Introduces an 'Open Folder' button to the UI, shown after a download completes, allowing users to quickly open the folder containing the downloaded file. Updates all language files to include translations for the new button tooltip.
This commit is contained in:
oop7
2025-10-25 18:10:04 +03:00
parent 6ed1314bec
commit c00ef14703
15 changed files with 113 additions and 15 deletions
+2 -1
View File
@@ -80,7 +80,8 @@
"update": "تحديث yt-dlp", "update": "تحديث yt-dlp",
"select_defaults": "اختر الافتراضي", "select_defaults": "اختر الافتراضي",
"select_all": "تحديد الكل", "select_all": "تحديد الكل",
"deselect_all": "إلغاء تحديد الكل" "deselect_all": "إلغاء تحديد الكل",
"open_folder": "فتح موقع المجلد"
}, },
"dialogs": { "dialogs": {
"custom_options": "خيارات مخصصة", "custom_options": "خيارات مخصصة",
+2 -1
View File
@@ -80,7 +80,8 @@
"update": "yt-dlp aktualisieren", "update": "yt-dlp aktualisieren",
"select_defaults": "Standard auswählen", "select_defaults": "Standard auswählen",
"select_all": "Alle auswählen", "select_all": "Alle auswählen",
"deselect_all": "Alle abwählen" "deselect_all": "Alle abwählen",
"open_folder": "Ordnerspeicherort öffnen"
}, },
"dialogs": { "dialogs": {
"custom_options": "Benutzerdefinierte Optionen", "custom_options": "Benutzerdefinierte Optionen",
+2 -1
View File
@@ -80,7 +80,8 @@
"update": "Update yt-dlp", "update": "Update yt-dlp",
"select_defaults": "Select Defaults", "select_defaults": "Select Defaults",
"select_all": "Select All", "select_all": "Select All",
"deselect_all": "Deselect All" "deselect_all": "Deselect All",
"open_folder": "Open folder location"
}, },
"dialogs": { "dialogs": {
"custom_options": "Custom Options", "custom_options": "Custom Options",
+2 -1
View File
@@ -47,7 +47,8 @@
"download_settings": "Configuración de Descarga", "download_settings": "Configuración de Descarga",
"select_defaults": "Seleccionar Predeterminados", "select_defaults": "Seleccionar Predeterminados",
"select_all": "Seleccionar Todos", "select_all": "Seleccionar Todos",
"deselect_all": "Deseleccionar Todos" "deselect_all": "Deseleccionar Todos",
"open_folder": "Abrir ubicación de carpeta"
}, },
"dialogs": { "dialogs": {
"custom_options": "Opciones Personalizadas", "custom_options": "Opciones Personalizadas",
+2 -1
View File
@@ -80,7 +80,8 @@
"update": "Mettre à jour yt-dlp", "update": "Mettre à jour yt-dlp",
"select_defaults": "Sélectionner par défaut", "select_defaults": "Sélectionner par défaut",
"select_all": "Tout sélectionner", "select_all": "Tout sélectionner",
"deselect_all": "Tout désélectionner" "deselect_all": "Tout désélectionner",
"open_folder": "Ouvrir l'emplacement du dossier"
}, },
"dialogs": { "dialogs": {
"custom_options": "Options personnalisées", "custom_options": "Options personnalisées",
+2 -1
View File
@@ -80,7 +80,8 @@
"update": "yt-dlp अपडेट करें", "update": "yt-dlp अपडेट करें",
"select_defaults": "डिफ़ॉल्ट चुनें", "select_defaults": "डिफ़ॉल्ट चुनें",
"select_all": "सभी चुनें", "select_all": "सभी चुनें",
"deselect_all": "सभी को अचयनित करें" "deselect_all": "सभी को अचयनित करें",
"open_folder": "फ़ोल्डर स्थान खोलें"
}, },
"dialogs": { "dialogs": {
"custom_options": "कस्टम विकल्प", "custom_options": "कस्टम विकल्प",
+2 -1
View File
@@ -80,7 +80,8 @@
"update": "Perbarui yt-dlp", "update": "Perbarui yt-dlp",
"select_defaults": "Pilih default", "select_defaults": "Pilih default",
"select_all": "Pilih semua", "select_all": "Pilih semua",
"deselect_all": "Batalkan pilihan semua" "deselect_all": "Batalkan pilihan semua",
"open_folder": "Buka lokasi folder"
}, },
"dialogs": { "dialogs": {
"custom_options": "Opsi khusus", "custom_options": "Opsi khusus",
+2 -1
View File
@@ -80,7 +80,8 @@
"update": "Aggiorna yt-dlp", "update": "Aggiorna yt-dlp",
"select_defaults": "Seleziona predefiniti", "select_defaults": "Seleziona predefiniti",
"select_all": "Seleziona tutto", "select_all": "Seleziona tutto",
"deselect_all": "Deseleziona tutto" "deselect_all": "Deseleziona tutto",
"open_folder": "Apri posizione cartella"
}, },
"dialogs": { "dialogs": {
"custom_options": "Opzioni personalizzate", "custom_options": "Opzioni personalizzate",
+2 -1
View File
@@ -80,7 +80,8 @@
"update": "yt-dlpを更新", "update": "yt-dlpを更新",
"select_defaults": "デフォルトを選択", "select_defaults": "デフォルトを選択",
"select_all": "すべて選択", "select_all": "すべて選択",
"deselect_all": "すべて解除" "deselect_all": "すべて解除",
"open_folder": "フォルダの場所を開く"
}, },
"dialogs": { "dialogs": {
"custom_options": "カスタムオプション", "custom_options": "カスタムオプション",
+2 -1
View File
@@ -80,7 +80,8 @@
"update": "Zaktualizuj yt-dlp", "update": "Zaktualizuj yt-dlp",
"select_defaults": "Wybierz domyślne", "select_defaults": "Wybierz domyślne",
"select_all": "Zaznacz wszystko", "select_all": "Zaznacz wszystko",
"deselect_all": "Odznacz wszystko" "deselect_all": "Odznacz wszystko",
"open_folder": "Otwórz lokalizację folderu"
}, },
"dialogs": { "dialogs": {
"custom_options": "Opcje niestandardowe", "custom_options": "Opcje niestandardowe",
+2 -1
View File
@@ -80,7 +80,8 @@
"update": "Atualizar yt-dlp", "update": "Atualizar yt-dlp",
"select_defaults": "Selecionar Padrões", "select_defaults": "Selecionar Padrões",
"select_all": "Selecionar Tudo", "select_all": "Selecionar Tudo",
"deselect_all": "Desmarcar Tudo" "deselect_all": "Desmarcar Tudo",
"open_folder": "Abrir local da pasta"
}, },
"dialogs": { "dialogs": {
"custom_options": "Opções Personalizadas", "custom_options": "Opções Personalizadas",
+2 -1
View File
@@ -80,7 +80,8 @@
"update": "Обновить yt-dlp", "update": "Обновить yt-dlp",
"select_defaults": "Выбрать по умолчанию", "select_defaults": "Выбрать по умолчанию",
"select_all": "Выбрать всё", "select_all": "Выбрать всё",
"deselect_all": "Снять выделение" "deselect_all": "Снять выделение",
"open_folder": "Открыть расположение папки"
}, },
"dialogs": { "dialogs": {
"custom_options": "Пользовательские опции", "custom_options": "Пользовательские опции",
+2 -1
View File
@@ -80,7 +80,8 @@
"update": "yt-dlp'yi güncelle", "update": "yt-dlp'yi güncelle",
"select_defaults": "Varsayılanları seç", "select_defaults": "Varsayılanları seç",
"select_all": "Tümünü seç", "select_all": "Tümünü seç",
"deselect_all": "Tüm seçimi kaldır" "deselect_all": "Tüm seçimi kaldır",
"open_folder": "Klasör konumunu aç"
}, },
"dialogs": { "dialogs": {
"custom_options": "Özel seçenekler", "custom_options": "Özel seçenekler",
+2 -1
View File
@@ -80,7 +80,8 @@
"update": "更新 yt-dlp", "update": "更新 yt-dlp",
"select_defaults": "选择默认值", "select_defaults": "选择默认值",
"select_all": "全选", "select_all": "全选",
"deselect_all": "取消全选" "deselect_all": "取消全选",
"open_folder": "打开文件夹位置"
}, },
"dialogs": { "dialogs": {
"custom_options": "自定义选项", "custom_options": "自定义选项",
+85 -1
View File
@@ -645,6 +645,9 @@ class YTSageApp(QMainWindow, FormatTableMixin, VideoInfoMixin): # Inherit from
) )
progress_layout.addWidget(self.download_details_label) progress_layout.addWidget(self.download_details_label)
# Create a horizontal layout for status label and open folder button
status_layout = QHBoxLayout()
self.status_label = QLabel(_("app.ready")) self.status_label = QLabel(_("app.ready"))
self.status_label.setAlignment(Qt.AlignmentFlag.AlignCenter) self.status_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.status_label.setStyleSheet( self.status_label.setStyleSheet(
@@ -656,7 +659,36 @@ class YTSageApp(QMainWindow, FormatTableMixin, VideoInfoMixin): # Inherit from
} }
""" """
) )
progress_layout.addWidget(self.status_label) status_layout.addWidget(self.status_label)
# Add "Open Folder" button (initially hidden)
self.open_folder_btn = QPushButton("📁")
self.open_folder_btn.setToolTip(_("buttons.open_folder"))
self.open_folder_btn.setFixedSize(30, 30)
self.open_folder_btn.setStyleSheet(
"""
QPushButton {
background-color: #2a2d2e;
color: #cccccc;
border: 1px solid #404040;
border-radius: 5px;
font-size: 16px;
padding: 2px;
}
QPushButton:hover {
background-color: #3a3d3e;
border: 1px solid #505050;
}
QPushButton:pressed {
background-color: #1a1d1e;
}
"""
)
self.open_folder_btn.clicked.connect(self.open_download_folder)
self.open_folder_btn.setVisible(False) # Hidden by default
status_layout.addWidget(self.open_folder_btn)
progress_layout.addLayout(status_layout)
layout.addLayout(progress_layout) layout.addLayout(progress_layout)
@@ -970,6 +1002,7 @@ class YTSageApp(QMainWindow, FormatTableMixin, VideoInfoMixin): # Inherit from
# Show preparation message # Show preparation message
self.status_label.setText(_('download.preparing')) self.status_label.setText(_('download.preparing'))
self.progress_bar.setValue(0) self.progress_bar.setValue(0)
self.open_folder_btn.setVisible(False) # Hide the open folder button on new download
# Get resolution for filename # Get resolution for filename
resolution = "default" resolution = "default"
@@ -1081,10 +1114,61 @@ class YTSageApp(QMainWindow, FormatTableMixin, VideoInfoMixin): # Inherit from
# Default case # Default case
else: else:
self.status_label.setText(_('download.completed')) self.status_label.setText(_('download.completed'))
# Show the open folder button
self.open_folder_btn.setVisible(True)
# Play notification sound when download completes # Play notification sound when download completes
self.play_notification_sound() self.play_notification_sound()
def open_download_folder(self) -> None:
"""Open the folder containing the downloaded file and select it if possible"""
try:
if self.download_thread and self.download_thread.last_file_path:
file_path = Path(self.download_thread.last_file_path)
if file_path.exists():
# On Windows, use explorer with /select to highlight the file
if subprocess.sys.platform == "win32":
subprocess.run(['explorer', '/select,', str(file_path)], creationflags=SUBPROCESS_CREATIONFLAGS)
# On macOS, use open with -R to reveal in Finder
elif subprocess.sys.platform == "darwin":
subprocess.run(['open', '-R', str(file_path)])
# On Linux, try to open the folder (file selection not widely supported)
else:
folder_path = file_path.parent
subprocess.run(['xdg-open', str(folder_path)])
logger.info(f"Opened folder for: {file_path}")
else:
# If file doesn't exist, just open the download folder
folder_path = Path(self.last_path)
if folder_path.exists():
if subprocess.sys.platform == "win32":
subprocess.run(['explorer', str(folder_path)], creationflags=SUBPROCESS_CREATIONFLAGS)
elif subprocess.sys.platform == "darwin":
subprocess.run(['open', str(folder_path)])
else:
subprocess.run(['xdg-open', str(folder_path)])
else:
logger.warning(f"Download folder does not exist: {folder_path}")
else:
# Fallback to opening the general download folder
folder_path = Path(self.last_path)
if folder_path.exists():
if subprocess.sys.platform == "win32":
subprocess.run(['explorer', str(folder_path)], creationflags=SUBPROCESS_CREATIONFLAGS)
elif subprocess.sys.platform == "darwin":
subprocess.run(['open', str(folder_path)])
else:
subprocess.run(['xdg-open', str(folder_path)])
else:
logger.warning(f"Download folder does not exist: {folder_path}")
except Exception as e:
logger.exception(f"Error opening download folder: {e}")
QMessageBox.warning(self, "Error", f"Could not open folder: {str(e)}")
def download_error(self, error_message) -> None: def download_error(self, error_message) -> None:
self.toggle_download_controls(True) self.toggle_download_controls(True)
self.pause_btn.setVisible(False) self.pause_btn.setVisible(False)