aboutsummaryrefslogtreecommitdiffstats
path: root/SoundListItemWidget.py
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.com>2026-07-24 21:49:20 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.com>2026-07-24 21:49:20 +0530
commitf741642a63799a45017b2fa62db25932e526b2f3 (patch)
tree69ca0af517c76e54ba3b4eeeafde37681e1ecad8 /SoundListItemWidget.py
parent79261efa3895867f1d962da58373bb338c534d11 (diff)
added download option
Diffstat (limited to 'SoundListItemWidget.py')
-rw-r--r--SoundListItemWidget.py27
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)