]> sigrok.org Git - pulseview.git/blame_incremental - pv/toolbars/mainbar.hpp
Free unused segment memory after acquisition
[pulseview.git] / pv / toolbars / mainbar.hpp
... / ...
CommitLineData
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 <stdint.h>
24
25#include <list>
26#include <memory>
27
28#include <glibmm/variant.h>
29
30#include <QComboBox>
31#include <QDoubleSpinBox>
32#include <QMenu>
33#include <QToolBar>
34#include <QToolButton>
35
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>
41
42namespace sigrok {
43class Device;
44class InputFormat;
45class OutputFormat;
46}
47
48Q_DECLARE_METATYPE(std::shared_ptr<sigrok::Device>)
49
50class QAction;
51
52namespace pv {
53
54class MainWindow;
55class Session;
56
57namespace views {
58namespace TraceView {
59class View;
60}
61}
62
63namespace toolbars {
64
65class MainBar : public pv::views::trace::StandardBar
66{
67 Q_OBJECT
68
69private:
70 static const uint64_t MinSampleCount;
71 static const uint64_t MaxSampleCount;
72 static const uint64_t DefaultSampleCount;
73
74 /**
75 * Name of the setting used to remember the directory
76 * containing the last file that was opened.
77 */
78 static const char *SettingOpenDirectory;
79
80 /**
81 * Name of the setting used to remember the directory
82 * containing the last file that was saved.
83 */
84 static const char *SettingSaveDirectory;
85
86public:
87 MainBar(Session &session, QWidget *parent,
88 pv::views::TraceView::View *view);
89
90 void update_device_list();
91
92 void set_capture_state(pv::Session::capture_state state);
93
94 void reset_device_selector();
95
96 QAction* action_new_view() const;
97 QAction* action_open() const;
98 QAction* action_save_as() const;
99 QAction* action_save_selection_as() const;
100 QAction* action_connect() const;
101
102 void session_error(const QString text, const QString info_text);
103
104private:
105 void run_stop();
106
107 void select_init_device();
108
109 void save_selection_to_file();
110
111 void update_sample_rate_selector();
112 void update_sample_rate_selector_value();
113 void update_sample_count_selector();
114 void update_device_config_widgets();
115 void commit_sample_rate();
116 void commit_sample_count();
117
118 QAction *const action_new_view_;
119 QAction *const action_open_;
120 QAction *const action_save_as_;
121 QAction *const action_save_selection_as_;
122 QAction *const action_connect_;
123
124private Q_SLOTS:
125 void show_session_error(const QString text, const QString info_text);
126
127 void add_decoder(srd_decoder *decoder);
128
129 void export_file(std::shared_ptr<sigrok::OutputFormat> format,
130 bool selection_only = false);
131 void import_file(std::shared_ptr<sigrok::InputFormat> format);
132
133 void on_device_selected();
134 void on_device_changed();
135 void on_capture_state_changed(int state);
136 void on_sample_count_changed();
137 void on_sample_rate_changed();
138
139 void on_config_changed();
140
141 void on_actionNewView_triggered();
142
143 void on_actionOpen_triggered();
144 void on_actionSaveAs_triggered();
145 void on_actionSaveSelectionAs_triggered();
146
147 void on_actionConnect_triggered();
148
149protected:
150 void add_toolbar_widgets();
151
152 bool eventFilter(QObject *watched, QEvent *event);
153
154Q_SIGNALS:
155 void new_view(Session *session);
156
157private:
158 QToolButton *open_button_, *save_button_;
159
160 pv::widgets::DeviceToolButton device_selector_;
161
162 pv::widgets::PopupToolButton configure_button_;
163 QAction *configure_button_action_;
164
165 pv::widgets::PopupToolButton channels_button_;
166 QAction *channels_button_action_;
167
168 pv::widgets::SweepTimingWidget sample_count_;
169 pv::widgets::SweepTimingWidget sample_rate_;
170 bool updating_sample_rate_;
171 bool updating_sample_count_;
172
173 bool sample_count_supported_;
174
175#ifdef ENABLE_DECODE
176 QToolButton *add_decoder_button_;
177 QMenu *const menu_decoders_add_;
178#endif
179};
180
181} // namespace toolbars
182} // namespace pv
183
184#endif // PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP