mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 13:32:47 +01:00
optionsmodel cleanup
- cleanup optionsmodel before adding new proxy options - place SOCKS version stuff below proxy port (IP, Port, SOCKS version) - simplyfy some parts of the code (e.g. don't check IP and port, as this is done in optionsdialog anyway, remove unneeded {} in switch/case) - small cosmetic changes in the header for better readability
This commit is contained in:
parent
45aa01fe89
commit
144bfd9c53
@ -144,8 +144,6 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
|||||||
return QVariant(fMinimizeOnClose);
|
return QVariant(fMinimizeOnClose);
|
||||||
case ProxyUse:
|
case ProxyUse:
|
||||||
return settings.value("fUseProxy", false);
|
return settings.value("fUseProxy", false);
|
||||||
case ProxySocksVersion:
|
|
||||||
return settings.value("nSocksVersion", 5);
|
|
||||||
case ProxyIP: {
|
case ProxyIP: {
|
||||||
CService addrProxy;
|
CService addrProxy;
|
||||||
if (GetProxy(NET_IPV4, addrProxy))
|
if (GetProxy(NET_IPV4, addrProxy))
|
||||||
@ -160,6 +158,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
|||||||
else
|
else
|
||||||
return 9050;
|
return 9050;
|
||||||
}
|
}
|
||||||
|
case ProxySocksVersion:
|
||||||
|
return settings.value("nSocksVersion", 5);
|
||||||
case Fee:
|
case Fee:
|
||||||
return QVariant(nTransactionFee);
|
return QVariant(nTransactionFee);
|
||||||
case DisplayUnit:
|
case DisplayUnit:
|
||||||
@ -192,11 +192,9 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
|||||||
settings.setValue("fMinimizeToTray", fMinimizeToTray);
|
settings.setValue("fMinimizeToTray", fMinimizeToTray);
|
||||||
break;
|
break;
|
||||||
case MapPortUPnP:
|
case MapPortUPnP:
|
||||||
{
|
fUseUPnP = value.toBool();
|
||||||
fUseUPnP = value.toBool();
|
settings.setValue("fUseUPnP", fUseUPnP);
|
||||||
settings.setValue("fUseUPnP", fUseUPnP);
|
MapPort();
|
||||||
MapPort();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case MinimizeOnClose:
|
case MinimizeOnClose:
|
||||||
fMinimizeOnClose = value.toBool();
|
fMinimizeOnClose = value.toBool();
|
||||||
@ -206,60 +204,41 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
|||||||
settings.setValue("fUseProxy", value.toBool());
|
settings.setValue("fUseProxy", value.toBool());
|
||||||
ApplyProxySettings();
|
ApplyProxySettings();
|
||||||
break;
|
break;
|
||||||
case ProxySocksVersion:
|
|
||||||
settings.setValue("nSocksVersion", value.toInt());
|
|
||||||
ApplyProxySettings();
|
|
||||||
break;
|
|
||||||
case ProxyIP:
|
case ProxyIP:
|
||||||
{
|
{
|
||||||
CService addrProxy("127.0.0.1", 9050);
|
CService addrProxy("127.0.0.1", 9050);
|
||||||
GetProxy(NET_IPV4, addrProxy);
|
GetProxy(NET_IPV4, addrProxy);
|
||||||
CNetAddr addr(value.toString().toStdString());
|
CNetAddr addr(value.toString().toStdString());
|
||||||
if (addr.IsValid())
|
addrProxy.SetIP(addr);
|
||||||
{
|
settings.setValue("addrProxy", addrProxy.ToStringIPPort().c_str());
|
||||||
addrProxy.SetIP(addr);
|
successful = ApplyProxySettings();
|
||||||
settings.setValue("addrProxy", addrProxy.ToStringIPPort().c_str());
|
|
||||||
successful = ApplyProxySettings();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
successful = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ProxyPort:
|
case ProxyPort:
|
||||||
{
|
{
|
||||||
CService addrProxy("127.0.0.1", 9050);
|
CService addrProxy("127.0.0.1", 9050);
|
||||||
GetProxy(NET_IPV4, addrProxy);
|
GetProxy(NET_IPV4, addrProxy);
|
||||||
int nPort = atoi(value.toString().toAscii().data());
|
addrProxy.SetPort(value.toInt());
|
||||||
if (nPort > 0 && nPort < std::numeric_limits<unsigned short>::max())
|
settings.setValue("addrProxy", addrProxy.ToStringIPPort().c_str());
|
||||||
{
|
successful = ApplyProxySettings();
|
||||||
addrProxy.SetPort(nPort);
|
|
||||||
settings.setValue("addrProxy", addrProxy.ToStringIPPort().c_str());
|
|
||||||
successful = ApplyProxySettings();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
successful = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Fee: {
|
case ProxySocksVersion:
|
||||||
|
settings.setValue("nSocksVersion", value.toInt());
|
||||||
|
ApplyProxySettings();
|
||||||
|
break;
|
||||||
|
case Fee:
|
||||||
nTransactionFee = value.toLongLong();
|
nTransactionFee = value.toLongLong();
|
||||||
settings.setValue("nTransactionFee", nTransactionFee);
|
settings.setValue("nTransactionFee", nTransactionFee);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case DisplayUnit: {
|
case DisplayUnit:
|
||||||
int unit = value.toInt();
|
nDisplayUnit = value.toInt();
|
||||||
nDisplayUnit = unit;
|
|
||||||
settings.setValue("nDisplayUnit", nDisplayUnit);
|
settings.setValue("nDisplayUnit", nDisplayUnit);
|
||||||
emit displayUnitChanged(unit);
|
emit displayUnitChanged(nDisplayUnit);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case DisplayAddresses: {
|
case DisplayAddresses:
|
||||||
bDisplayAddresses = value.toBool();
|
bDisplayAddresses = value.toBool();
|
||||||
settings.setValue("bDisplayAddresses", bDisplayAddresses);
|
settings.setValue("bDisplayAddresses", bDisplayAddresses);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case DetachDatabases: {
|
case DetachDatabases: {
|
||||||
bool fDetachDB = value.toBool();
|
bool fDetachDB = value.toBool();
|
||||||
@ -267,9 +246,8 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
|||||||
settings.setValue("detachDB", fDetachDB);
|
settings.setValue("detachDB", fDetachDB);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Language: {
|
case Language:
|
||||||
settings.setValue("language", value);
|
settings.setValue("language", value);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -12,23 +12,24 @@
|
|||||||
class OptionsModel : public QAbstractListModel
|
class OptionsModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit OptionsModel(QObject *parent = 0);
|
explicit OptionsModel(QObject *parent = 0);
|
||||||
|
|
||||||
enum OptionID {
|
enum OptionID {
|
||||||
StartAtStartup, // bool
|
StartAtStartup, // bool
|
||||||
MinimizeToTray, // bool
|
MinimizeToTray, // bool
|
||||||
MapPortUPnP, // bool
|
MapPortUPnP, // bool
|
||||||
MinimizeOnClose, // bool
|
MinimizeOnClose, // bool
|
||||||
ProxyUse, // bool
|
ProxyUse, // bool
|
||||||
|
ProxyIP, // QString
|
||||||
|
ProxyPort, // int
|
||||||
ProxySocksVersion, // int
|
ProxySocksVersion, // int
|
||||||
ProxyIP, // QString
|
Fee, // qint64
|
||||||
ProxyPort, // int
|
DisplayUnit, // BitcoinUnits::Unit
|
||||||
Fee, // qint64
|
DisplayAddresses, // bool
|
||||||
DisplayUnit, // BitcoinUnits::Unit
|
DetachDatabases, // bool
|
||||||
DisplayAddresses, // bool
|
Language, // QString
|
||||||
DetachDatabases, // bool
|
|
||||||
Language, // QString
|
|
||||||
OptionIDRowCount,
|
OptionIDRowCount,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -48,17 +49,16 @@ public:
|
|||||||
int getDisplayUnit();
|
int getDisplayUnit();
|
||||||
bool getDisplayAddresses();
|
bool getDisplayAddresses();
|
||||||
QString getLanguage() { return language; }
|
QString getLanguage() { return language; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int nDisplayUnit;
|
int nDisplayUnit;
|
||||||
bool bDisplayAddresses;
|
bool bDisplayAddresses;
|
||||||
bool fMinimizeToTray;
|
bool fMinimizeToTray;
|
||||||
bool fMinimizeOnClose;
|
bool fMinimizeOnClose;
|
||||||
QString language;
|
QString language;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void displayUnitChanged(int unit);
|
void displayUnitChanged(int unit);
|
||||||
|
|
||||||
public slots:
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // OPTIONSMODEL_H
|
#endif // OPTIONSMODEL_H
|
||||||
|
Loading…
Reference in New Issue
Block a user