Browse Source

Option to disable tracker's favicon download.

adaptive-webui-19844
sledgehammer999 8 years ago
parent
commit
fd5d1583de
  1. 6
      src/gui/advancedsettings.cpp
  2. 4
      src/gui/advancedsettings.h
  3. 15
      src/gui/mainwindow.cpp
  4. 4
      src/gui/mainwindow.h
  5. 20
      src/gui/transferlistfilterswidget.cpp
  6. 3
      src/gui/transferlistfilterswidget.h

6
src/gui/advancedsettings.cpp

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

4
src/gui/advancedsettings.h

@ -60,8 +60,8 @@ private:
QLabel labelQbtLink, labelLibtorrentLink; 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; 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, QCheckBox cb_os_cache, cb_recheck_completed, cb_resolve_countries, cb_resolve_hosts, cb_super_seeding,
cb_super_seeding, cb_program_notifications, cb_torrent_added_notifications, cb_tracker_status, 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; cb_confirm_torrent_recheck, cb_enable_tracker_ext, cb_listen_ipv6, cb_announce_all_trackers;
QComboBox combo_iface, combo_iface_address; QComboBox combo_iface, combo_iface_address;
QLineEdit txtAnnounceIP; QLineEdit txtAnnounceIP;

15
src/gui/mainwindow.cpp

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

4
src/gui/mainwindow.h

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

20
src/gui/transferlistfilterswidget.cpp

@ -440,6 +440,7 @@ int CategoryFiltersList::rowFromCategory(const QString &category) const
TrackerFiltersList::TrackerFiltersList(QWidget *parent, TransferListWidget *transferList) TrackerFiltersList::TrackerFiltersList(QWidget *parent, TransferListWidget *transferList)
: FiltersBase(parent, transferList) : FiltersBase(parent, transferList)
, m_totalTorrents(0) , m_totalTorrents(0)
, m_downloadTrackerFavicon(true)
{ {
QListWidgetItem *allTrackers = new QListWidgetItem(this); QListWidgetItem *allTrackers = new QListWidgetItem(this);
allTrackers->setData(Qt::DisplayRole, QVariant(tr("All (0)", "this is for the tracker filter"))); 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); 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) void TrackerFiltersList::trackerSuccess(const QString &hash, const QString &tracker)
{ {
QStringList errored = m_errors.value(hash); 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) void TrackerFiltersList::downloadFavicon(const QString& url)
{ {
if (!m_downloadTrackerFavicon) return;
Net::DownloadHandler *h = Net::DownloadManager::instance()->downloadUrl(url, true); Net::DownloadHandler *h = Net::DownloadManager::instance()->downloadUrl(url, true);
connect(h, SIGNAL(downloadFinished(QString, QString)), this, SLOT(handleFavicoDownload(QString, QString))); connect(h, SIGNAL(downloadFinished(QString, QString)), this, SLOT(handleFavicoDownload(QString, QString)));
connect(h, SIGNAL(downloadFailed(QString, QString)), this, SLOT(handleFavicoFailure(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 &))); 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) void TransferListFiltersWidget::addTrackers(BitTorrent::TorrentHandle *const torrent, const QList<BitTorrent::TrackerEntry> &trackers)
{ {
foreach (const BitTorrent::TrackerEntry &tracker, trackers) foreach (const BitTorrent::TrackerEntry &tracker, trackers)

3
src/gui/transferlistfilterswidget.h

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

Loading…
Cancel
Save