]>
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> |
3231fbf9 | 29 | #include <QSignalMapper> |
3b84fd0b | 30 | #include <QTabWidget> |
aca9aa83 | 31 | #include <QToolButton> |
d7bed479 | 32 | |
f65cd27b | 33 | #include "session.hpp" |
f4e57597 | 34 | #include "views/viewbase.hpp" |
2953961c | 35 | |
6f925ba9 UH |
36 | using std::list; |
37 | using std::map; | |
38 | using std::shared_ptr; | |
39 | using std::string; | |
40 | ||
269528f5 JH |
41 | struct srd_decoder; |
42 | ||
7d5425ef | 43 | class QVBoxLayout; |
7d5425ef | 44 | |
51e77110 JH |
45 | namespace pv { |
46 | ||
107ca6d3 | 47 | class DeviceManager; |
94574501 | 48 | |
f4c92e1c | 49 | namespace toolbars { |
404aad0e | 50 | class ContextBar; |
7c657094 | 51 | class MainBar; |
f4c92e1c | 52 | } |
51e77110 JH |
53 | |
54 | namespace view { | |
55 | class View; | |
56 | } | |
57 | ||
f0d37dab | 58 | namespace widgets { |
e79171dc | 59 | #ifdef ENABLE_DECODE |
f0d37dab | 60 | class DecoderMenu; |
19be0af1 | 61 | #endif |
f0d37dab JH |
62 | } |
63 | ||
d7bed479 JH |
64 | class MainWindow : public QMainWindow |
65 | { | |
66 | Q_OBJECT | |
67 | ||
33e1afbe SA |
68 | private: |
69 | static const QString WindowTitle; | |
70 | ||
d7bed479 | 71 | public: |
107ca6d3 | 72 | explicit MainWindow(DeviceManager &device_manager, |
6f925ba9 UH |
73 | string open_file_name = string(), |
74 | string open_file_format = string(), | |
f54fc97e | 75 | QWidget *parent = nullptr); |
d7bed479 | 76 | |
47e9e7bb SA |
77 | ~MainWindow(); |
78 | ||
6f925ba9 | 79 | shared_ptr<views::ViewBase> get_active_view() const; |
168bd8ac | 80 | |
6f925ba9 | 81 | shared_ptr<views::ViewBase> add_view(const QString &title, |
f4e57597 | 82 | views::ViewType type, Session &session); |
7cd2b5f3 | 83 | |
6f925ba9 | 84 | void remove_view(shared_ptr<views::ViewBase> view); |
f30eb549 | 85 | |
6f925ba9 | 86 | shared_ptr<Session> add_session(); |
101e7a9b | 87 | |
6f925ba9 | 88 | void remove_session(shared_ptr<Session> session); |
36a8185e | 89 | |
d7bed479 | 90 | private: |
7d5425ef JH |
91 | void setup_ui(); |
92 | ||
93f683ad SA |
93 | void save_ui_settings(); |
94 | ||
95 | void restore_ui_settings(); | |
96 | ||
6f925ba9 | 97 | shared_ptr<Session> get_tab_session(int index) const; |
e7aff437 | 98 | |
93f683ad SA |
99 | void closeEvent(QCloseEvent *event); |
100 | ||
d290e89f SA |
101 | virtual QMenu* createPopupMenu(); |
102 | ||
55547a45 SA |
103 | virtual bool restoreState(const QByteArray &state, int version = 0); |
104 | ||
3231fbf9 SA |
105 | void session_error(const QString text, const QString info_text); |
106 | ||
4df7756e | 107 | private Q_SLOTS: |
3231fbf9 SA |
108 | void show_session_error(const QString text, const QString info_text); |
109 | ||
f4e57597 | 110 | void on_add_view(const QString &title, views::ViewType type, |
3a21afa6 SA |
111 | Session *session); |
112 | ||
33e1afbe | 113 | void on_focus_changed(); |
6f925ba9 | 114 | void on_focused_session_changed(shared_ptr<Session> session); |
33e1afbe | 115 | |
f1e2d26b | 116 | void on_new_session_clicked(); |
3231fbf9 | 117 | void on_run_stop_clicked(); |
bf9f1268 | 118 | void on_settings_clicked(); |
3231fbf9 | 119 | |
33e1afbe | 120 | void on_session_name_changed(); |
3231fbf9 SA |
121 | void on_capture_state_changed(QObject *obj); |
122 | ||
c9da5118 | 123 | void on_new_view(Session *session); |
36a8185e | 124 | void on_view_close_clicked(); |
c9da5118 | 125 | |
e7aff437 | 126 | void on_tab_changed(int index); |
4a4e20f5 SA |
127 | void on_tab_close_requested(int index); |
128 | ||
9eae6de4 | 129 | void on_view_coloured_bg_shortcut(); |
87a97d8a | 130 | void on_view_sticky_scrolling_shortcut(); |
051ba3b3 | 131 | void on_view_show_sampling_points_shortcut(); |
0fb9d645 | 132 | |
24c29d4f | 133 | void on_settingViewColouredBg_changed(const QVariant new_value); |
051ba3b3 | 134 | void on_settingViewShowSamplingPoints_changed(const QVariant new_value); |
24c29d4f | 135 | |
763945bb PET |
136 | void on_close_current_tab(); |
137 | ||
7d5425ef | 138 | private: |
8dbbc7f0 | 139 | DeviceManager &device_manager_; |
d4984fe7 | 140 | |
6f925ba9 UH |
141 | list< shared_ptr<Session> > sessions_; |
142 | shared_ptr<Session> last_focused_session_; | |
18203d86 | 143 | |
6f925ba9 | 144 | map< QDockWidget*, shared_ptr<views::ViewBase> > view_docks_; |
7d5425ef | 145 | |
6f925ba9 | 146 | map< shared_ptr<Session>, QMainWindow*> session_windows_; |
3b84fd0b | 147 | |
cc964645 | 148 | QWidget *static_tab_widget_; |
4d1ec09a | 149 | QToolButton *new_session_button_, *run_stop_button_, *settings_button_; |
3b84fd0b | 150 | QTabWidget session_selector_; |
3231fbf9 | 151 | QSignalMapper session_state_mapper_; |
3b84fd0b | 152 | |
3231fbf9 SA |
153 | QIcon icon_red_; |
154 | QIcon icon_green_; | |
155 | QIcon icon_grey_; | |
45cb64ff | 156 | |
9eae6de4 | 157 | QShortcut *view_sticky_scrolling_shortcut_; |
051ba3b3 | 158 | QShortcut *view_show_sampling_points_shortcut_; |
9eae6de4 | 159 | QShortcut *view_coloured_bg_shortcut_; |
45cb64ff | 160 | QShortcut *run_stop_shortcut_; |
763945bb PET |
161 | QShortcut *close_application_shortcut_; |
162 | QShortcut *close_current_tab_shortcut_; | |
d7bed479 JH |
163 | }; |
164 | ||
51e77110 JH |
165 | } // namespace pv |
166 | ||
7a01bd36 | 167 | #endif // PULSEVIEW_PV_MAINWINDOW_HPP |