mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-19 15:07:22 -06:00
Handle "Delete confirmation" dialog result asynchronously
This is to avoid creating nested event loops as discussed in https://github.com/qbittorrent/qBittorrent/pull/10786#issuecomment-502795822
This commit is contained in:
@@ -39,10 +39,12 @@ DeletionConfirmationDialog::DeletionConfirmationDialog(QWidget *parent, const in
|
||||
, m_ui(new Ui::DeletionConfirmationDialog)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
if (size == 1)
|
||||
m_ui->label->setText(tr("Are you sure you want to delete '%1' from the transfer list?", "Are you sure you want to delete 'ubuntu-linux-iso' from the transfer list?").arg(name.toHtmlEscaped()));
|
||||
else
|
||||
m_ui->label->setText(tr("Are you sure you want to delete these %1 torrents from the transfer list?", "Are you sure you want to delete these 5 torrents from the transfer list?").arg(QString::number(size)));
|
||||
|
||||
// Icons
|
||||
const QSize iconSize = Utils::Gui::largeIconSize();
|
||||
m_ui->labelWarning->setPixmap(UIThemeManager::instance()->getIcon("dialog-warning").pixmap(iconSize));
|
||||
@@ -62,21 +64,11 @@ DeletionConfirmationDialog::~DeletionConfirmationDialog()
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool DeletionConfirmationDialog::shouldDeleteLocalFiles() const
|
||||
bool DeletionConfirmationDialog::isDeleteFileSelected() const
|
||||
{
|
||||
return m_ui->checkPermDelete->isChecked();
|
||||
}
|
||||
|
||||
bool DeletionConfirmationDialog::askForDeletionConfirmation(QWidget *parent, bool &deleteLocalFiles, const int size, const QString &name)
|
||||
{
|
||||
DeletionConfirmationDialog dlg(parent, size, name, deleteLocalFiles);
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
deleteLocalFiles = dlg.shouldDeleteLocalFiles();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DeletionConfirmationDialog::updateRememberButtonState()
|
||||
{
|
||||
m_ui->rememberBtn->setEnabled(m_ui->checkPermDelete->isChecked() != Preferences::instance()->deleteTorrentFilesAsDefault());
|
||||
|
||||
Reference in New Issue
Block a user