Prechádzať zdrojové kódy

more work on burning multiple cd's

Noah Vogt 1 rok pred
rodič
commit
1e8cb33d1f
4 zmenil súbory, kde vykonal 97 pridanie a 7 odobranie
  1. 1 1
      input/__init__.py
  2. 86 2
      input/gui.py
  3. 2 3
      set_cd_marker.py
  4. 8 1
      utils/scripts.py

+ 1 - 1
input/__init__.py

@@ -32,4 +32,4 @@ from .validate_config import (
     validate_cd_record_config,
 )
 from .slide_selection_iterator import slide_selection_iterator
-from .gui import RadioButtonDialog, InfoMsgBox
+from .gui import RadioButtonDialog, InfoMsgBox, SheetAndPreviewChooser

+ 86 - 2
input/gui.py

@@ -19,6 +19,9 @@ from PyQt5.QtWidgets import (  # pylint: disable=no-name-in-module
     QApplication,
     QDialog,
     QVBoxLayout,
+    QHBoxLayout,
+    QStyle,
+    QLabel,
     QRadioButton,
     QPushButton,
     QMessageBox,
@@ -26,6 +29,7 @@ from PyQt5.QtWidgets import (  # pylint: disable=no-name-in-module
     QScrollArea,
     QWidget,
 )
+from PyQt5.QtCore import QSize
 
 
 # pylint: disable=too-few-public-methods
@@ -65,12 +69,10 @@ class RadioButtonDialog(QDialog):  # pylint: disable=too-few-public-methods
         self.radio_button_group = QButtonGroup(self)
 
         self.chosen = ""
-        self.radio_buttons = []
         for num, item in enumerate(options):
             radio_button = QRadioButton(item)
             if num == 0:
                 radio_button.setChecked(True)
-            self.radio_buttons.append(radio_button)
             self.radio_button_group.addButton(radio_button)
             scroll_area_layout.addWidget(radio_button)
 
@@ -92,3 +94,85 @@ class RadioButtonDialog(QDialog):  # pylint: disable=too-few-public-methods
                 "No Selection",
                 "Please select an option before proceeding.",
             )
+
+
+class SheetAndPreviewChooser(QDialog):  # pylint: disable=too-few-public-methods
+    def __init__(
+        self, base_dir: str, options: list[str], window_title: str
+    ) -> None:
+        super().__init__()
+        self.setWindowTitle(window_title)
+
+        master_layout = QVBoxLayout(self)
+
+        scroll_area = QScrollArea()
+        scroll_area.setWidgetResizable(True)
+        master_layout.addWidget(scroll_area)
+
+        scroll_content = QWidget()
+        scroll_area.setWidget(scroll_content)
+        scroll_area_layout = QVBoxLayout(scroll_content)
+
+        self.radio_button_group = QButtonGroup(self)
+
+        self.chosen = ""
+        for num, item in enumerate(options):
+            radio_button = QRadioButton(item)
+            if num == 0:
+                radio_button.setChecked(True)
+            button_layout = QHBoxLayout()
+            self.radio_button_group.addButton(radio_button)
+
+            button_layout.addWidget(radio_button)
+
+            play_button = self.get_player_button("SP_MediaPlay")
+            play_button.setToolTip("Play CD Preview")
+
+            pause_button = self.get_player_button("SP_MediaPause")
+            pause_button.setToolTip("Pause CD Preview")
+
+            stop_button = self.get_player_button("SP_MediaStop")
+            stop_button.setToolTip("Stop CD Preview")
+
+            seek_bwd_button = self.get_player_button("SP_MediaSeekBackward")
+            seek_bwd_button.setToolTip("Seek 10 seconds backwards")
+
+            seek_fwd_button = self.get_player_button("SP_MediaSeekForward")
+            seek_fwd_button.setToolTip("Seek 10 seconds forwards")
+
+            button_layout.addWidget(play_button)
+            button_layout.addWidget(pause_button)
+            button_layout.addWidget(stop_button)
+            button_layout.addWidget(seek_bwd_button)
+            button_layout.addWidget(seek_fwd_button)
+            button_layout.addWidget(QLabel("01:23 / 80:00"))
+
+            scroll_area_layout.addLayout(button_layout)
+
+        ok_button = QPushButton("OK")
+        ok_button.clicked.connect(self.accept)
+        master_layout.addWidget(ok_button)
+
+    def get_player_button(self, icon_name: str) -> QPushButton:
+        stop_button = QPushButton("")
+        stop_button.setMinimumSize(QSize(40, 40))
+        stop_button.setMaximumSize(QSize(40, 40))
+        pixmapi = getattr(QStyle, icon_name)
+        icon = self.style().standardIcon(pixmapi)  # pyright: ignore
+        stop_button.setIcon(icon)
+        return stop_button
+
+    def accept(self):
+        selected_button = self.radio_button_group.checkedButton()
+        if selected_button:
+            self.chosen = selected_button.text()
+            # QMessageBox.information(
+            #     self, "Selection", f"You selected: {selected_button.text()}"
+            # )
+            super().accept()
+        else:
+            QMessageBox.warning(
+                self,
+                "No Selection",
+                "Please select an option before proceeding.",
+            )

+ 2 - 3
set_cd_marker.py

@@ -192,9 +192,8 @@ def update_cue_sheet(
         last_track_milis = int(cachefile_content[4])
         if unix_milis - last_track_milis < const.CD_RECORD_MIN_TRACK_MILIS:
             warn(
-                "Minimum track length of {}ms not satisfied".format(
-                    const.CD_RECORD_MIN_TRACK_MILIS
-                )
+                f"Minimum track length of {const.CD_RECORD_MIN_TRACK_MILIS}"
+                + "ms not satisfied, skipping..."
             )
             return
 

+ 8 - 1
utils/scripts.py

@@ -42,6 +42,7 @@ from input import (
     validate_cd_record_config,
     RadioButtonDialog,
     InfoMsgBox,
+    SheetAndPreviewChooser,
 )
 from os_agnostic import get_cd_drives, eject_drive
 import config as const
@@ -222,7 +223,7 @@ def burn_cds_of_day(yyyy_mm_dd: str) -> None:
         target_dir = path.join(
             expand_dir(const.CD_RECORD_OUTPUT_BASEDIR), yyyy_mm_dd
         )
-        if not path.isfile(target_dir):
+        if not path.isdir(target_dir):
             exit_as_no_cds_found(target_dir)
 
         target_files = sorted(listdir(target_dir))
@@ -239,6 +240,12 @@ def burn_cds_of_day(yyyy_mm_dd: str) -> None:
         else:
             for num, file in enumerate(cue_sheets):
                 log(f"file found: {file}")
+            app = QApplication([])
+            dialog = SheetAndPreviewChooser(
+                target_dir, cue_sheets, "Preview CD's"
+            )
+            if dialog.exec_() == QDialog.Accepted:
+                log(f"Burning CD from sheet: {dialog.chosen}")
 
     except (FileNotFoundError, PermissionError, IOError):
         InfoMsgBox(