]> sigrok.org Git - pulseview.git/blame - pv/toolbars/mainbar.cpp
View: Update signals without destroying layout
[pulseview.git] / pv / toolbars / mainbar.cpp
CommitLineData
d4984fe7 1/*
b3f22de0 2 * This file is part of the PulseView project.
d4984fe7 3 *
079d39ea 4 * Copyright (C) 2012-2015 Joel Holdsworth <joel@airwebreathe.org.uk>
d4984fe7
JH
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
09f5d123 21#include <extdef.h>
dde1a563 22
079d39ea
JH
23#include <algorithm>
24#include <cassert>
215f9499 25
dde1a563 26#include <QAction>
48888313 27#include <QDebug>
40065ab6 28#include <QHelpEvent>
87f0df9b 29#include <QMenu>
40065ab6 30#include <QToolTip>
dde1a563 31
7c657094 32#include "mainbar.hpp"
d4984fe7 33
2acdb232 34#include <pv/devicemanager.hpp>
da30ecb7 35#include <pv/devices/hardwaredevice.hpp>
4e7f5ba8 36#include <pv/mainwindow.hpp>
2acdb232
JH
37#include <pv/popups/deviceoptions.hpp>
38#include <pv/popups/channels.hpp>
39#include <pv/util.hpp>
998b89fd 40#include <pv/widgets/exportmenu.hpp>
ed43ef2e 41#include <pv/widgets/importmenu.hpp>
cdb50f67 42
fe3a1c21 43#include <libsigrokcxx/libsigrokcxx.hpp>
e8d00928 44
079d39ea
JH
45using std::back_inserter;
46using std::copy;
47using std::list;
19adbc2c 48using std::map;
b50ef520
JH
49using std::max;
50using std::min;
f9abf97e 51using std::shared_ptr;
819f4c25 52using std::string;
079d39ea 53using std::vector;
dd63af74 54
e8d00928
ML
55using sigrok::Capability;
56using sigrok::ConfigKey;
e8d00928 57using sigrok::Error;
ed43ef2e 58using sigrok::InputFormat;
e8d00928 59
51e77110 60namespace pv {
f4c92e1c 61namespace toolbars {
51e77110 62
7c657094
JH
63const uint64_t MainBar::MinSampleCount = 100ULL;
64const uint64_t MainBar::MaxSampleCount = 1000000000000ULL;
65const uint64_t MainBar::DefaultSampleCount = 1000000;
09f5d123 66
7c657094 67MainBar::MainBar(Session &session, MainWindow &main_window) :
4e7f5ba8 68 QToolBar("Sampling Bar", &main_window),
8dbbc7f0 69 session_(session),
4e7f5ba8 70 main_window_(main_window),
079d39ea
JH
71 device_selector_(this, session.device_manager(),
72 main_window.action_connect()),
8dbbc7f0 73 configure_button_(this),
4c60462b 74 configure_button_action_(nullptr),
8dbbc7f0 75 channels_button_(this),
9dd88889 76 channels_button_action_(nullptr),
8dbbc7f0
JH
77 sample_count_(" samples", this),
78 sample_rate_("Hz", this),
79 updating_sample_rate_(false),
80 updating_sample_count_(false),
81 sample_count_supported_(false),
82 icon_red_(":/icons/status-red.svg"),
83 icon_green_(":/icons/status-green.svg"),
84 icon_grey_(":/icons/status-grey.svg"),
87f0df9b 85 run_stop_button_(this),
9dd88889 86 run_stop_button_action_(nullptr),
87f0df9b 87 menu_button_(this)
6fb67b27 88{
7c657094 89 setObjectName(QString::fromUtf8("MainBar"));
0c7cdea2 90
f2dbf150
JH
91 setMovable(false);
92 setFloatable(false);
758f6023 93 setContextMenuPolicy(Qt::PreventContextMenu);
f2dbf150 94
ed43ef2e
JH
95 // Open button
96 QToolButton *const open_button = new QToolButton(this);
97
98 widgets::ImportMenu *import_menu = new widgets::ImportMenu(this,
99 session.device_manager().context(),
100 main_window.action_open());
101 connect(import_menu,
102 SIGNAL(format_selected(std::shared_ptr<sigrok::InputFormat>)),
103 &main_window_,
104 SLOT(import_file(std::shared_ptr<sigrok::InputFormat>)));
105
106 open_button->setMenu(import_menu);
107 open_button->setDefaultAction(main_window.action_open());
108 open_button->setPopupMode(QToolButton::MenuButtonPopup);
109
998b89fd
JH
110 // Save button
111 QToolButton *const save_button = new QToolButton(this);
112
113 widgets::ExportMenu *export_menu = new widgets::ExportMenu(this,
114 session.device_manager().context(),
115 main_window.action_save_as());
116 connect(export_menu,
117 SIGNAL(format_selected(std::shared_ptr<sigrok::OutputFormat>)),
118 &main_window_,
119 SLOT(export_file(std::shared_ptr<sigrok::OutputFormat>)));
120
121 save_button->setMenu(export_menu);
122 save_button->setDefaultAction(main_window.action_save_as());
123 save_button->setPopupMode(QToolButton::MenuButtonPopup);
124
079d39ea
JH
125 // Device selector menu
126 connect(&device_selector_, SIGNAL(device_selected()),
127 this, SLOT(on_device_selected()));
128
168888e2
JH
129 // Setup the decoder button
130#ifdef ENABLE_DECODE
131 QToolButton *add_decoder_button = new QToolButton(this);
132 add_decoder_button->setIcon(QIcon::fromTheme("add-decoder",
133 QIcon(":/icons/add-decoder.svg")));
134 add_decoder_button->setPopupMode(QToolButton::InstantPopup);
135 add_decoder_button->setMenu(main_window_.menu_decoder_add());
136#endif
137
87f0df9b
JH
138 // Setup the menu
139 QMenu *const menu = new QMenu(this);
140
141 QMenu *const menu_help = new QMenu;
142 menu_help->setTitle(tr("&Help"));
143 menu_help->addAction(main_window.action_about());
144
145 menu->addAction(menu_help->menuAction());
146 menu->addSeparator();
147 menu->addAction(main_window.action_quit());
148
149 menu_button_.setMenu(menu);
150 menu_button_.setPopupMode(QToolButton::InstantPopup);
151 menu_button_.setIcon(QIcon::fromTheme("menu",
152 QIcon(":/icons/menu.svg")));
153
154 // Setup the toolbar
ed43ef2e 155 addWidget(open_button);
998b89fd 156 addWidget(save_button);
87f0df9b
JH
157 addSeparator();
158 addAction(main_window.action_view_zoom_in());
159 addAction(main_window.action_view_zoom_out());
160 addAction(main_window.action_view_zoom_fit());
161 addAction(main_window.action_view_zoom_one_to_one());
162 addSeparator();
bdf57963
JH
163 addAction(main_window.action_view_show_cursors());
164 addSeparator();
87f0df9b 165
8dbbc7f0 166 connect(&run_stop_button_, SIGNAL(clicked()),
9f3d12f3 167 this, SLOT(on_run_stop()));
8dbbc7f0 168 connect(&sample_count_, SIGNAL(value_changed()),
124d97de 169 this, SLOT(on_sample_count_changed()));
8dbbc7f0 170 connect(&sample_rate_, SIGNAL(value_changed()),
1198b887 171 this, SLOT(on_sample_rate_changed()));
dde1a563 172
8dbbc7f0 173 sample_count_.show_min_max_step(0, UINT64_MAX, 1);
215f9499 174
2b81ae46 175 set_capture_state(pv::Session::Stopped);
274d4f13 176
8dbbc7f0 177 configure_button_.setIcon(QIcon::fromTheme("configure",
688ef645 178 QIcon(":/icons/configure.png")));
b7b659aa 179
8dbbc7f0 180 channels_button_.setIcon(QIcon::fromTheme("channels",
6ac6242b 181 QIcon(":/icons/channels.svg")));
cdb50f67 182
8dbbc7f0 183 run_stop_button_.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
f5798068 184
8dbbc7f0
JH
185 addWidget(&device_selector_);
186 configure_button_action_ = addWidget(&configure_button_);
9dd88889 187 channels_button_action_ = addWidget(&channels_button_);
8dbbc7f0
JH
188 addWidget(&sample_count_);
189 addWidget(&sample_rate_);
9dd88889 190 run_stop_button_action_ = addWidget(&run_stop_button_);
168888e2
JH
191#ifdef ENABLE_DECODE
192 addSeparator();
193 addWidget(add_decoder_button);
194#endif
40065ab6 195
87f0df9b
JH
196 QWidget *const spacer = new QWidget();
197 spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
198 addWidget(spacer);
199
200 addWidget(&menu_button_);
201
8dbbc7f0
JH
202 sample_count_.installEventFilter(this);
203 sample_rate_.installEventFilter(this);
6fb67b27
JH
204}
205
079d39ea 206void MainBar::update_device_list()
18203d86 207{
079d39ea 208 DeviceManager &mgr = session_.device_manager();
da30ecb7
JH
209 shared_ptr<devices::Device> selected_device = session_.device();
210 list< shared_ptr<devices::Device> > devs;
e8d00928 211
079d39ea 212 copy(mgr.devices().begin(), mgr.devices().end(), back_inserter(devs));
53a7cce4 213
079d39ea
JH
214 if (std::find(devs.begin(), devs.end(), selected_device) == devs.end())
215 devs.push_back(selected_device);
e95e8563 216
079d39ea 217 device_selector_.set_device_list(devs, selected_device);
e95e8563 218 update_device_config_widgets();
18203d86
JH
219}
220
6fb67b27 221
7c657094 222void MainBar::set_capture_state(pv::Session::capture_state state)
6ac96c2e 223{
8dbbc7f0
JH
224 const QIcon *icons[] = {&icon_grey_, &icon_red_, &icon_green_};
225 run_stop_button_.setIcon(*icons[state]);
2b81ae46 226 run_stop_button_.setText((state == pv::Session::Stopped) ?
2b49eeb0 227 tr("Run") : tr("Stop"));
8dbbc7f0 228 run_stop_button_.setShortcut(QKeySequence(Qt::Key_Space));
6ac96c2e
JH
229}
230
7c657094 231void MainBar::update_sample_rate_selector()
dde1a563 232{
e8d00928
ML
233 Glib::VariantContainerBase gvar_dict;
234 GVariant *gvar_list;
4c60462b 235 const uint64_t *elements = nullptr;
488f5d3f 236 gsize num_elements;
a6ed12bf 237 map< const ConfigKey*, std::set<Capability> > keys;
dde1a563 238
9dd88889
JH
239 if (updating_sample_rate_) {
240 sample_rate_.show_none();
3d4f16af 241 return;
9dd88889 242 }
3d4f16af 243
da30ecb7
JH
244 const shared_ptr<devices::Device> device =
245 device_selector_.selected_device();
e8d00928 246 if (!device)
ef4d0201
JH
247 return;
248
8dbbc7f0
JH
249 assert(!updating_sample_rate_);
250 updating_sample_rate_ = true;
1198b887 251
da30ecb7 252 const shared_ptr<sigrok::Device> sr_dev = device->device();
a6ed12bf
JH
253
254 try {
255 keys = sr_dev->config_keys(ConfigKey::DEVICE_OPTIONS);
256 } catch (Error) {}
257
ed1d9d81
JH
258 const auto iter = keys.find(ConfigKey::SAMPLERATE);
259 if (iter != keys.end() &&
260 (*iter).second.find(sigrok::LIST) != (*iter).second.end()) {
c2db8ec3 261 try {
da30ecb7 262 gvar_dict = sr_dev->config_list(ConfigKey::SAMPLERATE);
c2db8ec3
JH
263 } catch(const sigrok::Error &e) {
264 // Failed to enunmerate samplerate
265 (void)e;
266 }
267 }
268
0aff286e 269 if (!gvar_dict.gobj()) {
8dbbc7f0
JH
270 sample_rate_.show_none();
271 updating_sample_rate_ = false;
dde1a563 272 return;
1198b887 273 }
dde1a563 274
e8d00928 275 if ((gvar_list = g_variant_lookup_value(gvar_dict.gobj(),
1198b887
JH
276 "samplerate-steps", G_VARIANT_TYPE("at"))))
277 {
488f5d3f
BV
278 elements = (const uint64_t *)g_variant_get_fixed_array(
279 gvar_list, &num_elements, sizeof(uint64_t));
aafe53af
JH
280
281 const uint64_t min = elements[0];
282 const uint64_t max = elements[1];
283 const uint64_t step = elements[2];
284
488f5d3f 285 g_variant_unref(gvar_list);
aafe53af
JH
286
287 assert(min > 0);
288 assert(max > 0);
289 assert(max > min);
290 assert(step > 0);
291
292 if (step == 1)
8dbbc7f0 293 sample_rate_.show_125_list(min, max);
aafe53af
JH
294 else
295 {
296 // When the step is not 1, we cam't make a 1-2-5-10
297 // list of sample rates, because we may not be able to
298 // make round numbers. Therefore in this case, show a
299 // spin box.
8dbbc7f0 300 sample_rate_.show_min_max_step(min, max, step);
aafe53af 301 }
dde1a563 302 }
e8d00928 303 else if ((gvar_list = g_variant_lookup_value(gvar_dict.gobj(),
488f5d3f 304 "samplerates", G_VARIANT_TYPE("at"))))
dde1a563 305 {
488f5d3f
BV
306 elements = (const uint64_t *)g_variant_get_fixed_array(
307 gvar_list, &num_elements, sizeof(uint64_t));
8dbbc7f0 308 sample_rate_.show_list(elements, num_elements);
488f5d3f 309 g_variant_unref(gvar_list);
dde1a563 310 }
8dbbc7f0 311 updating_sample_rate_ = false;
48888313
JH
312
313 update_sample_rate_selector_value();
314}
315
7c657094 316void MainBar::update_sample_rate_selector_value()
48888313 317{
8dbbc7f0 318 if (updating_sample_rate_)
3d4f16af
JH
319 return;
320
da30ecb7
JH
321 const shared_ptr<devices::Device> device =
322 device_selector_.selected_device();
e8d00928 323 if (!device)
19adbc2c
JH
324 return;
325
e8d00928 326 try {
da30ecb7 327 auto gvar = device->device()->config_get(ConfigKey::SAMPLERATE);
e8d00928 328 uint64_t samplerate =
15289d5c 329 Glib::VariantBase::cast_dynamic<Glib::Variant<guint64>>(gvar).get();
8dbbc7f0
JH
330 assert(!updating_sample_rate_);
331 updating_sample_rate_ = true;
332 sample_rate_.set_value(samplerate);
333 updating_sample_rate_ = false;
e8d00928 334 } catch (Error error) {
8dd44190 335 qDebug() << "WARNING: Failed to get value of sample rate";
eb4008a6
JH
336 return;
337 }
48888313
JH
338}
339
7c657094 340void MainBar::update_sample_count_selector()
85756012 341{
8dbbc7f0 342 if (updating_sample_count_)
3d4f16af
JH
343 return;
344
da30ecb7
JH
345 const shared_ptr<devices::Device> device =
346 device_selector_.selected_device();
e8d00928 347 if (!device)
19adbc2c
JH
348 return;
349
da30ecb7
JH
350 const shared_ptr<sigrok::Device> sr_dev = device->device();
351
8dbbc7f0
JH
352 assert(!updating_sample_count_);
353 updating_sample_count_ = true;
85756012 354
3e7636f9 355 if (!sample_count_supported_)
df3c1aa3 356 {
3e7636f9
JH
357 sample_count_.show_none();
358 updating_sample_count_ = false;
359 return;
360 }
b50ef520 361
3e7636f9
JH
362 uint64_t sample_count = sample_count_.value();
363 uint64_t min_sample_count = 0;
364 uint64_t max_sample_count = MaxSampleCount;
3cbffdcf 365
3e7636f9
JH
366 if (sample_count == 0)
367 sample_count = DefaultSampleCount;
b50ef520 368
da30ecb7 369 const auto keys = sr_dev->config_keys(ConfigKey::DEVICE_OPTIONS);
ed1d9d81
JH
370 const auto iter = keys.find(ConfigKey::LIMIT_SAMPLES);
371 if (iter != keys.end() &&
372 (*iter).second.find(sigrok::LIST) != (*iter).second.end()) {
6454b1e9
JH
373 try {
374 auto gvar =
da30ecb7 375 sr_dev->config_list(ConfigKey::LIMIT_SAMPLES);
0aff286e 376 if (gvar.gobj())
6454b1e9
JH
377 g_variant_get(gvar.gobj(), "(tt)",
378 &min_sample_count, &max_sample_count);
379 } catch(const sigrok::Error &e) {
380 // Failed to query sample limit
381 (void)e;
382 }
ed1d9d81 383 }
1d04852f 384
3e7636f9
JH
385 min_sample_count = min(max(min_sample_count, MinSampleCount),
386 max_sample_count);
b50ef520 387
3e7636f9
JH
388 sample_count_.show_125_list(
389 min_sample_count, max_sample_count);
b50ef520 390
3e7636f9 391 try {
da30ecb7 392 auto gvar = sr_dev->config_get(ConfigKey::LIMIT_SAMPLES);
3e7636f9
JH
393 sample_count = g_variant_get_uint64(gvar.gobj());
394 if (sample_count == 0)
395 sample_count = DefaultSampleCount;
396 sample_count = min(max(sample_count, MinSampleCount),
397 max_sample_count);
398 } catch (Error error) {}
399
400 sample_count_.set_value(sample_count);
df3c1aa3 401
8dbbc7f0 402 updating_sample_count_ = false;
85756012
ML
403}
404
7c657094 405void MainBar::update_device_config_widgets()
e95e8563 406{
e95e8563
JH
407 using namespace pv::popups;
408
da30ecb7
JH
409 const shared_ptr<devices::Device> device =
410 device_selector_.selected_device();
9dd88889
JH
411
412 // Hide the widgets if no device is selected
413 channels_button_action_->setVisible(!!device);
414 run_stop_button_action_->setVisible(!!device);
415 if (!device) {
416 configure_button_action_->setVisible(false);
417 sample_count_.show_none();
418 sample_rate_.show_none();
e95e8563 419 return;
9dd88889 420 }
e95e8563 421
da30ecb7
JH
422 const shared_ptr<sigrok::Device> sr_dev = device->device();
423 if (!sr_dev)
424 return;
425
e95e8563 426 // Update the configure popup
da30ecb7 427 DeviceOptions *const opts = new DeviceOptions(sr_dev, this);
8dbbc7f0 428 configure_button_action_->setVisible(
e95e8563 429 !opts->binding().properties().empty());
8dbbc7f0 430 configure_button_.set_popup(opts);
e95e8563 431
6ac6242b 432 // Update the channels popup
8dbbc7f0
JH
433 Channels *const channels = new Channels(session_, this);
434 channels_button_.set_popup(channels);
e95e8563
JH
435
436 // Update supported options.
8dbbc7f0 437 sample_count_supported_ = false;
e95e8563 438
e8d00928 439 try {
da30ecb7 440 for (auto entry : sr_dev->config_keys(ConfigKey::DEVICE_OPTIONS))
e95e8563 441 {
e8d00928
ML
442 auto key = entry.first;
443 auto capabilities = entry.second;
444 switch (key->id()) {
e95e8563 445 case SR_CONF_LIMIT_SAMPLES:
e8d00928 446 if (capabilities.count(Capability::SET))
8dbbc7f0 447 sample_count_supported_ = true;
e95e8563
JH
448 break;
449 case SR_CONF_LIMIT_FRAMES:
e8d00928
ML
450 if (capabilities.count(Capability::SET))
451 {
da30ecb7 452 sr_dev->config_set(ConfigKey::LIMIT_FRAMES,
15289d5c 453 Glib::Variant<guint64>::create(1));
e8d00928
ML
454 on_config_changed();
455 }
456 break;
457 default:
e95e8563
JH
458 break;
459 }
460 }
e8d00928 461 } catch (Error error) {}
e95e8563
JH
462
463 // Add notification of reconfigure events
464 disconnect(this, SLOT(on_config_changed()));
e8d00928 465 connect(&opts->binding(), SIGNAL(config_changed()),
e95e8563
JH
466 this, SLOT(on_config_changed()));
467
468 // Update sweep timing widgets.
469 update_sample_count_selector();
470 update_sample_rate_selector();
471}
472
7c657094 473void MainBar::commit_sample_count()
124d97de
ML
474{
475 uint64_t sample_count = 0;
476
8dbbc7f0 477 if (updating_sample_count_)
3d4f16af
JH
478 return;
479
da30ecb7
JH
480 const shared_ptr<devices::Device> device =
481 device_selector_.selected_device();
e8d00928 482 if (!device)
19adbc2c
JH
483 return;
484
da30ecb7
JH
485 const shared_ptr<sigrok::Device> sr_dev = device->device();
486
8dbbc7f0 487 sample_count = sample_count_.value();
124d97de
ML
488
489 // Set the sample count
8dbbc7f0
JH
490 assert(!updating_sample_count_);
491 updating_sample_count_ = true;
492 if (sample_count_supported_)
e8d00928
ML
493 {
494 try {
da30ecb7 495 sr_dev->config_set(ConfigKey::LIMIT_SAMPLES,
15289d5c 496 Glib::Variant<guint64>::create(sample_count));
e8d00928
ML
497 on_config_changed();
498 } catch (Error error) {
499 qDebug() << "Failed to configure sample count.";
500 return;
501 }
124d97de 502 }
8dbbc7f0 503 updating_sample_count_ = false;
124d97de
ML
504}
505
7c657094 506void MainBar::commit_sample_rate()
48888313
JH
507{
508 uint64_t sample_rate = 0;
509
8dbbc7f0 510 if (updating_sample_rate_)
3d4f16af
JH
511 return;
512
da30ecb7
JH
513 const shared_ptr<devices::Device> device =
514 device_selector_.selected_device();
e8d00928 515 if (!device)
19adbc2c
JH
516 return;
517
da30ecb7
JH
518 const shared_ptr<sigrok::Device> sr_dev = device->device();
519
8dbbc7f0 520 sample_rate = sample_rate_.value();
f9541bde
JH
521 if (sample_rate == 0)
522 return;
523
48888313 524 // Set the samplerate
8dbbc7f0
JH
525 assert(!updating_sample_rate_);
526 updating_sample_rate_ = true;
e8d00928 527 try {
da30ecb7 528 sr_dev->config_set(ConfigKey::SAMPLERATE,
15289d5c 529 Glib::Variant<guint64>::create(sample_rate));
e8d00928
ML
530 on_config_changed();
531 } catch (Error error) {
48888313
JH
532 qDebug() << "Failed to configure samplerate.";
533 return;
534 }
8dbbc7f0 535 updating_sample_rate_ = false;
dde1a563
JH
536}
537
7c657094 538void MainBar::on_device_selected()
dde1a563 539{
da30ecb7 540 shared_ptr<devices::Device> device = device_selector_.selected_device();
e8d00928 541 if (!device)
19adbc2c
JH
542 return;
543
51cf49fe 544 main_window_.select_device(device);
51d4a9ab 545
e95e8563 546 update_device_config_widgets();
dde1a563 547}
51e77110 548
7c657094 549void MainBar::on_sample_count_changed()
124d97de 550{
3d4f16af 551 commit_sample_count();
124d97de
ML
552}
553
7c657094 554void MainBar::on_sample_rate_changed()
48888313 555{
3d4f16af 556 commit_sample_rate();
48888313
JH
557}
558
7c657094 559void MainBar::on_run_stop()
9f3d12f3 560{
b50ef520 561 commit_sample_count();
9f3d12f3 562 commit_sample_rate();
4e7f5ba8 563 main_window_.run_stop();
9f3d12f3
JH
564}
565
7c657094 566void MainBar::on_config_changed()
82afd5e3
JH
567{
568 commit_sample_count();
569 update_sample_count_selector();
570 commit_sample_rate();
571 update_sample_rate_selector();
572}
573
7c657094 574bool MainBar::eventFilter(QObject *watched, QEvent *event)
40065ab6 575{
8dbbc7f0 576 if ((watched == &sample_count_ || watched == &sample_rate_) &&
40065ab6 577 (event->type() == QEvent::ToolTip)) {
8dbbc7f0 578 double sec = (double)sample_count_.value() / sample_rate_.value();
40065ab6 579 QHelpEvent *help_event = static_cast<QHelpEvent*>(event);
62974f45
JS
580
581 QString str = tr("Total sampling time: %1").arg(pv::util::format_second(sec));
40065ab6
JS
582 QToolTip::showText(help_event->globalPos(), str);
583
584 return true;
585 }
586
587 return false;
588}
589
f4c92e1c 590} // namespace toolbars
51e77110 591} // namespace pv