mirror of
https://github.com/jwinterm/myriadcoin.git
synced 2026-12-03 12:34:12 +01:00
Myriadcoin 0.11 port
This commit is contained in:
+42
-67
@@ -1,9 +1,9 @@
|
||||
// Copyright (c) 2011-2014 The Bitcoin developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// Copyright (c) 2011-2014 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "bitcoin-config.h"
|
||||
#include "config/bitcoin-config.h"
|
||||
#endif
|
||||
|
||||
#include "optionsmodel.h"
|
||||
@@ -11,13 +11,15 @@
|
||||
#include "bitcoinunits.h"
|
||||
#include "guiutil.h"
|
||||
|
||||
#include "amount.h"
|
||||
#include "init.h"
|
||||
#include "main.h"
|
||||
#include "net.h"
|
||||
#include "txdb.h" // for -dbcache defaults
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
#include "wallet.h"
|
||||
#include "walletdb.h"
|
||||
#include "wallet/wallet.h"
|
||||
#include "wallet/walletdb.h"
|
||||
#endif
|
||||
|
||||
#include <QNetworkProxy>
|
||||
@@ -59,10 +61,6 @@ void OptionsModel::Init()
|
||||
settings.setValue("nDisplayUnit", BitcoinUnits::BTC);
|
||||
nDisplayUnit = settings.value("nDisplayUnit").toInt();
|
||||
|
||||
if (!settings.contains("bDisplayAddresses"))
|
||||
settings.setValue("bDisplayAddresses", false);
|
||||
bDisplayAddresses = settings.value("bDisplayAddresses", false).toBool();
|
||||
|
||||
if (!settings.contains("strThirdPartyTxUrls"))
|
||||
settings.setValue("strThirdPartyTxUrls", "");
|
||||
strThirdPartyTxUrls = settings.value("strThirdPartyTxUrls", "").toString();
|
||||
@@ -92,12 +90,6 @@ void OptionsModel::Init()
|
||||
|
||||
// Wallet
|
||||
#ifdef ENABLE_WALLET
|
||||
if (!settings.contains("nTransactionFee"))
|
||||
settings.setValue("nTransactionFee", (qint64)DEFAULT_TRANSACTION_FEE);
|
||||
nTransactionFee = settings.value("nTransactionFee").toLongLong(); // if -paytxfee is set, this will be overridden later in init.cpp
|
||||
if (mapArgs.count("-paytxfee"))
|
||||
addOverriddenOption("-paytxfee");
|
||||
|
||||
if (!settings.contains("bSpendZeroConfChange"))
|
||||
settings.setValue("bSpendZeroConfChange", true);
|
||||
if (!SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool()))
|
||||
@@ -106,14 +98,15 @@ void OptionsModel::Init()
|
||||
|
||||
// Network
|
||||
if (!settings.contains("fUseUPnP"))
|
||||
#ifdef USE_UPNP
|
||||
settings.setValue("fUseUPnP", true);
|
||||
#else
|
||||
settings.setValue("fUseUPnP", false);
|
||||
#endif
|
||||
settings.setValue("fUseUPnP", DEFAULT_UPNP);
|
||||
if (!SoftSetBoolArg("-upnp", settings.value("fUseUPnP").toBool()))
|
||||
addOverriddenOption("-upnp");
|
||||
|
||||
if (!settings.contains("fListen"))
|
||||
settings.setValue("fListen", DEFAULT_LISTEN);
|
||||
if (!SoftSetBoolArg("-listen", settings.value("fListen").toBool()))
|
||||
addOverriddenOption("-listen");
|
||||
|
||||
if (!settings.contains("fUseProxy"))
|
||||
settings.setValue("fUseProxy", false);
|
||||
if (!settings.contains("addrProxy"))
|
||||
@@ -121,11 +114,8 @@ void OptionsModel::Init()
|
||||
// Only try to set -proxy, if user has enabled fUseProxy
|
||||
if (settings.value("fUseProxy").toBool() && !SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString()))
|
||||
addOverriddenOption("-proxy");
|
||||
if (!settings.contains("nSocksVersion"))
|
||||
settings.setValue("nSocksVersion", 5);
|
||||
// Only try to set -socks, if user has enabled fUseProxy
|
||||
if (settings.value("fUseProxy").toBool() && !SoftSetArg("-socks", settings.value("nSocksVersion").toString().toStdString()))
|
||||
addOverriddenOption("-socks");
|
||||
else if(!settings.value("fUseProxy").toBool() && !GetArg("-proxy", "").empty())
|
||||
addOverriddenOption("-proxy");
|
||||
|
||||
// Display
|
||||
if (!settings.contains("language"))
|
||||
@@ -187,26 +177,13 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
||||
QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts);
|
||||
return strlIpPort.at(1);
|
||||
}
|
||||
case ProxySocksVersion:
|
||||
return settings.value("nSocksVersion", 5);
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
case Fee:
|
||||
// Attention: Init() is called before nTransactionFee is set in AppInit2()!
|
||||
// To ensure we can change the fee on-the-fly update our QSetting when
|
||||
// opening OptionsDialog, which queries Fee via the mapper.
|
||||
if (nTransactionFee != settings.value("nTransactionFee").toLongLong())
|
||||
settings.setValue("nTransactionFee", (qint64)nTransactionFee);
|
||||
// Todo: Consider to revert back to use just nTransactionFee here, if we don't want
|
||||
// -paytxfee to update our QSettings!
|
||||
return settings.value("nTransactionFee");
|
||||
case SpendZeroConfChange:
|
||||
return settings.value("bSpendZeroConfChange");
|
||||
#endif
|
||||
case DisplayUnit:
|
||||
return nDisplayUnit;
|
||||
case DisplayAddresses:
|
||||
return bDisplayAddresses;
|
||||
case ThirdPartyTxUrls:
|
||||
return strThirdPartyTxUrls;
|
||||
case Language:
|
||||
@@ -217,6 +194,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
||||
return settings.value("nDatabaseCache");
|
||||
case ThreadsScriptVerif:
|
||||
return settings.value("nThreadsScriptVerif");
|
||||
case Listen:
|
||||
return settings.value("fListen");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@@ -280,20 +259,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ProxySocksVersion: {
|
||||
if (settings.value("nSocksVersion") != value) {
|
||||
settings.setValue("nSocksVersion", value.toInt());
|
||||
setRestartRequired(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
#ifdef ENABLE_WALLET
|
||||
case Fee: // core option - can be changed on-the-fly
|
||||
// Todo: Add is valid check and warn via message, if not
|
||||
nTransactionFee = value.toLongLong();
|
||||
settings.setValue("nTransactionFee", (qint64)nTransactionFee);
|
||||
emit transactionFeeChanged(nTransactionFee);
|
||||
break;
|
||||
case SpendZeroConfChange:
|
||||
if (settings.value("bSpendZeroConfChange") != value) {
|
||||
settings.setValue("bSpendZeroConfChange", value);
|
||||
@@ -302,13 +268,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
||||
break;
|
||||
#endif
|
||||
case DisplayUnit:
|
||||
nDisplayUnit = value.toInt();
|
||||
settings.setValue("nDisplayUnit", nDisplayUnit);
|
||||
emit displayUnitChanged(nDisplayUnit);
|
||||
break;
|
||||
case DisplayAddresses:
|
||||
bDisplayAddresses = value.toBool();
|
||||
settings.setValue("bDisplayAddresses", bDisplayAddresses);
|
||||
setDisplayUnit(value);
|
||||
break;
|
||||
case ThirdPartyTxUrls:
|
||||
if (strThirdPartyTxUrls != value.toString()) {
|
||||
@@ -340,35 +300,50 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
||||
setRestartRequired(true);
|
||||
}
|
||||
break;
|
||||
case Listen:
|
||||
if (settings.value("fListen") != value) {
|
||||
settings.setValue("fListen", value);
|
||||
setRestartRequired(true);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
emit dataChanged(index, index);
|
||||
|
||||
return successful;
|
||||
}
|
||||
|
||||
/** Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal */
|
||||
void OptionsModel::setDisplayUnit(const QVariant &value)
|
||||
{
|
||||
if (!value.isNull())
|
||||
{
|
||||
QSettings settings;
|
||||
nDisplayUnit = value.toInt();
|
||||
settings.setValue("nDisplayUnit", nDisplayUnit);
|
||||
emit displayUnitChanged(nDisplayUnit);
|
||||
}
|
||||
}
|
||||
|
||||
bool OptionsModel::getProxySettings(QNetworkProxy& proxy) const
|
||||
{
|
||||
// Directly query current base proxy, because
|
||||
// GUI settings can be overridden with -proxy.
|
||||
proxyType curProxy;
|
||||
if (GetProxy(NET_IPV4, curProxy)) {
|
||||
if (curProxy.second == 5) {
|
||||
proxy.setType(QNetworkProxy::Socks5Proxy);
|
||||
proxy.setHostName(QString::fromStdString(curProxy.first.ToStringIP()));
|
||||
proxy.setPort(curProxy.first.GetPort());
|
||||
proxy.setType(QNetworkProxy::Socks5Proxy);
|
||||
proxy.setHostName(QString::fromStdString(curProxy.proxy.ToStringIP()));
|
||||
proxy.setPort(curProxy.proxy.GetPort());
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
proxy.setType(QNetworkProxy::NoProxy);
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void OptionsModel::setRestartRequired(bool fRequired)
|
||||
|
||||
Reference in New Issue
Block a user