diff options
| author | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2026-07-24 18:00:52 +0530 |
|---|---|---|
| committer | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2026-07-24 18:00:52 +0530 |
| commit | bc7d62ca9a406bc30419e985016c7f4f56e54e76 (patch) | |
| tree | b4f1091e7f008df31d20039f0fa4c683d05785e5 /CategoryListWidget.py | |
first commit
Diffstat (limited to 'CategoryListWidget.py')
| -rw-r--r-- | CategoryListWidget.py | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/CategoryListWidget.py b/CategoryListWidget.py new file mode 100644 index 0000000..3a66166 --- /dev/null +++ b/CategoryListWidget.py @@ -0,0 +1,87 @@ +# Soundboard Engine - customizable soundboard +# Copyright (C) 2026 Vidhu Kant Sharma <vidhukant@vidhukant.com> +# +# 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 <https://www.gnu.org/licenses/>. + +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 + ) |