]>
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 | |
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 | ||
7a01bd36 JH |
21 | #ifndef PULSEVIEW_PV_MAINWINDOW_HPP |
22 | #define PULSEVIEW_PV_MAINWINDOW_HPP | |
d7bed479 | 23 | |
18203d86 | 24 | #include <list> |
dd3fd4df | 25 | #include <map> |
f9abf97e | 26 | #include <memory> |
b1264f56 | 27 | |
dd3fd4df JH |
28 | #include <glibmm/variant.h> |
29 | ||
d7bed479 JH |
30 | #include <QMainWindow> |
31 | ||
f65cd27b | 32 | #include "session.hpp" |
7cd2b5f3 | 33 | #include "view/viewwidget.hpp" |
2953961c | 34 | |
269528f5 JH |
35 | struct srd_decoder; |
36 | ||
7d5425ef | 37 | class QVBoxLayout; |
7d5425ef | 38 | |
51cf49fe | 39 | namespace sigrok { |
dd3fd4df | 40 | class InputFormat; |
998b89fd | 41 | class OutputFormat; |
51cf49fe JH |
42 | } |
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; | |
55 | } | |
56 | ||
f0d37dab | 57 | namespace widgets { |
e79171dc | 58 | #ifdef ENABLE_DECODE |
f0d37dab | 59 | class DecoderMenu; |
19be0af1 | 60 | #endif |
f0d37dab JH |
61 | } |
62 | ||
d7bed479 JH |
63 | class MainWindow : public QMainWindow |
64 | { | |
65 | Q_OBJECT | |
66 | ||
619dfb11 JH |
67 | private: |
68 | /** | |
69 | * Name of the setting used to remember the directory | |
70 | * containing the last file that was opened. | |
71 | */ | |
72 | static const char *SettingOpenDirectory; | |
73 | ||
74 | /** | |
75 | * Name of the setting used to remember the directory | |
76 | * containing the last file that was saved. | |
77 | */ | |
78 | static const char *SettingSaveDirectory; | |
79 | ||
d7bed479 | 80 | public: |
107ca6d3 | 81 | explicit MainWindow(DeviceManager &device_manager, |
e3c79b07 JH |
82 | std::string open_file_name = std::string(), |
83 | std::string open_file_format = std::string(), | |
1d478458 | 84 | QWidget *parent = 0); |
d7bed479 | 85 | |
47e9e7bb SA |
86 | ~MainWindow(); |
87 | ||
69654681 JH |
88 | QAction* action_open() const; |
89 | QAction* action_save_as() const; | |
d2fc6be9 | 90 | QAction* action_save_selection_as() const; |
69654681 JH |
91 | QAction* action_connect() const; |
92 | QAction* action_quit() const; | |
93 | QAction* action_view_zoom_in() const; | |
94 | QAction* action_view_zoom_out() const; | |
95 | QAction* action_view_zoom_fit() const; | |
96 | QAction* action_view_zoom_one_to_one() const; | |
c7b03d9d | 97 | QAction* action_view_sticky_scrolling() const; |
0fb9d645 | 98 | QAction* action_view_coloured_bg() const; |
69654681 JH |
99 | QAction* action_view_show_cursors() const; |
100 | QAction* action_about() const; | |
101 | ||
e79171dc | 102 | #ifdef ENABLE_DECODE |
0f90452b | 103 | QMenu* menu_decoder_add() const; |
19be0af1 | 104 | #endif |
0f90452b | 105 | |
168bd8ac SA |
106 | std::shared_ptr<pv::view::View> get_active_view() const; |
107 | ||
7cd2b5f3 SA |
108 | std::shared_ptr<pv::view::View> add_view(const QString &title, |
109 | view::ViewType type, Session &session); | |
110 | ||
4e7f5ba8 JH |
111 | void run_stop(); |
112 | ||
da30ecb7 | 113 | void select_device(std::shared_ptr<devices::Device> device); |
51cf49fe | 114 | |
998b89fd | 115 | public Q_SLOTS: |
7d6984a5 SA |
116 | void export_file(std::shared_ptr<sigrok::OutputFormat> format, |
117 | bool selection_only = false); | |
ed43ef2e | 118 | void import_file(std::shared_ptr<sigrok::InputFormat> format); |
998b89fd | 119 | |
d7bed479 | 120 | private: |
7d5425ef JH |
121 | void setup_ui(); |
122 | ||
e3c79b07 JH |
123 | void select_init_device(); |
124 | ||
125 | void load_init_file(const std::string &file_name, | |
126 | const std::string &format); | |
127 | ||
93f683ad SA |
128 | void save_ui_settings(); |
129 | ||
130 | void restore_ui_settings(); | |
131 | ||
f2edb557 JH |
132 | void session_error(const QString text, const QString info_text); |
133 | ||
107ca6d3 | 134 | /** |
079d39ea | 135 | * Updates the device list in the toolbar |
107ca6d3 | 136 | */ |
1c4c23b8 | 137 | void update_device_list(); |
107ca6d3 | 138 | |
e3c79b07 JH |
139 | void load_file(QString file_name, |
140 | std::shared_ptr<sigrok::InputFormat> format = nullptr, | |
141 | const std::map<std::string, Glib::VariantBase> &options = | |
142 | std::map<std::string, Glib::VariantBase>()); | |
143 | ||
d2fc6be9 SA |
144 | void save_selection_to_file(); |
145 | ||
1c4c23b8 | 146 | private: |
93f683ad SA |
147 | void closeEvent(QCloseEvent *event); |
148 | ||
1c4c23b8 JH |
149 | void keyReleaseEvent(QKeyEvent *event); |
150 | ||
d290e89f SA |
151 | virtual QMenu* createPopupMenu(); |
152 | ||
55547a45 SA |
153 | virtual bool restoreState(const QByteArray &state, int version = 0); |
154 | ||
e9213170 | 155 | private Q_SLOTS: |
ef7e3146 JH |
156 | void show_session_error( |
157 | const QString text, const QString info_text); | |
158 | ||
159 | void on_actionOpen_triggered(); | |
0fbda3c2 | 160 | void on_actionSaveAs_triggered(); |
d2fc6be9 | 161 | void on_actionSaveSelectionAs_triggered(); |
ef7e3146 JH |
162 | void on_actionQuit_triggered(); |
163 | ||
164 | void on_actionConnect_triggered(); | |
165 | ||
166 | void on_actionViewZoomIn_triggered(); | |
167 | ||
168 | void on_actionViewZoomOut_triggered(); | |
169 | ||
ca46b534 JH |
170 | void on_actionViewZoomFit_triggered(); |
171 | ||
d1e7d82c JH |
172 | void on_actionViewZoomOneToOne_triggered(); |
173 | ||
c7b03d9d SA |
174 | void on_actionViewStickyScrolling_triggered(); |
175 | ||
0fb9d645 SA |
176 | void on_actionViewColouredBg_triggered(); |
177 | ||
ef7e3146 JH |
178 | void on_actionViewShowCursors_triggered(); |
179 | ||
180 | void on_actionAbout_triggered(); | |
181 | ||
f0d37dab | 182 | void add_decoder(srd_decoder *decoder); |
7dd093df | 183 | |
ef7e3146 | 184 | void capture_state_changed(int state); |
20f81a58 | 185 | void device_selected(); |
ef7e3146 | 186 | |
c7b03d9d SA |
187 | void sticky_scrolling_changed(bool state); |
188 | ||
ce11b2ea SA |
189 | void always_zoom_to_fit_changed(bool state); |
190 | ||
7d5425ef | 191 | private: |
8dbbc7f0 | 192 | DeviceManager &device_manager_; |
d4984fe7 | 193 | |
2b81ae46 | 194 | Session session_; |
18203d86 | 195 | |
25272fee SA |
196 | std::map< std::shared_ptr<QDockWidget>, |
197 | std::shared_ptr<pv::view::View> > view_docks_; | |
7d5425ef | 198 | |
7c657094 | 199 | toolbars::MainBar *main_bar_; |
69654681 JH |
200 | |
201 | QAction *const action_open_; | |
202 | QAction *const action_save_as_; | |
d2fc6be9 | 203 | QAction *const action_save_selection_as_; |
69654681 JH |
204 | QAction *const action_connect_; |
205 | QAction *const action_quit_; | |
206 | QAction *const action_view_zoom_in_; | |
207 | QAction *const action_view_zoom_out_; | |
208 | QAction *const action_view_zoom_fit_; | |
209 | QAction *const action_view_zoom_one_to_one_; | |
c7b03d9d | 210 | QAction *const action_view_sticky_scrolling_; |
0fb9d645 | 211 | QAction *const action_view_coloured_bg_; |
69654681 JH |
212 | QAction *const action_view_show_cursors_; |
213 | QAction *const action_about_; | |
0f90452b | 214 | |
e79171dc | 215 | #ifdef ENABLE_DECODE |
0f90452b | 216 | QMenu *const menu_decoders_add_; |
19be0af1 | 217 | #endif |
d7bed479 JH |
218 | }; |
219 | ||
51e77110 JH |
220 | } // namespace pv |
221 | ||
7a01bd36 | 222 | #endif // PULSEVIEW_PV_MAINWINDOW_HPP |