diff options
Diffstat (limited to 'SoundListItemWidget.py')
| -rw-r--r-- | SoundListItemWidget.py | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/SoundListItemWidget.py b/SoundListItemWidget.py index 92ba827..194b633 100644 --- a/SoundListItemWidget.py +++ b/SoundListItemWidget.py @@ -14,8 +14,12 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. +import sys +import shutil +from pathlib import Path + from PySide6.QtCore import Signal -from PySide6.QtWidgets import QFrame, QHBoxLayout, QLabel, QPushButton +from PySide6.QtWidgets import QFrame, QHBoxLayout, QLabel, QPushButton, QFileDialog from Soundboard import SoundboardSound @@ -23,7 +27,7 @@ from Soundboard import SoundboardSound class SoundListItemWidget(QFrame): play_requested = Signal(SoundboardSound) - def __init__(self, sound: SoundboardSound, parent=None): # noqa: F821 + def __init__(self, sound: SoundboardSound, parent=None): super().__init__(parent) self.sound = sound @@ -51,10 +55,23 @@ class SoundListItemWidget(QFrame): 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_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) |