Pharao Release
Version 4.0.0.4 - refactored code - migrated vom Qt4 to Qt5 - added secure messaging
This commit is contained in:
+27
-74
@@ -1,5 +1,5 @@
|
||||
#include "optionsmodel.h"
|
||||
#include "bitcoinunits.h"
|
||||
#include "trianglesunits.h"
|
||||
#include <QSettings>
|
||||
|
||||
#include "init.h"
|
||||
@@ -15,7 +15,7 @@ OptionsModel::OptionsModel(QObject *parent) :
|
||||
bool static ApplyProxySettings()
|
||||
{
|
||||
QSettings settings;
|
||||
CService addrProxy(settings.value("addrProxy", "127.0.0.1:9244").toString().toStdString());
|
||||
CService addrProxy(settings.value("addrProxy", "127.0.0.1:9050").toString().toStdString());
|
||||
int nSocksVersion(settings.value("nSocksVersion", 5).toInt());
|
||||
if (!settings.value("fUseProxy", false).toBool()) {
|
||||
addrProxy = CService();
|
||||
@@ -41,15 +41,16 @@ void OptionsModel::Init()
|
||||
QSettings settings;
|
||||
|
||||
// These are Qt-only settings:
|
||||
nDisplayUnit = settings.value("nDisplayUnit", BitcoinUnits::BTC).toInt();
|
||||
nDisplayUnit = settings.value("nDisplayUnit", TrianglesUnits::TRI).toInt();
|
||||
bDisplayAddresses = settings.value("bDisplayAddresses", false).toBool();
|
||||
fMinimizeToTray = settings.value("fMinimizeToTray", false).toBool();
|
||||
fMinimizeOnClose = settings.value("fMinimizeOnClose", false).toBool();
|
||||
fCoinControlFeatures = settings.value("fCoinControlFeatures", false).toBool();
|
||||
fCoinControlFeatures = settings.value("fCoinControlFeatures", false).toBool();
|
||||
nTransactionFee = settings.value("nTransactionFee").toLongLong();
|
||||
nReserveBalance = settings.value("nReserveBalance").toLongLong();
|
||||
language = settings.value("language", "").toString();
|
||||
|
||||
// These are shared with core Bitcoin; we want
|
||||
// These are shared with core Triangles; we want
|
||||
// command-line options to override the GUI settings:
|
||||
if (settings.contains("fUseUPnP"))
|
||||
SoftSetBoolArg("-upnp", settings.value("fUseUPnP").toBool());
|
||||
@@ -63,66 +64,6 @@ void OptionsModel::Init()
|
||||
SoftSetArg("-lang", language.toStdString());
|
||||
}
|
||||
|
||||
bool OptionsModel::Upgrade()
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
if (settings.contains("bImportFinished"))
|
||||
return false; // Already upgraded
|
||||
|
||||
settings.setValue("bImportFinished", true);
|
||||
|
||||
// Move settings from old wallet.dat (if any):
|
||||
CWalletDB walletdb("wallet.dat");
|
||||
|
||||
QList<QString> intOptions;
|
||||
intOptions << "nDisplayUnit" << "nTransactionFee";
|
||||
foreach(QString key, intOptions)
|
||||
{
|
||||
int value = 0;
|
||||
if (walletdb.ReadSetting(key.toStdString(), value))
|
||||
{
|
||||
settings.setValue(key, value);
|
||||
walletdb.EraseSetting(key.toStdString());
|
||||
}
|
||||
}
|
||||
QList<QString> boolOptions;
|
||||
boolOptions << "bDisplayAddresses" << "fMinimizeToTray" << "fMinimizeOnClose" << "fUseProxy" << "fUseUPnP";
|
||||
foreach(QString key, boolOptions)
|
||||
{
|
||||
bool value = false;
|
||||
if (walletdb.ReadSetting(key.toStdString(), value))
|
||||
{
|
||||
settings.setValue(key, value);
|
||||
walletdb.EraseSetting(key.toStdString());
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
CAddress addrProxyAddress;
|
||||
if (walletdb.ReadSetting("addrProxy", addrProxyAddress))
|
||||
{
|
||||
settings.setValue("addrProxy", addrProxyAddress.ToStringIPPort().c_str());
|
||||
walletdb.EraseSetting("addrProxy");
|
||||
}
|
||||
}
|
||||
catch (std::ios_base::failure &e)
|
||||
{
|
||||
// 0.6.0rc1 saved this as a CService, which causes failure when parsing as a CAddress
|
||||
CService addrProxy;
|
||||
if (walletdb.ReadSetting("addrProxy", addrProxy))
|
||||
{
|
||||
settings.setValue("addrProxy", addrProxy.ToStringIPPort().c_str());
|
||||
walletdb.EraseSetting("addrProxy");
|
||||
}
|
||||
}
|
||||
ApplyProxySettings();
|
||||
Init();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int OptionsModel::rowCount(const QModelIndex & parent) const
|
||||
{
|
||||
return OptionIDRowCount;
|
||||
@@ -157,12 +98,14 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
||||
if (GetProxy(NET_IPV4, proxy))
|
||||
return QVariant(proxy.first.GetPort());
|
||||
else
|
||||
return QVariant(9244);
|
||||
return QVariant(9050);
|
||||
}
|
||||
case ProxySocksVersion:
|
||||
return settings.value("nSocksVersion", 5);
|
||||
case Fee:
|
||||
return QVariant(nTransactionFee);
|
||||
return QVariant((qint64) nTransactionFee);
|
||||
case ReserveBalance:
|
||||
return QVariant((qint64) nReserveBalance);
|
||||
case DisplayUnit:
|
||||
return QVariant(nDisplayUnit);
|
||||
case DisplayAddresses:
|
||||
@@ -196,8 +139,9 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
||||
settings.setValue("fMinimizeToTray", fMinimizeToTray);
|
||||
break;
|
||||
case MapPortUPnP:
|
||||
settings.setValue("fUseUPnP", value.toBool());
|
||||
MapPort(value.toBool());
|
||||
fUseUPnP = value.toBool();
|
||||
settings.setValue("fUseUPnP", fUseUPnP);
|
||||
MapPort();
|
||||
break;
|
||||
case MinimizeOnClose:
|
||||
fMinimizeOnClose = value.toBool();
|
||||
@@ -209,7 +153,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
||||
break;
|
||||
case ProxyIP: {
|
||||
proxyType proxy;
|
||||
proxy.first = CService("127.0.0.1", 9244);
|
||||
proxy.first = CService("127.0.0.1", 9050);
|
||||
GetProxy(NET_IPV4, proxy);
|
||||
|
||||
CNetAddr addr(value.toString().toStdString());
|
||||
@@ -220,7 +164,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
||||
break;
|
||||
case ProxyPort: {
|
||||
proxyType proxy;
|
||||
proxy.first = CService("127.0.0.1", 9244);
|
||||
proxy.first = CService("127.0.0.1", 9050);
|
||||
GetProxy(NET_IPV4, proxy);
|
||||
|
||||
proxy.first.SetPort(value.toInt());
|
||||
@@ -240,9 +184,14 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
||||
break;
|
||||
case Fee:
|
||||
nTransactionFee = value.toLongLong();
|
||||
settings.setValue("nTransactionFee", nTransactionFee);
|
||||
settings.setValue("nTransactionFee", (qint64) nTransactionFee);
|
||||
emit transactionFeeChanged(nTransactionFee);
|
||||
break;
|
||||
case ReserveBalance:
|
||||
nReserveBalance = value.toLongLong();
|
||||
settings.setValue("nReserveBalance", (qint64) nReserveBalance);
|
||||
emit reserveBalanceChanged(nReserveBalance);
|
||||
break;
|
||||
case DisplayUnit:
|
||||
nDisplayUnit = value.toInt();
|
||||
settings.setValue("nDisplayUnit", nDisplayUnit);
|
||||
@@ -281,11 +230,15 @@ qint64 OptionsModel::getTransactionFee()
|
||||
return nTransactionFee;
|
||||
}
|
||||
|
||||
qint64 OptionsModel::getReserveBalance()
|
||||
{
|
||||
return nReserveBalance;
|
||||
}
|
||||
|
||||
bool OptionsModel::getCoinControlFeatures()
|
||||
{
|
||||
return fCoinControlFeatures;
|
||||
return fCoinControlFeatures;
|
||||
}
|
||||
|
||||
|
||||
bool OptionsModel::getMinimizeToTray()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user