Skip to content

Commit bf4ecc9

Browse files
committed
Add custom success message box with "Open Folder" option in MainApp
1 parent 7e381e8 commit bf4ecc9

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

main.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,44 @@ def _show_success(self, message):
657657
"""Display success message."""
658658
self.status_label.setText(f"Success! Saved to: {self.output_folder}")
659659
self.status_label.setStyleSheet("color: #4caf50;")
660-
QMessageBox.information(self, "Success", message)
660+
661+
# Create custom message box with "Open Folder" button
662+
msg_box = QMessageBox(self)
663+
msg_box.setWindowTitle("Success")
664+
msg_box.setText(message)
665+
msg_box.setIcon(QMessageBox.Icon.Information)
666+
667+
# Add standard OK button
668+
msg_box.addButton(QMessageBox.StandardButton.Ok)
669+
670+
# Add custom "Open Folder" button
671+
open_folder_btn = msg_box.addButton("Open Folder", QMessageBox.ButtonRole.ActionRole)
672+
673+
msg_box.exec()
674+
675+
# Check if user clicked "Open Folder"
676+
if msg_box.clickedButton() == open_folder_btn:
677+
self._open_output_folder()
678+
679+
def _open_output_folder(self):
680+
"""Open the output folder in the system file explorer."""
681+
if not self.output_folder:
682+
return
683+
684+
import subprocess
685+
import platform
686+
687+
folder_path = str(Path(self.output_folder).resolve())
688+
689+
try:
690+
if platform.system() == "Windows":
691+
os.startfile(folder_path)
692+
elif platform.system() == "Darwin": # macOS
693+
subprocess.run(["open", folder_path], check=True)
694+
else: # Linux and others
695+
subprocess.run(["xdg-open", folder_path], check=True)
696+
except Exception as e:
697+
QMessageBox.warning(self, "Error", f"Could not open folder:\n{str(e)}")
661698

662699
def _ensure_output_folder(self):
663700
"""Validate the output folder before writing files."""

0 commit comments

Comments
 (0)