Browse Source

Improve the message of the deletion dialog. Closes #1073.

adaptive-webui-19844
sledgehammer999 11 years ago
parent
commit
b1e682ef41
  1. 2
      src/confirmdeletiondlg.ui
  2. 12
      src/deletionconfirmationdlg.h
  3. 6
      src/transferlistwidget.cpp

2
src/confirmdeletiondlg.ui

@ -44,7 +44,7 @@ @@ -44,7 +44,7 @@
</sizepolicy>
</property>
<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 name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>

12
src/deletionconfirmationdlg.h

@ -40,8 +40,12 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg { @@ -40,8 +40,12 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
Q_OBJECT
public:
DeletionConfirmationDlg(QWidget *parent=0): QDialog(parent) {
DeletionConfirmationDlg(QWidget *parent, const int &size, const QString &name): QDialog(parent) {
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
lbl_warn->setPixmap(IconProvider::instance()->getIcon("dialog-warning").pixmap(lbl_warn->height()));
lbl_warn->setFixedWidth(lbl_warn->height());
@ -57,10 +61,10 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg { @@ -57,10 +61,10 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
return checkPermDelete->isChecked();
}
static bool askForDeletionConfirmation(bool *delete_local_files) {
DeletionConfirmationDlg dlg;
static bool askForDeletionConfirmation(bool& delete_local_files, const int& size, const QString& name) {
DeletionConfirmationDlg dlg(NULL, size, name);
if (dlg.exec() == QDialog::Accepted) {
*delete_local_files = dlg.shouldDeleteLocalFiles();
delete_local_files = dlg.shouldDeleteLocalFiles();
return true;
}
return false;

6
src/transferlistwidget.cpp

@ -305,9 +305,10 @@ void TransferListWidget::deleteSelectedTorrents() { @@ -305,9 +305,10 @@ void TransferListWidget::deleteSelectedTorrents() {
if (main_window->getCurrentTabWidget() != this) return;
const QStringList& hashes = getSelectedTorrentsHashes();
if (hashes.empty()) return;
QTorrentHandle torrent = BTSession->getTorrentHandle(hashes[0]);
bool delete_local_files = false;
if (Preferences().confirmTorrentDeletion() &&
!DeletionConfirmationDlg::askForDeletionConfirmation(&delete_local_files))
!DeletionConfirmationDlg::askForDeletionConfirmation(delete_local_files, hashes.size(), torrent.name()))
return;
foreach (const QString &hash, hashes) {
BTSession->deleteTorrent(hash, delete_local_files);
@ -316,9 +317,10 @@ void TransferListWidget::deleteSelectedTorrents() { @@ -316,9 +317,10 @@ void TransferListWidget::deleteSelectedTorrents() {
void TransferListWidget::deleteVisibleTorrents() {
if (nameFilterModel->rowCount() <= 0) return;
QTorrentHandle torrent = BTSession->getTorrentHandle(getHashFromRow(0));
bool delete_local_files = false;
if (Preferences().confirmTorrentDeletion() &&
!DeletionConfirmationDlg::askForDeletionConfirmation(&delete_local_files))
!DeletionConfirmationDlg::askForDeletionConfirmation(delete_local_files, nameFilterModel->rowCount(), torrent.name()))
return;
QStringList hashes;
for (int i=0; i<nameFilterModel->rowCount(); ++i) {

Loading…
Cancel
Save