X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fmainwindow.cpp;h=8b32046a6e8d3db5aa3ccdfce967bf7022fc3a25;hp=3a775edde104d2500f00397730e63c8844de74d3;hb=812c0e3592e51946947b55c54b906bf4a0cb30e9;hpb=b4543062e0c62f893861cc41067f93e13a588ce8 diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 3a775edd..8b32046a 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -106,6 +106,7 @@ MainWindow::MainWindow(DeviceManager &device_manager, action_view_zoom_out_(new QAction(this)), action_view_zoom_fit_(new QAction(this)), action_view_zoom_one_to_one_(new QAction(this)), + action_view_sticky_scrolling_(new QAction(this)), action_view_show_cursors_(new QAction(this)), action_about_(new QAction(this)) #ifdef ENABLE_DECODE @@ -160,6 +161,11 @@ QAction* MainWindow::action_view_zoom_one_to_one() const return action_view_zoom_one_to_one_; } +QAction* MainWindow::action_view_sticky_scrolling() const +{ + return action_view_sticky_scrolling_; +} + QAction* MainWindow::action_view_show_cursors() const { return action_view_show_cursors_; @@ -395,6 +401,7 @@ void MainWindow::setup_ui() QString::fromUtf8("actionViewZoomOut")); menu_view->addAction(action_view_zoom_out_); + action_view_zoom_fit_->setCheckable(true); action_view_zoom_fit_->setText(tr("Zoom to &Fit")); action_view_zoom_fit_->setIcon(QIcon::fromTheme("zoom-fit", QIcon(":/icons/zoom-fit.png"))); @@ -411,6 +418,18 @@ void MainWindow::setup_ui() QString::fromUtf8("actionViewZoomOneToOne")); menu_view->addAction(action_view_zoom_one_to_one_); + menu_file->addSeparator(); + + action_view_sticky_scrolling_->setCheckable(true); + action_view_sticky_scrolling_->setChecked(true); + action_view_sticky_scrolling_->setShortcut(QKeySequence(Qt::Key_S)); + action_view_sticky_scrolling_->setObjectName( + QString::fromUtf8("actionViewStickyScrolling")); + action_view_sticky_scrolling_->setText(tr("&Sticky Scrolling")); + menu_view->addAction(action_view_sticky_scrolling_); + + view_->enable_sticky_scrolling(action_view_sticky_scrolling_->isChecked()); + menu_view->addSeparator(); action_view_show_cursors_->setCheckable(true); @@ -473,6 +492,12 @@ void MainWindow::setup_ui() SLOT(capture_state_changed(int))); connect(&session_, SIGNAL(device_selected()), this, SLOT(device_selected())); + + // Setup view_ events + connect(view_, SIGNAL(sticky_scrolling_changed(bool)), this, + SLOT(sticky_scrolling_changed(bool))); + connect(view_, SIGNAL(always_zoom_to_fit_changed(bool)), this, + SLOT(always_zoom_to_fit_changed(bool))); } void MainWindow::select_init_device() { @@ -598,7 +623,6 @@ void MainWindow::load_file(QString file_name, { const QString errorMessage( QString("Failed to load file %1").arg(file_name)); - const QString infoMessage; try { if (format) @@ -621,7 +645,7 @@ void MainWindow::load_file(QString file_name, update_device_list(); - session_.start_capture([&, errorMessage, infoMessage](QString) { + session_.start_capture([&, errorMessage](QString infoMessage) { session_error(errorMessage, infoMessage); }); } @@ -707,7 +731,7 @@ void MainWindow::on_actionViewZoomOut_triggered() void MainWindow::on_actionViewZoomFit_triggered() { - view_->zoom_fit(); + view_->zoom_fit(action_view_zoom_fit_->isChecked()); } void MainWindow::on_actionViewZoomOneToOne_triggered() @@ -715,12 +739,17 @@ void MainWindow::on_actionViewZoomOneToOne_triggered() view_->zoom_one_to_one(); } +void MainWindow::on_actionViewStickyScrolling_triggered() +{ + view_->enable_sticky_scrolling(action_view_sticky_scrolling_->isChecked()); +} + void MainWindow::on_actionViewShowCursors_triggered() { assert(view_); const bool show = !view_->cursors_shown(); - if(show) + if (show) view_->centre_cursors(); view_->show_cursors(show); @@ -732,6 +761,16 @@ void MainWindow::on_actionAbout_triggered() dlg.exec(); } +void MainWindow::sticky_scrolling_changed(bool state) +{ + action_view_sticky_scrolling_->setChecked(state); +} + +void MainWindow::always_zoom_to_fit_changed(bool state) +{ + action_view_zoom_fit_->setChecked(state); +} + void MainWindow::add_decoder(srd_decoder *decoder) { #ifdef ENABLE_DECODE