2 * This file is part of the PulseView project.
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
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.
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP
21 #define PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP
28 #include <glibmm/variant.h>
31 #include <QDoubleSpinBox>
34 #include <QToolButton>
36 #include <pv/session.hpp>
37 #include <pv/views/trace/standardbar.hpp>
38 #include <pv/widgets/devicetoolbutton.hpp>
39 #include <pv/widgets/popuptoolbutton.hpp>
40 #include <pv/widgets/sweeptimingwidget.hpp>
42 using std::shared_ptr;
50 Q_DECLARE_METATYPE(shared_ptr<sigrok::Device>)
67 class MainBar : public pv::views::trace::StandardBar
72 static const uint64_t MinSampleCount;
73 static const uint64_t MaxSampleCount;
74 static const uint64_t DefaultSampleCount;
77 * Name of the setting used to remember the directory
78 * containing the last file that was opened.
80 static const char *SettingOpenDirectory;
83 * Name of the setting used to remember the directory
84 * containing the last file that was saved.
86 static const char *SettingSaveDirectory;
89 MainBar(Session &session, QWidget *parent,
90 pv::views::TraceView::View *view);
92 void update_device_list();
94 void set_capture_state(pv::Session::capture_state state);
96 void reset_device_selector();
98 QAction* action_new_view() const;
99 QAction* action_open() const;
100 QAction* action_save_as() const;
101 QAction* action_save_selection_as() const;
102 QAction* action_connect() const;
104 void session_error(const QString text, const QString info_text);
109 void select_init_device();
111 void save_selection_to_file();
113 void update_sample_rate_selector();
114 void update_sample_rate_selector_value();
115 void update_sample_count_selector();
116 void update_device_config_widgets();
117 void commit_sample_rate();
118 void commit_sample_count();
120 QAction *const action_new_view_;
121 QAction *const action_open_;
122 QAction *const action_save_as_;
123 QAction *const action_save_selection_as_;
124 QAction *const action_connect_;
127 void show_session_error(const QString text, const QString info_text);
129 void add_decoder(srd_decoder *decoder);
131 void export_file(shared_ptr<sigrok::OutputFormat> format,
132 bool selection_only = false);
133 void import_file(shared_ptr<sigrok::InputFormat> format);
135 void on_device_selected();
136 void on_device_changed();
137 void on_capture_state_changed(int state);
138 void on_sample_count_changed();
139 void on_sample_rate_changed();
141 void on_config_changed();
143 void on_actionNewView_triggered();
145 void on_actionOpen_triggered();
146 void on_actionSaveAs_triggered();
147 void on_actionSaveSelectionAs_triggered();
149 void on_actionConnect_triggered();
152 void add_toolbar_widgets();
154 bool eventFilter(QObject *watched, QEvent *event);
157 void new_view(Session *session);
160 QToolButton *open_button_, *save_button_;
162 pv::widgets::DeviceToolButton device_selector_;
164 pv::widgets::PopupToolButton configure_button_;
165 QAction *configure_button_action_;
167 pv::widgets::PopupToolButton channels_button_;
168 QAction *channels_button_action_;
170 pv::widgets::SweepTimingWidget sample_count_;
171 pv::widgets::SweepTimingWidget sample_rate_;
172 bool updating_sample_rate_;
173 bool updating_sample_count_;
175 bool sample_count_supported_;
178 QToolButton *add_decoder_button_;
179 QMenu *const menu_decoders_add_;
183 } // namespace toolbars
186 #endif // PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP