]>
Commit | Line | Data |
---|---|---|
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 | |
cafe470e | 23 | #include <cstdint> |
4fe06f49 | 24 | #include <list> |
f9abf97e | 25 | #include <memory> |
18203d86 | 26 | |
0f8f8c18 SA |
27 | #include <glibmm/variant.h> |
28 | ||
6fb67b27 | 29 | #include <QComboBox> |
dde1a563 | 30 | #include <QDoubleSpinBox> |
079d39ea | 31 | #include <QMenu> |
d4984fe7 | 32 | #include <QToolBar> |
dde1a563 JH |
33 | #include <QToolButton> |
34 | ||
f65cd27b | 35 | #include <pv/session.hpp> |
e0ba4f6f | 36 | #include <pv/views/trace/standardbar.hpp> |
079d39ea | 37 | #include <pv/widgets/devicetoolbutton.hpp> |
2acdb232 JH |
38 | #include <pv/widgets/popuptoolbutton.hpp> |
39 | #include <pv/widgets/sweeptimingwidget.hpp> | |
2b49eeb0 | 40 | |
6f925ba9 UH |
41 | using std::shared_ptr; |
42 | ||
e8d00928 | 43 | namespace sigrok { |
ed43ef2e JH |
44 | class Device; |
45 | class InputFormat; | |
0f8f8c18 | 46 | class OutputFormat; |
e8d00928 ML |
47 | } |
48 | ||
6f925ba9 | 49 | Q_DECLARE_METATYPE(shared_ptr<sigrok::Device>) |
e8d00928 | 50 | |
dde1a563 | 51 | class QAction; |
d4984fe7 | 52 | |
51e77110 | 53 | namespace pv { |
aca00b1e | 54 | |
4e7f5ba8 | 55 | class MainWindow; |
2b81ae46 | 56 | class Session; |
aca00b1e | 57 | |
e0ba4f6f | 58 | namespace views { |
f23c4692 | 59 | namespace trace { |
e0ba4f6f SA |
60 | class View; |
61 | } | |
62 | } | |
63 | ||
f4c92e1c | 64 | namespace toolbars { |
51e77110 | 65 | |
e0ba4f6f | 66 | class MainBar : public pv::views::trace::StandardBar |
d4984fe7 JH |
67 | { |
68 | Q_OBJECT | |
69 | ||
215f9499 | 70 | private: |
b50ef520 JH |
71 | static const uint64_t MinSampleCount; |
72 | static const uint64_t MaxSampleCount; | |
73 | static const uint64_t DefaultSampleCount; | |
215f9499 | 74 | |
0f8f8c18 SA |
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 | ||
d4984fe7 | 87 | public: |
e0ba4f6f | 88 | MainBar(Session &session, QWidget *parent, |
f23c4692 | 89 | pv::views::trace::View *view); |
6fb67b27 | 90 | |
079d39ea | 91 | void update_device_list(); |
18203d86 | 92 | |
2b81ae46 | 93 | void set_capture_state(pv::Session::capture_state state); |
6ac96c2e | 94 | |
7e0c99bf SA |
95 | void reset_device_selector(); |
96 | ||
c9da5118 | 97 | QAction* action_new_view() const; |
0f8f8c18 SA |
98 | QAction* action_open() const; |
99 | QAction* action_save_as() const; | |
100 | QAction* action_save_selection_as() const; | |
323715c4 SA |
101 | QAction* action_restore_setup() const; |
102 | QAction* action_save_setup() const; | |
0f8f8c18 | 103 | QAction* action_connect() const; |
0f8f8c18 | 104 | |
6fb67b27 | 105 | private: |
0f8f8c18 SA |
106 | void run_stop(); |
107 | ||
0f8f8c18 SA |
108 | void select_init_device(); |
109 | ||
0f8f8c18 SA |
110 | void save_selection_to_file(); |
111 | ||
dde1a563 | 112 | void update_sample_rate_selector(); |
48888313 | 113 | void update_sample_rate_selector_value(); |
85756012 | 114 | void update_sample_count_selector(); |
e95e8563 | 115 | void update_device_config_widgets(); |
48888313 | 116 | void commit_sample_rate(); |
124d97de | 117 | void commit_sample_count(); |
dde1a563 | 118 | |
e9213170 | 119 | private Q_SLOTS: |
0f8f8c18 SA |
120 | void show_session_error(const QString text, const QString info_text); |
121 | ||
6f925ba9 | 122 | void export_file(shared_ptr<sigrok::OutputFormat> format, |
0f8f8c18 | 123 | bool selection_only = false); |
6f925ba9 | 124 | void import_file(shared_ptr<sigrok::InputFormat> format); |
0f8f8c18 | 125 | |
dde1a563 | 126 | void on_device_selected(); |
91f8fe8c | 127 | void on_device_changed(); |
f4ce3e77 | 128 | void on_capture_state_changed(int state); |
124d97de | 129 | void on_sample_count_changed(); |
48888313 | 130 | void on_sample_rate_changed(); |
6fb67b27 | 131 | |
82afd5e3 JH |
132 | void on_config_changed(); |
133 | ||
baf867ed | 134 | void on_actionNewView_triggered(QAction* action = nullptr); |
c9da5118 | 135 | |
0f8f8c18 SA |
136 | void on_actionOpen_triggered(); |
137 | void on_actionSaveAs_triggered(); | |
138 | void on_actionSaveSelectionAs_triggered(); | |
139 | ||
323715c4 SA |
140 | void on_actionSaveSetup_triggered(); |
141 | void on_actionRestoreSetup_triggered(); | |
142 | ||
0f8f8c18 SA |
143 | void on_actionConnect_triggered(); |
144 | ||
97378470 SA |
145 | void on_add_decoder_clicked(); |
146 | ||
40065ab6 | 147 | protected: |
e0ba4f6f SA |
148 | void add_toolbar_widgets(); |
149 | ||
40065ab6 JS |
150 | bool eventFilter(QObject *watched, QEvent *event); |
151 | ||
c9da5118 | 152 | Q_SIGNALS: |
baf867ed | 153 | void new_view(Session *session, int type); |
97378470 | 154 | void show_decoder_selector(Session *session); |
c9da5118 | 155 | |
6fb67b27 | 156 | private: |
03408f5f SA |
157 | QAction *const action_new_view_; |
158 | QAction *const action_open_; | |
159 | QAction *const action_save_as_; | |
160 | QAction *const action_save_selection_as_; | |
161 | QAction *const action_restore_setup_; | |
162 | QAction *const action_save_setup_; | |
163 | QAction *const action_connect_; | |
164 | ||
baf867ed | 165 | QToolButton *new_view_button_, *open_button_, *save_button_; |
aca00b1e | 166 | |
079d39ea | 167 | pv::widgets::DeviceToolButton device_selector_; |
51d4a9ab | 168 | |
8dbbc7f0 JH |
169 | pv::widgets::PopupToolButton configure_button_; |
170 | QAction *configure_button_action_; | |
b7b659aa | 171 | |
8dbbc7f0 | 172 | pv::widgets::PopupToolButton channels_button_; |
9dd88889 | 173 | QAction *channels_button_action_; |
dde1a563 | 174 | |
8dbbc7f0 JH |
175 | pv::widgets::SweepTimingWidget sample_count_; |
176 | pv::widgets::SweepTimingWidget sample_rate_; | |
177 | bool updating_sample_rate_; | |
178 | bool updating_sample_count_; | |
274d4f13 | 179 | |
8dbbc7f0 | 180 | bool sample_count_supported_; |
6546a6a7 | 181 | |
0f8f8c18 | 182 | #ifdef ENABLE_DECODE |
e0ba4f6f | 183 | QToolButton *add_decoder_button_; |
0f8f8c18 | 184 | #endif |
d4984fe7 JH |
185 | }; |
186 | ||
f4c92e1c | 187 | } // namespace toolbars |
51e77110 JH |
188 | } // namespace pv |
189 | ||
7a01bd36 | 190 | #endif // PULSEVIEW_PV_TOOLBARS_MAINBAR_HPP |