X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Ftoolbars%2Fmainbar.cpp;h=34b120fec11ce0ec14bf21f16cc717e7b9d74222;hp=e1a666b11ce9ea28c9e83dab427d25d485a10857;hb=7b7ab1f5cb3607bf29885eeffcb2cb215b2c9e9f;hpb=3432032fbc693b58a0c65427c025b9553c419237 diff --git a/pv/toolbars/mainbar.cpp b/pv/toolbars/mainbar.cpp index e1a666b1..34b120fe 100644 --- a/pv/toolbars/mainbar.cpp +++ b/pv/toolbars/mainbar.cpp @@ -35,6 +35,7 @@ #include +#include #include #include #include @@ -46,7 +47,7 @@ #include #include #include -#include +#include #include #include #ifdef ENABLE_DECODE @@ -87,7 +88,7 @@ const char *MainBar::SettingOpenDirectory = "MainWindow/OpenDirectory"; const char *MainBar::SettingSaveDirectory = "MainWindow/SaveDirectory"; MainBar::MainBar(Session &session, QWidget *parent, - pv::views::TraceView::View *view) : + pv::views::trace::View *view) : StandardBar(session, parent, view, false), action_new_view_(new QAction(this)), action_open_(new QAction(this)), @@ -114,6 +115,8 @@ MainBar::MainBar(Session &session, QWidget *parent, { setObjectName(QString::fromUtf8("MainBar")); + setContextMenuPolicy(Qt::PreventContextMenu); + // Actions action_new_view_->setText(tr("New &View")); action_new_view_->setIcon(QIcon::fromTheme("window-new", @@ -199,8 +202,7 @@ MainBar::MainBar(Session &session, QWidget *parent, connect(menu_decoders_add_, SIGNAL(decoder_selected(srd_decoder*)), this, SLOT(add_decoder(srd_decoder*))); - add_decoder_button_->setIcon(QIcon::fromTheme("add-decoder", - QIcon(":/icons/add-decoder.svg"))); + add_decoder_button_->setIcon(QIcon(":/icons/add-decoder.svg")); add_decoder_button_->setPopupMode(QToolButton::InstantPopup); add_decoder_button_->setMenu(menu_decoders_add_); add_decoder_button_->setToolTip(tr("Add low-level, non-stacked protocol decoder")); @@ -220,8 +222,7 @@ MainBar::MainBar(Session &session, QWidget *parent, QIcon(":/icons/preferences-system.png"))); channels_button_.setToolTip(tr("Configure Channels")); - channels_button_.setIcon(QIcon::fromTheme("channels", - QIcon(":/icons/channels.svg"))); + channels_button_.setIcon(QIcon(":/icons/channels.svg")); add_toolbar_widgets(); @@ -479,12 +480,6 @@ void MainBar::update_device_config_widgets() if (sr_dev->config_check(ConfigKey::LIMIT_SAMPLES, Capability::SET)) sample_count_supported_ = true; - if (sr_dev->config_check(ConfigKey::LIMIT_FRAMES, Capability::SET)) { - sr_dev->config_set(ConfigKey::LIMIT_FRAMES, - Glib::Variant::create(1)); - on_config_changed(); - } - // Add notification of reconfigure events disconnect(this, SLOT(on_config_changed())); connect(&opts->binding(), SIGNAL(config_changed()), @@ -575,7 +570,9 @@ void MainBar::add_decoder(srd_decoder *decoder) { #ifdef ENABLE_DECODE assert(decoder); - session_.add_decoder(decoder); + shared_ptr signal = session_.add_decode_signal(); + if (signal) + signal->stack_decoder(decoder); #else (void)decoder; #endif @@ -595,13 +592,13 @@ void MainBar::export_file(shared_ptr format, bool selection_only) // Selection only? Verify that the cursors are active and fetch their values if (selection_only) { - views::TraceView::View *trace_view = - qobject_cast(session_.main_view().get()); + views::trace::View *trace_view = + qobject_cast(session_.main_view().get()); if (!trace_view->cursors()->enabled()) { show_session_error(tr("Missing Cursors"), tr("You need to set the " \ "cursors before you can save the data enclosed by them " \ - "to a session file (e.g. using ALT-V - Show Cursors).")); + "to a session file (e.g. using the Show Cursors button).")); return; } @@ -615,6 +612,13 @@ void MainBar::export_file(shared_ptr format, bool selection_only) const uint64_t end_sample = (uint64_t)max( (double)0, end_time.convert_to() * samplerate); + if ((start_sample == 0) && (end_sample == 0)) { + // Both cursors are negative and were clamped to 0 + show_session_error(tr("Invalid Range"), tr("The cursors don't " \ + "define a valid range of samples.")); + return; + } + sample_range = make_pair(start_sample, end_sample); } else { sample_range = make_pair(0, 0); @@ -626,9 +630,9 @@ void MainBar::export_file(shared_ptr format, bool selection_only) QString::fromStdString(format->description())); if (exts.empty()) - filter += "(*.*)"; + filter += "(*)"; else - filter += QString("(*.%1);;%2 (*.*)").arg( + filter += QString("(*.%1);;%2 (*)").arg( QString::fromStdString(join(exts, ", *.")), tr("All Files")); @@ -671,16 +675,19 @@ void MainBar::import_file(shared_ptr format) // Construct the filter const vector exts = format->extensions(); - const QString filter = exts.empty() ? "" : - tr("%1 files (*.%2)").arg( - QString::fromStdString(format->description()), - QString::fromStdString(join(exts, ", *."))); + const QString filter_exts = exts.empty() ? "" : QString::fromStdString("%1 (%2)").arg( + tr("%1 files").arg(QString::fromStdString(format->description())), + QString::fromStdString("*.%1").arg(QString::fromStdString(join(exts, " *.")))); + const QString filter_all = QString::fromStdString("%1 (%2)").arg( + tr("All Files"), QString::fromStdString("*")); + const QString filter = QString::fromStdString("%1%2%3").arg( + exts.empty() ? "" : filter_exts, + exts.empty() ? "" : ";;", + filter_all); // Show the file dialog const QString file_name = QFileDialog::getOpenFileName( - this, tr("Import File"), dir, tr( - "%1 files (*.*);;All Files (*.*)").arg( - QString::fromStdString(format->description()))); + this, tr("Import File"), dir, filter); if (file_name.isEmpty()) return; @@ -756,8 +763,8 @@ void MainBar::on_actionOpen_triggered() // Show the dialog const QString file_name = QFileDialog::getOpenFileName( this, tr("Open File"), dir, tr( - "Sigrok Sessions (*.sr);;" - "All Files (*.*)")); + "sigrok Sessions (*.sr);;" + "All Files (*)")); if (!file_name.isEmpty()) { session_.load_file(file_name);