From 8fd7b86f45873c2ace75b1403ded9788e20058d4 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 16 Jan 2011 15:29:44 +0000 Subject: [PATCH] FEATURE: Added option to skip torrent deletion confirmation (Ville Kiiskinen) --- Changelog | 3 +++ src/preferences/advancedsettings.h | 13 ++++++++++-- src/preferences/preferences.h | 6 ++++++ src/transferlistwidget.cpp | 33 +++++++++++++++--------------- 4 files changed, 37 insertions(+), 18 deletions(-) diff --git a/Changelog b/Changelog index 36c526a03..a7612e7c9 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,6 @@ +* Unknown - Christophe Dumez - v2.7.0 + - FEATURE: Added option to skip torrent deletion confirmation (Ville Kiiskinen) + * Sun Jan 9 2011 - Christophe Dumez - v2.6.0 - FEATURE: Use system icons (Linux, Qt >= 4.6) - FEATURE: Improved ETA calculation diff --git a/src/preferences/advancedsettings.h b/src/preferences/advancedsettings.h index 0620dc0d5..2e33c2a7d 100644 --- a/src/preferences/advancedsettings.h +++ b/src/preferences/advancedsettings.h @@ -18,14 +18,15 @@ enum AdvSettingsRows {DISK_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_L #if defined(Q_WS_X11) && (QT_VERSION >= QT_VERSION_CHECK(4,6,0)) USE_ICON_THEME, #endif - ROW_COUNT }; + CONFIRM_DELETE_TORRENT, + ROW_COUNT}; class AdvancedSettings: public QTableWidget { Q_OBJECT private: QSpinBox *spin_cache, *outgoing_ports_min, *outgoing_ports_max, *spin_list_refresh, *spin_maxhalfopen, *spin_tracker_port; - QCheckBox *cb_ignore_limits_lan, *cb_count_overhead, *cb_recheck_completed, *cb_resolve_countries, *cb_resolve_hosts, *cb_super_seeding, *cb_program_notifications, *cb_tracker_status; + QCheckBox *cb_ignore_limits_lan, *cb_count_overhead, *cb_recheck_completed, *cb_resolve_countries, *cb_resolve_hosts, *cb_super_seeding, *cb_program_notifications, *cb_tracker_status, *cb_confirm_torrent_deletion; QComboBox *combo_iface; #if defined(Q_WS_WIN) || defined(Q_WS_MAC) QCheckBox *cb_update_check; @@ -67,6 +68,7 @@ public: delete cb_program_notifications; delete spin_tracker_port; delete cb_tracker_status; + delete cb_confirm_torrent_deletion; #if defined(Q_WS_WIN) || defined(Q_WS_MAC) delete cb_update_check; #endif @@ -119,6 +121,7 @@ public slots: #if defined(Q_WS_X11) && (QT_VERSION >= QT_VERSION_CHECK(4,6,0)) pref.useSystemIconTheme(cb_use_icon_theme->isChecked()); #endif + pref.setConfirmTorrentDeletion(cb_confirm_torrent_deletion->isChecked()); } protected slots: @@ -255,6 +258,12 @@ protected slots: cb_use_icon_theme->setChecked(pref.useSystemIconTheme()); setCellWidget(USE_ICON_THEME, VALUE, cb_use_icon_theme); #endif + // Torrent deletion confirmation + setItem(CONFIRM_DELETE_TORRENT, PROPERTY, new QTableWidgetItem(tr("Confirm torrent deletion"))); + cb_confirm_torrent_deletion = new QCheckBox(); + connect(cb_confirm_torrent_deletion, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged())); + cb_confirm_torrent_deletion->setChecked(pref.confirmTorrentDeletion()); + setCellWidget(CONFIRM_DELETE_TORRENT, VALUE, cb_confirm_torrent_deletion); } void emitSettingsChanged() { diff --git a/src/preferences/preferences.h b/src/preferences/preferences.h index a9dcd0160..a4c1aa74a 100644 --- a/src/preferences/preferences.h +++ b/src/preferences/preferences.h @@ -1009,6 +1009,12 @@ public: setValue(QString::fromUtf8("Preferences/Advanced/updateCheck"), enabled); } #endif + bool confirmTorrentDeletion() const { + return value(QString::fromUtf8("Preferences/Advanced/confirmTorrentDeletion"), true).toBool(); + } + void setConfirmTorrentDeletion(bool enabled) { + setValue(QString::fromUtf8("Preferences/Advanced/confirmTorrentDeletion"), enabled); + } }; #endif // PREFERENCES_H diff --git a/src/transferlistwidget.cpp b/src/transferlistwidget.cpp index 7f632816f..45ac1a256 100644 --- a/src/transferlistwidget.cpp +++ b/src/transferlistwidget.cpp @@ -285,28 +285,29 @@ void TransferListWidget::pauseVisibleTorrents() { void TransferListWidget::deleteSelectedTorrents() { if(main_window->getCurrentTabWidget() != this) return; const QStringList& hashes = getSelectedTorrentsHashes(); - if(!hashes.empty()) { - bool delete_local_files = false; - if(DeletionConfirmationDlg::askForDeletionConfirmation(&delete_local_files)) { - foreach(const QString &hash, hashes) { - BTSession->deleteTorrent(hash, delete_local_files); - } - } + if(hashes.empty()) return; + bool delete_local_files = false; + if(Preferences().confirmTorrentDeletion() && + !DeletionConfirmationDlg::askForDeletionConfirmation(&delete_local_files)) + return; + foreach(const QString &hash, hashes) { + BTSession->deleteTorrent(hash, delete_local_files); } } void TransferListWidget::deleteVisibleTorrents() { if(nameFilterModel->rowCount() <= 0) return; bool delete_local_files = false; - if(DeletionConfirmationDlg::askForDeletionConfirmation(&delete_local_files)) { - QStringList hashes; - for(int i=0; irowCount(); ++i) { - const int row = mapToSource(nameFilterModel->index(i, 0)).row(); - hashes << getHashFromRow(row); - } - foreach(const QString &hash, hashes) { - BTSession->deleteTorrent(hash, delete_local_files); - } + if(Preferences().confirmTorrentDeletion() && + !DeletionConfirmationDlg::askForDeletionConfirmation(&delete_local_files)) + return; + QStringList hashes; + for(int i=0; irowCount(); ++i) { + const int row = mapToSource(nameFilterModel->index(i, 0)).row(); + hashes << getHashFromRow(row); + } + foreach(const QString &hash, hashes) { + BTSession->deleteTorrent(hash, delete_local_files); } }