#ifdef ENABLE_DECODE
#include "subwindows/decoder_selector/subwindow.hpp"
+#include "views/decoder_output/view.hpp"
#endif
#include <libsigrokcxx/libsigrokcxx.hpp>
namespace pv {
-namespace view {
-class ViewItem;
-}
-
using toolbars::MainBar;
const QString MainWindow::WindowTitle = tr("PulseView");
icon_green_(":/icons/status-green.svg"),
icon_grey_(":/icons/status-grey.svg")
{
- GlobalSettings::add_change_handler(this);
-
setup_ui();
restore_ui_settings();
}
MainWindow::~MainWindow()
{
- GlobalSettings::remove_change_handler(this);
-
// Make sure we no longer hold any shared pointers to widgets after the
// destructor finishes (goes for sessions and sub windows alike)
// This view will be the main view if there's no main bar yet
v = make_shared<views::trace::View>(session,
(main_bar ? false : true), dock_main);
+#ifdef ENABLE_DECODE
+ if (type == views::ViewTypeDecoderOutput)
+ v = make_shared<views::decoder_output::View>(session, false, dock_main);
+#endif
if (!v)
return nullptr;
views::trace::View *tv =
qobject_cast<views::trace::View*>(v.get());
- tv->enable_colored_bg(settings.value(GlobalSettings::Key_View_ColoredBG).toBool());
- tv->enable_show_sampling_points(settings.value(GlobalSettings::Key_View_ShowSamplingPoints).toBool());
- tv->enable_show_analog_minor_grid(settings.value(GlobalSettings::Key_View_ShowAnalogMinorGrid).toBool());
-
if (!main_bar) {
/* Initial view, create the main bar */
main_bar = make_shared<MainBar>(session, this, tv);
shared_ptr<subwindows::SubWindowBase> v;
QMainWindow *main_window = nullptr;
- for (auto entry : session_windows_)
+ for (auto& entry : session_windows_)
if (entry.first.get() == &session)
main_window = entry.second;
QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetClosable);
QAbstractButton *close_btn =
- dock->findChildren<QAbstractButton*>
+ dock->findChildren<QAbstractButton*> // clazy:exclude=detaching-temporary
("qt_dockwidget_closebutton").front();
connect(close_btn, SIGNAL(clicked(bool)),
}
}
-void MainWindow::on_setting_changed(const QString &key, const QVariant &value)
-{
- if (key == GlobalSettings::Key_View_ColoredBG)
- on_settingViewColoredBg_changed(value);
-
- if (key == GlobalSettings::Key_View_ShowSamplingPoints)
- on_settingViewShowSamplingPoints_changed(value);
-
- if (key == GlobalSettings::Key_View_ShowAnalogMinorGrid)
- on_settingViewShowAnalogMinorGrid_changed(value);
-}
-
void MainWindow::setup_ui()
{
setObjectName(QString::fromUtf8("MainWindow"));
icon.addFile(QString(":/icons/pulseview.png"));
setWindowIcon(icon);
+ // Set up keyboard shortcuts that affect all views at once
view_sticky_scrolling_shortcut_ = new QShortcut(QKeySequence(Qt::Key_S), this, SLOT(on_view_sticky_scrolling_shortcut()));
view_sticky_scrolling_shortcut_->setAutoRepeat(false);
{
#ifdef ENABLE_DECODE
// Close dock widget if it's already showing and return
- for (auto entry : sub_windows_) {
+ for (auto& entry : sub_windows_) {
QDockWidget* dock = entry.first;
- if (dynamic_pointer_cast<subwindows::decoder_selector::SubWindow>(entry.second)) {
+ shared_ptr<subwindows::SubWindowBase> decoder_selector =
+ dynamic_pointer_cast<subwindows::decoder_selector::SubWindow>(entry.second);
+
+ if (decoder_selector && (&decoder_selector->session() == session)) {
sub_windows_.erase(dock);
dock->close();
return;
}
// We get a pointer and need a reference
- for (shared_ptr<Session> s : sessions_)
+ for (shared_ptr<Session>& s : sessions_)
if (s.get() == session)
add_subwindow(subwindows::SubWindowTypeDecoderSelector, *s);
#endif
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();