]> sigrok.org Git - pulseview.git/blame - pv/toolbars/samplingbar.h
Use a generic approach when adding the "close on enter" hook for popups
[pulseview.git] / pv / toolbars / samplingbar.h
CommitLineData
d4984fe7 1/*
b3f22de0 2 * This file is part of the PulseView project.
d4984fe7
JH
3 *
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
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
f4c92e1c
JH
21#ifndef PULSEVIEW_PV_TOOLBARS_SAMPLINGBAR_H
22#define PULSEVIEW_PV_TOOLBARS_SAMPLINGBAR_H
d4984fe7 23
dde1a563
JH
24#include <stdint.h>
25
18203d86 26#include <list>
19adbc2c 27#include <map>
f9abf97e 28#include <memory>
18203d86 29
6fb67b27 30#include <QComboBox>
dde1a563 31#include <QDoubleSpinBox>
d4984fe7 32#include <QToolBar>
dde1a563
JH
33#include <QToolButton>
34
2b49eeb0 35#include <pv/sigsession.h>
51d4a9ab 36#include <pv/widgets/popuptoolbutton.h>
1198b887 37#include <pv/widgets/sweeptimingwidget.h>
2b49eeb0 38
dde1a563 39class QAction;
d4984fe7 40
51e77110 41namespace pv {
aca00b1e
JH
42
43class SigSession;
44
94574501
JH
45namespace device {
46class DevInst;
47}
48
f4c92e1c 49namespace toolbars {
51e77110 50
d4984fe7
JH
51class SamplingBar : public QToolBar
52{
53 Q_OBJECT
54
215f9499 55private:
b50ef520
JH
56 static const uint64_t MinSampleCount;
57 static const uint64_t MaxSampleCount;
58 static const uint64_t DefaultSampleCount;
215f9499 59
d4984fe7 60public:
aca00b1e 61 SamplingBar(SigSession &session, QWidget *parent);
6fb67b27 62
19adbc2c 63 void set_device_list(
f9abf97e 64 const std::list< std::shared_ptr<pv::device::DevInst> >
e95e8563 65 &devices,
f9abf97e 66 std::shared_ptr<pv::device::DevInst> selected);
18203d86 67
f9abf97e 68 std::shared_ptr<pv::device::DevInst> get_selected_device() const;
18203d86 69
2b49eeb0 70 void set_capture_state(pv::SigSession::capture_state state);
6ac96c2e 71
e9213170 72Q_SIGNALS:
274d4f13
JH
73 void run_stop();
74
6fb67b27 75private:
dde1a563 76 void update_sample_rate_selector();
48888313 77 void update_sample_rate_selector_value();
85756012 78 void update_sample_count_selector();
e95e8563 79 void update_device_config_widgets();
48888313 80 void commit_sample_rate();
124d97de 81 void commit_sample_count();
dde1a563 82
e9213170 83private Q_SLOTS:
dde1a563 84 void on_device_selected();
124d97de 85 void on_sample_count_changed();
48888313 86 void on_sample_rate_changed();
9f3d12f3 87 void on_run_stop();
6fb67b27 88
82afd5e3
JH
89 void on_config_changed();
90
40065ab6
JS
91protected:
92 bool eventFilter(QObject *watched, QEvent *event);
93
6fb67b27 94private:
aca00b1e
JH
95 SigSession &_session;
96
6fb67b27 97 QComboBox _device_selector;
f9abf97e 98 std::map<const sr_dev_inst*, std::weak_ptr<device::DevInst> >
19adbc2c 99 _device_selector_map;
95237c18 100 bool _updating_device_selector;
51d4a9ab
JH
101
102 pv::widgets::PopupToolButton _configure_button;
b3e8a5d8 103 QAction *_configure_button_action;
b7b659aa 104
6ac6242b 105 pv::widgets::PopupToolButton _channels_button;
dde1a563 106
124d97de 107 pv::widgets::SweepTimingWidget _sample_count;
1198b887
JH
108 pv::widgets::SweepTimingWidget _sample_rate;
109 bool _updating_sample_rate;
85756012 110 bool _updating_sample_count;
274d4f13 111
6546a6a7
ML
112 bool _sample_count_supported;
113
2b49eeb0 114 QIcon _icon_red;
f5798068
JH
115 QIcon _icon_green;
116 QIcon _icon_grey;
274d4f13 117 QToolButton _run_stop_button;
d4984fe7
JH
118};
119
f4c92e1c 120} // namespace toolbars
51e77110
JH
121} // namespace pv
122
f4c92e1c 123#endif // PULSEVIEW_PV_TOOLBARS_SAMPLINGBAR_H