]> sigrok.org Git - pulseview.git/blame - pv/toolbars/mainbar.hpp
Don't use std:: in the code directly (where possible).
[pulseview.git] / pv / toolbars / mainbar.hpp
CommitLineData
d4984fe7 1/*
b3f22de0 2 * This file is part of the PulseView project.
d4984fe7
JH
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
efdec55a 17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
d4984fe7
JH
18 */
19
7a01bd36
JH
20#ifndef PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP
21#define PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP
d4984fe7 22
dde1a563
JH
23#include <stdint.h>
24
4fe06f49 25#include <list>
f9abf97e 26#include <memory>
18203d86 27
0f8f8c18
SA
28#include <glibmm/variant.h>
29
6fb67b27 30#include <QComboBox>
dde1a563 31#include <QDoubleSpinBox>
079d39ea 32#include <QMenu>
d4984fe7 33#include <QToolBar>
dde1a563
JH
34#include <QToolButton>
35
f65cd27b 36#include <pv/session.hpp>
e0ba4f6f 37#include <pv/views/trace/standardbar.hpp>
079d39ea 38#include <pv/widgets/devicetoolbutton.hpp>
2acdb232
JH
39#include <pv/widgets/popuptoolbutton.hpp>
40#include <pv/widgets/sweeptimingwidget.hpp>
2b49eeb0 41
6f925ba9
UH
42using std::shared_ptr;
43
e8d00928 44namespace sigrok {
ed43ef2e
JH
45class Device;
46class InputFormat;
0f8f8c18 47class OutputFormat;
e8d00928
ML
48}
49
6f925ba9 50Q_DECLARE_METATYPE(shared_ptr<sigrok::Device>)
e8d00928 51
dde1a563 52class QAction;
d4984fe7 53
51e77110 54namespace pv {
aca00b1e 55
4e7f5ba8 56class MainWindow;
2b81ae46 57class Session;
aca00b1e 58
e0ba4f6f
SA
59namespace views {
60namespace TraceView {
61class View;
62}
63}
64
f4c92e1c 65namespace toolbars {
51e77110 66
e0ba4f6f 67class MainBar : public pv::views::trace::StandardBar
d4984fe7
JH
68{
69 Q_OBJECT
70
215f9499 71private:
b50ef520
JH
72 static const uint64_t MinSampleCount;
73 static const uint64_t MaxSampleCount;
74 static const uint64_t DefaultSampleCount;
215f9499 75
0f8f8c18
SA
76 /**
77 * Name of the setting used to remember the directory
78 * containing the last file that was opened.
79 */
80 static const char *SettingOpenDirectory;
81
82 /**
83 * Name of the setting used to remember the directory
84 * containing the last file that was saved.
85 */
86 static const char *SettingSaveDirectory;
87
d4984fe7 88public:
e0ba4f6f
SA
89 MainBar(Session &session, QWidget *parent,
90 pv::views::TraceView::View *view);
6fb67b27 91
079d39ea 92 void update_device_list();
18203d86 93
2b81ae46 94 void set_capture_state(pv::Session::capture_state state);
6ac96c2e 95
7e0c99bf
SA
96 void reset_device_selector();
97
c9da5118 98 QAction* action_new_view() const;
0f8f8c18
SA
99 QAction* action_open() const;
100 QAction* action_save_as() const;
101 QAction* action_save_selection_as() const;
102 QAction* action_connect() const;
0f8f8c18 103
fd22c71c
SA
104 void session_error(const QString text, const QString info_text);
105
6fb67b27 106private:
0f8f8c18
SA
107 void run_stop();
108
0f8f8c18
SA
109 void select_init_device();
110
0f8f8c18
SA
111 void save_selection_to_file();
112
dde1a563 113 void update_sample_rate_selector();
48888313 114 void update_sample_rate_selector_value();
85756012 115 void update_sample_count_selector();
e95e8563 116 void update_device_config_widgets();
48888313 117 void commit_sample_rate();
124d97de 118 void commit_sample_count();
dde1a563 119
c9da5118 120 QAction *const action_new_view_;
0f8f8c18
SA
121 QAction *const action_open_;
122 QAction *const action_save_as_;
123 QAction *const action_save_selection_as_;
124 QAction *const action_connect_;
0f8f8c18 125
e9213170 126private Q_SLOTS:
0f8f8c18
SA
127 void show_session_error(const QString text, const QString info_text);
128
0f8f8c18
SA
129 void add_decoder(srd_decoder *decoder);
130
6f925ba9 131 void export_file(shared_ptr<sigrok::OutputFormat> format,
0f8f8c18 132 bool selection_only = false);
6f925ba9 133 void import_file(shared_ptr<sigrok::InputFormat> format);
0f8f8c18 134
dde1a563 135 void on_device_selected();
91f8fe8c 136 void on_device_changed();
f4ce3e77 137 void on_capture_state_changed(int state);
124d97de 138 void on_sample_count_changed();
48888313 139 void on_sample_rate_changed();
6fb67b27 140
82afd5e3
JH
141 void on_config_changed();
142
c9da5118
SA
143 void on_actionNewView_triggered();
144
0f8f8c18
SA
145 void on_actionOpen_triggered();
146 void on_actionSaveAs_triggered();
147 void on_actionSaveSelectionAs_triggered();
148
149 void on_actionConnect_triggered();
150
40065ab6 151protected:
e0ba4f6f
SA
152 void add_toolbar_widgets();
153
40065ab6
JS
154 bool eventFilter(QObject *watched, QEvent *event);
155
c9da5118 156Q_SIGNALS:
c9da5118
SA
157 void new_view(Session *session);
158
6fb67b27 159private:
e0ba4f6f 160 QToolButton *open_button_, *save_button_;
aca00b1e 161
079d39ea 162 pv::widgets::DeviceToolButton device_selector_;
51d4a9ab 163
8dbbc7f0
JH
164 pv::widgets::PopupToolButton configure_button_;
165 QAction *configure_button_action_;
b7b659aa 166
8dbbc7f0 167 pv::widgets::PopupToolButton channels_button_;
9dd88889 168 QAction *channels_button_action_;
dde1a563 169
8dbbc7f0
JH
170 pv::widgets::SweepTimingWidget sample_count_;
171 pv::widgets::SweepTimingWidget sample_rate_;
172 bool updating_sample_rate_;
173 bool updating_sample_count_;
274d4f13 174
8dbbc7f0 175 bool sample_count_supported_;
6546a6a7 176
0f8f8c18 177#ifdef ENABLE_DECODE
e0ba4f6f 178 QToolButton *add_decoder_button_;
0f8f8c18
SA
179 QMenu *const menu_decoders_add_;
180#endif
d4984fe7
JH
181};
182
f4c92e1c 183} // namespace toolbars
51e77110
JH
184} // namespace pv
185
7a01bd36 186#endif // PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP