/** 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); Q_EMIT displayUnitChanged(nDisplayUnit); } }
int OptionsModel::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QAbstractListModel::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: displayUnitChanged((*reinterpret_cast< int(*)>(_a[1]))); break; default: ; } _id -= 1; } return _id; }
// write QSettings values bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, int role) { bool successful = true; /* set to false on parse error */ if(role == Qt::EditRole) { QSettings settings; switch(index.row()) { case StartAtStartup: successful = GUIUtil::SetStartOnSystemStartup(value.toBool()); break; case MinimizeToTray: fMinimizeToTray = value.toBool(); settings.setValue("fMinimizeToTray", fMinimizeToTray); break; case MapPortUPnP: // core option - can be changed on-the-fly settings.setValue("fUseUPnP", value.toBool()); MapPort(value.toBool()); break; case MinimizeOnClose: fMinimizeOnClose = value.toBool(); settings.setValue("fMinimizeOnClose", fMinimizeOnClose); break; // default proxy case ProxyUse: if (settings.value("fUseProxy") != value) { settings.setValue("fUseProxy", value.toBool()); setRestartRequired(true); } break; case ProxyIP: { // contains current IP at index 0 and current port at index 1 QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts); // if that key doesn't exist or has a changed IP if (!settings.contains("addrProxy") || strlIpPort.at(0) != value.toString()) { // construct new value from new IP and current port QString strNewValue = value.toString() + ":" + strlIpPort.at(1); settings.setValue("addrProxy", strNewValue); setRestartRequired(true); } } break; case ProxyPort: { // contains current IP at index 0 and current port at index 1 QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts); // if that key doesn't exist or has a changed port if (!settings.contains("addrProxy") || strlIpPort.at(1) != value.toString()) { // construct new value from current IP and new port QString strNewValue = strlIpPort.at(0) + ":" + value.toString(); settings.setValue("addrProxy", strNewValue); setRestartRequired(true); } } 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); setRestartRequired(true); } break; #endif case DisplayUnit: nDisplayUnit = value.toInt(); settings.setValue("nDisplayUnit", nDisplayUnit); emit displayUnitChanged(nDisplayUnit); break; case DisplayAddresses: bDisplayAddresses = value.toBool(); settings.setValue("bDisplayAddresses", bDisplayAddresses); break; case Language: if (settings.value("language") != value) { settings.setValue("language", value); setRestartRequired(true); } break; case CoinControlFeatures: fCoinControlFeatures = value.toBool(); settings.setValue("fCoinControlFeatures", fCoinControlFeatures); emit coinControlFeaturesChanged(fCoinControlFeatures); break; case DatabaseCache: if (settings.value("nDatabaseCache") != value) { settings.setValue("nDatabaseCache", value); setRestartRequired(true); } break; case ThreadsScriptVerif: if (settings.value("nThreadsScriptVerif") != value) { settings.setValue("nThreadsScriptVerif", value); setRestartRequired(true); } break; default: break; } } emit dataChanged(index, index); return successful; }
bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, int role) { bool successful = true; /* set to false on parse error */ if(role == Qt::EditRole) { QSettings settings; switch(index.row()) { case StartAtStartup: successful = GUIUtil::SetStartOnSystemStartup(value.toBool()); break; case MinimizeToTray: fMinimizeToTray = value.toBool(); settings.setValue("fMinimizeToTray", fMinimizeToTray); break; case MapPortUPnP: settings.setValue("fUseUPnP", value.toBool()); MapPort(value.toBool()); break; case MinimizeOnClose: fMinimizeOnClose = value.toBool(); settings.setValue("fMinimizeOnClose", fMinimizeOnClose); break; case ProxyUse: settings.setValue("fUseProxy", value.toBool()); ApplyProxySettings(); break; case ProxyIP: { proxyType proxy; proxy = CService("127.0.0.1", 9050); GetProxy(NET_IPV4, proxy); CNetAddr addr(value.toString().toStdString()); proxy.SetIP(addr); settings.setValue("addrProxy", proxy.ToStringIPPort().c_str()); successful = ApplyProxySettings(); } break; case ProxyPort: { proxyType proxy; proxy = CService("127.0.0.1", 9050); GetProxy(NET_IPV4, proxy); proxy.SetPort(value.toInt()); settings.setValue("addrProxy", proxy.ToStringIPPort().c_str()); successful = ApplyProxySettings(); } break; case Fee: nTransactionFee = value.toLongLong(); 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); emit displayUnitChanged(nDisplayUnit); break; case Language: settings.setValue("language", value); break; case CoinControlFeatures: { fCoinControlFeatures = value.toBool(); settings.setValue("fCoinControlFeatures", fCoinControlFeatures); emit coinControlFeaturesChanged(fCoinControlFeatures); } break; case MinimizeCoinAge: fMinimizeCoinAge = value.toBool(); settings.setValue("fMinimizeCoinAge", fMinimizeCoinAge); break; case UseBlackTheme: fUseBlackTheme = value.toBool(); settings.setValue("fUseBlackTheme", fUseBlackTheme); break; case DarksendRounds: nDarksendRounds = value.toInt(); settings.setValue("nDarksendRounds", nDarksendRounds); emit darksendRoundsChanged(nDarksendRounds); break; case anonymizeGridmasterAmount: nAnonymizeGridmasterAmount = value.toInt(); settings.setValue("nAnonymizeGridmasterAmount", nAnonymizeGridmasterAmount); emit anonymizeGridmasterAmountChanged(nAnonymizeGridmasterAmount); break; default: break; } } emit dataChanged(index, index); return successful; }
bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, int role) { bool successful = true; /* set to false on parse error */ if(role == Qt::EditRole) { QSettings settings; switch(index.row()) { case StartAtStartup: successful = GUIUtil::SetStartOnSystemStartup(value.toBool()); break; case MinimizeToTray: fMinimizeToTray = value.toBool(); settings.setValue("fMinimizeToTray", fMinimizeToTray); break; case MapPortUPnP: settings.setValue("fUseUPnP", value.toBool()); MapPort(value.toBool()); break; case MinimizeOnClose: fMinimizeOnClose = value.toBool(); settings.setValue("fMinimizeOnClose", fMinimizeOnClose); break; case ProxyUse: settings.setValue("fUseProxy", value.toBool()); ApplyProxySettings(); break; case ProxyIP: { proxyType proxy; proxy = CService("127.0.0.1", 9050); GetProxy(NET_IPV4, proxy); CNetAddr addr(value.toString().toStdString()); proxy.SetIP(addr); settings.setValue("addrProxy", proxy.ToStringIPPort().c_str()); successful = ApplyProxySettings(); } break; case ProxyPort: { proxyType proxy; proxy = CService("127.0.0.1", 9050); GetProxy(NET_IPV4, proxy); proxy.SetPort(value.toInt()); settings.setValue("addrProxy", proxy.ToStringIPPort().c_str()); successful = ApplyProxySettings(); } break; case Fee: nTransactionFee = value.toLongLong(); 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); emit displayUnitChanged(nDisplayUnit); break; case Language: settings.setValue("language", value); break; case CoinControlFeatures: { fCoinControlFeatures = value.toBool(); settings.setValue("fCoinControlFeatures", fCoinControlFeatures); emit coinControlFeaturesChanged(fCoinControlFeatures); } break; case MinimizeCoinAge: fMinimizeCoinAge = value.toBool(); settings.setValue("fMinimizeCoinAge", fMinimizeCoinAge); break; case UseBlackTheme: fUseBlackTheme = value.toBool(); settings.setValue("fUseBlackTheme", fUseBlackTheme); break; case DarksendRounds: nDarksendRounds = value.toInt(); settings.setValue("nDarksendRounds", nDarksendRounds); emit darksendRoundsChanged(nDarksendRounds); break; case anonymizecovenAmount: nAnonymizecovenAmount = value.toInt(); settings.setValue("nAnonymizecovenAmount", nAnonymizecovenAmount); emit anonymizecovenAmountChanged(nAnonymizecovenAmount); break; #ifdef USE_NATIVE_I2P case I2PUseI2POnly: { ScopeGroupHelper s(settings, I2P_OPTIONS_SECTION_NAME); settings.setValue("useI2POnly", value.toBool()); break; } case I2PSAMHost: { ScopeGroupHelper s(settings, I2P_OPTIONS_SECTION_NAME); settings.setValue("samhost", value.toString()); break; } case I2PSAMPort: { ScopeGroupHelper s(settings, I2P_OPTIONS_SECTION_NAME); settings.setValue("samport", value.toString()); break; } case I2PSessionName: { ScopeGroupHelper s(settings, I2P_OPTIONS_SECTION_NAME); settings.setValue("sessionName", value.toString()); break; } case I2PInboundQuantity: { ScopeGroupHelper s(settings, I2P_OPTIONS_SECTION_NAME); i2pInboundQuantity = value.toInt(); settings.setValue(SAM_NAME_INBOUND_QUANTITY, i2pInboundQuantity); break; } case I2PInboundLength: { ScopeGroupHelper s(settings, I2P_OPTIONS_SECTION_NAME); i2pInboundLength = value.toInt(); settings.setValue(SAM_NAME_INBOUND_LENGTH, i2pInboundLength); break; } case I2PInboundLengthVariance: { ScopeGroupHelper s(settings, I2P_OPTIONS_SECTION_NAME); i2pInboundLengthVariance = value.toInt(); settings.setValue(SAM_NAME_INBOUND_LENGTHVARIANCE, i2pInboundLengthVariance); break; } case I2PInboundBackupQuantity: { ScopeGroupHelper s(settings, I2P_OPTIONS_SECTION_NAME); i2pInboundBackupQuantity = value.toInt(); settings.setValue(SAM_NAME_INBOUND_BACKUPQUANTITY, i2pInboundBackupQuantity); break; } case I2PInboundAllowZeroHop: { ScopeGroupHelper s(settings, I2P_OPTIONS_SECTION_NAME); i2pInboundAllowZeroHop = value.toBool(); settings.setValue(SAM_NAME_INBOUND_ALLOWZEROHOP, i2pInboundAllowZeroHop); break; } case I2PInboundIPRestriction: { ScopeGroupHelper s(settings, I2P_OPTIONS_SECTION_NAME); i2pInboundIPRestriction = value.toInt(); settings.setValue(SAM_NAME_INBOUND_IPRESTRICTION, i2pInboundIPRestriction); break; } case I2POutboundQuantity: { ScopeGroupHelper s(settings, I2P_OPTIONS_SECTION_NAME); i2pOutboundQuantity = value.toInt(); settings.setValue(SAM_NAME_OUTBOUND_QUANTITY, i2pOutboundQuantity); break; } case I2POutboundLength: { ScopeGroupHelper s(settings, I2P_OPTIONS_SECTION_NAME); i2pOutboundLength = value.toInt(); settings.setValue(SAM_NAME_OUTBOUND_LENGTH, i2pOutboundLength); break; } case I2POutboundLengthVariance: { ScopeGroupHelper s(settings, I2P_OPTIONS_SECTION_NAME); i2pOutboundLengthVariance = value.toInt(); settings.setValue(SAM_NAME_OUTBOUND_LENGTHVARIANCE, i2pOutboundLengthVariance); break; } case I2POutboundBackupQuantity: { ScopeGroupHelper s(settings, I2P_OPTIONS_SECTION_NAME); i2pOutboundBackupQuantity = value.toInt(); settings.setValue(SAM_NAME_OUTBOUND_BACKUPQUANTITY, i2pOutboundBackupQuantity); break; } case I2POutboundAllowZeroHop: { ScopeGroupHelper s(settings, I2P_OPTIONS_SECTION_NAME); i2pOutboundAllowZeroHop = value.toBool(); settings.setValue(SAM_NAME_OUTBOUND_ALLOWZEROHOP, i2pOutboundAllowZeroHop); break; } case I2POutboundIPRestriction: { ScopeGroupHelper s(settings, I2P_OPTIONS_SECTION_NAME); i2pOutboundIPRestriction = value.toInt(); settings.setValue(SAM_NAME_OUTBOUND_IPRESTRICTION, i2pOutboundIPRestriction); break; } case I2POutboundPriority: { ScopeGroupHelper s(settings, I2P_OPTIONS_SECTION_NAME); i2pOutboundPriority = value.toInt(); settings.setValue(SAM_NAME_OUTBOUND_PRIORITY, i2pOutboundPriority); break; } #endif default: break; } } emit dataChanged(index, index); return successful; }
bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, int role) { bool successful = true; /* set to false on parse error */ if(role == Qt::EditRole) { QSettings settings; switch(index.row()) { case StartAtStartup: successful = GUIUtil::SetStartOnSystemStartup(value.toBool()); break; case MinimizeToTray: fMinimizeToTray = value.toBool(); settings.setValue("fMinimizeToTray", fMinimizeToTray); break; case MapPortUPnP: fUseUPnP = value.toBool(); settings.setValue("fUseUPnP", fUseUPnP); MapPort(); break; case MinimizeOnClose: fMinimizeOnClose = value.toBool(); settings.setValue("fMinimizeOnClose", fMinimizeOnClose); break; case ProxyUse: settings.setValue("fUseProxy", value.toBool()); ApplyProxySettings(); break; case ProxyIP: { proxyType proxy; proxy.first = CService("127.0.0.1", 9050); GetProxy(NET_IPV4, proxy); CNetAddr addr(value.toString().toStdString()); proxy.first.SetIP(addr); settings.setValue("addrProxy", proxy.first.ToStringIPPort().c_str()); successful = ApplyProxySettings(); } break; case ProxyPort: { proxyType proxy; proxy.first = CService("127.0.0.1", 9050); GetProxy(NET_IPV4, proxy); proxy.first.SetPort(value.toInt()); settings.setValue("addrProxy", proxy.first.ToStringIPPort().c_str()); successful = ApplyProxySettings(); } break; case ProxySocksVersion: { proxyType proxy; proxy.second = 5; GetProxy(NET_IPV4, proxy); proxy.second = value.toInt(); settings.setValue("nSocksVersion", proxy.second); successful = ApplyProxySettings(); } break; case Fee: nTransactionFee = value.toLongLong(); 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); emit displayUnitChanged(nDisplayUnit); break; case DisplayAddresses: bDisplayAddresses = value.toBool(); settings.setValue("bDisplayAddresses", bDisplayAddresses); break; case DetachDatabases: { bool fDetachDB = value.toBool(); bitdb.SetDetach(fDetachDB); settings.setValue("detachDB", fDetachDB); } break; case Language: settings.setValue("language", value); break; case CoinControlFeatures: { fCoinControlFeatures = value.toBool(); settings.setValue("fCoinControlFeatures", fCoinControlFeatures); emit coinControlFeaturesChanged(fCoinControlFeatures); } break; default: break; } } emit dataChanged(index, index); return successful; }
bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, int role) { bool successful = true; /* set to false on parse error */ if(role == Qt::EditRole) { CWalletDB walletdb(wallet->strWalletFile); switch(index.row()) { case StartAtStartup: successful = SetStartOnSystemStartup(value.toBool()); break; case MinimizeToTray: fMinimizeToTray = value.toBool(); walletdb.WriteSetting("fMinimizeToTray", fMinimizeToTray); break; case MapPortUPnP: fUseUPnP = value.toBool(); walletdb.WriteSetting("fUseUPnP", fUseUPnP); #ifdef USE_UPNP MapPort(fUseUPnP); #endif break; case MinimizeOnClose: fMinimizeOnClose = value.toBool(); walletdb.WriteSetting("fMinimizeOnClose", fMinimizeOnClose); break; case ConnectSOCKS4: fUseProxy = value.toBool(); walletdb.WriteSetting("fUseProxy", fUseProxy); break; case ProxyIP: { // Use CAddress to parse and check IP CNetAddr addr(value.toString().toStdString()); if (addr.IsValid()) { addrProxy.SetIP(addr); walletdb.WriteSetting("addrProxy", addrProxy); } else { successful = false; } } break; case ProxyPort: { int nPort = atoi(value.toString().toAscii().data()); if (nPort > 0 && nPort < std::numeric_limits<unsigned short>::max()) { addrProxy.SetPort(nPort); walletdb.WriteSetting("addrProxy", addrProxy); } else { successful = false; } } break; case Fee: { nTransactionFee = value.toLongLong(); walletdb.WriteSetting("nTransactionFee", nTransactionFee); } break; case DisplayUnit: { int unit = value.toInt(); nDisplayUnit = unit; walletdb.WriteSetting("nDisplayUnit", nDisplayUnit); emit displayUnitChanged(unit); } case DisplayAddresses: { bDisplayAddresses = value.toBool(); walletdb.WriteSetting("bDisplayAddresses", bDisplayAddresses); } default: break; } } emit dataChanged(index, index); return successful; }
bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, int role) { bool successful = true; /* set to false on parse error */ if(role == Qt::EditRole) { QSettings settings; switch(index.row()) { case StartAtStartup: successful = GUIUtil::SetStartOnSystemStartup(value.toBool()); break; case MinimizeToTray: fMinimizeToTray = value.toBool(); settings.setValue("fMinimizeToTray", fMinimizeToTray); break; case MapPortUPnP: fUseUPnP = value.toBool(); settings.setValue("fUseUPnP", value.toBool()); MapPort(value.toBool()); break; case MinimizeOnClose: fMinimizeOnClose = value.toBool(); settings.setValue("fMinimizeOnClose", fMinimizeOnClose); break; case ProxyUse: settings.setValue("fUseProxy", value.toBool()); ApplyProxySettings(); break; case ProxyIP: { proxyType proxy; proxy = CService("127.0.0.1", 9050); GetProxy(NET_IPV4, proxy); CNetAddr addr(value.toString().toStdString()); proxy.SetIP(addr); settings.setValue("addrProxy", proxy.ToStringIPPort().c_str()); successful = ApplyProxySettings(); } break; case ProxyPort: { proxyType proxy; proxy = CService("127.0.0.1", 9050); GetProxy(NET_IPV4, proxy); proxy.SetPort(value.toInt()); settings.setValue("addrProxy", proxy.ToStringIPPort().c_str()); successful = ApplyProxySettings(); } break; case Fee: nTransactionFee = value.toLongLong(); 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); emit displayUnitChanged(nDisplayUnit); break; case DisplayAddresses: bDisplayAddresses = value.toBool(); settings.setValue("bDisplayAddresses", bDisplayAddresses); emit displayUnitChanged(settings.value("nDisplayUnit", BitcoinUnits::LEO).toInt()); break; case DetachDatabases: { bool fDetachDB = value.toBool(); bitdb.SetDetach(fDetachDB); settings.setValue("detachDB", fDetachDB); } break; case Language: settings.setValue("language", value); break; case RowsPerPage: { nRowsPerPage = value.toInt(); settings.setValue("nRowsPerPage", nRowsPerPage); emit rowsPerPageChanged(nRowsPerPage); } break; case Notifications: { notifications = value.toStringList(); settings.setValue("notifications", notifications); } break; case VisibleTransactions: { visibleTransactions = value.toStringList(); settings.setValue("visibleTransactions", visibleTransactions); emit visibleTransactionsChanged(visibleTransactions); } break; case AutoRingSize: { fAutoRingSize = value.toBool(); settings.setValue("fAutoRingSize", fAutoRingSize); } break; case AutoRedeemLEOcoin: { fAutoRedeemLEOcoin = value.toBool(); settings.setValue("fAutoRedeemLEOcoin", fAutoRedeemLEOcoin); } break; case MinRingSize: { nMinRingSize = value.toInt(); settings.setValue("nMinRingSize", nMinRingSize); } break; case MaxRingSize: { nMaxRingSize = value.toInt(); settings.setValue("nMaxRingSize", nMaxRingSize); } break; case Staking: settings.setValue("fStaking", value.toBool()); break; case MinStakeInterval: nMinStakeInterval = value.toInt(); settings.setValue("nMinStakeInterval", nMinStakeInterval); break; case ThinMode: settings.setValue("fThinMode", value.toBool()); break; case ThinFullIndex: settings.setValue("fThinFullIndex", value.toBool()); break; case ThinIndexWindow: settings.setValue("fThinIndexWindow", value.toInt()); break; case SecureMessaging: { if(value.toBool()) { if(!fSecMsgEnabled) SecureMsgEnable(); } else SecureMsgDisable(); settings.setValue("fSecMsgEnabled", fSecMsgEnabled); } break; default: break; } } emit dataChanged(index, index); return successful; }