mirror of https://github.com/cutefishos/settings
Proxy: save configuration
parent
8e27723569
commit
27ea85b763
|
Before Width: | Height: | Size: 830 B After Width: | Height: | Size: 1004 B |
@ -0,0 +1,142 @@
|
|||||||
|
#include "networkproxy.h"
|
||||||
|
|
||||||
|
NetworkProxy::NetworkProxy(QObject *parent)
|
||||||
|
: QObject(parent)
|
||||||
|
, m_settings("cutefishos", "network")
|
||||||
|
{
|
||||||
|
m_flag = m_settings.value("ProxyFlag", 0).toInt();
|
||||||
|
m_useSameProxy = m_settings.value("UseSameProxy", false).toBool();
|
||||||
|
m_scriptProxy = m_settings.value("ProxyScriptProxy", "").toString();
|
||||||
|
m_httpProxy = m_settings.value("HttpProxy", "").toString();
|
||||||
|
m_ftpProxy = m_settings.value("FtpProxy", "").toString();
|
||||||
|
m_socksProxy = m_settings.value("SocksProxy", "").toString();
|
||||||
|
m_httpProxyPort = m_settings.value("HttpProxyPort", "").toString();
|
||||||
|
m_ftpProxyPort = m_settings.value("FtpProxyPort", "").toString();
|
||||||
|
m_socksProxyPort = m_settings.value("SocksProxyPort", "").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
int NetworkProxy::flag() const
|
||||||
|
{
|
||||||
|
return m_flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkProxy::setFlag(int flag)
|
||||||
|
{
|
||||||
|
if (m_flag != flag) {
|
||||||
|
m_flag = flag;
|
||||||
|
m_settings.setValue("ProxyFlag", flag);
|
||||||
|
emit flagChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NetworkProxy::useSameProxy() const
|
||||||
|
{
|
||||||
|
return m_useSameProxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkProxy::setUseSameProxy(bool enabled)
|
||||||
|
{
|
||||||
|
if (m_useSameProxy != enabled) {
|
||||||
|
m_useSameProxy = enabled;
|
||||||
|
m_settings.setValue("UseSameProxy", enabled);
|
||||||
|
emit useSameProxyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkProxy::scriptProxy() const
|
||||||
|
{
|
||||||
|
return m_scriptProxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkProxy::setScriptProxy(const QString &path)
|
||||||
|
{
|
||||||
|
if (m_scriptProxy != path) {
|
||||||
|
m_scriptProxy = path;
|
||||||
|
m_settings.setValue("ProxyScriptProxy", path);
|
||||||
|
emit scriptProxyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkProxy::httpProxy() const
|
||||||
|
{
|
||||||
|
return m_httpProxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkProxy::setHttpProxy(const QString &path)
|
||||||
|
{
|
||||||
|
if (m_httpProxy != path) {
|
||||||
|
m_httpProxy = path;
|
||||||
|
m_settings.setValue("HttpProxy", path);
|
||||||
|
emit httpProxyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkProxy::ftpProxy() const
|
||||||
|
{
|
||||||
|
return m_ftpProxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkProxy::setFtpProxy(const QString &path)
|
||||||
|
{
|
||||||
|
if (m_ftpProxy != path) {
|
||||||
|
m_ftpProxy = path;
|
||||||
|
m_settings.setValue("FtpProxy", path);
|
||||||
|
emit ftpProxyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkProxy::socksProxy() const
|
||||||
|
{
|
||||||
|
return m_socksProxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkProxy::setSocksProxy(const QString &path)
|
||||||
|
{
|
||||||
|
if (m_socksProxy != path) {
|
||||||
|
m_socksProxy = path;
|
||||||
|
m_settings.setValue("SocksProxy", path);
|
||||||
|
emit socksProxyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkProxy::httpProxyPort() const
|
||||||
|
{
|
||||||
|
return m_httpProxyPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkProxy::setHttpProxyPort(const QString &port)
|
||||||
|
{
|
||||||
|
if (m_httpProxyPort != port) {
|
||||||
|
m_httpProxyPort = port;
|
||||||
|
m_settings.setValue("HttpProxyPort", port);
|
||||||
|
emit httpProxyPortChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkProxy::ftpProxyPort() const
|
||||||
|
{
|
||||||
|
return m_ftpProxyPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkProxy::setFtpProxyPort(const QString &port)
|
||||||
|
{
|
||||||
|
if (m_ftpProxyPort != port) {
|
||||||
|
m_ftpProxyPort = port;
|
||||||
|
m_settings.setValue("FtpProxyPort", port);
|
||||||
|
emit ftpProxyPortChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkProxy::socksProxyPort() const
|
||||||
|
{
|
||||||
|
return m_socksProxyPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkProxy::setSocksProxyPort(const QString &port)
|
||||||
|
{
|
||||||
|
if (m_socksProxyPort != port) {
|
||||||
|
m_socksProxyPort = port;
|
||||||
|
m_settings.setValue("SocksProxyPort", port);
|
||||||
|
emit socksProxyPortChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,76 @@
|
|||||||
|
#ifndef NETWORKPROXY_H
|
||||||
|
#define NETWORKPROXY_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
|
class NetworkProxy : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(int flag READ flag WRITE setFlag NOTIFY flagChanged)
|
||||||
|
Q_PROPERTY(bool useSameProxy READ useSameProxy WRITE setUseSameProxy NOTIFY useSameProxyChanged)
|
||||||
|
Q_PROPERTY(QString scriptProxy READ scriptProxy WRITE setScriptProxy NOTIFY scriptProxyChanged)
|
||||||
|
Q_PROPERTY(QString httpProxy READ httpProxy WRITE setHttpProxy NOTIFY httpProxyChanged)
|
||||||
|
Q_PROPERTY(QString ftpProxy READ ftpProxy WRITE setFtpProxy NOTIFY ftpProxyChanged)
|
||||||
|
Q_PROPERTY(QString socksProxy READ socksProxy WRITE setSocksProxy NOTIFY socksProxyChanged)
|
||||||
|
Q_PROPERTY(QString httpProxyPort READ httpProxyPort WRITE setHttpProxyPort NOTIFY httpProxyPortChanged)
|
||||||
|
Q_PROPERTY(QString ftpProxyPort READ ftpProxyPort WRITE setFtpProxyPort NOTIFY ftpProxyPortChanged)
|
||||||
|
Q_PROPERTY(QString socksProxyPort READ socksProxyPort WRITE setSocksProxyPort NOTIFY socksProxyPortChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit NetworkProxy(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
int flag() const;
|
||||||
|
void setFlag(int flag);
|
||||||
|
|
||||||
|
bool useSameProxy() const;
|
||||||
|
void setUseSameProxy(bool enabled);
|
||||||
|
|
||||||
|
QString scriptProxy() const;
|
||||||
|
void setScriptProxy(const QString &path);
|
||||||
|
|
||||||
|
QString httpProxy() const;
|
||||||
|
void setHttpProxy(const QString &path);
|
||||||
|
|
||||||
|
QString ftpProxy() const;
|
||||||
|
void setFtpProxy(const QString &path);
|
||||||
|
|
||||||
|
QString socksProxy() const;
|
||||||
|
void setSocksProxy(const QString &path);
|
||||||
|
|
||||||
|
QString httpProxyPort() const;
|
||||||
|
void setHttpProxyPort(const QString &port);
|
||||||
|
|
||||||
|
QString ftpProxyPort() const;
|
||||||
|
void setFtpProxyPort(const QString &port);
|
||||||
|
|
||||||
|
QString socksProxyPort() const;
|
||||||
|
void setSocksProxyPort(const QString &port);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void flagChanged();
|
||||||
|
void useSameProxyChanged();
|
||||||
|
void scriptProxyChanged();
|
||||||
|
void httpProxyChanged();
|
||||||
|
void ftpProxyChanged();
|
||||||
|
void socksProxyChanged();
|
||||||
|
void httpProxyPortChanged();
|
||||||
|
void ftpProxyPortChanged();
|
||||||
|
void socksProxyPortChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QSettings m_settings;
|
||||||
|
int m_flag;
|
||||||
|
bool m_useSameProxy;
|
||||||
|
|
||||||
|
QString m_scriptProxy;
|
||||||
|
QString m_httpProxy;
|
||||||
|
QString m_ftpProxy;
|
||||||
|
QString m_socksProxy;
|
||||||
|
|
||||||
|
QString m_httpProxyPort;
|
||||||
|
QString m_ftpProxyPort;
|
||||||
|
QString m_socksProxyPort;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NETWORKPROXY_H
|
||||||
Loading…
Reference in New Issue