mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-10 13:54:23 +00:00
- Added option to disable peer host name resolution (disabled as a default)
- Fix several other bugs related to properties and preferences
This commit is contained in:
parent
3762c37517
commit
5962ef79cb
@ -760,6 +760,10 @@ void GUI::processDownloadedFiles(QString path, QString url) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI::optionsSaved() {
|
||||||
|
loadPreferences();
|
||||||
|
}
|
||||||
|
|
||||||
// Load program preferences
|
// Load program preferences
|
||||||
void GUI::loadPreferences(bool configure_session) {
|
void GUI::loadPreferences(bool configure_session) {
|
||||||
BTSession->addConsoleMessage(tr("Options were saved successfully."));
|
BTSession->addConsoleMessage(tr("Options were saved successfully."));
|
||||||
@ -830,6 +834,9 @@ void GUI::loadPreferences(bool configure_session) {
|
|||||||
displayRSSTab(false);
|
displayRSSTab(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Torrent properties
|
||||||
|
properties->reloadPreferences();
|
||||||
|
|
||||||
if(configure_session)
|
if(configure_session)
|
||||||
BTSession->configureSession();
|
BTSession->configureSession();
|
||||||
|
|
||||||
@ -1001,7 +1008,7 @@ void GUI::createTrayIcon() {
|
|||||||
// Display Program Options
|
// Display Program Options
|
||||||
void GUI::on_actionOptions_triggered() {
|
void GUI::on_actionOptions_triggered() {
|
||||||
options = new options_imp(this);
|
options = new options_imp(this);
|
||||||
connect(options, SIGNAL(status_changed()), this, SLOT(loadPreferences(bool)));
|
connect(options, SIGNAL(status_changed()), this, SLOT(optionsSaved()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GUI::initWebUi(QString username, QString password, int port) {
|
bool GUI::initWebUi(QString username, QString password, int port) {
|
||||||
|
@ -156,6 +156,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
|
|||||||
void scrapeTrackers();
|
void scrapeTrackers();
|
||||||
// Options slots
|
// Options slots
|
||||||
void on_actionOptions_triggered();
|
void on_actionOptions_triggered();
|
||||||
|
void optionsSaved();
|
||||||
// HTTP slots
|
// HTTP slots
|
||||||
void on_actionDownload_from_URL_triggered();
|
void on_actionDownload_from_URL_triggered();
|
||||||
|
|
||||||
|
@ -364,6 +364,8 @@ void options_imp::saveOptions(){
|
|||||||
settings.setValue(QString::fromUtf8("NAT-PMP"), isNATPMPEnabled());
|
settings.setValue(QString::fromUtf8("NAT-PMP"), isNATPMPEnabled());
|
||||||
settings.setValue(QString::fromUtf8("GlobalDLLimit"), getGlobalBandwidthLimits().first);
|
settings.setValue(QString::fromUtf8("GlobalDLLimit"), getGlobalBandwidthLimits().first);
|
||||||
settings.setValue(QString::fromUtf8("GlobalUPLimit"), getGlobalBandwidthLimits().second);
|
settings.setValue(QString::fromUtf8("GlobalUPLimit"), getGlobalBandwidthLimits().second);
|
||||||
|
settings.setValue("ResolvePeerCountries", checkResolveCountries->isChecked());
|
||||||
|
settings.setValue("ResolvePeerHostNames", checkResolveHosts->isChecked());
|
||||||
settings.setValue(QString::fromUtf8("ProxyType"), getProxyType());
|
settings.setValue(QString::fromUtf8("ProxyType"), getProxyType());
|
||||||
//if(isProxyEnabled()) {
|
//if(isProxyEnabled()) {
|
||||||
settings.beginGroup("Proxy");
|
settings.beginGroup("Proxy");
|
||||||
@ -604,6 +606,10 @@ void options_imp::loadOptions(){
|
|||||||
checkUploadLimit->setChecked(false);
|
checkUploadLimit->setChecked(false);
|
||||||
spinUploadLimit->setEnabled(false);
|
spinUploadLimit->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
// Peer connections
|
||||||
|
checkResolveCountries->setChecked(Preferences::resolvePeerCountries());
|
||||||
|
checkResolveHosts->setChecked(Preferences::resolvePeerHostNames());
|
||||||
|
|
||||||
intValue = Preferences::getProxyType();
|
intValue = Preferences::getProxyType();
|
||||||
if(intValue <= 0) {
|
if(intValue <= 0) {
|
||||||
intValue = 0;
|
intValue = 0;
|
||||||
|
@ -31,13 +31,15 @@
|
|||||||
#include "peerlistwidget.h"
|
#include "peerlistwidget.h"
|
||||||
#include "peerlistdelegate.h"
|
#include "peerlistdelegate.h"
|
||||||
#include "reverseresolution.h"
|
#include "reverseresolution.h"
|
||||||
|
#include "preferences.h"
|
||||||
|
#include "propertieswidget.h"
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
PeerListWidget::PeerListWidget() {
|
PeerListWidget::PeerListWidget(PropertiesWidget *parent): properties(parent) {
|
||||||
// Visual settings
|
// Visual settings
|
||||||
setRootIsDecorated(false);
|
setRootIsDecorated(false);
|
||||||
setItemsExpandable(false);
|
setItemsExpandable(false);
|
||||||
@ -64,9 +66,7 @@ PeerListWidget::PeerListWidget() {
|
|||||||
// Load settings
|
// Load settings
|
||||||
loadSettings();
|
loadSettings();
|
||||||
// IP to Hostname resolver
|
// IP to Hostname resolver
|
||||||
resolver = new ReverseResolution(this);
|
updatePeerHostNameResolutionState();
|
||||||
connect(resolver, SIGNAL(ip_resolved(QString,QString)), this, SLOT(handleResolved(QString,QString)));
|
|
||||||
resolver->start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PeerListWidget::~PeerListWidget() {
|
PeerListWidget::~PeerListWidget() {
|
||||||
@ -74,9 +74,35 @@ PeerListWidget::~PeerListWidget() {
|
|||||||
delete proxyModel;
|
delete proxyModel;
|
||||||
delete listModel;
|
delete listModel;
|
||||||
delete listDelegate;
|
delete listDelegate;
|
||||||
|
if(resolver)
|
||||||
delete resolver;
|
delete resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PeerListWidget::updatePeerHostNameResolutionState() {
|
||||||
|
if(Preferences::resolvePeerHostNames()) {
|
||||||
|
if(!resolver) {
|
||||||
|
resolver = new ReverseResolution(this);
|
||||||
|
connect(resolver, SIGNAL(ip_resolved(QString,QString)), this, SLOT(handleResolved(QString,QString)));
|
||||||
|
resolver->start();
|
||||||
|
clear();
|
||||||
|
loadPeers(properties->getCurrentTorrent());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(resolver)
|
||||||
|
delete resolver;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PeerListWidget::clear() {
|
||||||
|
qDebug("clearing peer list");
|
||||||
|
peerItems.clear();
|
||||||
|
int nbrows = listModel->rowCount();
|
||||||
|
if(nbrows > 0) {
|
||||||
|
qDebug("Cleared %d peers", nbrows);
|
||||||
|
listModel->removeRows(0, nbrows);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PeerListWidget::loadSettings() {
|
void PeerListWidget::loadSettings() {
|
||||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||||
QVariantList contentColsWidths = settings.value(QString::fromUtf8("TorrentProperties/Peers/peersColsWidth"), QVariantList()).toList();
|
QVariantList contentColsWidths = settings.value(QString::fromUtf8("TorrentProperties/Peers/peersColsWidth"), QVariantList()).toList();
|
||||||
@ -96,7 +122,8 @@ void PeerListWidget::saveSettings() const {
|
|||||||
settings.setValue(QString::fromUtf8("TorrentProperties/Peers/peersColsWidth"), contentColsWidths);
|
settings.setValue(QString::fromUtf8("TorrentProperties/Peers/peersColsWidth"), contentColsWidths);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerListWidget::loadPeers(QTorrentHandle &h) {
|
void PeerListWidget::loadPeers(const QTorrentHandle &h) {
|
||||||
|
if(!h.is_valid()) return;
|
||||||
std::vector<peer_info> peers;
|
std::vector<peer_info> peers;
|
||||||
h.get_peer_info(peers);
|
h.get_peer_info(peers);
|
||||||
std::vector<peer_info>::iterator itr;
|
std::vector<peer_info>::iterator itr;
|
||||||
@ -126,6 +153,8 @@ QStandardItem* PeerListWidget::addPeer(QString ip, peer_info peer) {
|
|||||||
// Adding Peer to peer list
|
// Adding Peer to peer list
|
||||||
listModel->insertRow(row);
|
listModel->insertRow(row);
|
||||||
listModel->setData(listModel->index(row, IP), ip);
|
listModel->setData(listModel->index(row, IP), ip);
|
||||||
|
// Resolve peer host name is asked
|
||||||
|
if(resolver)
|
||||||
resolver->resolve(peer.ip);
|
resolver->resolve(peer.ip);
|
||||||
listModel->setData(listModel->index(row, CLIENT), misc::toQString(peer.client));
|
listModel->setData(listModel->index(row, CLIENT), misc::toQString(peer.client));
|
||||||
listModel->setData(listModel->index(row, PROGRESS), peer.progress);
|
listModel->setData(listModel->index(row, PROGRESS), peer.progress);
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
#include <QPointer>
|
||||||
#include "qtorrenthandle.h"
|
#include "qtorrenthandle.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
@ -41,6 +42,7 @@ class QStandardItem;
|
|||||||
class QSortFilterProxyModel;
|
class QSortFilterProxyModel;
|
||||||
class PeerListDelegate;
|
class PeerListDelegate;
|
||||||
class ReverseResolution;
|
class ReverseResolution;
|
||||||
|
class PropertiesWidget;
|
||||||
|
|
||||||
class PeerListWidget : public QTreeView {
|
class PeerListWidget : public QTreeView {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -50,17 +52,20 @@ private:
|
|||||||
PeerListDelegate *listDelegate;
|
PeerListDelegate *listDelegate;
|
||||||
QSortFilterProxyModel * proxyModel;
|
QSortFilterProxyModel * proxyModel;
|
||||||
QHash<QString, QStandardItem*> peerItems;
|
QHash<QString, QStandardItem*> peerItems;
|
||||||
ReverseResolution *resolver;
|
QPointer<ReverseResolution> resolver;
|
||||||
|
PropertiesWidget* properties;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PeerListWidget();
|
PeerListWidget(PropertiesWidget *parent);
|
||||||
~PeerListWidget();
|
~PeerListWidget();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void loadPeers(QTorrentHandle &h);
|
void loadPeers(const QTorrentHandle &h);
|
||||||
QStandardItem* addPeer(QString ip, peer_info peer);
|
QStandardItem* addPeer(QString ip, peer_info peer);
|
||||||
void updatePeer(QString ip, peer_info peer);
|
void updatePeer(QString ip, peer_info peer);
|
||||||
void handleResolved(QString ip, QString hostname);
|
void handleResolved(QString ip, QString hostname);
|
||||||
|
void updatePeerHostNameResolutionState();
|
||||||
|
void clear();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
|
@ -187,6 +187,16 @@ public:
|
|||||||
return settings.value(QString::fromUtf8("Preferences/Connection/GlobalUPLimit"), -1).toInt();
|
return settings.value(QString::fromUtf8("Preferences/Connection/GlobalUPLimit"), -1).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool resolvePeerCountries() {
|
||||||
|
QSettings settings("qBittorrent", "qBittorrent");
|
||||||
|
return settings.value(QString::fromUtf8("Preferences/Connection/ResolvePeerCountries"), false).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool resolvePeerHostNames() {
|
||||||
|
QSettings settings("qBittorrent", "qBittorrent");
|
||||||
|
return settings.value(QString::fromUtf8("Preferences/Connection/ResolvePeerHostNames"), false).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
// Proxy options
|
// Proxy options
|
||||||
static bool isHTTPProxyEnabled() {
|
static bool isHTTPProxyEnabled() {
|
||||||
QSettings settings("qBittorrent", "qBittorrent");
|
QSettings settings("qBittorrent", "qBittorrent");
|
||||||
|
@ -92,7 +92,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transfer
|
|||||||
progressBar->setForegroundColor(Qt::blue);
|
progressBar->setForegroundColor(Qt::blue);
|
||||||
ProgressHLayout->insertWidget(1, progressBar);
|
ProgressHLayout->insertWidget(1, progressBar);
|
||||||
// Peers list
|
// Peers list
|
||||||
peersList = new PeerListWidget();
|
peersList = new PeerListWidget(this);
|
||||||
peerpage_layout->addWidget(peersList);
|
peerpage_layout->addWidget(peersList);
|
||||||
// Pointers init
|
// Pointers init
|
||||||
progressBarUpdater = 0;
|
progressBarUpdater = 0;
|
||||||
@ -144,6 +144,7 @@ void PropertiesWidget::slide() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesWidget::clear() {
|
void PropertiesWidget::clear() {
|
||||||
|
qDebug("Clearing torrent properties");
|
||||||
save_path->clear();
|
save_path->clear();
|
||||||
lbl_creationDate->clear();
|
lbl_creationDate->clear();
|
||||||
hash_lbl->clear();
|
hash_lbl->clear();
|
||||||
@ -155,6 +156,7 @@ void PropertiesWidget::clear() {
|
|||||||
wasted->clear();
|
wasted->clear();
|
||||||
upTotal->clear();
|
upTotal->clear();
|
||||||
dlTotal->clear();
|
dlTotal->clear();
|
||||||
|
peersList->clear();
|
||||||
lbl_uplimit->clear();
|
lbl_uplimit->clear();
|
||||||
lbl_dllimit->clear();
|
lbl_dllimit->clear();
|
||||||
lbl_elapsed->clear();
|
lbl_elapsed->clear();
|
||||||
@ -165,6 +167,10 @@ void PropertiesWidget::clear() {
|
|||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QTorrentHandle& PropertiesWidget::getCurrentTorrent() const {
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) {
|
void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) {
|
||||||
h = _h;
|
h = _h;
|
||||||
if(!h.is_valid()) {
|
if(!h.is_valid()) {
|
||||||
@ -258,8 +264,9 @@ void PropertiesWidget::saveSettings() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesWidget::loadPeers() {
|
void PropertiesWidget::reloadPreferences() {
|
||||||
// TODO
|
// Take program preferences into consideration
|
||||||
|
peersList->updatePeerHostNameResolutionState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesWidget::loadDynamicData() {
|
void PropertiesWidget::loadDynamicData() {
|
||||||
|
@ -81,7 +81,6 @@ protected slots:
|
|||||||
void setIncrementalDownload(int checkboxState);
|
void setIncrementalDownload(int checkboxState);
|
||||||
void loadTrackers();
|
void loadTrackers();
|
||||||
void loadUrlSeeds();
|
void loadUrlSeeds();
|
||||||
void loadPeers();
|
|
||||||
void on_main_infos_button_clicked();
|
void on_main_infos_button_clicked();
|
||||||
void on_trackers_button_clicked();
|
void on_trackers_button_clicked();
|
||||||
void on_peers_button_clicked();
|
void on_peers_button_clicked();
|
||||||
@ -108,10 +107,12 @@ public slots:
|
|||||||
void clear();
|
void clear();
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
|
void reloadPreferences();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PropertiesWidget(QWidget *parent, TransferListWidget *transferList, bittorrent* BTSession);
|
PropertiesWidget(QWidget *parent, TransferListWidget *transferList, bittorrent* BTSession);
|
||||||
~PropertiesWidget();
|
~PropertiesWidget();
|
||||||
|
const QTorrentHandle& getCurrentTorrent() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PROPERTIESWIDGET_H
|
#endif // PROPERTIESWIDGET_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user