mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Improve the message of the deletion dialog. Closes #1073.
This commit is contained in:
parent
475aa6aad8
commit
b1e682ef41
@ -44,7 +44,7 @@
|
|||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Are you sure you want to delete the selected torrents from the transfer list?</string>
|
<string notr="true">deletion message goes here</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
|
@ -40,8 +40,12 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DeletionConfirmationDlg(QWidget *parent=0): QDialog(parent) {
|
DeletionConfirmationDlg(QWidget *parent, const int &size, const QString &name): QDialog(parent) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
if (size == 1)
|
||||||
|
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));
|
||||||
|
else
|
||||||
|
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
|
// Icons
|
||||||
lbl_warn->setPixmap(IconProvider::instance()->getIcon("dialog-warning").pixmap(lbl_warn->height()));
|
lbl_warn->setPixmap(IconProvider::instance()->getIcon("dialog-warning").pixmap(lbl_warn->height()));
|
||||||
lbl_warn->setFixedWidth(lbl_warn->height());
|
lbl_warn->setFixedWidth(lbl_warn->height());
|
||||||
@ -57,10 +61,10 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
|
|||||||
return checkPermDelete->isChecked();
|
return checkPermDelete->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool askForDeletionConfirmation(bool *delete_local_files) {
|
static bool askForDeletionConfirmation(bool& delete_local_files, const int& size, const QString& name) {
|
||||||
DeletionConfirmationDlg dlg;
|
DeletionConfirmationDlg dlg(NULL, size, name);
|
||||||
if (dlg.exec() == QDialog::Accepted) {
|
if (dlg.exec() == QDialog::Accepted) {
|
||||||
*delete_local_files = dlg.shouldDeleteLocalFiles();
|
delete_local_files = dlg.shouldDeleteLocalFiles();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -305,9 +305,10 @@ void TransferListWidget::deleteSelectedTorrents() {
|
|||||||
if (main_window->getCurrentTabWidget() != this) return;
|
if (main_window->getCurrentTabWidget() != this) return;
|
||||||
const QStringList& hashes = getSelectedTorrentsHashes();
|
const QStringList& hashes = getSelectedTorrentsHashes();
|
||||||
if (hashes.empty()) return;
|
if (hashes.empty()) return;
|
||||||
|
QTorrentHandle torrent = BTSession->getTorrentHandle(hashes[0]);
|
||||||
bool delete_local_files = false;
|
bool delete_local_files = false;
|
||||||
if (Preferences().confirmTorrentDeletion() &&
|
if (Preferences().confirmTorrentDeletion() &&
|
||||||
!DeletionConfirmationDlg::askForDeletionConfirmation(&delete_local_files))
|
!DeletionConfirmationDlg::askForDeletionConfirmation(delete_local_files, hashes.size(), torrent.name()))
|
||||||
return;
|
return;
|
||||||
foreach (const QString &hash, hashes) {
|
foreach (const QString &hash, hashes) {
|
||||||
BTSession->deleteTorrent(hash, delete_local_files);
|
BTSession->deleteTorrent(hash, delete_local_files);
|
||||||
@ -316,9 +317,10 @@ void TransferListWidget::deleteSelectedTorrents() {
|
|||||||
|
|
||||||
void TransferListWidget::deleteVisibleTorrents() {
|
void TransferListWidget::deleteVisibleTorrents() {
|
||||||
if (nameFilterModel->rowCount() <= 0) return;
|
if (nameFilterModel->rowCount() <= 0) return;
|
||||||
|
QTorrentHandle torrent = BTSession->getTorrentHandle(getHashFromRow(0));
|
||||||
bool delete_local_files = false;
|
bool delete_local_files = false;
|
||||||
if (Preferences().confirmTorrentDeletion() &&
|
if (Preferences().confirmTorrentDeletion() &&
|
||||||
!DeletionConfirmationDlg::askForDeletionConfirmation(&delete_local_files))
|
!DeletionConfirmationDlg::askForDeletionConfirmation(delete_local_files, nameFilterModel->rowCount(), torrent.name()))
|
||||||
return;
|
return;
|
||||||
QStringList hashes;
|
QStringList hashes;
|
||||||
for (int i=0; i<nameFilterModel->rowCount(); ++i) {
|
for (int i=0; i<nameFilterModel->rowCount(); ++i) {
|
||||||
|
Loading…
Reference in New Issue
Block a user