]> sigrok.org Git - pulseview.git/commitdiff
Fix "always zoom to fit" feature
authorSoeren Apel <redacted>
Wed, 30 Nov 2016 07:23:56 +0000 (08:23 +0100)
committerSoeren Apel <redacted>
Sun, 4 Dec 2016 13:37:38 +0000 (14:37 +0100)
pv/mainwindow.cpp
pv/views/trace/standardbar.cpp
pv/views/trace/standardbar.hpp

index 4a98e4081b68e9999a2f07b3f17d78fdd9276951..a47089620c6c1239f2adc5a565d8346bbec007f3 100644 (file)
@@ -212,15 +212,16 @@ shared_ptr<views::ViewBase> 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;
index def3ebc594c2e1d860a89b17214909bf020feefb..eee00b3f2f642b2d5b9c0a41e22faaf0f8492293 100644 (file)
@@ -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()
index e41beebc79448d41ccfed7927b33ee5c2e5214fc..ce9bf91b4c7f6dc7fc79e5a9f40a084b6818752c 100644 (file)
@@ -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();