+ // Close dock widget if it's already showing and return
+ for (auto entry : sub_windows_) {
+ QDockWidget* dock = entry.first;
+ if (dynamic_pointer_cast<subwindows::decoder_selector::SubWindow>(entry.second)) {
+ sub_windows_.erase(dock);
+ dock->close();
+ return;
+ }
+ }
+
+ // We get a pointer and need a reference
+ for (shared_ptr<Session> s : sessions_)
+ if (s.get() == session)
+ add_subwindow(subwindows::SubWindowTypeDecoderSelector, *s);
+}
+
+void MainWindow::on_sub_window_close_clicked()
+{
+ // Find the dock widget that contains the close button that was clicked
+ QObject *w = QObject::sender();
+ QDockWidget *dock = nullptr;
+
+ while (w) {
+ dock = qobject_cast<QDockWidget*>(w);
+ if (dock)
+ break;
+ w = w->parent();
+ }
+
+ sub_windows_.erase(dock);
+ dock->close();
+}
+
+void MainWindow::on_view_colored_bg_shortcut()
+{
+ GlobalSettings settings;
+
+ bool state = settings.value(GlobalSettings::Key_View_ColoredBG).toBool();
+ settings.setValue(GlobalSettings::Key_View_ColoredBG, !state);
+}
+
+void MainWindow::on_view_sticky_scrolling_shortcut()
+{
+ GlobalSettings settings;
+
+ bool state = settings.value(GlobalSettings::Key_View_StickyScrolling).toBool();
+ settings.setValue(GlobalSettings::Key_View_StickyScrolling, !state);
+}
+
+void MainWindow::on_view_show_sampling_points_shortcut()
+{
+ GlobalSettings settings;
+
+ bool state = settings.value(GlobalSettings::Key_View_ShowSamplingPoints).toBool();
+ settings.setValue(GlobalSettings::Key_View_ShowSamplingPoints, !state);
+}
+
+void MainWindow::on_view_show_analog_minor_grid_shortcut()
+{
+ GlobalSettings settings;
+
+ bool state = settings.value(GlobalSettings::Key_View_ShowAnalogMinorGrid).toBool();
+ settings.setValue(GlobalSettings::Key_View_ShowAnalogMinorGrid, !state);
+}
+
+void MainWindow::on_settingViewColoredBg_changed(const QVariant new_value)
+{
+ bool state = new_value.toBool();
+
+ for (auto& entry : view_docks_) {
+ shared_ptr<views::ViewBase> viewbase = entry.second;
+
+ // Only trace views have this setting
+ views::trace::View* view =
+ qobject_cast<views::trace::View*>(viewbase.get());
+ if (view)
+ view->enable_colored_bg(state);
+ }
+}
+
+void MainWindow::on_settingViewShowSamplingPoints_changed(const QVariant new_value)
+{
+ bool state = new_value.toBool();
+
+ for (auto& entry : view_docks_) {
+ shared_ptr<views::ViewBase> viewbase = entry.second;
+
+ // Only trace views have this setting
+ views::trace::View* view =
+ qobject_cast<views::trace::View*>(viewbase.get());
+ if (view)
+ view->enable_show_sampling_points(state);
+ }
+}
+
+void MainWindow::on_settingViewShowAnalogMinorGrid_changed(const QVariant new_value)
+{
+ bool state = new_value.toBool();
+
+ for (auto& entry : view_docks_) {
+ shared_ptr<views::ViewBase> viewbase = entry.second;
+
+ // Only trace views have this setting
+ views::trace::View* view =
+ qobject_cast<views::trace::View*>(viewbase.get());
+ if (view)
+ view->enable_show_analog_minor_grid(state);
+ }
+}
+
+void MainWindow::on_close_current_tab()
+{
+ int tab = session_selector_.currentIndex();
+
+ on_tab_close_requested(tab);