]> sigrok.org Git - pulseview.git/blame_incremental - pv/mainwindow.cpp
Settings: Change view settings shortcuts
[pulseview.git] / pv / mainwindow.cpp
... / ...
CommitLineData
1/*
2 * This file is part of the PulseView project.
3 *
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
5 *
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.
10 *
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.
15 *
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/>.
18 */
19
20#ifdef ENABLE_DECODE
21#include <libsigrokdecode/libsigrokdecode.h>
22#endif
23
24#include <cassert>
25#include <algorithm>
26#include <iterator>
27#include <cstdint>
28#include <cstdarg>
29
30#include <QAction>
31#include <QApplication>
32#include <QCloseEvent>
33#include <QDockWidget>
34#include <QHBoxLayout>
35#include <QMessageBox>
36#include <QSettings>
37#include <QWidget>
38#include <QShortcut>
39
40#include "mainwindow.hpp"
41
42#include "devicemanager.hpp"
43#include "globalsettings.hpp"
44#include "util.hpp"
45#include "devices/hardwaredevice.hpp"
46#include "dialogs/settings.hpp"
47#include "toolbars/mainbar.hpp"
48#include "view/view.hpp"
49#include "views/trace/standardbar.hpp"
50
51#include <libsigrokcxx/libsigrokcxx.hpp>
52
53using std::dynamic_pointer_cast;
54using std::list;
55using std::make_shared;
56using std::map;
57using std::shared_ptr;
58using std::string;
59
60namespace pv {
61
62namespace view {
63class ViewItem;
64}
65
66using toolbars::MainBar;
67
68using std::bind;
69using std::placeholders::_1;
70
71const QString MainWindow::WindowTitle = tr("PulseView");
72
73MainWindow::MainWindow(DeviceManager &device_manager,
74 string open_file_name, string open_file_format,
75 QWidget *parent) :
76 QMainWindow(parent),
77 device_manager_(device_manager),
78 session_selector_(this),
79 session_state_mapper_(this),
80 icon_red_(":/icons/status-red.svg"),
81 icon_green_(":/icons/status-green.svg"),
82 icon_grey_(":/icons/status-grey.svg")
83{
84 qRegisterMetaType<util::Timestamp>("util::Timestamp");
85 qRegisterMetaType<uint64_t>("uint64_t");
86
87 GlobalSettings::register_change_handler(GlobalSettings::Key_View_ColouredBG,
88 bind(&MainWindow::on_settingViewColouredBg_changed, this, _1));
89
90 setup_ui();
91 restore_ui_settings();
92
93 if (!open_file_name.empty()) {
94 shared_ptr<Session> session = add_session();
95 session->load_init_file(open_file_name, open_file_format);
96 }
97
98 // Add empty default session if there aren't any sessions
99 if (sessions_.size() == 0) {
100 shared_ptr<Session> session = add_session();
101
102 map<string, string> dev_info;
103 shared_ptr<devices::HardwareDevice> other_device, demo_device;
104
105 // Use any available device that's not demo
106 for (shared_ptr<devices::HardwareDevice> dev : device_manager_.devices()) {
107 if (dev->hardware_device()->driver()->name() == "demo") {
108 demo_device = dev;
109 } else {
110 other_device = dev;
111 }
112 }
113
114 // ...and if there isn't any, just use demo then
115 session->select_device(other_device ? other_device : demo_device);
116 }
117}
118
119MainWindow::~MainWindow()
120{
121 while (!sessions_.empty())
122 remove_session(sessions_.front());
123}
124
125shared_ptr<views::ViewBase> MainWindow::get_active_view() const
126{
127 // If there's only one view, use it...
128 if (view_docks_.size() == 1)
129 return view_docks_.begin()->second;
130
131 // ...otherwise find the dock widget the widget with focus is contained in
132 QObject *w = QApplication::focusWidget();
133 QDockWidget *dock = nullptr;
134
135 while (w) {
136 dock = qobject_cast<QDockWidget*>(w);
137 if (dock)
138 break;
139 w = w->parent();
140 }
141
142 // Get the view contained in the dock widget
143 for (auto entry : view_docks_)
144 if (entry.first == dock)
145 return entry.second;
146
147 return nullptr;
148}
149
150shared_ptr<views::ViewBase> MainWindow::add_view(const QString &title,
151 views::ViewType type, Session &session)
152{
153 GlobalSettings settings;
154 shared_ptr<views::ViewBase> v;
155
156 QMainWindow *main_window = nullptr;
157 for (auto entry : session_windows_)
158 if (entry.first.get() == &session)
159 main_window = entry.second;
160
161 assert(main_window);
162
163 shared_ptr<MainBar> main_bar = session.main_bar();
164
165 QDockWidget* dock = new QDockWidget(title, main_window);
166 dock->setObjectName(title);
167 main_window->addDockWidget(Qt::TopDockWidgetArea, dock);
168
169 // Insert a QMainWindow into the dock widget to allow for a tool bar
170 QMainWindow *dock_main = new QMainWindow(dock);
171 dock_main->setWindowFlags(Qt::Widget); // Remove Qt::Window flag
172
173 if (type == views::ViewTypeTrace)
174 // This view will be the main view if there's no main bar yet
175 v = make_shared<views::TraceView::View>(session,
176 (main_bar ? false : true), dock_main);
177
178 if (!v)
179 return nullptr;
180
181 view_docks_[dock] = v;
182 session.register_view(v);
183
184 dock_main->setCentralWidget(v.get());
185 dock->setWidget(dock_main);
186
187 dock->setFeatures(QDockWidget::DockWidgetMovable |
188 QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetClosable);
189
190 QAbstractButton *close_btn =
191 dock->findChildren<QAbstractButton*>
192 ("qt_dockwidget_closebutton").front();
193
194 connect(close_btn, SIGNAL(clicked(bool)),
195 this, SLOT(on_view_close_clicked()));
196
197 connect(&session, SIGNAL(trigger_event(util::Timestamp)),
198 qobject_cast<views::ViewBase*>(v.get()),
199 SLOT(trigger_event(util::Timestamp)));
200
201 if (type == views::ViewTypeTrace) {
202 views::TraceView::View *tv =
203 qobject_cast<views::TraceView::View*>(v.get());
204
205 tv->enable_sticky_scrolling(true);
206 tv->enable_coloured_bg(settings.value(GlobalSettings::Key_View_ColouredBG).toBool());
207
208 if (!main_bar) {
209 /* Initial view, create the main bar */
210 main_bar = make_shared<MainBar>(session, this, tv);
211 dock_main->addToolBar(main_bar.get());
212 session.set_main_bar(main_bar);
213
214 connect(main_bar.get(), SIGNAL(new_view(Session*)),
215 this, SLOT(on_new_view(Session*)));
216
217 main_bar->action_view_show_cursors()->setChecked(tv->cursors_shown());
218
219 /* For the main view we need to prevent the dock widget from
220 * closing itself when its close button is clicked. This is
221 * so we can confirm with the user first. Regular views don't
222 * need this */
223 close_btn->disconnect(SIGNAL(clicked()), dock, SLOT(close()));
224 } else {
225 /* Additional view, create a standard bar */
226 pv::views::trace::StandardBar *standard_bar =
227 new pv::views::trace::StandardBar(session, this, tv);
228 dock_main->addToolBar(standard_bar);
229
230 standard_bar->action_view_show_cursors()->setChecked(tv->cursors_shown());
231 }
232 }
233
234 return v;
235}
236
237void MainWindow::remove_view(shared_ptr<views::ViewBase> view)
238{
239 for (shared_ptr<Session> session : sessions_) {
240 if (!session->has_view(view))
241 continue;
242
243 // Find the dock the view is contained in and remove it
244 for (auto entry : view_docks_)
245 if (entry.second == view) {
246 // Remove the view from the session
247 session->deregister_view(view);
248
249 // Remove the view from its parent; otherwise, Qt will
250 // call deleteLater() on it, which causes a double free
251 // since the shared_ptr in view_docks_ doesn't know
252 // that Qt keeps a pointer to the view around
253 view->setParent(nullptr);
254
255 // Delete the view's dock widget and all widgets inside it
256 entry.first->deleteLater();
257
258 // Remove the dock widget from the list and stop iterating
259 view_docks_.erase(entry.first);
260 break;
261 }
262 }
263}
264
265shared_ptr<Session> MainWindow::add_session()
266{
267 static int last_session_id = 1;
268 QString name = tr("Session %1").arg(last_session_id++);
269
270 shared_ptr<Session> session = make_shared<Session>(device_manager_, name);
271
272 connect(session.get(), SIGNAL(add_view(const QString&, views::ViewType, Session*)),
273 this, SLOT(on_add_view(const QString&, views::ViewType, Session*)));
274 connect(session.get(), SIGNAL(name_changed()),
275 this, SLOT(on_session_name_changed()));
276 session_state_mapper_.setMapping(session.get(), session.get());
277 connect(session.get(), SIGNAL(capture_state_changed(int)),
278 &session_state_mapper_, SLOT(map()));
279
280 sessions_.push_back(session);
281
282 QMainWindow *window = new QMainWindow();
283 window->setWindowFlags(Qt::Widget); // Remove Qt::Window flag
284 session_windows_[session] = window;
285
286 int index = session_selector_.addTab(window, name);
287 session_selector_.setCurrentIndex(index);
288 last_focused_session_ = session;
289
290 window->setDockNestingEnabled(true);
291
292 shared_ptr<views::ViewBase> main_view =
293 add_view(name, views::ViewTypeTrace, *session);
294
295 return session;
296}
297
298void MainWindow::remove_session(shared_ptr<Session> session)
299{
300 int h = new_session_button_->height();
301
302 for (shared_ptr<views::ViewBase> view : session->views())
303 remove_view(view);
304
305 QMainWindow *window = session_windows_.at(session);
306 session_selector_.removeTab(session_selector_.indexOf(window));
307
308 session_windows_.erase(session);
309
310 if (last_focused_session_ == session)
311 last_focused_session_.reset();
312
313 sessions_.remove_if([&](shared_ptr<Session> s) {
314 return s == session; });
315
316 if (sessions_.empty()) {
317 // When there are no more tabs, the height of the QTabWidget
318 // drops to zero. We must prevent this to keep the static
319 // widgets visible
320 for (QWidget *w : static_tab_widget_->findChildren<QWidget*>())
321 w->setMinimumHeight(h);
322
323 int margin = static_tab_widget_->layout()->contentsMargins().bottom();
324 static_tab_widget_->setMinimumHeight(h + 2 * margin);
325 session_selector_.setMinimumHeight(h + 2 * margin);
326
327 // Update the window title if there is no view left to
328 // generate focus change events
329 setWindowTitle(WindowTitle);
330 }
331}
332
333void MainWindow::setup_ui()
334{
335 setObjectName(QString::fromUtf8("MainWindow"));
336
337 setCentralWidget(&session_selector_);
338
339 // Set the window icon
340 QIcon icon;
341 icon.addFile(QString(":/icons/sigrok-logo-notext.png"));
342 setWindowIcon(icon);
343
344 view_sticky_scrolling_shortcut_ = new QShortcut(QKeySequence(Qt::Key_S), this, SLOT(on_view_sticky_scrolling_shortcut()));
345 view_sticky_scrolling_shortcut_->setAutoRepeat(false);
346
347 view_coloured_bg_shortcut_ = new QShortcut(QKeySequence(Qt::Key_B), this, SLOT(on_view_coloured_bg_shortcut()));
348 view_coloured_bg_shortcut_->setAutoRepeat(false);
349
350 // Set up the tab area
351 new_session_button_ = new QToolButton();
352 new_session_button_->setIcon(QIcon::fromTheme("document-new",
353 QIcon(":/icons/document-new.png")));
354 new_session_button_->setToolTip(tr("Create New Session"));
355 new_session_button_->setAutoRaise(true);
356
357 run_stop_button_ = new QToolButton();
358 run_stop_button_->setAutoRaise(true);
359 run_stop_button_->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
360 run_stop_button_->setToolTip(tr("Start/Stop Acquisition"));
361
362 run_stop_shortcut_ = new QShortcut(QKeySequence(Qt::Key_Space), run_stop_button_, SLOT(click()));
363 run_stop_shortcut_->setAutoRepeat(false);
364
365 settings_button_ = new QToolButton();
366 settings_button_->setIcon(QIcon::fromTheme("configure",
367 QIcon(":/icons/configure.png")));
368 settings_button_->setToolTip(tr("Settings"));
369 settings_button_->setAutoRaise(true);
370
371 QFrame *separator1 = new QFrame();
372 separator1->setFrameStyle(QFrame::VLine | QFrame::Raised);
373 QFrame *separator2 = new QFrame();
374 separator2->setFrameStyle(QFrame::VLine | QFrame::Raised);
375
376 QHBoxLayout* layout = new QHBoxLayout();
377 layout->setContentsMargins(2, 2, 2, 2);
378 layout->addWidget(new_session_button_);
379 layout->addWidget(separator1);
380 layout->addWidget(run_stop_button_);
381 layout->addWidget(separator2);
382 layout->addWidget(settings_button_);
383
384 static_tab_widget_ = new QWidget();
385 static_tab_widget_->setLayout(layout);
386
387 session_selector_.setCornerWidget(static_tab_widget_, Qt::TopLeftCorner);
388 session_selector_.setTabsClosable(true);
389
390 close_application_shortcut_ = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this, SLOT(close()));
391 close_application_shortcut_->setAutoRepeat(false);
392
393 close_current_tab_shortcut_ = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this, SLOT(on_close_current_tab()));
394
395 connect(new_session_button_, SIGNAL(clicked(bool)),
396 this, SLOT(on_new_session_clicked()));
397 connect(run_stop_button_, SIGNAL(clicked(bool)),
398 this, SLOT(on_run_stop_clicked()));
399 connect(&session_state_mapper_, SIGNAL(mapped(QObject*)),
400 this, SLOT(on_capture_state_changed(QObject*)));
401 connect(settings_button_, SIGNAL(clicked(bool)),
402 this, SLOT(on_settings_clicked()));
403
404 connect(&session_selector_, SIGNAL(tabCloseRequested(int)),
405 this, SLOT(on_tab_close_requested(int)));
406 connect(&session_selector_, SIGNAL(currentChanged(int)),
407 this, SLOT(on_tab_changed(int)));
408
409
410 connect(static_cast<QApplication *>(QCoreApplication::instance()),
411 SIGNAL(focusChanged(QWidget*, QWidget*)),
412 this, SLOT(on_focus_changed()));
413}
414
415void MainWindow::save_ui_settings()
416{
417 QSettings settings;
418 int id = 0;
419
420 settings.beginGroup("MainWindow");
421 settings.setValue("state", saveState());
422 settings.setValue("geometry", saveGeometry());
423 settings.endGroup();
424
425 for (shared_ptr<Session> session : sessions_) {
426 // Ignore sessions using the demo device or no device at all
427 if (session->device()) {
428 shared_ptr<devices::HardwareDevice> device =
429 dynamic_pointer_cast< devices::HardwareDevice >
430 (session->device());
431
432 if (device &&
433 device->hardware_device()->driver()->name() == "demo")
434 continue;
435
436 settings.beginGroup("Session" + QString::number(id++));
437 settings.remove(""); // Remove all keys in this group
438 session->save_settings(settings);
439 settings.endGroup();
440 }
441 }
442
443 settings.setValue("sessions", id);
444}
445
446void MainWindow::restore_ui_settings()
447{
448 QSettings settings;
449 int i, session_count;
450
451 settings.beginGroup("MainWindow");
452
453 if (settings.contains("geometry")) {
454 restoreGeometry(settings.value("geometry").toByteArray());
455 restoreState(settings.value("state").toByteArray());
456 } else
457 resize(1000, 720);
458
459 settings.endGroup();
460
461 session_count = settings.value("sessions", 0).toInt();
462
463 for (i = 0; i < session_count; i++) {
464 settings.beginGroup("Session" + QString::number(i));
465 shared_ptr<Session> session = add_session();
466 session->restore_settings(settings);
467 settings.endGroup();
468 }
469}
470
471std::shared_ptr<Session> MainWindow::get_tab_session(int index) const
472{
473 // Find the session that belongs to the tab's main window
474 for (auto entry : session_windows_)
475 if (entry.second == session_selector_.widget(index))
476 return entry.first;
477
478 return nullptr;
479}
480
481void MainWindow::closeEvent(QCloseEvent *event)
482{
483 bool data_saved = true;
484
485 for (auto entry : session_windows_)
486 if (!entry.first->data_saved())
487 data_saved = false;
488
489 if (!data_saved && (QMessageBox::question(this, tr("Confirmation"),
490 tr("There is unsaved data. Close anyway?"),
491 QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)) {
492 event->ignore();
493 } else {
494 save_ui_settings();
495 event->accept();
496 }
497}
498
499QMenu* MainWindow::createPopupMenu()
500{
501 return nullptr;
502}
503
504bool MainWindow::restoreState(const QByteArray &state, int version)
505{
506 (void)state;
507 (void)version;
508
509 // Do nothing. We don't want Qt to handle this, or else it
510 // will try to restore all the dock widgets and create havoc.
511
512 return false;
513}
514
515void MainWindow::session_error(const QString text, const QString info_text)
516{
517 QMetaObject::invokeMethod(this, "show_session_error",
518 Qt::QueuedConnection, Q_ARG(QString, text),
519 Q_ARG(QString, info_text));
520}
521
522void MainWindow::show_session_error(const QString text, const QString info_text)
523{
524 QMessageBox msg(this);
525 msg.setText(text);
526 msg.setInformativeText(info_text);
527 msg.setStandardButtons(QMessageBox::Ok);
528 msg.setIcon(QMessageBox::Warning);
529 msg.exec();
530}
531
532void MainWindow::on_add_view(const QString &title, views::ViewType type,
533 Session *session)
534{
535 // We get a pointer and need a reference
536 for (std::shared_ptr<Session> s : sessions_)
537 if (s.get() == session)
538 add_view(title, type, *s);
539}
540
541void MainWindow::on_focus_changed()
542{
543 shared_ptr<views::ViewBase> view = get_active_view();
544
545 if (view) {
546 for (shared_ptr<Session> session : sessions_) {
547 if (session->has_view(view)) {
548 if (session != last_focused_session_) {
549 // Activate correct tab if necessary
550 shared_ptr<Session> tab_session = get_tab_session(
551 session_selector_.currentIndex());
552 if (tab_session != session)
553 session_selector_.setCurrentWidget(
554 session_windows_.at(session));
555
556 on_focused_session_changed(session);
557 }
558
559 break;
560 }
561 }
562 }
563
564 if (sessions_.empty())
565 setWindowTitle(WindowTitle);
566}
567
568void MainWindow::on_focused_session_changed(shared_ptr<Session> session)
569{
570 last_focused_session_ = session;
571
572 setWindowTitle(session->name() + " - " + WindowTitle);
573
574 // Update the state of the run/stop button, too
575 on_capture_state_changed(session.get());
576}
577
578void MainWindow::on_new_session_clicked()
579{
580 add_session();
581}
582
583void MainWindow::on_run_stop_clicked()
584{
585 shared_ptr<Session> session = last_focused_session_;
586
587 if (!session)
588 return;
589
590 switch (session->get_capture_state()) {
591 case Session::Stopped:
592 session->start_capture([&](QString message) {
593 session_error("Capture failed", message); });
594 break;
595 case Session::AwaitingTrigger:
596 case Session::Running:
597 session->stop_capture();
598 break;
599 }
600}
601
602void MainWindow::on_settings_clicked()
603{
604 dialogs::Settings dlg(device_manager_);
605 dlg.exec();
606}
607
608void MainWindow::on_session_name_changed()
609{
610 // Update the corresponding dock widget's name(s)
611 Session *session = qobject_cast<Session*>(QObject::sender());
612 assert(session);
613
614 for (shared_ptr<views::ViewBase> view : session->views()) {
615 // Get the dock that contains the view
616 for (auto entry : view_docks_)
617 if (entry.second == view) {
618 entry.first->setObjectName(session->name());
619 entry.first->setWindowTitle(session->name());
620 }
621 }
622
623 // Update the tab widget by finding the main window and the tab from that
624 for (auto entry : session_windows_)
625 if (entry.first.get() == session) {
626 QMainWindow *window = entry.second;
627 const int index = session_selector_.indexOf(window);
628 session_selector_.setTabText(index, session->name());
629 }
630
631 // Refresh window title if the affected session has focus
632 if (session == last_focused_session_.get())
633 setWindowTitle(session->name() + " - " + WindowTitle);
634}
635
636void MainWindow::on_capture_state_changed(QObject *obj)
637{
638 Session *caller = qobject_cast<Session*>(obj);
639
640 // Ignore if caller is not the currently focused session
641 // unless there is only one session
642 if ((sessions_.size() > 1) && (caller != last_focused_session_.get()))
643 return;
644
645 int state = caller->get_capture_state();
646
647 const QIcon *icons[] = {&icon_grey_, &icon_red_, &icon_green_};
648 run_stop_button_->setIcon(*icons[state]);
649 run_stop_button_->setText((state == pv::Session::Stopped) ?
650 tr("Run") : tr("Stop"));
651}
652
653void MainWindow::on_new_view(Session *session)
654{
655 // We get a pointer and need a reference
656 for (std::shared_ptr<Session> s : sessions_)
657 if (s.get() == session)
658 add_view(session->name(), views::ViewTypeTrace, *s);
659}
660
661void MainWindow::on_view_close_clicked()
662{
663 // Find the dock widget that contains the close button that was clicked
664 QObject *w = QObject::sender();
665 QDockWidget *dock = nullptr;
666
667 while (w) {
668 dock = qobject_cast<QDockWidget*>(w);
669 if (dock)
670 break;
671 w = w->parent();
672 }
673
674 // Get the view contained in the dock widget
675 shared_ptr<views::ViewBase> view;
676
677 for (auto entry : view_docks_)
678 if (entry.first == dock)
679 view = entry.second;
680
681 // Deregister the view
682 for (shared_ptr<Session> session : sessions_) {
683 if (!session->has_view(view))
684 continue;
685
686 // Also destroy the entire session if its main view is closing...
687 if (view == session->main_view()) {
688 // ...but only if data is saved or the user confirms closing
689 if (session->data_saved() || (QMessageBox::question(this, tr("Confirmation"),
690 tr("This session contains unsaved data. Close it anyway?"),
691 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes))
692 remove_session(session);
693 break;
694 } else
695 // All other views can be closed at any time as no data will be lost
696 remove_view(view);
697 }
698}
699
700void MainWindow::on_tab_changed(int index)
701{
702 shared_ptr<Session> session = get_tab_session(index);
703
704 if (session)
705 on_focused_session_changed(session);
706}
707
708void MainWindow::on_tab_close_requested(int index)
709{
710 shared_ptr<Session> session = get_tab_session(index);
711
712 assert(session);
713
714 if (session->data_saved() || (QMessageBox::question(this, tr("Confirmation"),
715 tr("This session contains unsaved data. Close it anyway?"),
716 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes))
717 remove_session(session);
718}
719
720void MainWindow::on_view_sticky_scrolling_shortcut()
721{
722 shared_ptr<views::ViewBase> viewbase = get_active_view();
723 views::TraceView::View* view =
724 qobject_cast<views::TraceView::View*>(viewbase.get());
725 if (view)
726 view->toggle_sticky_scrolling();
727}
728
729void MainWindow::on_view_coloured_bg_shortcut()
730{
731 GlobalSettings settings;
732
733 bool state = settings.value(GlobalSettings::Key_View_ColouredBG).toBool();
734 settings.setValue(GlobalSettings::Key_View_ColouredBG, !state);
735}
736
737void MainWindow::on_settingViewColouredBg_changed(const QVariant new_value)
738{
739 bool state = new_value.toBool();
740
741 for (auto entry : view_docks_) {
742 shared_ptr<views::ViewBase> viewbase = entry.second;
743
744 // Only trace views have this setting
745 views::TraceView::View* view =
746 qobject_cast<views::TraceView::View*>(viewbase.get());
747 if (view)
748 view->enable_coloured_bg(state);
749 }
750}
751
752void MainWindow::on_close_current_tab()
753{
754 int tab = session_selector_.currentIndex();
755
756 on_tab_close_requested(tab);
757}
758
759} // namespace pv