MCPcopy Index your code
hub / github.com/DreamSourceLab/DSView / load_config_from_file

Method load_config_from_file

DSView/pv/mainwindow.cpp:637–680  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

635 }
636
637 bool MainWindow::load_config_from_file(QString file)
638 {
639 if (file == ""){
640 dsv_err("File name is empty.");
641 assert(false);
642 }
643
644 _protocol_widget->del_all_protocol();
645
646 std::string file_name = pv::path::ToUnicodePath(file);
647 dsv_info("Load device profile: \"%s\"", file_name.c_str());
648
649 QFile sf(file);
650
651 if (!sf.exists()){
652 dsv_warn("Warning: device profile is not exists: \"%s\"", file_name.c_str());
653 return false;
654 }
655
656 if (!sf.open(QIODevice::ReadOnly))
657 {
658 dsv_warn("Warning: Couldn't open device profile to load!");
659 return false;
660 }
661
662 QString data = QString::fromUtf8(sf.readAll());
663 QJsonDocument doc = QJsonDocument::fromJson(data.toUtf8());
664 sf.close();
665
666 bool bDecoder = false;
667 int ret = load_config_from_json(doc, bDecoder);
668
669 if (ret && _device_agent->get_work_mode() == DSO)
670 {
671 _dso_trigger_widget->update_view();
672 }
673
674 if (_device_agent->is_hardware()){
675 _title_ext_string = file;
676 update_title_bar_text();
677 }
678
679 return ret;
680 }
681
682 bool MainWindow::gen_config_json(QJsonObject &sessionVar)
683 {

Callers

nothing calls this directly

Calls 6

ToUnicodePathFunction · 0.85
del_all_protocolMethod · 0.80
closeMethod · 0.80
get_work_modeMethod · 0.80
is_hardwareMethod · 0.80
update_viewMethod · 0.45

Tested by

no test coverage detected