projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
decodetrace.cpp: Drop unused "using std::all_of".
[pulseview.git]
/
pv
/
toolbars
/
mainbar.cpp
diff --git
a/pv/toolbars/mainbar.cpp
b/pv/toolbars/mainbar.cpp
index 34b120fec11ce0ec14bf21f16cc717e7b9d74222..3c8b71e2f7b59a8162fcf39f23135c2d819cd46b 100644
(file)
--- a/
pv/toolbars/mainbar.cpp
+++ b/
pv/toolbars/mainbar.cpp
@@
-87,8
+87,7
@@
const uint64_t MainBar::DefaultSampleCount = 1000000;
const char *MainBar::SettingOpenDirectory = "MainWindow/OpenDirectory";
const char *MainBar::SettingSaveDirectory = "MainWindow/SaveDirectory";
const char *MainBar::SettingOpenDirectory = "MainWindow/OpenDirectory";
const char *MainBar::SettingSaveDirectory = "MainWindow/SaveDirectory";
-MainBar::MainBar(Session &session, QWidget *parent,
- pv::views::trace::View *view) :
+MainBar::MainBar(Session &session, QWidget *parent, pv::views::trace::View *view) :
StandardBar(session, parent, view, false),
action_new_view_(new QAction(this)),
action_open_(new QAction(this)),
StandardBar(session, parent, view, false),
action_new_view_(new QAction(this)),
action_open_(new QAction(this)),
@@
-97,8
+96,7
@@
MainBar::MainBar(Session &session, QWidget *parent,
action_connect_(new QAction(this)),
open_button_(new QToolButton()),
save_button_(new QToolButton()),
action_connect_(new QAction(this)),
open_button_(new QToolButton()),
save_button_(new QToolButton()),
- device_selector_(parent, session.device_manager(),
- action_connect_),
+ device_selector_(parent, session.device_manager(), action_connect_),
configure_button_(this),
configure_button_action_(nullptr),
channels_button_(this),
configure_button_(this),
configure_button_action_(nullptr),
channels_button_(this),
@@
-148,15
+146,13
@@
MainBar::MainBar(Session &session, QWidget *parent,
widgets::ExportMenu *menu_file_export = new widgets::ExportMenu(this,
session.device_manager().context());
menu_file_export->setTitle(tr("&Export"));
widgets::ExportMenu *menu_file_export = new widgets::ExportMenu(this,
session.device_manager().context());
menu_file_export->setTitle(tr("&Export"));
- connect(menu_file_export,
- SIGNAL(format_selected(shared_ptr<sigrok::OutputFormat>)),
+ connect(menu_file_export, SIGNAL(format_selected(shared_ptr<sigrok::OutputFormat>)),
this, SLOT(export_file(shared_ptr<sigrok::OutputFormat>)));
widgets::ImportMenu *menu_file_import = new widgets::ImportMenu(this,
session.device_manager().context());
menu_file_import->setTitle(tr("&Import"));
this, SLOT(export_file(shared_ptr<sigrok::OutputFormat>)));
widgets::ImportMenu *menu_file_import = new widgets::ImportMenu(this,
session.device_manager().context());
menu_file_import->setTitle(tr("&Import"));
- connect(menu_file_import,
- SIGNAL(format_selected(shared_ptr<sigrok::InputFormat>)),
+ connect(menu_file_import, SIGNAL(format_selected(shared_ptr<sigrok::InputFormat>)),
this, SLOT(import_file(shared_ptr<sigrok::InputFormat>)));
action_connect_->setText(tr("&Connect to Device..."));
this, SLOT(import_file(shared_ptr<sigrok::InputFormat>)));
action_connect_->setText(tr("&Connect to Device..."));
@@
-166,27
+162,22
@@
MainBar::MainBar(Session &session, QWidget *parent,
// Open button
widgets::ImportMenu *import_menu = new widgets::ImportMenu(this,
session.device_manager().context(), action_open_);
// Open button
widgets::ImportMenu *import_menu = new widgets::ImportMenu(this,
session.device_manager().context(), action_open_);
- connect(import_menu,
- SIGNAL(format_selected(shared_ptr<sigrok::InputFormat>)),
- this,
- SLOT(import_file(shared_ptr<sigrok::InputFormat>)));
+ connect(import_menu, SIGNAL(format_selected(shared_ptr<sigrok::InputFormat>)),
+ this, SLOT(import_file(shared_ptr<sigrok::InputFormat>)));
open_button_->setMenu(import_menu);
open_button_->setDefaultAction(action_open_);
open_button_->setPopupMode(QToolButton::MenuButtonPopup);
// Save button
open_button_->setMenu(import_menu);
open_button_->setDefaultAction(action_open_);
open_button_->setPopupMode(QToolButton::MenuButtonPopup);
// Save button
- vector<QAction
*> open_actions;
+ vector<QAction*> open_actions;
open_actions.push_back(action_save_as_);
open_actions.push_back(action_save_selection_as_);
widgets::ExportMenu *export_menu = new widgets::ExportMenu(this,
open_actions.push_back(action_save_as_);
open_actions.push_back(action_save_selection_as_);
widgets::ExportMenu *export_menu = new widgets::ExportMenu(this,
- session.device_manager().context(),
- open_actions);
- connect(export_menu,
- SIGNAL(format_selected(shared_ptr<sigrok::OutputFormat>)),
- this,
- SLOT(export_file(shared_ptr<sigrok::OutputFormat>)));
+ session.device_manager().context(), open_actions);
+ connect(export_menu, SIGNAL(format_selected(shared_ptr<sigrok::OutputFormat>)),
+ this, SLOT(export_file(shared_ptr<sigrok::OutputFormat>)));
save_button_->setMenu(export_menu);
save_button_->setDefaultAction(action_save_as_);
save_button_->setMenu(export_menu);
save_button_->setDefaultAction(action_save_as_);
@@
-302,8
+293,7
@@
void MainBar::update_sample_rate_selector()
return;
}
return;
}
- const shared_ptr<devices::Device> device =
- device_selector_.selected_device();
+ const shared_ptr<devices::Device> device = device_selector_.selected_device();
if (!device)
return;
if (!device)
return;
@@
-313,7
+303,11
@@
void MainBar::update_sample_rate_selector()
const shared_ptr<sigrok::Device> sr_dev = device->device();
if (sr_dev->config_check(ConfigKey::SAMPLERATE, Capability::LIST)) {
const shared_ptr<sigrok::Device> sr_dev = device->device();
if (sr_dev->config_check(ConfigKey::SAMPLERATE, Capability::LIST)) {
- gvar_dict = sr_dev->config_list(ConfigKey::SAMPLERATE);
+ try {
+ gvar_dict = sr_dev->config_list(ConfigKey::SAMPLERATE);
+ } catch (Error& error) {
+ qDebug() << tr("Failed to get sample rate list:") << error.what();
+ }
} else {
sample_rate_.show_none();
updating_sample_rate_ = false;
} else {
sample_rate_.show_none();
updating_sample_rate_ = false;
@@
-323,7
+317,7
@@
void MainBar::update_sample_rate_selector()
if ((gvar_list = g_variant_lookup_value(gvar_dict.gobj(),
"samplerate-steps", G_VARIANT_TYPE("at")))) {
elements = (const uint64_t *)g_variant_get_fixed_array(
if ((gvar_list = g_variant_lookup_value(gvar_dict.gobj(),
"samplerate-steps", G_VARIANT_TYPE("at")))) {
elements = (const uint64_t *)g_variant_get_fixed_array(
-
gvar_list, &num_elements, sizeof(uint64_t));
+ gvar_list, &num_elements, sizeof(uint64_t));
const uint64_t min = elements[0];
const uint64_t max = elements[1];
const uint64_t min = elements[0];
const uint64_t max = elements[1];
@@
-348,7
+342,7
@@
void MainBar::update_sample_rate_selector()
} else if ((gvar_list = g_variant_lookup_value(gvar_dict.gobj(),
"samplerates", G_VARIANT_TYPE("at")))) {
elements = (const uint64_t *)g_variant_get_fixed_array(
} else if ((gvar_list = g_variant_lookup_value(gvar_dict.gobj(),
"samplerates", G_VARIANT_TYPE("at")))) {
elements = (const uint64_t *)g_variant_get_fixed_array(
-
gvar_list, &num_elements, sizeof(uint64_t));
+ gvar_list, &num_elements, sizeof(uint64_t));
sample_rate_.show_list(elements, num_elements);
g_variant_unref(gvar_list);
}
sample_rate_.show_list(elements, num_elements);
g_variant_unref(gvar_list);
}
@@
-362,8
+356,7
@@
void MainBar::update_sample_rate_selector_value()
if (updating_sample_rate_)
return;
if (updating_sample_rate_)
return;
- const shared_ptr<devices::Device> device =
- device_selector_.selected_device();
+ const shared_ptr<devices::Device> device = device_selector_.selected_device();
if (!device)
return;
if (!device)
return;
@@
-375,9
+368,8
@@
void MainBar::update_sample_rate_selector_value()
updating_sample_rate_ = true;
sample_rate_.set_value(samplerate);
updating_sample_rate_ = false;
updating_sample_rate_ = true;
sample_rate_.set_value(samplerate);
updating_sample_rate_ = false;
- } catch (Error error) {
- qDebug() << "WARNING: Failed to get value of sample rate";
- return;
+ } catch (Error& error) {
+ qDebug() << tr("Failed to get value of sample rate:") << error.what();
}
}
}
}
@@
-386,8
+378,7
@@
void MainBar::update_sample_count_selector()
if (updating_sample_count_)
return;
if (updating_sample_count_)
return;
- const shared_ptr<devices::Device> device =
- device_selector_.selected_device();
+ const shared_ptr<devices::Device> device = device_selector_.selected_device();
if (!device)
return;
if (!device)
return;
@@
-413,10
+404,14
@@
void MainBar::update_sample_count_selector()
}
if (sr_dev->config_check(ConfigKey::LIMIT_SAMPLES, Capability::LIST)) {
}
if (sr_dev->config_check(ConfigKey::LIMIT_SAMPLES, Capability::LIST)) {
- auto gvar = sr_dev->config_list(ConfigKey::LIMIT_SAMPLES);
- if (gvar.gobj())
- g_variant_get(gvar.gobj(), "(tt)",
- &min_sample_count, &max_sample_count);
+ try {
+ auto gvar = sr_dev->config_list(ConfigKey::LIMIT_SAMPLES);
+ if (gvar.gobj())
+ g_variant_get(gvar.gobj(), "(tt)",
+ &min_sample_count, &max_sample_count);
+ } catch (Error& error) {
+ qDebug() << tr("Failed to get sample limit list:") << error.what();
+ }
}
min_sample_count = min(max(min_sample_count, MinSampleCount),
}
min_sample_count = min(max(min_sample_count, MinSampleCount),
@@
-448,8
+443,7
@@
void MainBar::update_device_config_widgets()
{
using namespace pv::popups;
{
using namespace pv::popups;
- const shared_ptr<devices::Device> device =
- device_selector_.selected_device();
+ const shared_ptr<devices::Device> device = device_selector_.selected_device();
// Hide the widgets if no device is selected
channels_button_action_->setVisible(!!device);
// Hide the widgets if no device is selected
channels_button_action_->setVisible(!!device);
@@
-466,8
+460,7
@@
void MainBar::update_device_config_widgets()
// Update the configure popup
DeviceOptions *const opts = new DeviceOptions(sr_dev, this);
// Update the configure popup
DeviceOptions *const opts = new DeviceOptions(sr_dev, this);
- configure_button_action_->setVisible(
- !opts->binding().properties().empty());
+ configure_button_action_->setVisible(!opts->binding().properties().empty());
configure_button_.set_popup(opts);
// Update the channels popup
configure_button_.set_popup(opts);
// Update the channels popup
@@
-494,8
+487,7
@@
void MainBar::commit_sample_rate()
{
uint64_t sample_rate = 0;
{
uint64_t sample_rate = 0;
- const shared_ptr<devices::Device> device =
- device_selector_.selected_device();
+ const shared_ptr<devices::Device> device = device_selector_.selected_device();
if (!device)
return;
if (!device)
return;
@@
-509,8
+501,8
@@
void MainBar::commit_sample_rate()
sr_dev->config_set(ConfigKey::SAMPLERATE,
Glib::Variant<guint64>::create(sample_rate));
update_sample_rate_selector();
sr_dev->config_set(ConfigKey::SAMPLERATE,
Glib::Variant<guint64>::create(sample_rate));
update_sample_rate_selector();
- } catch (Error error) {
- qDebug() <<
"Failed to configure samplerate."
;
+ } catch (Error
&
error) {
+ qDebug() <<
tr("Failed to configure samplerate:") << error.what()
;
return;
}
return;
}
@@
-524,8
+516,7
@@
void MainBar::commit_sample_count()
{
uint64_t sample_count = 0;
{
uint64_t sample_count = 0;
- const shared_ptr<devices::Device> device =
- device_selector_.selected_device();
+ const shared_ptr<devices::Device> device = device_selector_.selected_device();
if (!device)
return;
if (!device)
return;
@@
-537,8
+528,8
@@
void MainBar::commit_sample_count()
sr_dev->config_set(ConfigKey::LIMIT_SAMPLES,
Glib::Variant<guint64>::create(sample_count));
update_sample_count_selector();
sr_dev->config_set(ConfigKey::LIMIT_SAMPLES,
Glib::Variant<guint64>::create(sample_count));
update_sample_count_selector();
- } catch (Error error) {
- qDebug() <<
"Failed to configure sample count."
;
+ } catch (Error
&
error) {
+ qDebug() <<
tr("Failed to configure sample count:") << error.what()
;
return;
}
}
return;
}
}
@@
-549,13
+540,6
@@
void MainBar::commit_sample_count()
update_sample_rate_selector();
}
update_sample_rate_selector();
}
-void MainBar::session_error(const QString text, const QString info_text)
-{
- QMetaObject::invokeMethod(this, "show_session_error",
- Qt::QueuedConnection, Q_ARG(QString, text),
- Q_ARG(QString, info_text));
-}
-
void MainBar::show_session_error(const QString text, const QString info_text)
{
QMessageBox msg(this);
void MainBar::show_session_error(const QString text, const QString info_text)
{
QMessageBox msg(this);
@@
-597,8
+581,8
@@
void MainBar::export_file(shared_ptr<OutputFormat> format, bool selection_only)
if (!trace_view->cursors()->enabled()) {
show_session_error(tr("Missing Cursors"), tr("You need to set the " \
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 the Show Cursors button)."));
+ "cursors before you can save the data enclosed by them " \
+ "to a session file (e.g. using the Show Cursors button)."));
return;
}
return;
}
@@
-615,7
+599,7
@@
void MainBar::export_file(shared_ptr<OutputFormat> format, bool selection_only)
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 " \
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."));
+ "define a valid range of samples."));
return;
}
return;
}
@@
-713,12
+697,11
@@
void MainBar::import_file(shared_ptr<InputFormat> format)
void MainBar::on_device_selected()
{
shared_ptr<devices::Device> device = device_selector_.selected_device();
void MainBar::on_device_selected()
{
shared_ptr<devices::Device> device = device_selector_.selected_device();
- if (!device) {
- reset_device_selector();
- return;
- }
- session_.select_device(device);
+ if (device)
+ session_.select_device(device);
+ else
+ reset_device_selector();
}
void MainBar::on_device_changed()
}
void MainBar::on_device_changed()
@@
-823,8
+806,9
@@
void MainBar::add_toolbar_widgets()
bool MainBar::eventFilter(QObject *watched, QEvent *event)
{
if (sample_count_supported_ && (watched == &sample_count_ ||
bool MainBar::eventFilter(QObject *watched, QEvent *event)
{
if (sample_count_supported_ && (watched == &sample_count_ ||
- watched == &sample_rate_) &&
- (event->type() == QEvent::ToolTip)) {
+ watched == &sample_rate_) &&
+ (event->type() == QEvent::ToolTip)) {
+
auto sec = pv::util::Timestamp(sample_count_.value()) / sample_rate_.value();
QHelpEvent *help_event = static_cast<QHelpEvent*>(event);
auto sec = pv::util::Timestamp(sample_count_.value()) / sample_rate_.value();
QHelpEvent *help_event = static_cast<QHelpEvent*>(event);