]> sigrok.org Git - pulseview.git/blame_incremental - pv/toolbars/samplingbar.hpp
SamplingBar: Use DeviceManager::get_display_name() directly
[pulseview.git] / pv / toolbars / samplingbar.hpp
... / ...
CommitLineData
1/*
2 * This file is part of the PulseView project.
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
21#ifndef PULSEVIEW_PV_TOOLBARS_SAMPLINGBAR_H
22#define PULSEVIEW_PV_TOOLBARS_SAMPLINGBAR_H
23
24#include <stdint.h>
25
26#include <list>
27#include <memory>
28
29#include <QComboBox>
30#include <QDoubleSpinBox>
31#include <QToolBar>
32#include <QToolButton>
33
34#include <pv/session.hpp>
35#include <pv/widgets/popuptoolbutton.hpp>
36#include <pv/widgets/sweeptimingwidget.hpp>
37
38namespace sigrok {
39 class Device;
40}
41
42Q_DECLARE_METATYPE(std::shared_ptr<sigrok::Device>)
43
44class QAction;
45
46namespace pv {
47
48class MainWindow;
49class Session;
50
51namespace toolbars {
52
53class SamplingBar : public QToolBar
54{
55 Q_OBJECT
56
57private:
58 static const uint64_t MinSampleCount;
59 static const uint64_t MaxSampleCount;
60 static const uint64_t DefaultSampleCount;
61
62public:
63 SamplingBar(Session &session, pv::MainWindow &main_window);
64
65 void set_device_list(
66 const std::list< std::shared_ptr<sigrok::Device> > &devices,
67 std::shared_ptr<sigrok::Device> selected);
68
69 std::shared_ptr<sigrok::Device> get_selected_device() const;
70
71 void set_capture_state(pv::Session::capture_state state);
72
73Q_SIGNALS:
74 void run_stop();
75
76private:
77 void update_sample_rate_selector();
78 void update_sample_rate_selector_value();
79 void update_sample_count_selector();
80 void update_device_config_widgets();
81 void commit_sample_rate();
82 void commit_sample_count();
83
84private Q_SLOTS:
85 void on_device_selected();
86 void on_sample_count_changed();
87 void on_sample_rate_changed();
88 void on_run_stop();
89
90 void on_config_changed();
91
92protected:
93 bool eventFilter(QObject *watched, QEvent *event);
94
95private:
96 Session &session_;
97 MainWindow &main_window_;
98
99 QComboBox device_selector_;
100 bool updating_device_selector_;
101
102 pv::widgets::PopupToolButton configure_button_;
103 QAction *configure_button_action_;
104
105 pv::widgets::PopupToolButton channels_button_;
106
107 pv::widgets::SweepTimingWidget sample_count_;
108 pv::widgets::SweepTimingWidget sample_rate_;
109 bool updating_sample_rate_;
110 bool updating_sample_count_;
111
112 bool sample_count_supported_;
113
114 QIcon icon_red_;
115 QIcon icon_green_;
116 QIcon icon_grey_;
117 QToolButton run_stop_button_;
118};
119
120} // namespace toolbars
121} // namespace pv
122
123#endif // PULSEVIEW_PV_TOOLBARS_SAMPLINGBAR_H