From ca7cb853bdf289f9e0776fe8ac9d517ca744e204 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Fri, 30 Oct 2026 13:46:12 -0700 Subject: chore(gui): refactor dialogs into their own modules --- dialogs/rip_cd_dialog.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 dialogs/rip_cd_dialog.py (limited to 'dialogs/rip_cd_dialog.py') diff --git a/dialogs/rip_cd_dialog.py b/dialogs/rip_cd_dialog.py new file mode 100644 index 0000000..dd3ac8f --- /dev/null +++ b/dialogs/rip_cd_dialog.py @@ -0,0 +1,50 @@ +from PyQt6.QtCore import Qt +from PyQt6.QtWidgets import ( + QDialog, + QHBoxLayout, + QLabel, + QListWidget, + QListWidgetItem, + QMessageBox, + QPushButton, + QVBoxLayout, +) + + +class RipCdDialog(QDialog): + def __init__(self, drives: list[tuple[str, str]], parent=None): + super().__init__(parent) + self.setWindowTitle("Select optical drive") + self.resize(680, 360) + self.selected_drive: str | None = None + + layout = QVBoxLayout(self) + layout.addWidget(QLabel("Select the optical drive to use for CD ripping:")) + + self.drives = QListWidget() + for path, label in drives: + item = QListWidgetItem(label) + item.setData(Qt.ItemDataRole.UserRole, path) + self.drives.addItem(item) + if drives: + self.drives.setCurrentRow(0) + self.drives.itemDoubleClicked.connect(lambda _: self._accept()) + layout.addWidget(self.drives, 1) + + buttons = QHBoxLayout() + buttons.addStretch(1) + ok_btn = QPushButton("Use Drive") + ok_btn.clicked.connect(self._accept) + cancel_btn = QPushButton("Cancel") + cancel_btn.clicked.connect(self.reject) + buttons.addWidget(ok_btn) + buttons.addWidget(cancel_btn) + layout.addLayout(buttons) + + def _accept(self): + item = self.drives.currentItem() + if not item: + QMessageBox.information(self, "No drive selected", "Select an optical drive first.") + return + self.selected_drive = item.data(Qt.ItemDataRole.UserRole) + self.accept() -- cgit v1.2.3