# Soundboard Engine - customizable soundboard # Copyright (C) 2026 Vidhu Kant Sharma # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import sys import shutil from pathlib import Path from PySide6.QtCore import Signal from PySide6.QtWidgets import QFrame, QHBoxLayout, QLabel, QPushButton, QFileDialog from Soundboard import SoundboardSound class SoundListItemWidget(QFrame): play_requested = Signal(SoundboardSound) def __init__(self, sound: SoundboardSound, parent=None): super().__init__(parent) self.sound = sound self.setFixedHeight(48) self.setStyleSheet(""" SoundListItemWidget { border: none; border-bottom: 1px solid palette(shadow); background-color: palette(window); } SoundListItemWidget:hover { background-color: palette(mid); } """) layout = QHBoxLayout(self) layout.setContentsMargins(12, 6, 12, 6) layout.setSpacing(10) self.title_label = QLabel(sound.title) font = self.title_label.font() font.setBold(True) self.title_label.setFont(font) layout.addWidget(self.title_label, stretch=1) self.btn_download = QPushButton("Download") self.btn_download.clicked.connect(self.download) layout.addWidget(self.btn_download) self.btn_play = QPushButton("Play") self.btn_play.clicked.connect(lambda: self.play_requested.emit(self.sound)) layout.addWidget(self.btn_play) def download(self): selected_folder = QFileDialog.getSaveFileName( self, "Save Audio File", self.sound.title + Path(self.sound.path).suffix, "All Files (*)" ) if selected_folder: self.download_dest = Path(selected_folder[0]) print(self.download_dest) shutil.copy2(self.sound.path, self.download_dest)