MCPcopy Create free account
hub / github.com/ElementsProject/elements / setData

Method setData

src/qt/optionsmodel.cpp:393–568  ·  view source on GitHub ↗

write QSettings values

Source from the content-addressed store, hash-verified

391
392// write QSettings values
393bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, int role)
394{
395 bool successful = true; /* set to false on parse error */
396 if(role == Qt::EditRole)
397 {
398 QSettings settings;
399 switch(index.row())
400 {
401 case StartAtStartup:
402 successful = GUIUtil::SetStartOnSystemStartup(value.toBool());
403 break;
404 case ShowTrayIcon:
405 m_show_tray_icon = value.toBool();
406 settings.setValue("fHideTrayIcon", !m_show_tray_icon);
407 Q_EMIT showTrayIconChanged(m_show_tray_icon);
408 break;
409 case MinimizeToTray:
410 fMinimizeToTray = value.toBool();
411 settings.setValue("fMinimizeToTray", fMinimizeToTray);
412 break;
413 case MapPortUPnP: // core option - can be changed on-the-fly
414 settings.setValue("fUseUPnP", value.toBool());
415 break;
416 case MapPortNatpmp: // core option - can be changed on-the-fly
417 settings.setValue("fUseNatpmp", value.toBool());
418 break;
419 case MinimizeOnClose:
420 fMinimizeOnClose = value.toBool();
421 settings.setValue("fMinimizeOnClose", fMinimizeOnClose);
422 break;
423
424 // default proxy
425 case ProxyUse:
426 if (settings.value("fUseProxy") != value) {
427 settings.setValue("fUseProxy", value.toBool());
428 setRestartRequired(true);
429 }
430 break;
431 case ProxyIP: {
432 auto ip_port = GetProxySetting(settings, "addrProxy");
433 if (!ip_port.is_set || ip_port.ip != value.toString()) {
434 ip_port.ip = value.toString();
435 SetProxySetting(settings, "addrProxy", ip_port);
436 setRestartRequired(true);
437 }
438 }
439 break;
440 case ProxyPort: {
441 auto ip_port = GetProxySetting(settings, "addrProxy");
442 if (!ip_port.is_set || ip_port.port != value.toString()) {
443 ip_port.port = value.toString();
444 SetProxySetting(settings, "addrProxy", ip_port);
445 setRestartRequired(true);
446 }
447 }
448 break;
449
450 // separate Tor proxy

Callers 2

updateViewMethod · 0.45
createContextMenuMethod · 0.45

Calls 6

SetStartOnSystemStartupFunction · 0.85
GetProxySettingFunction · 0.85
SetProxySettingFunction · 0.85
setDisplayUnitFunction · 0.85
setValueMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected