aboutsummaryrefslogtreecommitdiffstats
path: root/SoundListItemWidget.py
blob: 92ba827f0d04a3d57ca2cb2c9e8b19495cae9f2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# 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.QtWidgets import QFrame, QHBoxLayout, QLabel, QPushButton

from Soundboard import SoundboardSound


class SoundListItemWidget(QFrame):
    play_requested = Signal(SoundboardSound)

    def __init__(self, sound: SoundboardSound, parent=None):  # noqa: F821
        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(lambda: self.download_requested.emit(self.sound_data))
        # 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)