X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fmainwindow.cpp;h=e6f1a5e156c5fa36b72194e9cc6394c704a7a4f5;hp=797944b9bea2295a50b00d0d374e3b8ee6c0f186;hb=3d87310109576c77819c4c592d41bc1d9731978b;hpb=e3c79b07a04a6621e7f3d8d36c1afac5ef7d0db5 diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 797944b9..e6f1a5e1 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_R)); + action_view_sticky_scrolling_->setObjectName( + QString::fromUtf8("actionViewStickyScrolling")); + action_view_sticky_scrolling_->setText(tr("Sticky Sc&rolling")); + 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); @@ -453,6 +472,10 @@ void MainWindow::setup_ui() setMenuBar(menu_bar); QMetaObject::connectSlotsByName(this); + // Also add all actions to the main window for always-enabled hotkeys + for (QAction* action : menu_bar->actions()) + this->addAction(action); + // Setup the toolbar main_bar_ = new toolbars::MainBar(session_, *this); @@ -469,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() { @@ -703,7 +732,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() @@ -711,12 +740,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); @@ -728,6 +762,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