mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-21 08:09:35 +08:00
Add torrent and files deletion with Shift+Delete hotkey
This commit is contained in:
parent
affebf3431
commit
5f4114ae76
@ -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;
|
||||
|
@ -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()));
|
||||
|
@ -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<BitTorrent::TorrentHandle *> 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()
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user