# 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 . from PySide6.QtCore import Signal from PySide6.QtGui import Qt from PySide6.QtWidgets import ( QHBoxLayout, QLabel, QPushButton, QScrollArea, QVBoxLayout, QWidget, ) from Soundboard import SoundboardSound class CategoryListWidget(QWidget): play_random = Signal() def __init__(self, parent=None): super().__init__(parent) layout = QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) header_layout = QHBoxLayout() header_layout.setContentsMargins(12, 8, 12, 8) self.title_label = QLabel() font = self.title_label.font() font.setBold(True) font.setPointSize(13) self.title_label.setFont(font) header_layout.addWidget(self.title_label, stretch=1) self.random_btn = QPushButton("Play Random") self.random_btn.clicked.connect(self.play_random.emit) header_layout.addWidget(self.random_btn) layout.addLayout(header_layout) self.scroll_area = QScrollArea() self.scroll_area.setWidgetResizable(True) self.scroll_area.setVerticalScrollBarPolicy( Qt.ScrollBarPolicy.ScrollBarAlwaysOn ) self.scroll_area.setFrameShape(QScrollArea.Shape.NoFrame) self.scroll_area.setStyleSheet(""" QScrollArea { border: 1px solid palette(shadow); } """) self.categories_container = QWidget() self.categories_container.setObjectName("lightbg") self.categories_container.setStyleSheet(""" #lightbg { background-color: palette(light); } """) self.categories_layout = QVBoxLayout(self.categories_container) self.categories_layout.setContentsMargins(0, 20, 0, 20) self.categories_layout.setSpacing(16) self.scroll_area.setWidget(self.categories_container) layout.addWidget(self.scroll_area, stretch=1) def set_cards(self, cards): for card in cards: self.categories_layout.addWidget( card, alignment=Qt.AlignmentFlag.AlignHCenter )