+ shared_ptr<devices::HardwareDevice> hw_device =
+ dynamic_pointer_cast< devices::HardwareDevice >(device_);
+
+ if (hw_device) {
+ settings.setValue("device_type", "hardware");
+ settings.beginGroup("device");
+
+ key_list.push_back("vendor");
+ key_list.push_back("model");
+ key_list.push_back("version");
+ key_list.push_back("serial_num");
+ key_list.push_back("connection_id");
+
+ dev_info = device_manager_.get_device_info(device_);
+
+ for (string key : key_list) {
+ if (dev_info.count(key))
+ settings.setValue(QString::fromUtf8(key.c_str()),
+ QString::fromUtf8(dev_info.at(key).c_str()));
+ else
+ settings.remove(QString::fromUtf8(key.c_str()));
+ }
+
+ settings.endGroup();
+ }
+
+ shared_ptr<devices::SessionFile> sessionfile_device =
+ dynamic_pointer_cast< devices::SessionFile >(device_);
+
+ if (sessionfile_device) {
+ settings.setValue("device_type", "sessionfile");
+ settings.beginGroup("device");
+ settings.setValue("filename", QString::fromStdString(
+ sessionfile_device->full_name()));
+ settings.endGroup();
+ }
+
+ // Save channels and decoders
+ for (shared_ptr<data::SignalBase> base : signalbases_) {
+#ifdef ENABLE_DECODE
+ if (base->is_decode_signal()) {
+ shared_ptr<pv::data::DecoderStack> decoder_stack =
+ base->decoder_stack();
+ std::shared_ptr<data::decode::Decoder> top_decoder =
+ decoder_stack->stack().front();
+
+ settings.beginGroup("decoder_stack" + QString::number(stacks++));
+ settings.setValue("id", top_decoder->decoder()->id);
+ settings.setValue("name", top_decoder->decoder()->name);
+ settings.endGroup();
+ } else
+#endif
+ {
+ settings.beginGroup(base->internal_name());
+ base->save_settings(settings);
+ settings.endGroup();
+ }
+ }
+
+ settings.setValue("decoder_stacks", stacks);
+
+ // Save view states and their signal settings
+ // Note: main_view must be saved as view0
+ settings.beginGroup("view" + QString::number(views++));
+ main_view_->save_settings(settings);
+ settings.endGroup();