#include <boost/algorithm/string/join.hpp>
+#include <pv/data/mathsignal.hpp>
#include <pv/devicemanager.hpp>
#include <pv/devices/hardwaredevice.hpp>
#include <pv/devices/inputfile.hpp>
using std::copy;
using std::list;
using std::make_pair;
+using std::make_shared;
using std::map;
using std::max;
using std::min;
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"));
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()));
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()));
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()));
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()),
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()));
show_decoder_selector(&session_);
}
+void MainBar::on_add_math_signal_clicked()
+{
+ shared_ptr<data::SignalBase> signal = make_shared<data::MathSignal>(session_);
+ session_.add_generated_signal(signal);
+}
+
void MainBar::add_toolbar_widgets()
{
addWidget(new_view_button_);
addSeparator();
addWidget(add_decoder_button_);
#endif
+ addWidget(add_math_signal_button_);
}
bool MainBar::eventFilter(QObject *watched, QEvent *event)