2 * This file is part of the PulseView project.
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <libsigrokdecode/libsigrokdecode.h>
30 #include <boost/algorithm/string/join.hpp>
33 #include <QApplication>
34 #include <QButtonGroup>
35 #include <QCloseEvent>
36 #include <QFileDialog>
37 #include <QMessageBox>
42 #include <QVBoxLayout>
45 #include <QDockWidget>
47 #include "mainwindow.hpp"
49 #include "devicemanager.hpp"
51 #include "data/segment.hpp"
52 #include "devices/hardwaredevice.hpp"
53 #include "devices/inputfile.hpp"
54 #include "devices/sessionfile.hpp"
55 #include "dialogs/about.hpp"
56 #include "dialogs/connect.hpp"
57 #include "dialogs/inputoutputoptions.hpp"
58 #include "dialogs/storeprogress.hpp"
59 #include "toolbars/mainbar.hpp"
60 #include "view/logicsignal.hpp"
61 #include "view/view.hpp"
62 #include "widgets/exportmenu.hpp"
63 #include "widgets/importmenu.hpp"
65 #include "widgets/decodermenu.hpp"
67 #include "widgets/hidingmenubar.hpp"
73 #include <libsigrokcxx/libsigrokcxx.hpp>
78 using std::make_shared;
82 using std::shared_ptr;
86 using boost::algorithm::join;
89 using sigrok::OutputFormat;
90 using sigrok::InputFormat;
98 const char *MainWindow::SettingOpenDirectory = "MainWindow/OpenDirectory";
99 const char *MainWindow::SettingSaveDirectory = "MainWindow/SaveDirectory";
101 MainWindow::MainWindow(DeviceManager &device_manager,
102 string open_file_name, string open_file_format,
105 device_manager_(device_manager),
106 session_(device_manager),
107 action_open_(new QAction(this)),
108 action_save_as_(new QAction(this)),
109 action_save_selection_as_(new QAction(this)),
110 action_connect_(new QAction(this)),
111 action_quit_(new QAction(this)),
112 action_view_zoom_in_(new QAction(this)),
113 action_view_zoom_out_(new QAction(this)),
114 action_view_zoom_fit_(new QAction(this)),
115 action_view_zoom_one_to_one_(new QAction(this)),
116 action_view_sticky_scrolling_(new QAction(this)),
117 action_view_coloured_bg_(new QAction(this)),
118 action_view_show_cursors_(new QAction(this)),
119 action_about_(new QAction(this))
121 , menu_decoders_add_(new pv::widgets::DecoderMenu(this, true))
124 qRegisterMetaType<util::Timestamp>("util::Timestamp");
127 restore_ui_settings();
128 if (open_file_name.empty())
129 select_init_device();
131 load_init_file(open_file_name, open_file_format);
134 MainWindow::~MainWindow()
136 for (auto entry : view_docks_) {
137 const std::shared_ptr<QDockWidget> dock = entry.first;
139 const std::shared_ptr<pv::view::View> view = entry.second;
140 session_.deregister_view(view);
144 QAction* MainWindow::action_open() const
149 QAction* MainWindow::action_save_as() const
151 return action_save_as_;
154 QAction* MainWindow::action_save_selection_as() const
156 return action_save_selection_as_;
159 QAction* MainWindow::action_connect() const
161 return action_connect_;
164 QAction* MainWindow::action_quit() const
169 QAction* MainWindow::action_view_zoom_in() const
171 return action_view_zoom_in_;
174 QAction* MainWindow::action_view_zoom_out() const
176 return action_view_zoom_out_;
179 QAction* MainWindow::action_view_zoom_fit() const
181 return action_view_zoom_fit_;
184 QAction* MainWindow::action_view_zoom_one_to_one() const
186 return action_view_zoom_one_to_one_;
189 QAction* MainWindow::action_view_sticky_scrolling() const
191 return action_view_sticky_scrolling_;
194 QAction* MainWindow::action_view_coloured_bg() const
196 return action_view_coloured_bg_;
199 QAction* MainWindow::action_view_show_cursors() const
201 return action_view_show_cursors_;
204 QAction* MainWindow::action_about() const
206 return action_about_;
210 QMenu* MainWindow::menu_decoder_add() const
212 return menu_decoders_add_;
216 shared_ptr<pv::view::View> MainWindow::get_active_view() const
218 // If there's only one view, use it...
219 if (view_docks_.size() == 1)
220 return view_docks_.begin()->second;
222 // ...otherwise find the dock widget the widget with focus is contained in
223 QObject *w = QApplication::focusWidget();
224 QDockWidget *dock = 0;
227 dock = qobject_cast<QDockWidget*>(w);
233 // Get the view contained in the dock widget
234 for (auto entry : view_docks_)
235 if (entry.first.get() == dock)
238 return shared_ptr<pv::view::View>();
241 shared_ptr<pv::view::View> MainWindow::add_view(const QString &title,
242 view::ViewType type, Session &session)
244 shared_ptr<pv::view::View> v;
246 if (type == pv::view::TraceView)
247 v = make_shared<pv::view::View>(session, this);
250 shared_ptr<QDockWidget> dock = make_shared<QDockWidget>(title, this);
251 dock->setWidget(v.get());
252 dock->setObjectName(title);
253 addDockWidget(Qt::TopDockWidgetArea, dock.get());
254 view_docks_[dock] = v;
256 dock->setFeatures(QDockWidget::DockWidgetMovable |
257 QDockWidget::DockWidgetFloatable);
259 if (type == view::TraceView) {
260 connect(&session, SIGNAL(trigger_event(util::Timestamp)), v.get(),
261 SLOT(trigger_event(util::Timestamp)));
262 connect(v.get(), SIGNAL(sticky_scrolling_changed(bool)), this,
263 SLOT(sticky_scrolling_changed(bool)));
264 connect(v.get(), SIGNAL(always_zoom_to_fit_changed(bool)), this,
265 SLOT(always_zoom_to_fit_changed(bool)));
267 v->enable_sticky_scrolling(action_view_sticky_scrolling_->isChecked());
268 v->enable_coloured_bg(action_view_coloured_bg_->isChecked());
269 action_view_show_cursors_->setChecked(v->cursors_shown());
272 session.register_view(v);
278 void MainWindow::run_stop()
280 switch (session_.get_capture_state()) {
281 case Session::Stopped:
282 session_.start_capture([&](QString message) {
283 session_error("Capture failed", message); });
285 case Session::AwaitingTrigger:
286 case Session::Running:
287 session_.stop_capture();
292 void MainWindow::select_device(shared_ptr<devices::Device> device)
296 session_.set_device(device);
298 session_.set_default_device();
299 } catch (const QString &e) {
300 QMessageBox msg(this);
302 msg.setInformativeText(tr("Failed to Select Device"));
303 msg.setStandardButtons(QMessageBox::Ok);
304 msg.setIcon(QMessageBox::Warning);
309 void MainWindow::export_file(shared_ptr<OutputFormat> format,
312 using pv::dialogs::StoreProgress;
314 // Make sure there's a view selected to pull the data from
315 shared_ptr<pv::view::View> view = get_active_view();
317 show_session_error(tr("No View Selected"), tr("Please click on the " \
318 "view whose data you want to save and try again."));
322 // Stop any currently running capture session
323 session_.stop_capture();
326 const QString dir = settings.value(SettingSaveDirectory).toString();
328 std::pair<uint64_t, uint64_t> sample_range;
330 // Selection only? Verify that the cursors are active and fetch their values
331 if (selection_only) {
332 if (!view->cursors()->enabled()) {
333 show_session_error(tr("Missing Cursors"), tr("You need to set the " \
334 "cursors before you can save the data enclosed by them " \
335 "to a session file (e.g. using ALT-V - Show Cursors)."));
339 const double samplerate = session_.get_samplerate();
341 const pv::util::Timestamp& start_time = view->cursors()->first()->time();
342 const pv::util::Timestamp& end_time = view->cursors()->second()->time();
344 const uint64_t start_sample =
345 std::max((double)0, start_time.convert_to<double>() * samplerate);
346 const uint64_t end_sample = end_time.convert_to<double>() * samplerate;
348 sample_range = std::make_pair(start_sample, end_sample);
350 sample_range = std::make_pair(0, 0);
353 // Construct the filter
354 const vector<string> exts = format->extensions();
355 QString filter = tr("%1 files ").arg(
356 QString::fromStdString(format->description()));
361 filter += QString("(*.%1);;%2 (*.*)").arg(
362 QString::fromStdString(join(exts, ", *.")),
365 // Show the file dialog
366 const QString file_name = QFileDialog::getSaveFileName(
367 this, tr("Save File"), dir, filter);
369 if (file_name.isEmpty())
372 const QString abs_path = QFileInfo(file_name).absolutePath();
373 settings.setValue(SettingSaveDirectory, abs_path);
375 // Show the options dialog
376 map<string, Glib::VariantBase> options;
377 if (!format->options().empty()) {
378 dialogs::InputOutputOptions dlg(
379 tr("Export %1").arg(QString::fromStdString(
380 format->description())),
381 format->options(), this);
384 options = dlg.options();
387 StoreProgress *dlg = new StoreProgress(file_name, format, options,
388 sample_range, session_, this);
392 void MainWindow::import_file(shared_ptr<InputFormat> format)
397 const QString dir = settings.value(SettingOpenDirectory).toString();
399 // Construct the filter
400 const vector<string> exts = format->extensions();
401 const QString filter = exts.empty() ? "" :
402 tr("%1 files (*.%2)").arg(
403 QString::fromStdString(format->description()),
404 QString::fromStdString(join(exts, ", *.")));
406 // Show the file dialog
407 const QString file_name = QFileDialog::getOpenFileName(
408 this, tr("Import File"), dir, tr(
409 "%1 files (*.*);;All Files (*.*)").arg(
410 QString::fromStdString(format->description())));
412 if (file_name.isEmpty())
415 // Show the options dialog
416 map<string, Glib::VariantBase> options;
417 if (!format->options().empty()) {
418 dialogs::InputOutputOptions dlg(
419 tr("Import %1").arg(QString::fromStdString(
420 format->description())),
421 format->options(), this);
424 options = dlg.options();
427 load_file(file_name, format, options);
429 const QString abs_path = QFileInfo(file_name).absolutePath();
430 settings.setValue(SettingOpenDirectory, abs_path);
433 void MainWindow::setup_ui()
435 setObjectName(QString::fromUtf8("MainWindow"));
437 // Set the window icon
439 icon.addFile(QString(":/icons/sigrok-logo-notext.png"));
442 // Setup the menu bar
443 pv::widgets::HidingMenuBar *const menu_bar =
444 new pv::widgets::HidingMenuBar(this);
447 QMenu *const menu_file = new QMenu;
448 menu_file->setTitle(tr("&File"));
450 action_open_->setText(tr("&Open..."));
451 action_open_->setIcon(QIcon::fromTheme("document-open",
452 QIcon(":/icons/document-open.png")));
453 action_open_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O));
454 action_open_->setObjectName(QString::fromUtf8("actionOpen"));
455 menu_file->addAction(action_open_);
457 action_save_as_->setText(tr("&Save As..."));
458 action_save_as_->setIcon(QIcon::fromTheme("document-save-as",
459 QIcon(":/icons/document-save-as.png")));
460 action_save_as_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
461 action_save_as_->setObjectName(QString::fromUtf8("actionSaveAs"));
462 menu_file->addAction(action_save_as_);
464 action_save_selection_as_->setText(tr("Save Selected &Range As..."));
465 action_save_selection_as_->setIcon(QIcon::fromTheme("document-save-as",
466 QIcon(":/icons/document-save-as.png")));
467 action_save_selection_as_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));
468 action_save_selection_as_->setObjectName(QString::fromUtf8("actionSaveSelectionAs"));
469 menu_file->addAction(action_save_selection_as_);
471 menu_file->addSeparator();
473 widgets::ExportMenu *menu_file_export = new widgets::ExportMenu(this,
474 device_manager_.context());
475 menu_file_export->setTitle(tr("&Export"));
476 connect(menu_file_export,
477 SIGNAL(format_selected(std::shared_ptr<sigrok::OutputFormat>)),
478 this, SLOT(export_file(std::shared_ptr<sigrok::OutputFormat>)));
479 menu_file->addAction(menu_file_export->menuAction());
481 widgets::ImportMenu *menu_file_import = new widgets::ImportMenu(this,
482 device_manager_.context());
483 menu_file_import->setTitle(tr("&Import"));
484 connect(menu_file_import,
485 SIGNAL(format_selected(std::shared_ptr<sigrok::InputFormat>)),
486 this, SLOT(import_file(std::shared_ptr<sigrok::InputFormat>)));
487 menu_file->addAction(menu_file_import->menuAction());
489 menu_file->addSeparator();
491 action_connect_->setText(tr("&Connect to Device..."));
492 action_connect_->setObjectName(QString::fromUtf8("actionConnect"));
493 menu_file->addAction(action_connect_);
495 menu_file->addSeparator();
497 action_quit_->setText(tr("&Quit"));
498 action_quit_->setIcon(QIcon::fromTheme("application-exit",
499 QIcon(":/icons/application-exit.png")));
500 action_quit_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
501 action_quit_->setObjectName(QString::fromUtf8("actionQuit"));
502 menu_file->addAction(action_quit_);
505 QMenu *menu_view = new QMenu;
506 menu_view->setTitle(tr("&View"));
508 action_view_zoom_in_->setText(tr("Zoom &In"));
509 action_view_zoom_in_->setIcon(QIcon::fromTheme("zoom-in",
510 QIcon(":/icons/zoom-in.png")));
511 // simply using Qt::Key_Plus shows no + in the menu
512 action_view_zoom_in_->setShortcut(QKeySequence::ZoomIn);
513 action_view_zoom_in_->setObjectName(
514 QString::fromUtf8("actionViewZoomIn"));
515 menu_view->addAction(action_view_zoom_in_);
517 action_view_zoom_out_->setText(tr("Zoom &Out"));
518 action_view_zoom_out_->setIcon(QIcon::fromTheme("zoom-out",
519 QIcon(":/icons/zoom-out.png")));
520 action_view_zoom_out_->setShortcut(QKeySequence::ZoomOut);
521 action_view_zoom_out_->setObjectName(
522 QString::fromUtf8("actionViewZoomOut"));
523 menu_view->addAction(action_view_zoom_out_);
525 action_view_zoom_fit_->setCheckable(true);
526 action_view_zoom_fit_->setText(tr("Zoom to &Fit"));
527 action_view_zoom_fit_->setIcon(QIcon::fromTheme("zoom-fit",
528 QIcon(":/icons/zoom-fit.png")));
529 action_view_zoom_fit_->setShortcut(QKeySequence(Qt::Key_F));
530 action_view_zoom_fit_->setObjectName(
531 QString::fromUtf8("actionViewZoomFit"));
532 menu_view->addAction(action_view_zoom_fit_);
534 action_view_zoom_one_to_one_->setText(tr("Zoom to O&ne-to-One"));
535 action_view_zoom_one_to_one_->setIcon(QIcon::fromTheme("zoom-original",
536 QIcon(":/icons/zoom-original.png")));
537 action_view_zoom_one_to_one_->setShortcut(QKeySequence(Qt::Key_O));
538 action_view_zoom_one_to_one_->setObjectName(
539 QString::fromUtf8("actionViewZoomOneToOne"));
540 menu_view->addAction(action_view_zoom_one_to_one_);
542 menu_view->addSeparator();
544 action_view_sticky_scrolling_->setCheckable(true);
545 action_view_sticky_scrolling_->setChecked(true);
546 action_view_sticky_scrolling_->setShortcut(QKeySequence(Qt::Key_S));
547 action_view_sticky_scrolling_->setObjectName(
548 QString::fromUtf8("actionViewStickyScrolling"));
549 action_view_sticky_scrolling_->setText(tr("&Sticky Scrolling"));
550 menu_view->addAction(action_view_sticky_scrolling_);
552 menu_view->addSeparator();
554 action_view_coloured_bg_->setCheckable(true);
555 action_view_coloured_bg_->setChecked(true);
556 action_view_coloured_bg_->setShortcut(QKeySequence(Qt::Key_B));
557 action_view_coloured_bg_->setObjectName(
558 QString::fromUtf8("actionViewColouredBg"));
559 action_view_coloured_bg_->setText(tr("Use &coloured backgrounds"));
560 menu_view->addAction(action_view_coloured_bg_);
562 menu_view->addSeparator();
564 action_view_show_cursors_->setCheckable(true);
565 action_view_show_cursors_->setIcon(QIcon::fromTheme("show-cursors",
566 QIcon(":/icons/show-cursors.svg")));
567 action_view_show_cursors_->setShortcut(QKeySequence(Qt::Key_C));
568 action_view_show_cursors_->setObjectName(
569 QString::fromUtf8("actionViewShowCursors"));
570 action_view_show_cursors_->setText(tr("Show &Cursors"));
571 menu_view->addAction(action_view_show_cursors_);
575 QMenu *const menu_decoders = new QMenu;
576 menu_decoders->setTitle(tr("&Decoders"));
578 menu_decoders_add_->setTitle(tr("&Add"));
579 connect(menu_decoders_add_, SIGNAL(decoder_selected(srd_decoder*)),
580 this, SLOT(add_decoder(srd_decoder*)));
582 menu_decoders->addMenu(menu_decoders_add_);
586 QMenu *const menu_help = new QMenu;
587 menu_help->setTitle(tr("&Help"));
589 action_about_->setObjectName(QString::fromUtf8("actionAbout"));
590 action_about_->setText(tr("&About..."));
591 menu_help->addAction(action_about_);
593 menu_bar->addAction(menu_file->menuAction());
594 menu_bar->addAction(menu_view->menuAction());
596 menu_bar->addAction(menu_decoders->menuAction());
598 menu_bar->addAction(menu_help->menuAction());
600 setMenuBar(menu_bar);
601 QMetaObject::connectSlotsByName(this);
603 // Also add all actions to the main window for always-enabled hotkeys
604 for (QAction* action : menu_bar->actions())
605 this->addAction(action);
608 main_bar_ = new toolbars::MainBar(session_, *this);
610 // Set up the initial view
611 add_view(tr("Untitled"), pv::view::TraceView, session_);
613 // Populate the device list and select the initially selected device
614 update_device_list();
616 addToolBar(main_bar_);
619 setWindowTitle(tr("PulseView"));
621 // Setup session_ events
622 connect(&session_, SIGNAL(capture_state_changed(int)), this,
623 SLOT(capture_state_changed(int)));
624 connect(&session_, SIGNAL(device_selected()), this,
625 SLOT(device_selected()));
628 void MainWindow::select_init_device()
631 map<string, string> dev_info;
632 list<string> key_list;
633 shared_ptr<devices::HardwareDevice> device;
635 // Re-select last used device if possible but only if it's not demo
636 settings.beginGroup("Device");
637 key_list.push_back("vendor");
638 key_list.push_back("model");
639 key_list.push_back("version");
640 key_list.push_back("serial_num");
641 key_list.push_back("connection_id");
643 for (string key : key_list) {
644 const QString k = QString::fromStdString(key);
645 if (!settings.contains(k))
648 const string value = settings.value(k).toString().toStdString();
650 dev_info.insert(std::make_pair(key, value));
653 if (dev_info.count("model") > 0)
654 if (dev_info.at("model").find("Demo device") == std::string::npos)
655 device = device_manager_.find_device_from_info(dev_info);
657 // When we can't find a device similar to the one we used last
658 // time and there is at least one device aside from demo, use it
660 for (shared_ptr<devices::HardwareDevice> dev : device_manager_.devices()) {
661 dev_info = device_manager_.get_device_info(dev);
663 if (dev_info.count("model") > 0)
664 if (dev_info.at("model").find("Demo device") == std::string::npos) {
671 select_device(device);
672 update_device_list();
677 void MainWindow::load_init_file(const std::string &file_name,
678 const std::string &format)
680 shared_ptr<InputFormat> input_format;
682 if (!format.empty()) {
683 const map<string, shared_ptr<InputFormat> > formats =
684 device_manager_.context()->input_formats();
685 const auto iter = find_if(formats.begin(), formats.end(),
686 [&](const pair<string, shared_ptr<InputFormat> > f) {
687 return f.first == format; });
688 if (iter == formats.end()) {
689 cerr << "Unexpected input format: " << format << endl;
693 input_format = (*iter).second;
696 load_file(QString::fromStdString(file_name), input_format);
700 void MainWindow::save_ui_settings()
704 map<string, string> dev_info;
705 list<string> key_list;
707 settings.beginGroup("MainWindow");
708 settings.setValue("state", saveState());
709 settings.setValue("geometry", saveGeometry());
712 if (session_.device()) {
713 settings.beginGroup("Device");
714 key_list.push_back("vendor");
715 key_list.push_back("model");
716 key_list.push_back("version");
717 key_list.push_back("serial_num");
718 key_list.push_back("connection_id");
720 dev_info = device_manager_.get_device_info(
723 for (string key : key_list) {
724 if (dev_info.count(key))
725 settings.setValue(QString::fromUtf8(key.c_str()),
726 QString::fromUtf8(dev_info.at(key).c_str()));
728 settings.remove(QString::fromUtf8(key.c_str()));
735 void MainWindow::restore_ui_settings()
739 settings.beginGroup("MainWindow");
741 if (settings.contains("geometry")) {
742 restoreGeometry(settings.value("geometry").toByteArray());
743 restoreState(settings.value("state").toByteArray());
750 void MainWindow::session_error(
751 const QString text, const QString info_text)
753 QMetaObject::invokeMethod(this, "show_session_error",
754 Qt::QueuedConnection, Q_ARG(QString, text),
755 Q_ARG(QString, info_text));
758 void MainWindow::update_device_list()
760 main_bar_->update_device_list();
763 void MainWindow::load_file(QString file_name,
764 std::shared_ptr<sigrok::InputFormat> format,
765 const std::map<std::string, Glib::VariantBase> &options)
767 const QString errorMessage(
768 QString("Failed to load file %1").arg(file_name));
772 session_.set_device(shared_ptr<devices::Device>(
773 new devices::InputFile(
774 device_manager_.context(),
775 file_name.toStdString(),
778 session_.set_device(shared_ptr<devices::Device>(
779 new devices::SessionFile(
780 device_manager_.context(),
781 file_name.toStdString())));
783 show_session_error(tr("Failed to load ") + file_name, e.what());
784 session_.set_default_device();
785 update_device_list();
789 update_device_list();
791 session_.start_capture([&, errorMessage](QString infoMessage) {
792 session_error(errorMessage, infoMessage); });
795 void MainWindow::closeEvent(QCloseEvent *event)
801 void MainWindow::keyReleaseEvent(QKeyEvent *event)
803 if (event->key() == Qt::Key_Alt) {
804 menuBar()->setHidden(!menuBar()->isHidden());
805 menuBar()->setFocus();
807 QMainWindow::keyReleaseEvent(event);
810 void MainWindow::show_session_error(
811 const QString text, const QString info_text)
813 QMessageBox msg(this);
815 msg.setInformativeText(info_text);
816 msg.setStandardButtons(QMessageBox::Ok);
817 msg.setIcon(QMessageBox::Warning);
821 void MainWindow::on_actionOpen_triggered()
824 const QString dir = settings.value(SettingOpenDirectory).toString();
827 const QString file_name = QFileDialog::getOpenFileName(
828 this, tr("Open File"), dir, tr(
829 "Sigrok Sessions (*.sr);;"
832 if (!file_name.isEmpty()) {
833 load_file(file_name);
835 const QString abs_path = QFileInfo(file_name).absolutePath();
836 settings.setValue(SettingOpenDirectory, abs_path);
840 void MainWindow::on_actionSaveAs_triggered()
842 export_file(device_manager_.context()->output_formats()["srzip"]);
845 void MainWindow::on_actionSaveSelectionAs_triggered()
847 export_file(device_manager_.context()->output_formats()["srzip"], true);
850 void MainWindow::on_actionConnect_triggered()
852 // Stop any currently running capture session
853 session_.stop_capture();
855 dialogs::Connect dlg(this, device_manager_);
857 // If the user selected a device, select it in the device list. Select the
858 // current device otherwise.
860 select_device(dlg.get_selected_device());
862 update_device_list();
865 void MainWindow::on_actionQuit_triggered()
870 void MainWindow::on_actionViewZoomIn_triggered()
872 shared_ptr<pv::view::View> view = get_active_view();
877 void MainWindow::on_actionViewZoomOut_triggered()
879 shared_ptr<pv::view::View> view = get_active_view();
884 void MainWindow::on_actionViewZoomFit_triggered()
886 shared_ptr<pv::view::View> view = get_active_view();
888 view->zoom_fit(action_view_zoom_fit_->isChecked());
891 void MainWindow::on_actionViewZoomOneToOne_triggered()
893 shared_ptr<pv::view::View> view = get_active_view();
895 view->zoom_one_to_one();
898 void MainWindow::on_actionViewStickyScrolling_triggered()
900 shared_ptr<pv::view::View> view = get_active_view();
902 view->enable_sticky_scrolling(action_view_sticky_scrolling_->isChecked());
905 void MainWindow::on_actionViewColouredBg_triggered()
907 shared_ptr<pv::view::View> view = get_active_view();
909 view->enable_coloured_bg(action_view_coloured_bg_->isChecked());
912 void MainWindow::on_actionViewShowCursors_triggered()
914 shared_ptr<pv::view::View> view = get_active_view();
918 const bool show = !view->cursors_shown();
920 view->centre_cursors();
922 view->show_cursors(show);
925 void MainWindow::on_actionAbout_triggered()
927 dialogs::About dlg(device_manager_.context(), this);
931 void MainWindow::sticky_scrolling_changed(bool state)
933 action_view_sticky_scrolling_->setChecked(state);
936 void MainWindow::always_zoom_to_fit_changed(bool state)
938 action_view_zoom_fit_->setChecked(state);
941 void MainWindow::add_decoder(srd_decoder *decoder)
945 session_.add_decoder(decoder);
951 void MainWindow::capture_state_changed(int state)
953 main_bar_->set_capture_state((pv::Session::capture_state)state);
956 void MainWindow::device_selected()
958 // Set the title to include the device/file name
959 const shared_ptr<devices::Device> device = session_.device();
962 main_bar_->reset_device_selector();
966 const string display_name = device->display_name(device_manager_);
967 setWindowTitle(tr("%1 - PulseView").arg(display_name.c_str()));