From: Soeren Apel Date: Wed, 30 Nov 2016 07:23:56 +0000 (+0100) Subject: Fix "always zoom to fit" feature X-Git-Tag: pulseview-0.4.0~218 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=dfe1bf82619704af27e4cbf83b75c6b5f367f425;p=pulseview.git Fix "always zoom to fit" feature --- diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 4a98e408..a4708962 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -212,15 +212,16 @@ shared_ptr MainWindow::add_view(const QString &title, connect(main_bar.get(), SIGNAL(new_view(Session*)), this, SLOT(on_new_view(Session*))); + + main_bar->action_view_show_cursors()->setChecked(v->cursors_shown()); } else { /* Additional view, create a standard bar */ - dock_main->addToolBar( - new pv::views::trace::StandardBar(session, this, v.get())); - } - main_bar->action_view_show_cursors()->setChecked(v->cursors_shown()); + pv::views::trace::StandardBar *standard_bar = + new pv::views::trace::StandardBar(session, this, v.get()); + dock_main->addToolBar(standard_bar); - connect(v.get(), SIGNAL(always_zoom_to_fit_changed(bool)), - main_bar.get(), SLOT(on_always_zoom_to_fit_changed(bool))); + standard_bar->action_view_show_cursors()->setChecked(v->cursors_shown()); + } } return v; diff --git a/pv/views/trace/standardbar.cpp b/pv/views/trace/standardbar.cpp index def3ebc5..eee00b3f 100644 --- a/pv/views/trace/standardbar.cpp +++ b/pv/views/trace/standardbar.cpp @@ -69,7 +69,7 @@ StandardBar::StandardBar(Session &session, QWidget *parent, QIcon(":/icons/zoom-fit.png"))); action_view_zoom_fit_->setShortcut(QKeySequence(Qt::Key_F)); connect(action_view_zoom_fit_, SIGNAL(triggered(bool)), - this, SLOT(on_actionViewZoomFit_triggered())); + this, SLOT(on_actionViewZoomFit_triggered(bool))); action_view_zoom_one_to_one_->setText(tr("Zoom to O&ne-to-One")); action_view_zoom_one_to_one_->setIcon(QIcon::fromTheme("zoom-original", @@ -86,6 +86,9 @@ StandardBar::StandardBar(Session &session, QWidget *parent, this, SLOT(on_actionViewShowCursors_triggered())); action_view_show_cursors_->setText(tr("Show &Cursors")); + connect(view_, SIGNAL(always_zoom_to_fit_changed(bool)), + this, SLOT(on_always_zoom_to_fit_changed(bool))); + if (add_default_widgets) add_toolbar_widgets(); } @@ -141,9 +144,9 @@ void StandardBar::on_actionViewZoomOut_triggered() view_->zoom(-1); } -void StandardBar::on_actionViewZoomFit_triggered() +void StandardBar::on_actionViewZoomFit_triggered(bool checked) { - view_->zoom_fit(action_view_zoom_fit_->isChecked()); + view_->zoom_fit(checked); } void StandardBar::on_actionViewZoomOneToOne_triggered() diff --git a/pv/views/trace/standardbar.hpp b/pv/views/trace/standardbar.hpp index e41beebc..ce9bf91b 100644 --- a/pv/views/trace/standardbar.hpp +++ b/pv/views/trace/standardbar.hpp @@ -76,7 +76,7 @@ protected Q_SLOTS: void on_actionViewZoomOut_triggered(); - void on_actionViewZoomFit_triggered(); + void on_actionViewZoomFit_triggered(bool checked); void on_actionViewZoomOneToOne_triggered();