Option to disable tracker's favicon download.

This commit is contained in:
sledgehammer999 2016-11-13 22:46:17 +02:00
parent 7923b54456
commit fd5d1583de
6 changed files with 50 additions and 2 deletions

View File

@ -66,6 +66,7 @@ enum AdvSettingsRows
RESOLVE_COUNTRIES,
PROGRAM_NOTIFICATIONS,
TORRENT_ADDED_NOTIFICATIONS,
DOWNLOAD_TRACKER_FAVICON,
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
USE_ICON_THEME,
#endif
@ -171,6 +172,8 @@ void AdvancedSettings::saveAdvancedSettings()
MainWindow * const mainWindow = static_cast<Application*>(QCoreApplication::instance())->mainWindow();
mainWindow->setNotificationsEnabled(cb_program_notifications.isChecked());
mainWindow->setTorrentAddedNotificationsEnabled(cb_torrent_added_notifications.isChecked());
// Misc GUI properties
mainWindow->setDownloadTrackerFavicon(cb_tracker_favicon.isChecked());
// Tracker
session->setTrackerEnabled(cb_tracker_status.isChecked());
@ -354,6 +357,9 @@ void AdvancedSettings::loadAdvancedSettings()
// Torrent added notifications
cb_torrent_added_notifications.setChecked(mainWindow->isTorrentAddedNotificationsEnabled());
addRow(TORRENT_ADDED_NOTIFICATIONS, tr("Display notifications for added torrents"), &cb_torrent_added_notifications);
// Download tracker's favicon
cb_tracker_favicon.setChecked(mainWindow->isDownloadTrackerFavicon());
addRow(DOWNLOAD_TRACKER_FAVICON, tr("Download tracker's favicon"), &cb_tracker_favicon);
// Tracker State
cb_tracker_status.setChecked(session->isTrackerEnabled());

View File

@ -60,8 +60,8 @@ private:
QLabel labelQbtLink, labelLibtorrentLink;
QSpinBox spin_cache, spin_save_resume_data_interval, outgoing_ports_min, outgoing_ports_max, spin_list_refresh, spin_maxhalfopen, spin_tracker_port, spin_cache_ttl;
QCheckBox cb_os_cache, cb_recheck_completed, cb_resolve_countries, cb_resolve_hosts,
cb_super_seeding, cb_program_notifications, cb_torrent_added_notifications, cb_tracker_status,
QCheckBox cb_os_cache, cb_recheck_completed, cb_resolve_countries, cb_resolve_hosts, cb_super_seeding,
cb_program_notifications, cb_torrent_added_notifications, cb_tracker_favicon, cb_tracker_status,
cb_confirm_torrent_recheck, cb_enable_tracker_ext, cb_listen_ipv6, cb_announce_all_trackers;
QComboBox combo_iface, combo_iface_address;
QLineEdit txtAnnounceIP;

View File

@ -114,6 +114,9 @@ namespace
const QString KEY_NOTIFICATIONS_ENABLED = NOTIFICATIONS_SETTINGS_KEY("Enabled");
const QString KEY_NOTIFICATIONS_TORRENTADDED = NOTIFICATIONS_SETTINGS_KEY("TorrentAdded");
// Misc
const QString KEY_DOWNLOAD_TRACKER_FAVICON = NOTIFICATIONS_SETTINGS_KEY("DownloadTrackerFavicon");
//just a shortcut
inline SettingsStorage *settings() { return SettingsStorage::instance(); }
}
@ -220,6 +223,7 @@ MainWindow::MainWindow(QWidget *parent)
//transferList->setStyleSheet("QTreeView {border: none;}"); // borderless
m_propertiesWidget = new PropertiesWidget(hSplitter, this, m_transferListWidget);
m_transferListFiltersWidget = new TransferListFiltersWidget(m_splitter, m_transferListWidget);
m_transferListFiltersWidget->setDownloadTrackerFavicon(isDownloadTrackerFavicon());
hSplitter->addWidget(m_transferListWidget);
hSplitter->addWidget(m_propertiesWidget);
m_splitter->addWidget(m_transferListFiltersWidget);
@ -444,6 +448,17 @@ void MainWindow::setTorrentAddedNotificationsEnabled(bool value)
settings()->storeValue(KEY_NOTIFICATIONS_TORRENTADDED, value);
}
bool MainWindow::isDownloadTrackerFavicon() const
{
return settings()->loadValue(KEY_DOWNLOAD_TRACKER_FAVICON, true).toBool();
}
void MainWindow::setDownloadTrackerFavicon(bool value)
{
m_transferListFiltersWidget->setDownloadTrackerFavicon(value);
settings()->storeValue(KEY_DOWNLOAD_TRACKER_FAVICON, value);
}
void MainWindow::addToolbarContextMenu()
{
const Preferences* const pref = Preferences::instance();

View File

@ -94,6 +94,10 @@ public:
bool isTorrentAddedNotificationsEnabled() const;
void setTorrentAddedNotificationsEnabled(bool value);
// Misc properties
bool isDownloadTrackerFavicon() const;
void setDownloadTrackerFavicon(bool value);
void activate();
void cleanup();

View File

@ -440,6 +440,7 @@ int CategoryFiltersList::rowFromCategory(const QString &category) const
TrackerFiltersList::TrackerFiltersList(QWidget *parent, TransferListWidget *transferList)
: FiltersBase(parent, transferList)
, m_totalTorrents(0)
, m_downloadTrackerFavicon(true)
{
QListWidgetItem *allTrackers = new QListWidgetItem(this);
allTrackers->setData(Qt::DisplayRole, QVariant(tr("All (0)", "this is for the tracker filter")));
@ -566,6 +567,19 @@ void TrackerFiltersList::changeTrackerless(bool trackerless, const QString &hash
removeItem("", hash);
}
void TrackerFiltersList::setDownloadTrackerFavicon(bool value)
{
if (value == m_downloadTrackerFavicon) return;
m_downloadTrackerFavicon = value;
if (m_downloadTrackerFavicon) {
foreach (const QString &tracker, m_trackers.keys()) {
if (!tracker.isEmpty())
downloadFavicon(QString("http://%1/favicon.ico").arg(tracker));
}
}
}
void TrackerFiltersList::trackerSuccess(const QString &hash, const QString &tracker)
{
QStringList errored = m_errors.value(hash);
@ -630,6 +644,7 @@ void TrackerFiltersList::trackerWarning(const QString &hash, const QString &trac
void TrackerFiltersList::downloadFavicon(const QString& url)
{
if (!m_downloadTrackerFavicon) return;
Net::DownloadHandler *h = Net::DownloadManager::instance()->downloadUrl(url, true);
connect(h, SIGNAL(downloadFinished(QString, QString)), this, SLOT(handleFavicoDownload(QString, QString)));
connect(h, SIGNAL(downloadFailed(QString, QString)), this, SLOT(handleFavicoFailure(QString, QString)));
@ -835,6 +850,11 @@ TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferLi
connect(this, SIGNAL(trackerWarning(const QString &, const QString &)), trackerFilters, SLOT(trackerWarning(const QString &, const QString &)));
}
void TransferListFiltersWidget::setDownloadTrackerFavicon(bool value)
{
trackerFilters->setDownloadTrackerFavicon(value);
}
void TransferListFiltersWidget::addTrackers(BitTorrent::TorrentHandle *const torrent, const QList<BitTorrent::TrackerEntry> &trackers)
{
foreach (const BitTorrent::TrackerEntry &tracker, trackers)

View File

@ -136,6 +136,7 @@ public:
void addItem(const QString &tracker, const QString &hash);
void removeItem(const QString &tracker, const QString &hash);
void changeTrackerless(bool trackerless, const QString &hash);
void setDownloadTrackerFavicon(bool value);
public slots:
void trackerSuccess(const QString &hash, const QString &tracker);
@ -165,6 +166,7 @@ private:
QHash<QString, QStringList> m_warnings;
QStringList m_iconPaths;
int m_totalTorrents;
bool m_downloadTrackerFavicon;
};
class TransferListFiltersWidget: public QFrame
@ -173,6 +175,7 @@ class TransferListFiltersWidget: public QFrame
public:
TransferListFiltersWidget(QWidget *parent, TransferListWidget *transferList);
void setDownloadTrackerFavicon(bool value);
public slots:
void addTrackers(BitTorrent::TorrentHandle *const torrent, const QList<BitTorrent::TrackerEntry> &trackers);