]>
Commit | Line | Data |
---|---|---|
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_MAINBAR_HPP | |
22 | #define PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP | |
23 | ||
24 | #include <stdint.h> | |
25 | ||
26 | #include <list> | |
27 | #include <memory> | |
28 | ||
29 | #include <glibmm/variant.h> | |
30 | ||
31 | #include <QComboBox> | |
32 | #include <QDoubleSpinBox> | |
33 | #include <QMenu> | |
34 | #include <QToolBar> | |
35 | #include <QToolButton> | |
36 | ||
37 | #include <pv/session.hpp> | |
38 | #include <pv/widgets/devicetoolbutton.hpp> | |
39 | #include <pv/widgets/popuptoolbutton.hpp> | |
40 | #include <pv/widgets/sweeptimingwidget.hpp> | |
41 | ||
42 | namespace sigrok { | |
43 | class Device; | |
44 | class InputFormat; | |
45 | class OutputFormat; | |
46 | } | |
47 | ||
48 | Q_DECLARE_METATYPE(std::shared_ptr<sigrok::Device>) | |
49 | ||
50 | class QAction; | |
51 | ||
52 | namespace pv { | |
53 | ||
54 | class MainWindow; | |
55 | class Session; | |
56 | ||
57 | namespace toolbars { | |
58 | ||
59 | class MainBar : public QToolBar | |
60 | { | |
61 | Q_OBJECT | |
62 | ||
63 | private: | |
64 | static const uint64_t MinSampleCount; | |
65 | static const uint64_t MaxSampleCount; | |
66 | static const uint64_t DefaultSampleCount; | |
67 | ||
68 | /** | |
69 | * Name of the setting used to remember the directory | |
70 | * containing the last file that was opened. | |
71 | */ | |
72 | static const char *SettingOpenDirectory; | |
73 | ||
74 | /** | |
75 | * Name of the setting used to remember the directory | |
76 | * containing the last file that was saved. | |
77 | */ | |
78 | static const char *SettingSaveDirectory; | |
79 | ||
80 | public: | |
81 | MainBar(Session &session, pv::MainWindow &main_window); | |
82 | ||
83 | Session &session(void) const; | |
84 | ||
85 | void update_device_list(); | |
86 | ||
87 | void set_capture_state(pv::Session::capture_state state); | |
88 | ||
89 | void reset_device_selector(); | |
90 | ||
91 | void select_device(std::shared_ptr<devices::Device> device); | |
92 | ||
93 | void load_init_file(const std::string &file_name, | |
94 | const std::string &format); | |
95 | ||
96 | QAction* action_open() const; | |
97 | QAction* action_save_as() const; | |
98 | QAction* action_save_selection_as() const; | |
99 | QAction* action_connect() const; | |
100 | QAction* action_quit() const; | |
101 | QAction* action_view_zoom_in() const; | |
102 | QAction* action_view_zoom_out() const; | |
103 | QAction* action_view_zoom_fit() const; | |
104 | QAction* action_view_zoom_one_to_one() const; | |
105 | QAction* action_view_show_cursors() const; | |
106 | ||
107 | private: | |
108 | void run_stop(); | |
109 | ||
110 | void select_init_device(); | |
111 | ||
112 | void load_file(QString file_name, | |
113 | std::shared_ptr<sigrok::InputFormat> format = nullptr, | |
114 | const std::map<std::string, Glib::VariantBase> &options = | |
115 | std::map<std::string, Glib::VariantBase>()); | |
116 | ||
117 | void save_selection_to_file(); | |
118 | ||
119 | void update_sample_rate_selector(); | |
120 | void update_sample_rate_selector_value(); | |
121 | void update_sample_count_selector(); | |
122 | void update_device_config_widgets(); | |
123 | void commit_sample_rate(); | |
124 | void commit_sample_count(); | |
125 | ||
126 | void session_error(const QString text, const QString info_text); | |
127 | ||
128 | QAction *const action_open_; | |
129 | QAction *const action_save_as_; | |
130 | QAction *const action_save_selection_as_; | |
131 | QAction *const action_connect_; | |
132 | QAction *const action_view_zoom_in_; | |
133 | QAction *const action_view_zoom_out_; | |
134 | QAction *const action_view_zoom_fit_; | |
135 | QAction *const action_view_zoom_one_to_one_; | |
136 | QAction *const action_view_show_cursors_; | |
137 | ||
138 | private Q_SLOTS: | |
139 | void show_session_error(const QString text, const QString info_text); | |
140 | ||
141 | void capture_state_changed(int state); | |
142 | ||
143 | void add_decoder(srd_decoder *decoder); | |
144 | ||
145 | void export_file(std::shared_ptr<sigrok::OutputFormat> format, | |
146 | bool selection_only = false); | |
147 | void import_file(std::shared_ptr<sigrok::InputFormat> format); | |
148 | ||
149 | void on_device_selected(); | |
150 | void on_device_changed(); | |
151 | void on_sample_count_changed(); | |
152 | void on_sample_rate_changed(); | |
153 | void on_run_stop(); | |
154 | ||
155 | void on_config_changed(); | |
156 | ||
157 | void on_actionOpen_triggered(); | |
158 | void on_actionSaveAs_triggered(); | |
159 | void on_actionSaveSelectionAs_triggered(); | |
160 | ||
161 | void on_actionConnect_triggered(); | |
162 | ||
163 | void on_actionViewZoomIn_triggered(); | |
164 | ||
165 | void on_actionViewZoomOut_triggered(); | |
166 | ||
167 | void on_actionViewZoomFit_triggered(); | |
168 | ||
169 | void on_actionViewZoomOneToOne_triggered(); | |
170 | ||
171 | void on_actionViewShowCursors_triggered(); | |
172 | ||
173 | protected: | |
174 | bool eventFilter(QObject *watched, QEvent *event); | |
175 | ||
176 | private: | |
177 | Session &session_; | |
178 | ||
179 | pv::widgets::DeviceToolButton device_selector_; | |
180 | ||
181 | pv::widgets::PopupToolButton configure_button_; | |
182 | QAction *configure_button_action_; | |
183 | ||
184 | pv::widgets::PopupToolButton channels_button_; | |
185 | QAction *channels_button_action_; | |
186 | ||
187 | pv::widgets::SweepTimingWidget sample_count_; | |
188 | pv::widgets::SweepTimingWidget sample_rate_; | |
189 | bool updating_sample_rate_; | |
190 | bool updating_sample_count_; | |
191 | ||
192 | bool sample_count_supported_; | |
193 | ||
194 | QIcon icon_red_; | |
195 | QIcon icon_green_; | |
196 | QIcon icon_grey_; | |
197 | QToolButton run_stop_button_; | |
198 | QAction *run_stop_button_action_; | |
199 | ||
200 | QToolButton menu_button_; | |
201 | ||
202 | #ifdef ENABLE_DECODE | |
203 | QMenu *const menu_decoders_add_; | |
204 | #endif | |
205 | }; | |
206 | ||
207 | } // namespace toolbars | |
208 | } // namespace pv | |
209 | ||
210 | #endif // PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP |