]>
Commit | Line | Data |
---|---|---|
d7bed479 | 1 | /* |
b3f22de0 | 2 | * This file is part of the PulseView project. |
d7bed479 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/>. |
d7bed479 JH |
18 | */ |
19 | ||
7a01bd36 JH |
20 | #ifndef PULSEVIEW_PV_MAINWINDOW_HPP |
21 | #define PULSEVIEW_PV_MAINWINDOW_HPP | |
d7bed479 | 22 | |
18203d86 | 23 | #include <list> |
dd3fd4df | 24 | #include <map> |
f9abf97e | 25 | #include <memory> |
b1264f56 | 26 | |
d7bed479 | 27 | #include <QMainWindow> |
aca9aa83 | 28 | #include <QShortcut> |
3b84fd0b | 29 | #include <QTabWidget> |
aca9aa83 | 30 | #include <QToolButton> |
d7bed479 | 31 | |
f65cd27b | 32 | #include "session.hpp" |
97378470 | 33 | #include "subwindows/subwindowbase.hpp" |
2953961c | 34 | |
6f925ba9 UH |
35 | using std::list; |
36 | using std::map; | |
37 | using std::shared_ptr; | |
38 | using std::string; | |
39 | ||
269528f5 JH |
40 | struct srd_decoder; |
41 | ||
7d5425ef | 42 | class QVBoxLayout; |
7d5425ef | 43 | |
51e77110 JH |
44 | namespace pv { |
45 | ||
107ca6d3 | 46 | class DeviceManager; |
94574501 | 47 | |
f4c92e1c | 48 | namespace toolbars { |
404aad0e | 49 | class ContextBar; |
7c657094 | 50 | class MainBar; |
f4c92e1c | 51 | } |
51e77110 JH |
52 | |
53 | namespace view { | |
54 | class View; | |
2c5b0f46 | 55 | class ViewBase; |
51e77110 JH |
56 | } |
57 | ||
f0d37dab | 58 | namespace widgets { |
e79171dc | 59 | #ifdef ENABLE_DECODE |
f0d37dab | 60 | class DecoderMenu; |
19be0af1 | 61 | #endif |
f0d37dab JH |
62 | } |
63 | ||
2c5b0f46 SA |
64 | using pv::views::ViewBase; |
65 | using pv::views::ViewType; | |
66 | ||
8ba6f8b7 | 67 | class MainWindow : public QMainWindow |
d7bed479 JH |
68 | { |
69 | Q_OBJECT | |
70 | ||
33e1afbe SA |
71 | private: |
72 | static const QString WindowTitle; | |
73 | ||
d7bed479 | 74 | public: |
107ca6d3 | 75 | explicit MainWindow(DeviceManager &device_manager, |
f54fc97e | 76 | QWidget *parent = nullptr); |
d7bed479 | 77 | |
47e9e7bb SA |
78 | ~MainWindow(); |
79 | ||
5e685656 SA |
80 | static void show_session_error(const QString text, const QString info_text); |
81 | ||
6f925ba9 | 82 | shared_ptr<views::ViewBase> get_active_view() const; |
168bd8ac | 83 | |
2c5b0f46 | 84 | shared_ptr<views::ViewBase> add_view(ViewType type, Session &session); |
7cd2b5f3 | 85 | |
2c5b0f46 | 86 | void remove_view(shared_ptr<ViewBase> view); |
f30eb549 | 87 | |
97378470 SA |
88 | shared_ptr<subwindows::SubWindowBase> add_subwindow( |
89 | subwindows::SubWindowType type, Session &session); | |
90 | ||
6f925ba9 | 91 | shared_ptr<Session> add_session(); |
101e7a9b | 92 | |
6f925ba9 | 93 | void remove_session(shared_ptr<Session> session); |
36a8185e | 94 | |
96dbf014 | 95 | void add_session_with_file(string open_file_name, string open_file_format, |
611c8625 | 96 | string open_setup_file_name); |
3ed18835 SA |
97 | |
98 | void add_default_session(); | |
99 | ||
100 | void save_sessions(); | |
101 | void restore_sessions(); | |
102 | ||
d7bed479 | 103 | private: |
7d5425ef | 104 | void setup_ui(); |
31d1aca6 | 105 | void update_acq_button(Session *session); |
7d5425ef | 106 | |
93f683ad | 107 | void save_ui_settings(); |
3ed18835 | 108 | void restore_ui_settings(); |
93f683ad | 109 | |
6f925ba9 | 110 | shared_ptr<Session> get_tab_session(int index) const; |
e7aff437 | 111 | |
93f683ad SA |
112 | void closeEvent(QCloseEvent *event); |
113 | ||
d290e89f SA |
114 | virtual QMenu* createPopupMenu(); |
115 | ||
55547a45 SA |
116 | virtual bool restoreState(const QByteArray &state, int version = 0); |
117 | ||
ab10caf9 SA |
118 | public Q_SLOTS: |
119 | void on_run_stop_clicked(); | |
120 | ||
4df7756e | 121 | private Q_SLOTS: |
2c5b0f46 | 122 | void on_add_view(ViewType type, Session *session); |
3a21afa6 | 123 | |
33e1afbe | 124 | void on_focus_changed(); |
6f925ba9 | 125 | void on_focused_session_changed(shared_ptr<Session> session); |
33e1afbe | 126 | |
f1e2d26b | 127 | void on_new_session_clicked(); |
bf9f1268 | 128 | void on_settings_clicked(); |
3231fbf9 | 129 | |
33e1afbe | 130 | void on_session_name_changed(); |
31d1aca6 | 131 | void on_session_device_changed(); |
f1f3fa71 | 132 | void on_session_capture_state_changed(int state); |
3231fbf9 | 133 | |
baf867ed | 134 | void on_new_view(Session *session, int view_type); |
36a8185e | 135 | void on_view_close_clicked(); |
c9da5118 | 136 | |
e7aff437 | 137 | void on_tab_changed(int index); |
4a4e20f5 SA |
138 | void on_tab_close_requested(int index); |
139 | ||
97378470 SA |
140 | void on_show_decoder_selector(Session *session); |
141 | void on_sub_window_close_clicked(); | |
142 | ||
641574bc | 143 | void on_view_colored_bg_shortcut(); |
87a97d8a | 144 | void on_view_sticky_scrolling_shortcut(); |
051ba3b3 | 145 | void on_view_show_sampling_points_shortcut(); |
8ad61f40 | 146 | void on_view_show_analog_minor_grid_shortcut(); |
0fb9d645 | 147 | |
763945bb PET |
148 | void on_close_current_tab(); |
149 | ||
7d5425ef | 150 | private: |
8dbbc7f0 | 151 | DeviceManager &device_manager_; |
d4984fe7 | 152 | |
6f925ba9 UH |
153 | list< shared_ptr<Session> > sessions_; |
154 | shared_ptr<Session> last_focused_session_; | |
18203d86 | 155 | |
6f925ba9 | 156 | map< QDockWidget*, shared_ptr<views::ViewBase> > view_docks_; |
97378470 | 157 | map< QDockWidget*, shared_ptr<subwindows::SubWindowBase> > sub_windows_; |
7d5425ef | 158 | |
6f925ba9 | 159 | map< shared_ptr<Session>, QMainWindow*> session_windows_; |
3b84fd0b | 160 | |
cc964645 | 161 | QWidget *static_tab_widget_; |
4d1ec09a | 162 | QToolButton *new_session_button_, *run_stop_button_, *settings_button_; |
3b84fd0b SA |
163 | QTabWidget session_selector_; |
164 | ||
3231fbf9 SA |
165 | QIcon icon_red_; |
166 | QIcon icon_green_; | |
167 | QIcon icon_grey_; | |
45cb64ff | 168 | |
9eae6de4 | 169 | QShortcut *view_sticky_scrolling_shortcut_; |
051ba3b3 | 170 | QShortcut *view_show_sampling_points_shortcut_; |
8ad61f40 | 171 | QShortcut *view_show_analog_minor_grid_shortcut_; |
641574bc | 172 | QShortcut *view_colored_bg_shortcut_; |
45cb64ff | 173 | QShortcut *run_stop_shortcut_; |
763945bb PET |
174 | QShortcut *close_application_shortcut_; |
175 | QShortcut *close_current_tab_shortcut_; | |
d7bed479 JH |
176 | }; |
177 | ||
51e77110 JH |
178 | } // namespace pv |
179 | ||
7a01bd36 | 180 | #endif // PULSEVIEW_PV_MAINWINDOW_HPP |