]> sigrok.org Git - pulseview.git/blobdiff - pv/toolbars/mainbar.cpp
Untangle the time formatting functions a bit
[pulseview.git] / pv / toolbars / mainbar.cpp
index 0bf2270259b8f58138da8fb89bf19c605f0b6192..dcc35ecee8f4e42800354080e0b2b34d047ebbcb 100644 (file)
@@ -135,13 +135,19 @@ MainBar::MainBar(Session &session, MainWindow &main_window) :
        add_decoder_button->setMenu(main_window_.menu_decoder_add());
 #endif
 
-       // Setup the menu
+       // Setup the burger menu
        QMenu *const menu = new QMenu(this);
 
+       QMenu *const menu_view = new QMenu;
+       menu_view->setTitle(tr("&View"));
+       menu_view->addAction(main_window.action_view_sticky_scrolling());
+
        QMenu *const menu_help = new QMenu;
        menu_help->setTitle(tr("&Help"));
        menu_help->addAction(main_window.action_about());
 
+       menu->addAction(menu_view->menuAction());
+       menu->addSeparator();
        menu->addAction(menu_help->menuAction());
        menu->addSeparator();
        menu->addAction(main_window.action_quit());
@@ -226,6 +232,14 @@ void MainBar::set_capture_state(pv::Session::capture_state state)
        run_stop_button_.setText((state == pv::Session::Stopped) ?
                tr("Run") : tr("Stop"));
        run_stop_button_.setShortcut(QKeySequence(Qt::Key_Space));
+
+       bool ui_enabled = (state == pv::Session::Stopped) ? true : false;
+
+       device_selector_.setEnabled(ui_enabled);
+       configure_button_.setEnabled(ui_enabled);
+       channels_button_.setEnabled(ui_enabled);
+       sample_count_.setEnabled(ui_enabled);
+       sample_rate_.setEnabled(ui_enabled);
 }
 
 void MainBar::update_sample_rate_selector()
@@ -493,6 +507,11 @@ void MainBar::commit_sample_count()
                        return;
                }
        }
+
+       // Devices with built-in memory might impose limits on certain
+       // configurations, so let's check what sample rate the driver
+       // lets us use now.
+       update_sample_rate_selector();
 }
 
 void MainBar::commit_sample_rate()
@@ -518,6 +537,11 @@ void MainBar::commit_sample_rate()
                qDebug() << "Failed to configure samplerate.";
                return;
        }
+
+       // Devices with built-in memory might impose limits on certain
+       // configurations, so let's check what sample count the driver
+       // lets us use now.
+       update_sample_count_selector();
 }
 
 void MainBar::on_device_selected()
@@ -560,10 +584,11 @@ bool MainBar::eventFilter(QObject *watched, QEvent *event)
 {
        if ((watched == &sample_count_ || watched == &sample_rate_) &&
                (event->type() == QEvent::ToolTip)) {
-               double sec = (double)sample_count_.value() / sample_rate_.value();
+               auto sec = pv::util::Timestamp(sample_count_.value()) / sample_rate_.value();
                QHelpEvent *help_event = static_cast<QHelpEvent*>(event);
 
-               QString str = tr("Total sampling time: %1").arg(pv::util::format_second(sec));
+               QString str = tr("Total sampling time: %1").arg(
+                       pv::util::format_time_si(sec, pv::util::SIPrefix::unspecified, 0, "s", false));
                QToolTip::showText(help_event->globalPos(), str);
 
                return true;