MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / loadPreferences

Method loadPreferences

src/openms_gui/source/VISUAL/APPLICATIONS/TOPPViewBase.cpp:1493–1570  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1491 }
1492
1493 void TOPPViewBase::loadPreferences(String filename)
1494 {
1495 // compose default ini file path
1496 String default_ini_file = String(QDir::homePath()) + "/.TOPPView.ini";
1497
1498 bool tool_params_added = false;
1499
1500 if (filename == "") { filename = default_ini_file; }
1501
1502 // load preferences, if file exists
1503 if (File::exists(filename))
1504 {
1505 bool error = false;
1506 Param tmp;
1507 try // the file might be corrupt
1508 {
1509 ParamXMLFile().load(filename, tmp);
1510 }
1511 catch (...)
1512 {
1513 error = true;
1514 }
1515 // apply preferences if they are of the current TOPPView version
1516 if (!error && tmp.exists("preferences:version") &&
1517 tmp.getValue("preferences:version").toString() == VersionInfo::getVersion())
1518 {
1519 try
1520 {
1521 setParameters(tmp.copy("preferences:"));
1522 }
1523 catch (Exception::InvalidParameter& /*e*/)
1524 {
1525 error = true;
1526 }
1527 }
1528 else
1529 {
1530 error = true;
1531 }
1532
1533 // set parameters to defaults when something is fishy with the parameters file
1534 if (error)
1535 {
1536 // reset parameters (they will be stored again when TOPPView quits)
1537 setParameters(Param());
1538 cerr << "The TOPPView preferences files '" << filename << "' was ignored. It is no longer compatible with this TOPPView version and will be replaced." << endl;
1539 }
1540 else
1541 {
1542 // Load tool/util params
1543 if (scan_mode_ != TOOL_SCAN::FORCE_SCAN && tmp.hasSection("tool_params:"))
1544 {
1545 param_.insert("tool_params:", tmp.copy("tool_params:", true));
1546 tool_params_added = true;
1547 }
1548 // If the saved plugin path does not exist
1549 if (!tool_scanner_.setPluginPath(param_.getValue(user_section + "plugins_path").toString()))
1550 {

Callers

nothing calls this directly

Calls 14

ParamXMLFileClass · 0.85
hasSectionMethod · 0.80
setPluginPathMethod · 0.80
loadToolParamsMethod · 0.80
setFromParamMethod · 0.80
StringClass · 0.50
ParamClass · 0.50
loadMethod · 0.45
existsMethod · 0.45
toStringMethod · 0.45
getValueMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected