X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=main.cpp;h=3a5ac29fc2bca41ae597f812ee90d88040b2a02f;hp=a4c7e72badfd6fb4fca88e3cf559d47c5a4586da;hb=852a25198bc051a57179961cb9d7836212a62184;hpb=045d81160abe3e545fc44e3b4246b9ed336a7841 diff --git a/main.cpp b/main.cpp index a4c7e72b..3a5ac29f 100644 --- a/main.cpp +++ b/main.cpp @@ -26,7 +26,7 @@ #include #include -#ifdef ENABLE_GSTREAMERMM +#ifdef ENABLE_FLOW #include #include #endif @@ -60,6 +60,7 @@ #include "pv/mainwindow.hpp" #include "pv/session.hpp" #include "pv/util.hpp" +#include "pv/data/segment.hpp" #ifdef ANDROID #include @@ -159,6 +160,7 @@ void usage() " -d, --driver Specify the device driver to use\n" " -D, --dont-scan Don't auto-scan for devices, use -d spec only\n" " -i, --input-file Load input from file\n" + " -s, --settings Load PulseView session setup from file\n" " -I, --input-format Input format\n" " -c, --clean Don't restore previous sessions on startup\n" "\n", PV_BIN_NAME); @@ -168,15 +170,18 @@ int main(int argc, char *argv[]) { int ret = 0; shared_ptr context; - string open_file_format, driver; + string open_file_format, open_setup_file, driver; vector open_files; bool restore_sessions = true; bool do_scan = true; bool show_version = false; -#ifdef ENABLE_GSTREAMERMM +#ifdef ENABLE_FLOW // Initialise gstreamermm. Must be called before any other GLib stuff. Gst::init(); + + // Initialize libsigrokflow. Must be called after Gst::init(). + Srf::init(); #endif Application a(argc, argv); @@ -196,6 +201,7 @@ int main(int argc, char *argv[]) {"driver", required_argument, nullptr, 'd'}, {"dont-scan", no_argument, nullptr, 'D'}, {"input-file", required_argument, nullptr, 'i'}, + {"settings", required_argument, nullptr, 's'}, {"input-format", required_argument, nullptr, 'I'}, {"clean", no_argument, nullptr, 'c'}, {"log-to-stdout", no_argument, nullptr, 's'}, @@ -203,7 +209,7 @@ int main(int argc, char *argv[]) }; const int c = getopt_long(argc, argv, - "h?VDcl:d:i:I:", long_options, nullptr); + "h?VDcl:d:i:s:I:", long_options, nullptr); if (c == -1) break; @@ -250,6 +256,10 @@ int main(int argc, char *argv[]) open_files.emplace_back(optarg); break; + case 's': + open_setup_file = optarg; + break; + case 'I': open_file_format = optarg; break; @@ -265,13 +275,17 @@ int main(int argc, char *argv[]) for (int i = 0; i < argc; i++) open_files.emplace_back(argv[i]); - qRegisterMetaType("util::Timestamp"); qRegisterMetaType("uint64_t"); + qRegisterMetaType("util::Timestamp"); + qRegisterMetaType("SharedPtrToSegment"); + qRegisterMetaType>("shared_ptr"); // Prepare the global settings since logging needs them early on pv::GlobalSettings settings; + settings.add_change_handler(&a); // Only the application object can't register itself settings.save_internal_defaults(); settings.set_defaults_where_needed(); + settings.apply_language(); settings.apply_theme(); pv::logging.init(); @@ -331,15 +345,14 @@ int main(int argc, char *argv[]) w.add_default_session(); else for (string& open_file : open_files) - w.add_session_with_file(open_file, open_file_format); + w.add_session_with_file(open_file, open_file_format, open_setup_file); #ifdef ENABLE_SIGNALS if (SignalHandler::prepare_signals()) { SignalHandler *const handler = new SignalHandler(&w); - QObject::connect(handler, SIGNAL(int_received()), - &w, SLOT(close())); - QObject::connect(handler, SIGNAL(term_received()), - &w, SLOT(close())); + QObject::connect(handler, SIGNAL(int_received()), &w, SLOT(close())); + QObject::connect(handler, SIGNAL(term_received()), &w, SLOT(close())); + QObject::connect(handler, SIGNAL(usr1_received()), &w, SLOT(on_run_stop_clicked())); } else qWarning() << "Could not prepare signal handler."; #endif