PulseView  unreleased development snapshot
A Qt-based sigrok GUI
mainbar.hpp
Go to the documentation of this file.
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, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP
21 #define PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP
22 
23 #include <cstdint>
24 #include <list>
25 #include <memory>
26 
27 #include <glibmm/variant.h>
28 
29 #include <QComboBox>
30 #include <QDoubleSpinBox>
31 #include <QMenu>
32 #include <QToolBar>
33 #include <QToolButton>
34 
35 #include <pv/session.hpp>
40 
41 using std::shared_ptr;
42 
43 namespace sigrok {
44 class Device;
45 class InputFormat;
46 class OutputFormat;
47 }
48 
49 Q_DECLARE_METATYPE(shared_ptr<sigrok::Device>)
50 
51 class QAction;
52 
53 namespace pv {
54 
55 class MainWindow;
56 class Session;
57 
58 namespace views {
59 namespace trace {
60 class View;
61 }
62 }
63 
64 namespace toolbars {
65 
67 {
68  Q_OBJECT
69 
70 private:
71  static const uint64_t MinSampleCount;
72  static const uint64_t MaxSampleCount;
73  static const uint64_t DefaultSampleCount;
74 
79  static const char *SettingOpenDirectory;
80 
85  static const char *SettingSaveDirectory;
86 
87 public:
88  MainBar(Session &session, QWidget *parent,
90 
91  void update_device_list();
92 
93  void set_capture_state(pv::Session::capture_state state);
94 
95  void reset_device_selector();
96 
97  QAction* action_new_view() const;
98  QAction* action_open() const;
99  QAction* action_save() const;
100  QAction* action_save_as() const;
101  QAction* action_save_selection_as() const;
102  QAction* action_restore_setup() const;
103  QAction* action_save_setup() const;
104  QAction* action_connect() const;
105 
106 private:
107  void run_stop();
108 
109  void select_init_device();
110 
111  void save_selection_to_file();
112 
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();
119 
120 private Q_SLOTS:
121  void show_session_error(const QString text, const QString info_text);
122 
123  void export_file(shared_ptr<sigrok::OutputFormat> format,
124  bool selection_only = false, QString file_name = "");
125  void import_file(shared_ptr<sigrok::InputFormat> format);
126 
127  void on_device_selected();
128  void on_device_changed();
129  void on_capture_state_changed(int state);
130  void on_sample_count_changed();
131  void on_sample_rate_changed();
132 
133  void on_config_changed();
134 
135  void on_actionNewView_triggered(QAction* action = nullptr);
136 
137  void on_actionOpen_triggered();
138  void on_actionSave_triggered();
139  void on_actionSaveAs_triggered();
140  void on_actionSaveSelectionAs_triggered();
141 
142  void on_actionSaveSetup_triggered();
143  void on_actionRestoreSetup_triggered();
144 
145  void on_actionConnect_triggered();
146 
147  void on_add_decoder_clicked();
148  void on_add_math_signal_clicked();
149 
150 protected:
151  void add_toolbar_widgets();
152 
153  bool eventFilter(QObject *watched, QEvent *event);
154 
155 Q_SIGNALS:
156  void new_view(Session *session, int type);
157  void show_decoder_selector(Session *session);
158 
159 private:
160  QAction *const action_new_view_;
161  QAction *const action_open_;
162  QAction *const action_save_;
163  QAction *const action_save_as_;
165  QAction *const action_restore_setup_;
166  QAction *const action_save_setup_;
167  QAction *const action_connect_;
168 
169  QToolButton *new_view_button_, *open_button_, *save_button_;
170 
172 
175 
178 
183 
185 
186 #ifdef ENABLE_DECODE
187  QToolButton *add_decoder_button_;
188 #endif
189 
191 };
192 
193 } // namespace toolbars
194 } // namespace pv
195 
196 #endif // PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP
libsigrok allows users to import and export data from files in various formats some of them as generic as others very specific For a list and make sure to check not so common and outright exotic ways to represent data and sigrok tries to suit as many needs as it can To see which formats your version of PulseView just click on the small arrow next to the _Open_ PulseView will ask for the file name to open Once you picked the you may be asked to specify the details of the format
static const uint64_t MinSampleCount
Definition: mainbar.hpp:71
pv::widgets::SweepTimingWidget sample_rate_
Definition: mainbar.hpp:180
QAction *const action_open_
Definition: mainbar.hpp:161
QAction *const action_restore_setup_
Definition: mainbar.hpp:165
QAction * configure_button_action_
Definition: mainbar.hpp:174
QToolButton * save_button_
Definition: mainbar.hpp:169
QAction *const action_new_view_
Definition: mainbar.hpp:160
QAction *const action_connect_
Definition: mainbar.hpp:167
pv::widgets::PopupToolButton channels_button_
Definition: mainbar.hpp:176
QAction *const action_save_selection_as_
Definition: mainbar.hpp:164
pv::widgets::SweepTimingWidget sample_count_
Definition: mainbar.hpp:179
static const char * SettingSaveDirectory
Definition: mainbar.hpp:85
Q_DECLARE_METATYPE(SharedPtrToSegment)
QAction * channels_button_action_
Definition: mainbar.hpp:177
pv::widgets::DeviceToolButton device_selector_
Definition: mainbar.hpp:171
QToolButton * add_math_signal_button_
Definition: mainbar.hpp:190
static const uint64_t MaxSampleCount
Definition: mainbar.hpp:72
QAction *const action_save_as_
Definition: mainbar.hpp:163
pv::widgets::PopupToolButton configure_button_
Definition: mainbar.hpp:173
static const char * SettingOpenDirectory
Definition: mainbar.hpp:79
QAction *const action_save_setup_
Definition: mainbar.hpp:166
QAction *const action_save_
Definition: mainbar.hpp:162
static const uint64_t DefaultSampleCount
Definition: mainbar.hpp:73