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, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP
22 #define PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP
29 #include <glibmm/variant.h>
32 #include <QDoubleSpinBox>
35 #include <QToolButton>
37 #include <pv/session.hpp>
38 #include <pv/widgets/devicetoolbutton.hpp>
39 #include <pv/widgets/popuptoolbutton.hpp>
40 #include <pv/widgets/sweeptimingwidget.hpp>
48 Q_DECLARE_METATYPE(std::shared_ptr<sigrok::Device>)
59 class MainBar : public QToolBar
64 static const uint64_t MinSampleCount;
65 static const uint64_t MaxSampleCount;
66 static const uint64_t DefaultSampleCount;
69 * Name of the setting used to remember the directory
70 * containing the last file that was opened.
72 static const char *SettingOpenDirectory;
75 * Name of the setting used to remember the directory
76 * containing the last file that was saved.
78 static const char *SettingSaveDirectory;
81 MainBar(Session &session, pv::MainWindow &main_window);
83 Session &session(void) const;
85 void update_device_list();
87 void set_capture_state(pv::Session::capture_state state);
89 void reset_device_selector();
91 QAction* action_new_view() const;
92 QAction* action_open() const;
93 QAction* action_save_as() const;
94 QAction* action_save_selection_as() const;
95 QAction* action_connect() const;
96 QAction* action_quit() const;
97 QAction* action_view_zoom_in() const;
98 QAction* action_view_zoom_out() const;
99 QAction* action_view_zoom_fit() const;
100 QAction* action_view_zoom_one_to_one() const;
101 QAction* action_view_show_cursors() const;
103 void session_error(const QString text, const QString info_text);
108 void select_init_device();
110 void save_selection_to_file();
112 void update_sample_rate_selector();
113 void update_sample_rate_selector_value();
114 void update_sample_count_selector();
115 void update_device_config_widgets();
116 void commit_sample_rate();
117 void commit_sample_count();
119 QAction *const action_new_view_;
120 QAction *const action_open_;
121 QAction *const action_save_as_;
122 QAction *const action_save_selection_as_;
123 QAction *const action_connect_;
124 QAction *const action_view_zoom_in_;
125 QAction *const action_view_zoom_out_;
126 QAction *const action_view_zoom_fit_;
127 QAction *const action_view_zoom_one_to_one_;
128 QAction *const action_view_show_cursors_;
131 void show_session_error(const QString text, const QString info_text);
133 void capture_state_changed(int state);
135 void add_decoder(srd_decoder *decoder);
137 void export_file(std::shared_ptr<sigrok::OutputFormat> format,
138 bool selection_only = false);
139 void import_file(std::shared_ptr<sigrok::InputFormat> format);
141 void on_device_selected();
142 void on_device_changed();
143 void on_sample_count_changed();
144 void on_sample_rate_changed();
146 void on_config_changed();
148 void on_actionNewView_triggered();
150 void on_actionOpen_triggered();
151 void on_actionSaveAs_triggered();
152 void on_actionSaveSelectionAs_triggered();
154 void on_actionConnect_triggered();
156 void on_actionViewZoomIn_triggered();
158 void on_actionViewZoomOut_triggered();
160 void on_actionViewZoomFit_triggered();
162 void on_actionViewZoomOneToOne_triggered();
164 void on_actionViewShowCursors_triggered();
166 void on_always_zoom_to_fit_changed(bool state);
169 bool eventFilter(QObject *watched, QEvent *event);
172 void new_view(Session *session);
177 pv::widgets::DeviceToolButton device_selector_;
179 pv::widgets::PopupToolButton configure_button_;
180 QAction *configure_button_action_;
182 pv::widgets::PopupToolButton channels_button_;
183 QAction *channels_button_action_;
185 pv::widgets::SweepTimingWidget sample_count_;
186 pv::widgets::SweepTimingWidget sample_rate_;
187 bool updating_sample_rate_;
188 bool updating_sample_count_;
190 bool sample_count_supported_;
193 QMenu *const menu_decoders_add_;
197 } // namespace toolbars
200 #endif // PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP