custom question box with details
This commit is contained in:
parent
7ee1026421
commit
1970235224
@ -18,10 +18,12 @@ from PyQt5.QtWidgets import (
|
||||
QAction,
|
||||
QHeaderView,
|
||||
QMenu,
|
||||
QPlainTextEdit,
|
||||
QTableView,
|
||||
QShortcut,
|
||||
QMessageBox,
|
||||
QAbstractItemView,
|
||||
QVBoxLayout,
|
||||
)
|
||||
from PyQt5.QtCore import (
|
||||
QItemSelectionModel,
|
||||
@ -37,6 +39,7 @@ from components.ErrorDialog import ErrorDialog
|
||||
from components.LyricsWindow import LyricsWindow
|
||||
from components.AddToPlaylistWindow import AddToPlaylistWindow
|
||||
from components.MetadataWindow import MetadataWindow
|
||||
from components.QuestionBoxDetails import QuestionBoxDetails
|
||||
|
||||
from main import Worker
|
||||
from utils.batch_delete_filepaths_from_database import (
|
||||
@ -496,21 +499,20 @@ class MusicTable(QTableView):
|
||||
# FIXME: need to get indexes based on the proxy model
|
||||
selected_filepaths = self.get_selected_songs_filepaths()
|
||||
formatted_selected_filepaths = "\n".join(selected_filepaths)
|
||||
reply = QMessageBox.question(
|
||||
self,
|
||||
"Confirmation",
|
||||
f"Remove these songs from the library? (Files stay on your computer)\n{formatted_selected_filepaths}",
|
||||
QMessageBox.Yes | QMessageBox.No,
|
||||
QMessageBox.Yes,
|
||||
question_dialog = QuestionBoxDetails(
|
||||
title="Delete songs",
|
||||
description="Remove these songs from the library?",
|
||||
details=formatted_selected_filepaths,
|
||||
)
|
||||
if reply == QMessageBox.Yes:
|
||||
pprint(selected_filepaths)
|
||||
reply = question_dialog.execute()
|
||||
if reply:
|
||||
worker = Worker(batch_delete_filepaths_from_database, selected_filepaths)
|
||||
worker.signals.signal_progress.connect(self.qapp.handle_progress)
|
||||
worker.signals.signal_finished.connect(self.delete_selected_row_indices)
|
||||
if self.qapp:
|
||||
threadpool = self.qapp.threadpool
|
||||
threadpool.start(worker)
|
||||
return
|
||||
|
||||
def delete_selected_row_indices(self):
|
||||
"""
|
||||
|
||||
57
components/QuestionBoxDetails.py
Normal file
57
components/QuestionBoxDetails.py
Normal file
@ -0,0 +1,57 @@
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialog,
|
||||
QHBoxLayout,
|
||||
QPlainTextEdit,
|
||||
QVBoxLayout,
|
||||
QLabel,
|
||||
QPushButton,
|
||||
)
|
||||
from PyQt5.QtGui import QFont
|
||||
from components.ErrorDialog import ErrorDialog
|
||||
from utils import set_id3_tag
|
||||
from logging import debug
|
||||
|
||||
|
||||
class QuestionBoxDetails(QDialog):
|
||||
def __init__(self, title: str, description: str, details):
|
||||
super(QuestionBoxDetails, self).__init__()
|
||||
self.title: str = title
|
||||
self.description: str = description
|
||||
self.details: str = details
|
||||
self.reply: bool = False
|
||||
self.setWindowTitle(title)
|
||||
self.setMinimumSize(400, 400)
|
||||
layout = QVBoxLayout()
|
||||
h_layout = QHBoxLayout()
|
||||
|
||||
# Labels & input fields
|
||||
label = QLabel(description)
|
||||
layout.addWidget(label)
|
||||
self.text_field = QPlainTextEdit(self.details)
|
||||
layout.addWidget(self.text_field)
|
||||
# cancel
|
||||
cancel_button = QPushButton("cancel")
|
||||
cancel_button.clicked.connect(self.cancel)
|
||||
h_layout.addWidget(cancel_button)
|
||||
# ok
|
||||
ok_button = QPushButton("ok")
|
||||
ok_button.clicked.connect(self.ok)
|
||||
h_layout.addWidget(ok_button)
|
||||
|
||||
layout.addLayout(h_layout)
|
||||
self.setLayout(layout)
|
||||
|
||||
ok_button.setFocus()
|
||||
|
||||
def execute(self):
|
||||
self.exec_()
|
||||
return self.reply
|
||||
|
||||
def cancel(self):
|
||||
self.reply = False
|
||||
self.close()
|
||||
|
||||
def ok(self):
|
||||
self.reply = True
|
||||
self.close()
|
||||
@ -9,3 +9,4 @@ from .AddToPlaylistWindow import AddToPlaylistWindow
|
||||
from .CreatePlaylistWindow import CreatePlaylistWindow
|
||||
from .PlaylistsPane import PlaylistsPane
|
||||
from .ExportPlaylistWindow import ExportPlaylistWindow
|
||||
from .QuestionBoxDetails import QuestionBoxDetails
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user