// 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 ReserveBalance: nReserveBalance = value.toLongLong(); settings.setValue("nReserveBalance", (qint64) nReserveBalance); emit reserveBalanceChanged(nReserveBalance); break; #endif case DisplayUnit: nDisplayUnit = value.toInt(); settings.setValue("nDisplayUnit", nDisplayUnit); emit displayUnitChanged(nDisplayUnit); 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 UseBlackTheme: fUseBlackTheme = value.toBool(); settings.setValue("fUseBlackTheme", fUseBlackTheme); break; case DarksendRounds: nDarksendRounds = value.toInt(); settings.setValue("nDarksendRounds", nDarksendRounds); emit darksendRoundsChanged(nDarksendRounds); break; case AnonymizeOxidAmount: nAnonymizeOxidAmount = value.toInt(); settings.setValue("nAnonymizeOxidAmount", nAnonymizeOxidAmount); emit AnonymizeOxidAmountChanged(nAnonymizeOxidAmount); 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: 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; }
// 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; #ifdef ENABLE_WALLET case SpendZeroConfChange: if (settings.value("bSpendZeroConfChange") != value) { settings.setValue("bSpendZeroConfChange", value); setRestartRequired(true); } break; #endif case DisplayUnit: setDisplayUnit(value); break; case ThirdPartyTxUrls: if (strThirdPartyTxUrls != value.toString()) { strThirdPartyTxUrls = value.toString(); settings.setValue("strThirdPartyTxUrls", strThirdPartyTxUrls); setRestartRequired(true); } break; case Digits: if (settings.value("digits") != value) { settings.setValue("digits", value); setRestartRequired(true); } break; case Theme: if (settings.value("theme") != value) { settings.setValue("theme", value); setRestartRequired(true); } break; case Language: if (settings.value("language") != value) { settings.setValue("language", value); setRestartRequired(true); } break; case DarksendRounds: nDarksendRounds = value.toInt(); settings.setValue("nDarksendRounds", nDarksendRounds); emit darksendRoundsChanged(nDarksendRounds); break; case AnonymizeDarkcoinAmount: nAnonymizeDarkcoinAmount = value.toInt(); settings.setValue("nAnonymizeDarkcoinAmount", nAnonymizeDarkcoinAmount); emit anonymizeDarkcoinAmountChanged(nAnonymizeDarkcoinAmount); 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; case Listen: if (settings.value("fListen") != value) { settings.setValue("fListen", value); setRestartRequired(true); } break; default: break; } } emit dataChanged(index, index); return successful; }