X-Git-Url: http://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=main.cpp;h=8f495419fee7467de77c4074c32927ce658de919;hp=8054e49be3315810bcd355d994c689f30471cd61;hb=HEAD;hpb=4971985821bf983a56a8e6399a8609f0e4dacbe7 diff --git a/main.cpp b/main.cpp index 8054e49b..0867187c 100644 --- a/main.cpp +++ b/main.cpp @@ -26,6 +26,11 @@ #include #include +#ifdef ENABLE_FLOW +#include +#include +#endif + #include #include @@ -54,6 +59,8 @@ #include "pv/logging.hpp" #include "pv/mainwindow.hpp" #include "pv/session.hpp" +#include "pv/util.hpp" +#include "pv/data/segment.hpp" #ifdef ANDROID #include @@ -63,9 +70,11 @@ #ifdef _WIN32 #include +#ifdef QT_STATIC Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin) Q_IMPORT_PLUGIN(QSvgPlugin) #endif +#endif using std::exception; using std::ifstream; @@ -151,8 +160,9 @@ void usage() " -V, --version Show release version\n" " -l, --loglevel Set libsigrok/libsigrokdecode loglevel\n" " -d, --driver Specify the device driver to use\n" - " -D, --no-scan Don't auto-scan for devices, use -d spec only\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); @@ -162,12 +172,20 @@ 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_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); #ifdef ANDROID @@ -183,8 +201,9 @@ int main(int argc, char *argv[]) {"version", no_argument, nullptr, 'V'}, {"loglevel", required_argument, nullptr, 'l'}, {"driver", required_argument, nullptr, 'd'}, - {"no-scan", no_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'}, @@ -192,7 +211,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; @@ -239,6 +258,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; @@ -254,9 +277,18 @@ int main(int argc, char *argv[]) for (int i = 0; i < argc; i++) open_files.emplace_back(argv[i]); + 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(); @@ -300,7 +332,7 @@ int main(int argc, char *argv[]) // Create the device manager, initialise the drivers pv::DeviceManager device_manager(context, driver, do_scan); - a.collect_version_info(context); + a.collect_version_info(device_manager); if (show_version) { a.print_version_info(); } else { @@ -314,16 +346,15 @@ int main(int argc, char *argv[]) if (open_files.empty()) w.add_default_session(); else - for (string open_file : open_files) - w.add_session_with_file(open_file, open_file_format); + for (string& open_file : open_files) + 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