X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fmainwindow.cpp;h=3c5af937fda9546eaf67e84b08a04eb819e41861;hb=06ef804f11e4e0213013e7729f43ebde529fca48;hp=8006b65d8d992296245793bcc26269fedcc7c349;hpb=a55e791833e84bf030ff6122c64b45a46f028e43;p=pulseview.git diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 8006b65d..3c5af937 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -110,12 +110,15 @@ MainWindow::MainWindow(DeviceManager &device_manager, 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_coloured_bg_(new QAction(this)), action_view_show_cursors_(new QAction(this)), action_about_(new QAction(this)) #ifdef ENABLE_DECODE , menu_decoders_add_(new pv::widgets::DecoderMenu(this, true)) #endif { + qRegisterMetaType("util::Timestamp"); + setup_ui(); restore_ui_settings(); if (open_file_name.empty()) @@ -193,12 +196,11 @@ QMenu* MainWindow::menu_decoder_add() const void MainWindow::run_stop() { - switch(session_.get_capture_state()) { + switch (session_.get_capture_state()) { case Session::Stopped: session_.start_capture([&](QString message) { session_error("Capture failed", message); }); break; - case Session::AwaitingTrigger: case Session::Running: session_.stop_capture(); @@ -213,7 +215,7 @@ void MainWindow::select_device(shared_ptr device) session_.set_device(device); else session_.set_default_device(); - } catch(const QString &e) { + } catch (const QString &e) { QMessageBox msg(this); msg.setText(e); msg.setInformativeText(tr("Failed to Select Device")); @@ -251,9 +253,9 @@ void MainWindow::export_file(shared_ptr format, const pv::util::Timestamp& end_time = view_->cursors()->second()->time(); const uint64_t start_sample = start_time.convert_to() * samplerate; - const uint64_t end_sample = end_time.convert_to() * samplerate; + const uint64_t end_sample = end_time.convert_to() * samplerate; - sample_range = std::make_pair(start_sample, end_sample); + sample_range = std::make_pair(start_sample, end_sample); } else { sample_range = std::make_pair(0, 0); } @@ -458,7 +460,7 @@ void MainWindow::setup_ui() QString::fromUtf8("actionViewZoomOneToOne")); menu_view->addAction(action_view_zoom_one_to_one_); - menu_file->addSeparator(); + menu_view->addSeparator(); action_view_sticky_scrolling_->setCheckable(true); action_view_sticky_scrolling_->setChecked(true); @@ -472,6 +474,18 @@ void MainWindow::setup_ui() menu_view->addSeparator(); + action_view_coloured_bg_->setCheckable(true); + action_view_coloured_bg_->setChecked(true); + action_view_coloured_bg_->setShortcut(QKeySequence(Qt::Key_B)); + action_view_coloured_bg_->setObjectName( + QString::fromUtf8("actionViewColouredBg")); + action_view_coloured_bg_->setText(tr("Use &coloured backgrounds")); + menu_view->addAction(action_view_coloured_bg_); + + view_->enable_coloured_bg(action_view_coloured_bg_->isChecked()); + + menu_view->addSeparator(); + action_view_show_cursors_->setCheckable(true); action_view_show_cursors_->setChecked(view_->cursors_shown()); action_view_show_cursors_->setIcon(QIcon::fromTheme("show-cursors", @@ -532,15 +546,19 @@ void MainWindow::setup_ui() SLOT(capture_state_changed(int))); connect(&session_, SIGNAL(device_selected()), this, SLOT(device_selected())); + connect(&session_, SIGNAL(trigger_event(util::Timestamp)), view_, + SLOT(trigger_event(util::Timestamp))); // 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() { +void MainWindow::select_init_device() +{ QSettings settings; map dev_info; list key_list; @@ -572,7 +590,8 @@ void MainWindow::select_init_device() { } void MainWindow::load_init_file(const std::string &file_name, - const std::string &format) { + const std::string &format) +{ shared_ptr input_format; if (!format.empty()) { @@ -617,7 +636,6 @@ void MainWindow::save_ui_settings() session_.device()); for (string key : key_list) { - if (dev_info.count(key)) settings.setValue(QString::fromUtf8(key.c_str()), QString::fromUtf8(dev_info.at(key).c_str())); @@ -676,7 +694,7 @@ void MainWindow::load_file(QString file_name, new devices::SessionFile( device_manager_.context(), file_name.toStdString()))); - } catch(Error e) { + } catch (Error e) { show_session_error(tr("Failed to load ") + file_name, e.what()); session_.set_default_device(); update_device_list(); @@ -789,6 +807,11 @@ void MainWindow::on_actionViewStickyScrolling_triggered() view_->enable_sticky_scrolling(action_view_sticky_scrolling_->isChecked()); } +void MainWindow::on_actionViewColouredBg_triggered() +{ + view_->enable_coloured_bg(action_view_coloured_bg_->isChecked()); +} + void MainWindow::on_actionViewShowCursors_triggered() { assert(view_);