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, see <http://www.gnu.org/licenses/>.
21 #include <libsigrokdecode/libsigrokdecode.h>
31 #include <QApplication>
32 #include <QCloseEvent>
33 #include <QDockWidget>
34 #include <QHBoxLayout>
35 #include <QMessageBox>
40 #include "mainwindow.hpp"
42 #include "devicemanager.hpp"
43 #include "devices/hardwaredevice.hpp"
44 #include "dialogs/settings.hpp"
45 #include "globalsettings.hpp"
46 #include "toolbars/mainbar.hpp"
48 #include "views/trace/view.hpp"
49 #include "views/trace/standardbar.hpp"
51 #include <libsigrokcxx/libsigrokcxx.hpp>
53 using std::dynamic_pointer_cast;
54 using std::make_shared;
55 using std::shared_ptr;
64 using toolbars::MainBar;
66 const QString MainWindow::WindowTitle = tr("PulseView");
68 MainWindow::MainWindow(DeviceManager &device_manager, QWidget *parent) :
70 device_manager_(device_manager),
71 session_selector_(this),
72 session_state_mapper_(this),
73 icon_red_(":/icons/status-red.svg"),
74 icon_green_(":/icons/status-green.svg"),
75 icon_grey_(":/icons/status-grey.svg")
77 qRegisterMetaType<util::Timestamp>("util::Timestamp");
78 qRegisterMetaType<uint64_t>("uint64_t");
80 GlobalSettings::add_change_handler(this);
83 restore_ui_settings();
86 MainWindow::~MainWindow()
88 GlobalSettings::remove_change_handler(this);
90 while (!sessions_.empty())
91 remove_session(sessions_.front());
94 shared_ptr<views::ViewBase> MainWindow::get_active_view() const
96 // If there's only one view, use it...
97 if (view_docks_.size() == 1)
98 return view_docks_.begin()->second;
100 // ...otherwise find the dock widget the widget with focus is contained in
101 QObject *w = QApplication::focusWidget();
102 QDockWidget *dock = nullptr;
105 dock = qobject_cast<QDockWidget*>(w);
111 // Get the view contained in the dock widget
112 for (auto entry : view_docks_)
113 if (entry.first == dock)
119 shared_ptr<views::ViewBase> MainWindow::add_view(const QString &title,
120 views::ViewType type, Session &session)
122 GlobalSettings settings;
123 shared_ptr<views::ViewBase> v;
125 QMainWindow *main_window = nullptr;
126 for (auto entry : session_windows_)
127 if (entry.first.get() == &session)
128 main_window = entry.second;
132 shared_ptr<MainBar> main_bar = session.main_bar();
134 QDockWidget* dock = new QDockWidget(title, main_window);
135 dock->setObjectName(title);
136 main_window->addDockWidget(Qt::TopDockWidgetArea, dock);
138 // Insert a QMainWindow into the dock widget to allow for a tool bar
139 QMainWindow *dock_main = new QMainWindow(dock);
140 dock_main->setWindowFlags(Qt::Widget); // Remove Qt::Window flag
142 if (type == views::ViewTypeTrace)
143 // This view will be the main view if there's no main bar yet
144 v = make_shared<views::trace::View>(session,
145 (main_bar ? false : true), dock_main);
150 view_docks_[dock] = v;
151 session.register_view(v);
153 dock_main->setCentralWidget(v.get());
154 dock->setWidget(dock_main);
156 dock->setContextMenuPolicy(Qt::PreventContextMenu);
157 dock->setFeatures(QDockWidget::DockWidgetMovable |
158 QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetClosable);
160 QAbstractButton *close_btn =
161 dock->findChildren<QAbstractButton*>
162 ("qt_dockwidget_closebutton").front();
164 connect(close_btn, SIGNAL(clicked(bool)),
165 this, SLOT(on_view_close_clicked()));
167 connect(&session, SIGNAL(trigger_event(int, util::Timestamp)),
168 qobject_cast<views::ViewBase*>(v.get()),
169 SLOT(trigger_event(int, util::Timestamp)));
171 if (type == views::ViewTypeTrace) {
172 views::trace::View *tv =
173 qobject_cast<views::trace::View*>(v.get());
175 tv->enable_coloured_bg(settings.value(GlobalSettings::Key_View_ColouredBG).toBool());
176 tv->enable_show_sampling_points(settings.value(GlobalSettings::Key_View_ShowSamplingPoints).toBool());
177 tv->enable_show_analog_minor_grid(settings.value(GlobalSettings::Key_View_ShowAnalogMinorGrid).toBool());
180 /* Initial view, create the main bar */
181 main_bar = make_shared<MainBar>(session, this, tv);
182 dock_main->addToolBar(main_bar.get());
183 session.set_main_bar(main_bar);
185 connect(main_bar.get(), SIGNAL(new_view(Session*)),
186 this, SLOT(on_new_view(Session*)));
188 main_bar->action_view_show_cursors()->setChecked(tv->cursors_shown());
190 /* For the main view we need to prevent the dock widget from
191 * closing itself when its close button is clicked. This is
192 * so we can confirm with the user first. Regular views don't
194 close_btn->disconnect(SIGNAL(clicked()), dock, SLOT(close()));
196 /* Additional view, create a standard bar */
197 pv::views::trace::StandardBar *standard_bar =
198 new pv::views::trace::StandardBar(session, this, tv);
199 dock_main->addToolBar(standard_bar);
201 standard_bar->action_view_show_cursors()->setChecked(tv->cursors_shown());
208 void MainWindow::remove_view(shared_ptr<views::ViewBase> view)
210 for (shared_ptr<Session> session : sessions_) {
211 if (!session->has_view(view))
214 // Find the dock the view is contained in and remove it
215 for (auto entry : view_docks_)
216 if (entry.second == view) {
217 // Remove the view from the session
218 session->deregister_view(view);
220 // Remove the view from its parent; otherwise, Qt will
221 // call deleteLater() on it, which causes a double free
222 // since the shared_ptr in view_docks_ doesn't know
223 // that Qt keeps a pointer to the view around
224 view->setParent(nullptr);
226 // Delete the view's dock widget and all widgets inside it
227 entry.first->deleteLater();
229 // Remove the dock widget from the list and stop iterating
230 view_docks_.erase(entry.first);
236 shared_ptr<Session> MainWindow::add_session()
238 static int last_session_id = 1;
239 QString name = tr("Session %1").arg(last_session_id++);
241 shared_ptr<Session> session = make_shared<Session>(device_manager_, name);
243 connect(session.get(), SIGNAL(add_view(const QString&, views::ViewType, Session*)),
244 this, SLOT(on_add_view(const QString&, views::ViewType, Session*)));
245 connect(session.get(), SIGNAL(name_changed()),
246 this, SLOT(on_session_name_changed()));
247 session_state_mapper_.setMapping(session.get(), session.get());
248 connect(session.get(), SIGNAL(capture_state_changed(int)),
249 &session_state_mapper_, SLOT(map()));
251 sessions_.push_back(session);
253 QMainWindow *window = new QMainWindow();
254 window->setWindowFlags(Qt::Widget); // Remove Qt::Window flag
255 session_windows_[session] = window;
257 int index = session_selector_.addTab(window, name);
258 session_selector_.setCurrentIndex(index);
259 last_focused_session_ = session;
261 window->setDockNestingEnabled(true);
263 shared_ptr<views::ViewBase> main_view =
264 add_view(name, views::ViewTypeTrace, *session);
269 void MainWindow::remove_session(shared_ptr<Session> session)
271 // Determine the height of the button before it collapses
272 int h = new_session_button_->height();
274 // Stop capture while the session still exists so that the UI can be
275 // updated in case we're currently running. If so, this will schedule a
276 // call to our on_capture_state_changed() slot for the next run of the
277 // event loop. We need to have this executed immediately or else it will
278 // be dismissed since the session object will be deleted by the time we
279 // leave this method and the event loop gets a chance to run again.
280 session->stop_capture();
281 QApplication::processEvents();
283 for (shared_ptr<views::ViewBase> view : session->views())
286 QMainWindow *window = session_windows_.at(session);
287 session_selector_.removeTab(session_selector_.indexOf(window));
289 session_windows_.erase(session);
291 if (last_focused_session_ == session)
292 last_focused_session_.reset();
294 // Remove the session from our list of sessions (which also destroys it)
295 sessions_.remove_if([&](shared_ptr<Session> s) {
296 return s == session; });
298 if (sessions_.empty()) {
299 // When there are no more tabs, the height of the QTabWidget
300 // drops to zero. We must prevent this to keep the static
302 for (QWidget *w : static_tab_widget_->findChildren<QWidget*>())
303 w->setMinimumHeight(h);
305 int margin = static_tab_widget_->layout()->contentsMargins().bottom();
306 static_tab_widget_->setMinimumHeight(h + 2 * margin);
307 session_selector_.setMinimumHeight(h + 2 * margin);
309 // Update the window title if there is no view left to
310 // generate focus change events
311 setWindowTitle(WindowTitle);
315 void MainWindow::add_session_with_file(string open_file_name,
316 string open_file_format)
318 shared_ptr<Session> session = add_session();
319 session->load_init_file(open_file_name, open_file_format);
322 void MainWindow::add_default_session()
324 // Only add the default session if there would be no session otherwise
325 if (sessions_.size() > 0)
328 shared_ptr<Session> session = add_session();
330 // Check the list of available devices. Prefer the one that was
331 // found with user supplied scan specs (if applicable). Then try
332 // one of the auto detected devices that are not the demo device.
333 // Pick demo in the absence of "genuine" hardware devices.
334 shared_ptr<devices::HardwareDevice> user_device, other_device, demo_device;
335 for (shared_ptr<devices::HardwareDevice> dev : device_manager_.devices()) {
336 if (dev == device_manager_.user_spec_device()) {
338 } else if (dev->hardware_device()->driver()->name() == "demo") {
345 session->select_device(user_device);
346 else if (other_device)
347 session->select_device(other_device);
349 session->select_device(demo_device);
352 void MainWindow::save_sessions()
357 for (shared_ptr<Session> session : sessions_) {
358 // Ignore sessions using the demo device or no device at all
359 if (session->device()) {
360 shared_ptr<devices::HardwareDevice> device =
361 dynamic_pointer_cast< devices::HardwareDevice >
365 device->hardware_device()->driver()->name() == "demo")
368 settings.beginGroup("Session" + QString::number(id++));
369 settings.remove(""); // Remove all keys in this group
370 session->save_settings(settings);
375 settings.setValue("sessions", id);
378 void MainWindow::restore_sessions()
381 int i, session_count;
383 session_count = settings.value("sessions", 0).toInt();
385 for (i = 0; i < session_count; i++) {
386 settings.beginGroup("Session" + QString::number(i));
387 shared_ptr<Session> session = add_session();
388 session->restore_settings(settings);
393 void MainWindow::on_setting_changed(const QString &key, const QVariant &value)
395 if (key == GlobalSettings::Key_View_ColouredBG)
396 on_settingViewColouredBg_changed(value);
398 if (key == GlobalSettings::Key_View_ShowSamplingPoints)
399 on_settingViewShowSamplingPoints_changed(value);
401 if (key == GlobalSettings::Key_View_ShowAnalogMinorGrid)
402 on_settingViewShowAnalogMinorGrid_changed(value);
405 void MainWindow::setup_ui()
407 setObjectName(QString::fromUtf8("MainWindow"));
409 setCentralWidget(&session_selector_);
411 // Set the window icon
413 icon.addFile(QString(":/icons/pulseview.png"));
416 view_sticky_scrolling_shortcut_ = new QShortcut(QKeySequence(Qt::Key_S), this, SLOT(on_view_sticky_scrolling_shortcut()));
417 view_sticky_scrolling_shortcut_->setAutoRepeat(false);
419 view_show_sampling_points_shortcut_ = new QShortcut(QKeySequence(Qt::Key_Period), this, SLOT(on_view_show_sampling_points_shortcut()));
420 view_show_sampling_points_shortcut_->setAutoRepeat(false);
422 view_show_analog_minor_grid_shortcut_ = new QShortcut(QKeySequence(Qt::Key_G), this, SLOT(on_view_show_analog_minor_grid_shortcut()));
423 view_show_analog_minor_grid_shortcut_->setAutoRepeat(false);
425 view_coloured_bg_shortcut_ = new QShortcut(QKeySequence(Qt::Key_B), this, SLOT(on_view_coloured_bg_shortcut()));
426 view_coloured_bg_shortcut_->setAutoRepeat(false);
428 // Set up the tab area
429 new_session_button_ = new QToolButton();
430 new_session_button_->setIcon(QIcon::fromTheme("document-new",
431 QIcon(":/icons/document-new.png")));
432 new_session_button_->setToolTip(tr("Create New Session"));
433 new_session_button_->setAutoRaise(true);
435 run_stop_button_ = new QToolButton();
436 run_stop_button_->setAutoRaise(true);
437 run_stop_button_->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
438 run_stop_button_->setToolTip(tr("Start/Stop Acquisition"));
440 run_stop_shortcut_ = new QShortcut(QKeySequence(Qt::Key_Space), run_stop_button_, SLOT(click()));
441 run_stop_shortcut_->setAutoRepeat(false);
443 settings_button_ = new QToolButton();
444 settings_button_->setIcon(QIcon::fromTheme("preferences-system",
445 QIcon(":/icons/preferences-system.png")));
446 settings_button_->setToolTip(tr("Settings"));
447 settings_button_->setAutoRaise(true);
449 QFrame *separator1 = new QFrame();
450 separator1->setFrameStyle(QFrame::VLine | QFrame::Raised);
451 QFrame *separator2 = new QFrame();
452 separator2->setFrameStyle(QFrame::VLine | QFrame::Raised);
454 QHBoxLayout* layout = new QHBoxLayout();
455 layout->setContentsMargins(2, 2, 2, 2);
456 layout->addWidget(new_session_button_);
457 layout->addWidget(separator1);
458 layout->addWidget(run_stop_button_);
459 layout->addWidget(separator2);
460 layout->addWidget(settings_button_);
462 static_tab_widget_ = new QWidget();
463 static_tab_widget_->setLayout(layout);
465 session_selector_.setCornerWidget(static_tab_widget_, Qt::TopLeftCorner);
466 session_selector_.setTabsClosable(true);
468 close_application_shortcut_ = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this, SLOT(close()));
469 close_application_shortcut_->setAutoRepeat(false);
471 close_current_tab_shortcut_ = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this, SLOT(on_close_current_tab()));
473 connect(new_session_button_, SIGNAL(clicked(bool)),
474 this, SLOT(on_new_session_clicked()));
475 connect(run_stop_button_, SIGNAL(clicked(bool)),
476 this, SLOT(on_run_stop_clicked()));
477 connect(&session_state_mapper_, SIGNAL(mapped(QObject*)),
478 this, SLOT(on_capture_state_changed(QObject*)));
479 connect(settings_button_, SIGNAL(clicked(bool)),
480 this, SLOT(on_settings_clicked()));
482 connect(&session_selector_, SIGNAL(tabCloseRequested(int)),
483 this, SLOT(on_tab_close_requested(int)));
484 connect(&session_selector_, SIGNAL(currentChanged(int)),
485 this, SLOT(on_tab_changed(int)));
488 connect(static_cast<QApplication *>(QCoreApplication::instance()),
489 SIGNAL(focusChanged(QWidget*, QWidget*)),
490 this, SLOT(on_focus_changed()));
493 void MainWindow::save_ui_settings()
497 settings.beginGroup("MainWindow");
498 settings.setValue("state", saveState());
499 settings.setValue("geometry", saveGeometry());
503 void MainWindow::restore_ui_settings()
507 settings.beginGroup("MainWindow");
509 if (settings.contains("geometry")) {
510 restoreGeometry(settings.value("geometry").toByteArray());
511 restoreState(settings.value("state").toByteArray());
518 shared_ptr<Session> MainWindow::get_tab_session(int index) const
520 // Find the session that belongs to the tab's main window
521 for (auto entry : session_windows_)
522 if (entry.second == session_selector_.widget(index))
528 void MainWindow::closeEvent(QCloseEvent *event)
530 bool data_saved = true;
532 for (auto entry : session_windows_)
533 if (!entry.first->data_saved())
536 if (!data_saved && (QMessageBox::question(this, tr("Confirmation"),
537 tr("There is unsaved data. Close anyway?"),
538 QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)) {
547 QMenu* MainWindow::createPopupMenu()
552 bool MainWindow::restoreState(const QByteArray &state, int version)
557 // Do nothing. We don't want Qt to handle this, or else it
558 // will try to restore all the dock widgets and create havoc.
563 void MainWindow::session_error(const QString text, const QString info_text)
565 QMetaObject::invokeMethod(this, "show_session_error",
566 Qt::QueuedConnection, Q_ARG(QString, text),
567 Q_ARG(QString, info_text));
570 void MainWindow::show_session_error(const QString text, const QString info_text)
572 QMessageBox msg(this);
574 msg.setInformativeText(info_text);
575 msg.setStandardButtons(QMessageBox::Ok);
576 msg.setIcon(QMessageBox::Warning);
580 void MainWindow::on_add_view(const QString &title, views::ViewType type,
583 // We get a pointer and need a reference
584 for (shared_ptr<Session> s : sessions_)
585 if (s.get() == session)
586 add_view(title, type, *s);
589 void MainWindow::on_focus_changed()
591 shared_ptr<views::ViewBase> view = get_active_view();
594 for (shared_ptr<Session> session : sessions_) {
595 if (session->has_view(view)) {
596 if (session != last_focused_session_) {
597 // Activate correct tab if necessary
598 shared_ptr<Session> tab_session = get_tab_session(
599 session_selector_.currentIndex());
600 if (tab_session != session)
601 session_selector_.setCurrentWidget(
602 session_windows_.at(session));
604 on_focused_session_changed(session);
612 if (sessions_.empty())
613 setWindowTitle(WindowTitle);
616 void MainWindow::on_focused_session_changed(shared_ptr<Session> session)
618 last_focused_session_ = session;
620 setWindowTitle(session->name() + " - " + WindowTitle);
622 // Update the state of the run/stop button, too
623 on_capture_state_changed(session.get());
626 void MainWindow::on_new_session_clicked()
631 void MainWindow::on_run_stop_clicked()
633 shared_ptr<Session> session = last_focused_session_;
638 switch (session->get_capture_state()) {
639 case Session::Stopped:
640 session->start_capture([&](QString message) {
641 session_error("Capture failed", message); });
643 case Session::AwaitingTrigger:
644 case Session::Running:
645 session->stop_capture();
650 void MainWindow::on_settings_clicked()
652 dialogs::Settings dlg(device_manager_);
656 void MainWindow::on_session_name_changed()
658 // Update the corresponding dock widget's name(s)
659 Session *session = qobject_cast<Session*>(QObject::sender());
662 for (shared_ptr<views::ViewBase> view : session->views()) {
663 // Get the dock that contains the view
664 for (auto entry : view_docks_)
665 if (entry.second == view) {
666 entry.first->setObjectName(session->name());
667 entry.first->setWindowTitle(session->name());
671 // Update the tab widget by finding the main window and the tab from that
672 for (auto entry : session_windows_)
673 if (entry.first.get() == session) {
674 QMainWindow *window = entry.second;
675 const int index = session_selector_.indexOf(window);
676 session_selector_.setTabText(index, session->name());
679 // Refresh window title if the affected session has focus
680 if (session == last_focused_session_.get())
681 setWindowTitle(session->name() + " - " + WindowTitle);
684 void MainWindow::on_capture_state_changed(QObject *obj)
686 Session *caller = qobject_cast<Session*>(obj);
688 // Ignore if caller is not the currently focused session
689 // unless there is only one session
690 if ((sessions_.size() > 1) && (caller != last_focused_session_.get()))
693 int state = caller->get_capture_state();
695 const QIcon *icons[] = {&icon_grey_, &icon_red_, &icon_green_};
696 run_stop_button_->setIcon(*icons[state]);
697 run_stop_button_->setText((state == pv::Session::Stopped) ?
698 tr("Run") : tr("Stop"));
701 void MainWindow::on_new_view(Session *session)
703 // We get a pointer and need a reference
704 for (shared_ptr<Session> s : sessions_)
705 if (s.get() == session)
706 add_view(session->name(), views::ViewTypeTrace, *s);
709 void MainWindow::on_view_close_clicked()
711 // Find the dock widget that contains the close button that was clicked
712 QObject *w = QObject::sender();
713 QDockWidget *dock = nullptr;
716 dock = qobject_cast<QDockWidget*>(w);
722 // Get the view contained in the dock widget
723 shared_ptr<views::ViewBase> view;
725 for (auto entry : view_docks_)
726 if (entry.first == dock)
729 // Deregister the view
730 for (shared_ptr<Session> session : sessions_) {
731 if (!session->has_view(view))
734 // Also destroy the entire session if its main view is closing...
735 if (view == session->main_view()) {
736 // ...but only if data is saved or the user confirms closing
737 if (session->data_saved() || (QMessageBox::question(this, tr("Confirmation"),
738 tr("This session contains unsaved data. Close it anyway?"),
739 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes))
740 remove_session(session);
743 // All other views can be closed at any time as no data will be lost
748 void MainWindow::on_tab_changed(int index)
750 shared_ptr<Session> session = get_tab_session(index);
753 on_focused_session_changed(session);
756 void MainWindow::on_tab_close_requested(int index)
758 shared_ptr<Session> session = get_tab_session(index);
763 if (session->data_saved() || (QMessageBox::question(this, tr("Confirmation"),
764 tr("This session contains unsaved data. Close it anyway?"),
765 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes))
766 remove_session(session);
769 void MainWindow::on_view_coloured_bg_shortcut()
771 GlobalSettings settings;
773 bool state = settings.value(GlobalSettings::Key_View_ColouredBG).toBool();
774 settings.setValue(GlobalSettings::Key_View_ColouredBG, !state);
777 void MainWindow::on_view_sticky_scrolling_shortcut()
779 GlobalSettings settings;
781 bool state = settings.value(GlobalSettings::Key_View_StickyScrolling).toBool();
782 settings.setValue(GlobalSettings::Key_View_StickyScrolling, !state);
785 void MainWindow::on_view_show_sampling_points_shortcut()
787 GlobalSettings settings;
789 bool state = settings.value(GlobalSettings::Key_View_ShowSamplingPoints).toBool();
790 settings.setValue(GlobalSettings::Key_View_ShowSamplingPoints, !state);
793 void MainWindow::on_view_show_analog_minor_grid_shortcut()
795 GlobalSettings settings;
797 bool state = settings.value(GlobalSettings::Key_View_ShowAnalogMinorGrid).toBool();
798 settings.setValue(GlobalSettings::Key_View_ShowAnalogMinorGrid, !state);
801 void MainWindow::on_settingViewColouredBg_changed(const QVariant new_value)
803 bool state = new_value.toBool();
805 for (auto entry : view_docks_) {
806 shared_ptr<views::ViewBase> viewbase = entry.second;
808 // Only trace views have this setting
809 views::trace::View* view =
810 qobject_cast<views::trace::View*>(viewbase.get());
812 view->enable_coloured_bg(state);
816 void MainWindow::on_settingViewShowSamplingPoints_changed(const QVariant new_value)
818 bool state = new_value.toBool();
820 for (auto entry : view_docks_) {
821 shared_ptr<views::ViewBase> viewbase = entry.second;
823 // Only trace views have this setting
824 views::trace::View* view =
825 qobject_cast<views::trace::View*>(viewbase.get());
827 view->enable_show_sampling_points(state);
831 void MainWindow::on_settingViewShowAnalogMinorGrid_changed(const QVariant new_value)
833 bool state = new_value.toBool();
835 for (auto entry : view_docks_) {
836 shared_ptr<views::ViewBase> viewbase = entry.second;
838 // Only trace views have this setting
839 views::trace::View* view =
840 qobject_cast<views::trace::View*>(viewbase.get());
842 view->enable_show_analog_minor_grid(state);
846 void MainWindow::on_close_current_tab()
848 int tab = session_selector_.currentIndex();
850 on_tab_close_requested(tab);