mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-11-17 08:17:59 +00:00
Downloader: introduce proxyAddress property
This commit is contained in:
parent
63e32c4a83
commit
380b955bce
2 changed files with 26 additions and 0 deletions
|
@ -220,3 +220,23 @@ quint64 Downloader::total() const
|
|||
{
|
||||
return m_httpClient->contentLength();
|
||||
}
|
||||
|
||||
QString Downloader::proxyAddress() const
|
||||
{
|
||||
QMutexLocker locker(&m_proxyMutex);
|
||||
return m_proxyAddress;
|
||||
}
|
||||
|
||||
void Downloader::setProxyAddress(QString address)
|
||||
{
|
||||
m_scheduler.run([this, address] {
|
||||
if (!m_httpClient->set_proxy(address.toStdString()))
|
||||
{
|
||||
qCritical() << "Failed to set proxy address" << address;
|
||||
}
|
||||
|
||||
QMutexLocker locker(&m_proxyMutex);
|
||||
m_proxyAddress = address;
|
||||
emit proxyAddressChanged();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ class Downloader : public QObject
|
|||
Q_PROPERTY(bool active READ active NOTIFY activeChanged);
|
||||
Q_PROPERTY(quint64 loaded READ loaded NOTIFY loadedChanged);
|
||||
Q_PROPERTY(quint64 total READ total NOTIFY totalChanged);
|
||||
Q_PROPERTY(QString proxyAddress READ proxyAddress WRITE setProxyAddress NOTIFY proxyAddressChanged)
|
||||
|
||||
public:
|
||||
Downloader(QObject *parent = nullptr);
|
||||
|
@ -51,11 +52,14 @@ signals:
|
|||
void activeChanged() const;
|
||||
void loadedChanged() const;
|
||||
void totalChanged() const;
|
||||
void proxyAddressChanged() const;
|
||||
|
||||
private:
|
||||
bool active() const;
|
||||
quint64 loaded() const;
|
||||
quint64 total() const;
|
||||
QString proxyAddress() const;
|
||||
void setProxyAddress(QString address);
|
||||
|
||||
private:
|
||||
bool m_active;
|
||||
|
@ -63,5 +67,7 @@ private:
|
|||
std::shared_ptr<HttpClient> m_httpClient;
|
||||
mutable QReadWriteLock m_mutex;
|
||||
Network m_network;
|
||||
QString m_proxyAddress;
|
||||
mutable QMutex m_proxyMutex;
|
||||
mutable FutureScheduler m_scheduler;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue