X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Ftoolbars%2Fmainbar.cpp;h=cd46c063bdc8a84d78d1e42e1c616c2fc8a3b270;hp=b798683c33a0fee228553501cadd528c48704a41;hb=HEAD;hpb=e6d85b8936b5b7aee80b03834f095fd5b52fe6f4 diff --git a/pv/toolbars/mainbar.cpp b/pv/toolbars/mainbar.cpp index b798683c..cd46c063 100644 --- a/pv/toolbars/mainbar.cpp +++ b/pv/toolbars/mainbar.cpp @@ -35,6 +35,7 @@ #include +#include #include #include #include @@ -59,6 +60,7 @@ using std::back_inserter; using std::copy; using std::list; using std::make_pair; +using std::make_shared; using std::map; using std::max; using std::min; @@ -108,10 +110,11 @@ MainBar::MainBar(Session &session, QWidget *parent, pv::views::trace::View *view sample_rate_("Hz", this), updating_sample_rate_(false), updating_sample_count_(false), - sample_count_supported_(false) + sample_count_supported_(false), #ifdef ENABLE_DECODE - , add_decoder_button_(new QToolButton()) + add_decoder_button_(new QToolButton()), #endif + add_math_signal_button_(new QToolButton()) { setObjectName(QString::fromUtf8("MainBar")); @@ -127,7 +130,11 @@ MainBar::MainBar(Session &session, QWidget *parent, pv::views::trace::View *view action_open_->setText(tr("&Open...")); action_open_->setIcon(QIcon::fromTheme("document-open", QIcon(":/icons/document-open.png"))); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + action_open_->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_O)); +#else action_open_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O)); +#endif connect(action_open_, SIGNAL(triggered(bool)), this, SLOT(on_actionOpen_triggered())); @@ -138,7 +145,11 @@ MainBar::MainBar(Session &session, QWidget *parent, pv::views::trace::View *view action_save_->setText(tr("&Save...")); action_save_->setIcon(QIcon::fromTheme("document-save-as", QIcon(":/icons/document-save-as.png"))); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + action_save_->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_S)); +#else action_save_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S)); +#endif connect(action_save_, SIGNAL(triggered(bool)), this, SLOT(on_actionSave_triggered())); @@ -151,7 +162,11 @@ MainBar::MainBar(Session &session, QWidget *parent, pv::views::trace::View *view action_save_selection_as_->setText(tr("Save Selected &Range As...")); action_save_selection_as_->setIcon(QIcon::fromTheme("document-save-as", QIcon(":/icons/document-save-as.png"))); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + action_save_selection_as_->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_R)); +#else action_save_selection_as_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R)); +#endif connect(action_save_selection_as_, SIGNAL(triggered(bool)), this, SLOT(on_actionSaveSelectionAs_triggered())); @@ -240,6 +255,16 @@ MainBar::MainBar(Session &session, QWidget *parent, pv::views::trace::View *view this, SLOT(on_add_decoder_clicked())); #endif + // Setup the math signal button + add_math_signal_button_->setIcon(QIcon(":/icons/add-math-signal.svg")); + add_math_signal_button_->setPopupMode(QToolButton::InstantPopup); + add_math_signal_button_->setToolTip(tr("Add math signal")); + add_math_signal_button_->setShortcut(QKeySequence(Qt::Key_M)); + + connect(add_math_signal_button_, SIGNAL(clicked()), + this, SLOT(on_add_math_signal_clicked())); + + connect(&sample_count_, SIGNAL(value_changed()), this, SLOT(on_sample_count_changed())); connect(&sample_rate_, SIGNAL(value_changed()), @@ -535,7 +560,7 @@ void MainBar::update_device_config_widgets() sample_count_supported_ = true; // Add notification of reconfigure events - disconnect(this, SLOT(on_config_changed())); + // Note: No need to disconnect the previous signal as that QObject instance is destroyed connect(&opts->binding(), SIGNAL(config_changed()), this, SLOT(on_config_changed())); @@ -689,11 +714,10 @@ void MainBar::export_file(shared_ptr format, bool selection_only, } if (!selection_only) { - session_.set_name(QFileInfo(file_name).fileName()); - - if (format == session_.device_manager().context()->output_formats()["srzip"]) + if (format == session_.device_manager().context()->output_formats()["srzip"]) { session_.set_save_path(QFileInfo(file_name).absolutePath()); - else + session_.set_name(QFileInfo(file_name).fileName()); + } else session_.set_save_path(""); } @@ -825,7 +849,7 @@ void MainBar::on_actionSave_triggered() return; } - QFileInfo fi = QFileInfo(session_.save_path(), session_.name()); + QFileInfo fi = QFileInfo(QDir(session_.save_path()), session_.name()); export_file(session_.device_manager().context()->output_formats()["srzip"], false, fi.absoluteFilePath()); } @@ -894,6 +918,12 @@ void MainBar::on_add_decoder_clicked() show_decoder_selector(&session_); } +void MainBar::on_add_math_signal_clicked() +{ + shared_ptr signal = make_shared(session_); + session_.add_generated_signal(signal); +} + void MainBar::add_toolbar_widgets() { addWidget(new_view_button_); @@ -913,6 +943,7 @@ void MainBar::add_toolbar_widgets() addSeparator(); addWidget(add_decoder_button_); #endif + addWidget(add_math_signal_button_); } bool MainBar::eventFilter(QObject *watched, QEvent *event)