]>
Commit | Line | Data |
---|---|---|
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 | ||
7a01bd36 JH |
21 | #ifndef PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP |
22 | #define PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP | |
d4984fe7 | 23 | |
dde1a563 JH |
24 | #include <stdint.h> |
25 | ||
4fe06f49 | 26 | #include <list> |
f9abf97e | 27 | #include <memory> |
18203d86 | 28 | |
0f8f8c18 SA |
29 | #include <glibmm/variant.h> |
30 | ||
6fb67b27 | 31 | #include <QComboBox> |
dde1a563 | 32 | #include <QDoubleSpinBox> |
079d39ea | 33 | #include <QMenu> |
d4984fe7 | 34 | #include <QToolBar> |
dde1a563 JH |
35 | #include <QToolButton> |
36 | ||
f65cd27b | 37 | #include <pv/session.hpp> |
079d39ea | 38 | #include <pv/widgets/devicetoolbutton.hpp> |
2acdb232 JH |
39 | #include <pv/widgets/popuptoolbutton.hpp> |
40 | #include <pv/widgets/sweeptimingwidget.hpp> | |
2b49eeb0 | 41 | |
e8d00928 | 42 | namespace sigrok { |
ed43ef2e JH |
43 | class Device; |
44 | class InputFormat; | |
0f8f8c18 | 45 | class OutputFormat; |
e8d00928 ML |
46 | } |
47 | ||
48 | Q_DECLARE_METATYPE(std::shared_ptr<sigrok::Device>) | |
49 | ||
dde1a563 | 50 | class QAction; |
d4984fe7 | 51 | |
51e77110 | 52 | namespace pv { |
aca00b1e | 53 | |
4e7f5ba8 | 54 | class MainWindow; |
2b81ae46 | 55 | class Session; |
aca00b1e | 56 | |
f4c92e1c | 57 | namespace toolbars { |
51e77110 | 58 | |
7c657094 | 59 | class MainBar : public QToolBar |
d4984fe7 JH |
60 | { |
61 | Q_OBJECT | |
62 | ||
215f9499 | 63 | private: |
b50ef520 JH |
64 | static const uint64_t MinSampleCount; |
65 | static const uint64_t MaxSampleCount; | |
66 | static const uint64_t DefaultSampleCount; | |
215f9499 | 67 | |
0f8f8c18 SA |
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 | ||
d4984fe7 | 80 | public: |
101e7a9b | 81 | MainBar(Session &session, pv::MainWindow &main_window); |
0f8f8c18 SA |
82 | |
83 | Session &session(void) const; | |
6fb67b27 | 84 | |
079d39ea | 85 | void update_device_list(); |
18203d86 | 86 | |
2b81ae46 | 87 | void set_capture_state(pv::Session::capture_state state); |
6ac96c2e | 88 | |
7e0c99bf SA |
89 | void reset_device_selector(); |
90 | ||
101e7a9b SA |
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 | ||
c9da5118 SA |
96 | QAction* action_new_session() const; |
97 | QAction* action_new_view() const; | |
0f8f8c18 SA |
98 | QAction* action_open() const; |
99 | QAction* action_save_as() const; | |
100 | QAction* action_save_selection_as() const; | |
101 | QAction* action_connect() const; | |
102 | QAction* action_quit() const; | |
103 | QAction* action_view_zoom_in() const; | |
104 | QAction* action_view_zoom_out() const; | |
105 | QAction* action_view_zoom_fit() const; | |
106 | QAction* action_view_zoom_one_to_one() const; | |
107 | QAction* action_view_show_cursors() const; | |
108 | ||
6fb67b27 | 109 | private: |
0f8f8c18 SA |
110 | void run_stop(); |
111 | ||
0f8f8c18 SA |
112 | void select_init_device(); |
113 | ||
114 | void load_file(QString file_name, | |
115 | std::shared_ptr<sigrok::InputFormat> format = nullptr, | |
116 | const std::map<std::string, Glib::VariantBase> &options = | |
117 | std::map<std::string, Glib::VariantBase>()); | |
118 | ||
0f8f8c18 SA |
119 | void save_selection_to_file(); |
120 | ||
dde1a563 | 121 | void update_sample_rate_selector(); |
48888313 | 122 | void update_sample_rate_selector_value(); |
85756012 | 123 | void update_sample_count_selector(); |
e95e8563 | 124 | void update_device_config_widgets(); |
48888313 | 125 | void commit_sample_rate(); |
124d97de | 126 | void commit_sample_count(); |
dde1a563 | 127 | |
0f8f8c18 SA |
128 | void session_error(const QString text, const QString info_text); |
129 | ||
c9da5118 SA |
130 | QAction *const action_new_session_; |
131 | QAction *const action_new_view_; | |
0f8f8c18 SA |
132 | QAction *const action_open_; |
133 | QAction *const action_save_as_; | |
134 | QAction *const action_save_selection_as_; | |
135 | QAction *const action_connect_; | |
136 | QAction *const action_view_zoom_in_; | |
137 | QAction *const action_view_zoom_out_; | |
138 | QAction *const action_view_zoom_fit_; | |
139 | QAction *const action_view_zoom_one_to_one_; | |
140 | QAction *const action_view_show_cursors_; | |
141 | ||
e9213170 | 142 | private Q_SLOTS: |
0f8f8c18 SA |
143 | void show_session_error(const QString text, const QString info_text); |
144 | ||
145 | void capture_state_changed(int state); | |
146 | ||
147 | void add_decoder(srd_decoder *decoder); | |
148 | ||
149 | void export_file(std::shared_ptr<sigrok::OutputFormat> format, | |
150 | bool selection_only = false); | |
151 | void import_file(std::shared_ptr<sigrok::InputFormat> format); | |
152 | ||
dde1a563 | 153 | void on_device_selected(); |
91f8fe8c | 154 | void on_device_changed(); |
124d97de | 155 | void on_sample_count_changed(); |
48888313 | 156 | void on_sample_rate_changed(); |
9f3d12f3 | 157 | void on_run_stop(); |
6fb67b27 | 158 | |
82afd5e3 JH |
159 | void on_config_changed(); |
160 | ||
c9da5118 SA |
161 | void on_actionNewSession_triggered(); |
162 | void on_actionNewView_triggered(); | |
163 | ||
0f8f8c18 SA |
164 | void on_actionOpen_triggered(); |
165 | void on_actionSaveAs_triggered(); | |
166 | void on_actionSaveSelectionAs_triggered(); | |
167 | ||
168 | void on_actionConnect_triggered(); | |
169 | ||
170 | void on_actionViewZoomIn_triggered(); | |
171 | ||
172 | void on_actionViewZoomOut_triggered(); | |
173 | ||
174 | void on_actionViewZoomFit_triggered(); | |
175 | ||
176 | void on_actionViewZoomOneToOne_triggered(); | |
177 | ||
178 | void on_actionViewShowCursors_triggered(); | |
179 | ||
d552c5c7 SA |
180 | void on_always_zoom_to_fit_changed(bool state); |
181 | ||
40065ab6 JS |
182 | protected: |
183 | bool eventFilter(QObject *watched, QEvent *event); | |
184 | ||
c9da5118 SA |
185 | Q_SIGNALS: |
186 | void new_session(); | |
187 | void new_view(Session *session); | |
188 | ||
6fb67b27 | 189 | private: |
2b81ae46 | 190 | Session &session_; |
aca00b1e | 191 | |
079d39ea | 192 | pv::widgets::DeviceToolButton device_selector_; |
51d4a9ab | 193 | |
8dbbc7f0 JH |
194 | pv::widgets::PopupToolButton configure_button_; |
195 | QAction *configure_button_action_; | |
b7b659aa | 196 | |
8dbbc7f0 | 197 | pv::widgets::PopupToolButton channels_button_; |
9dd88889 | 198 | QAction *channels_button_action_; |
dde1a563 | 199 | |
8dbbc7f0 JH |
200 | pv::widgets::SweepTimingWidget sample_count_; |
201 | pv::widgets::SweepTimingWidget sample_rate_; | |
202 | bool updating_sample_rate_; | |
203 | bool updating_sample_count_; | |
274d4f13 | 204 | |
8dbbc7f0 | 205 | bool sample_count_supported_; |
6546a6a7 | 206 | |
8dbbc7f0 JH |
207 | QIcon icon_red_; |
208 | QIcon icon_green_; | |
209 | QIcon icon_grey_; | |
210 | QToolButton run_stop_button_; | |
9dd88889 | 211 | QAction *run_stop_button_action_; |
87f0df9b | 212 | |
0f8f8c18 SA |
213 | #ifdef ENABLE_DECODE |
214 | QMenu *const menu_decoders_add_; | |
215 | #endif | |
d4984fe7 JH |
216 | }; |
217 | ||
f4c92e1c | 218 | } // namespace toolbars |
51e77110 JH |
219 | } // namespace pv |
220 | ||
7a01bd36 | 221 | #endif // PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP |