]> sigrok.org Git - pulseview.git/blame_incremental - pv/toolbars/mainbar.hpp
Fix "always zoom to fit" feature
[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, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP
22#define PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP
23
24#include <stdint.h>
25
26#include <list>
27#include <memory>
28
29#include <glibmm/variant.h>
30
31#include <QComboBox>
32#include <QDoubleSpinBox>
33#include <QMenu>
34#include <QToolBar>
35#include <QToolButton>
36
37#include <pv/session.hpp>
38#include <pv/views/trace/standardbar.hpp>
39#include <pv/widgets/devicetoolbutton.hpp>
40#include <pv/widgets/popuptoolbutton.hpp>
41#include <pv/widgets/sweeptimingwidget.hpp>
42
43namespace sigrok {
44class Device;
45class InputFormat;
46class OutputFormat;
47}
48
49Q_DECLARE_METATYPE(std::shared_ptr<sigrok::Device>)
50
51class QAction;
52
53namespace pv {
54
55class MainWindow;
56class Session;
57
58namespace views {
59namespace TraceView {
60class View;
61}
62}
63
64namespace toolbars {
65
66class MainBar : public pv::views::trace::StandardBar
67{
68 Q_OBJECT
69
70private:
71 static const uint64_t MinSampleCount;
72 static const uint64_t MaxSampleCount;
73 static const uint64_t DefaultSampleCount;
74
75 /**
76 * Name of the setting used to remember the directory
77 * containing the last file that was opened.
78 */
79 static const char *SettingOpenDirectory;
80
81 /**
82 * Name of the setting used to remember the directory
83 * containing the last file that was saved.
84 */
85 static const char *SettingSaveDirectory;
86
87public:
88 MainBar(Session &session, QWidget *parent,
89 pv::views::TraceView::View *view);
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_as() const;
100 QAction* action_save_selection_as() const;
101 QAction* action_connect() const;
102
103 void session_error(const QString text, const QString info_text);
104
105private:
106 void run_stop();
107
108 void select_init_device();
109
110 void save_selection_to_file();
111
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();
118
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
125private Q_SLOTS:
126 void show_session_error(const QString text, const QString info_text);
127
128 void capture_state_changed(int state);
129
130 void add_decoder(srd_decoder *decoder);
131
132 void export_file(std::shared_ptr<sigrok::OutputFormat> format,
133 bool selection_only = false);
134 void import_file(std::shared_ptr<sigrok::InputFormat> format);
135
136 void on_device_selected();
137 void on_device_changed();
138 void on_sample_count_changed();
139 void on_sample_rate_changed();
140
141 void on_config_changed();
142
143 void on_actionNewView_triggered();
144
145 void on_actionOpen_triggered();
146 void on_actionSaveAs_triggered();
147 void on_actionSaveSelectionAs_triggered();
148
149 void on_actionConnect_triggered();
150
151protected:
152 void add_toolbar_widgets();
153
154 bool eventFilter(QObject *watched, QEvent *event);
155
156Q_SIGNALS:
157 void new_view(Session *session);
158
159private:
160 QToolButton *open_button_, *save_button_;
161
162 pv::widgets::DeviceToolButton device_selector_;
163
164 pv::widgets::PopupToolButton configure_button_;
165 QAction *configure_button_action_;
166
167 pv::widgets::PopupToolButton channels_button_;
168 QAction *channels_button_action_;
169
170 pv::widgets::SweepTimingWidget sample_count_;
171 pv::widgets::SweepTimingWidget sample_rate_;
172 bool updating_sample_rate_;
173 bool updating_sample_count_;
174
175 bool sample_count_supported_;
176
177#ifdef ENABLE_DECODE
178 QToolButton *add_decoder_button_;
179 QMenu *const menu_decoders_add_;
180#endif
181};
182
183} // namespace toolbars
184} // namespace pv
185
186#endif // PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP