diff --git a/src/gui/deletionconfirmationdlg.h b/src/gui/deletionconfirmationdlg.h index 056fb526e..2715f7ce9 100644 --- a/src/gui/deletionconfirmationdlg.h +++ b/src/gui/deletionconfirmationdlg.h @@ -42,7 +42,7 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg { Q_OBJECT public: - DeletionConfirmationDlg(QWidget *parent, const int &size, const QString &name): QDialog(parent) { + DeletionConfirmationDlg(QWidget *parent, const int &size, const QString &name, bool defaultDeleteFiles): 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)); @@ -54,7 +54,7 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg { rememberBtn->setIcon(GuiIconProvider::instance()->getIcon("object-locked")); move(Utils::Misc::screenCenter(this)); - checkPermDelete->setChecked(Preferences::instance()->deleteTorrentFilesAsDefault()); + checkPermDelete->setChecked(defaultDeleteFiles || Preferences::instance()->deleteTorrentFilesAsDefault()); connect(checkPermDelete, SIGNAL(clicked()), this, SLOT(updateRememberButtonState())); buttonBox->button(QDialogButtonBox::Cancel)->setFocus(); } @@ -63,10 +63,10 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg { return checkPermDelete->isChecked(); } - static bool askForDeletionConfirmation(bool& delete_local_files, const int& size, const QString& name) { - DeletionConfirmationDlg dlg(NULL, size, name); + static bool askForDeletionConfirmation(bool& deleteLocalFiles, const int& size, const QString& name) { + DeletionConfirmationDlg dlg(NULL, size, name, deleteLocalFiles); if (dlg.exec() == QDialog::Accepted) { - delete_local_files = dlg.shouldDeleteLocalFiles(); + deleteLocalFiles = dlg.shouldDeleteLocalFiles(); return true; } return false; diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 23bef83b4..66239e69d 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -248,7 +248,7 @@ MainWindow::MainWindow(QWidget *parent) connect(m_ui->actionStartAll, SIGNAL(triggered()), m_transferListWidget, SLOT(resumeAllTorrents())); connect(m_ui->actionPause, SIGNAL(triggered()), m_transferListWidget, SLOT(pauseSelectedTorrents())); connect(m_ui->actionPauseAll, SIGNAL(triggered()), m_transferListWidget, SLOT(pauseAllTorrents())); - connect(m_ui->actionDelete, SIGNAL(triggered()), m_transferListWidget, SLOT(deleteSelectedTorrents())); + connect(m_ui->actionDelete, SIGNAL(triggered()), m_transferListWidget, SLOT(softDeleteSelectedTorrents())); connect(m_ui->actionTopPriority, SIGNAL(triggered()), m_transferListWidget, SLOT(topPrioSelectedTorrents())); connect(m_ui->actionIncreasePriority, SIGNAL(triggered()), m_transferListWidget, SLOT(increasePrioSelectedTorrents())); connect(m_ui->actionDecreasePriority, SIGNAL(triggered()), m_transferListWidget, SLOT(decreasePrioSelectedTorrents())); diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index 92287c9de..fb1c637eb 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -155,7 +155,8 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window) connect(header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(saveSettings())); editHotkey = new QShortcut(QKeySequence("F2"), this, SLOT(renameSelectedTorrent()), 0, Qt::WidgetShortcut); - deleteHotkey = new QShortcut(QKeySequence::Delete, this, SLOT(deleteSelectedTorrents()), 0, Qt::WidgetShortcut); + deleteHotkey = new QShortcut(QKeySequence::Delete, this, SLOT(softDeleteSelectedTorrents()), 0, Qt::WidgetShortcut); + permDeleteHotkey = new QShortcut(QKeySequence("Shift+Delete"), this, SLOT(permDeleteSelectedTorrents()), 0, Qt::WidgetShortcut); #ifdef QBT_USES_QT5 // This hack fixes reordering of first column with Qt5. @@ -309,19 +310,28 @@ void TransferListWidget::pauseVisibleTorrents() } } -void TransferListWidget::deleteSelectedTorrents() +void TransferListWidget::softDeleteSelectedTorrents() +{ + deleteSelectedTorrents(false); +} + +void TransferListWidget::permDeleteSelectedTorrents() +{ + deleteSelectedTorrents(true); +} + +void TransferListWidget::deleteSelectedTorrents(bool deleteLocalFiles) { if (main_window->currentTabWidget() != this) return; const QList torrents = getSelectedTorrents(); if (torrents.empty()) return; - bool delete_local_files = false; if (Preferences::instance()->confirmTorrentDeletion() && - !DeletionConfirmationDlg::askForDeletionConfirmation(delete_local_files, torrents.size(), torrents[0]->name())) + !DeletionConfirmationDlg::askForDeletionConfirmation(deleteLocalFiles, torrents.size(), torrents[0]->name())) return; foreach (BitTorrent::TorrentHandle *const torrent, torrents) - BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), delete_local_files); + BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteLocalFiles); } void TransferListWidget::deleteVisibleTorrents() @@ -332,12 +342,12 @@ void TransferListWidget::deleteVisibleTorrents() for (int i = 0; i < nameFilterModel->rowCount(); ++i) torrents << listModel->torrentHandle(mapToSource(nameFilterModel->index(i, 0))); - bool delete_local_files = false; + bool deleteLocalFiles = false; if (Preferences::instance()->confirmTorrentDeletion() && - !DeletionConfirmationDlg::askForDeletionConfirmation(delete_local_files, torrents.size(), torrents[0]->name())) + !DeletionConfirmationDlg::askForDeletionConfirmation(deleteLocalFiles, torrents.size(), torrents[0]->name())) return; foreach (BitTorrent::TorrentHandle *const torrent, torrents) - BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), delete_local_files); + BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteLocalFiles); } void TransferListWidget::increasePrioSelectedTorrents() diff --git a/src/gui/transferlistwidget.h b/src/gui/transferlistwidget.h index 0f001141b..46ec1c371 100644 --- a/src/gui/transferlistwidget.h +++ b/src/gui/transferlistwidget.h @@ -68,7 +68,9 @@ public slots: void startVisibleTorrents(); void pauseSelectedTorrents(); void pauseVisibleTorrents(); - void deleteSelectedTorrents(); + void softDeleteSelectedTorrents(); + void permDeleteSelectedTorrents(); + void deleteSelectedTorrents(bool deleteLocalFiles); void deleteVisibleTorrents(); void increasePrioSelectedTorrents(); void decreasePrioSelectedTorrents(); @@ -119,6 +121,7 @@ private: MainWindow *main_window; QShortcut *editHotkey; QShortcut *deleteHotkey; + QShortcut *permDeleteHotkey; }; #endif // TRANSFERLISTWIDGET_H