]>
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" |
2953961c | 33 | |
269528f5 JH |
34 | struct srd_decoder; |
35 | ||
7d5425ef | 36 | class QVBoxLayout; |
7d5425ef | 37 | |
51cf49fe | 38 | namespace sigrok { |
dd3fd4df | 39 | class InputFormat; |
998b89fd | 40 | class OutputFormat; |
51cf49fe JH |
41 | } |
42 | ||
51e77110 JH |
43 | namespace pv { |
44 | ||
107ca6d3 | 45 | class DeviceManager; |
94574501 | 46 | |
f4c92e1c | 47 | namespace toolbars { |
404aad0e | 48 | class ContextBar; |
7c657094 | 49 | class MainBar; |
f4c92e1c | 50 | } |
51e77110 JH |
51 | |
52 | namespace view { | |
53 | class View; | |
54 | } | |
55 | ||
f0d37dab | 56 | namespace widgets { |
e79171dc | 57 | #ifdef ENABLE_DECODE |
f0d37dab | 58 | class DecoderMenu; |
19be0af1 | 59 | #endif |
f0d37dab JH |
60 | } |
61 | ||
d7bed479 JH |
62 | class MainWindow : public QMainWindow |
63 | { | |
64 | Q_OBJECT | |
65 | ||
619dfb11 JH |
66 | private: |
67 | /** | |
68 | * Name of the setting used to remember the directory | |
69 | * containing the last file that was opened. | |
70 | */ | |
71 | static const char *SettingOpenDirectory; | |
72 | ||
73 | /** | |
74 | * Name of the setting used to remember the directory | |
75 | * containing the last file that was saved. | |
76 | */ | |
77 | static const char *SettingSaveDirectory; | |
78 | ||
d7bed479 | 79 | public: |
107ca6d3 | 80 | explicit MainWindow(DeviceManager &device_manager, |
e3c79b07 JH |
81 | std::string open_file_name = std::string(), |
82 | std::string open_file_format = std::string(), | |
1d478458 | 83 | QWidget *parent = 0); |
d7bed479 | 84 | |
69654681 JH |
85 | QAction* action_open() const; |
86 | QAction* action_save_as() const; | |
87 | QAction* action_connect() const; | |
88 | QAction* action_quit() const; | |
89 | QAction* action_view_zoom_in() const; | |
90 | QAction* action_view_zoom_out() const; | |
91 | QAction* action_view_zoom_fit() const; | |
92 | QAction* action_view_zoom_one_to_one() const; | |
c7b03d9d | 93 | QAction* action_view_sticky_scrolling() const; |
69654681 JH |
94 | QAction* action_view_show_cursors() const; |
95 | QAction* action_about() const; | |
96 | ||
e79171dc | 97 | #ifdef ENABLE_DECODE |
0f90452b | 98 | QMenu* menu_decoder_add() const; |
19be0af1 | 99 | #endif |
0f90452b | 100 | |
4e7f5ba8 JH |
101 | void run_stop(); |
102 | ||
da30ecb7 | 103 | void select_device(std::shared_ptr<devices::Device> device); |
51cf49fe | 104 | |
998b89fd JH |
105 | public Q_SLOTS: |
106 | void export_file(std::shared_ptr<sigrok::OutputFormat> format); | |
ed43ef2e | 107 | void import_file(std::shared_ptr<sigrok::InputFormat> format); |
998b89fd | 108 | |
d7bed479 | 109 | private: |
7d5425ef JH |
110 | void setup_ui(); |
111 | ||
e3c79b07 JH |
112 | void select_init_device(); |
113 | ||
114 | void load_init_file(const std::string &file_name, | |
115 | const std::string &format); | |
116 | ||
93f683ad SA |
117 | void save_ui_settings(); |
118 | ||
119 | void restore_ui_settings(); | |
120 | ||
f2edb557 JH |
121 | void session_error(const QString text, const QString info_text); |
122 | ||
107ca6d3 | 123 | /** |
079d39ea | 124 | * Updates the device list in the toolbar |
107ca6d3 | 125 | */ |
1c4c23b8 | 126 | void update_device_list(); |
107ca6d3 | 127 | |
e3c79b07 JH |
128 | void load_file(QString file_name, |
129 | std::shared_ptr<sigrok::InputFormat> format = nullptr, | |
130 | const std::map<std::string, Glib::VariantBase> &options = | |
131 | std::map<std::string, Glib::VariantBase>()); | |
132 | ||
1c4c23b8 | 133 | private: |
93f683ad SA |
134 | void closeEvent(QCloseEvent *event); |
135 | ||
1c4c23b8 JH |
136 | void keyReleaseEvent(QKeyEvent *event); |
137 | ||
e9213170 | 138 | private Q_SLOTS: |
ef7e3146 JH |
139 | void show_session_error( |
140 | const QString text, const QString info_text); | |
141 | ||
142 | void on_actionOpen_triggered(); | |
0fbda3c2 | 143 | void on_actionSaveAs_triggered(); |
ef7e3146 JH |
144 | void on_actionQuit_triggered(); |
145 | ||
146 | void on_actionConnect_triggered(); | |
147 | ||
148 | void on_actionViewZoomIn_triggered(); | |
149 | ||
150 | void on_actionViewZoomOut_triggered(); | |
151 | ||
ca46b534 JH |
152 | void on_actionViewZoomFit_triggered(); |
153 | ||
d1e7d82c JH |
154 | void on_actionViewZoomOneToOne_triggered(); |
155 | ||
c7b03d9d SA |
156 | void on_actionViewStickyScrolling_triggered(); |
157 | ||
ef7e3146 JH |
158 | void on_actionViewShowCursors_triggered(); |
159 | ||
160 | void on_actionAbout_triggered(); | |
161 | ||
f0d37dab | 162 | void add_decoder(srd_decoder *decoder); |
7dd093df | 163 | |
ef7e3146 | 164 | void capture_state_changed(int state); |
20f81a58 | 165 | void device_selected(); |
ef7e3146 | 166 | |
c7b03d9d SA |
167 | void sticky_scrolling_changed(bool state); |
168 | ||
ce11b2ea SA |
169 | void always_zoom_to_fit_changed(bool state); |
170 | ||
7d5425ef | 171 | private: |
8dbbc7f0 | 172 | DeviceManager &device_manager_; |
d4984fe7 | 173 | |
2b81ae46 | 174 | Session session_; |
18203d86 | 175 | |
8dbbc7f0 | 176 | pv::view::View *view_; |
30236a54 | 177 | |
8dbbc7f0 JH |
178 | QWidget *central_widget_; |
179 | QVBoxLayout *vertical_layout_; | |
7d5425ef | 180 | |
7c657094 | 181 | toolbars::MainBar *main_bar_; |
69654681 JH |
182 | |
183 | QAction *const action_open_; | |
184 | QAction *const action_save_as_; | |
185 | QAction *const action_connect_; | |
186 | QAction *const action_quit_; | |
187 | QAction *const action_view_zoom_in_; | |
188 | QAction *const action_view_zoom_out_; | |
189 | QAction *const action_view_zoom_fit_; | |
190 | QAction *const action_view_zoom_one_to_one_; | |
c7b03d9d | 191 | QAction *const action_view_sticky_scrolling_; |
69654681 JH |
192 | QAction *const action_view_show_cursors_; |
193 | QAction *const action_about_; | |
0f90452b | 194 | |
e79171dc | 195 | #ifdef ENABLE_DECODE |
0f90452b | 196 | QMenu *const menu_decoders_add_; |
19be0af1 | 197 | #endif |
d7bed479 JH |
198 | }; |
199 | ||
51e77110 JH |
200 | } // namespace pv |
201 | ||
7a01bd36 | 202 | #endif // PULSEVIEW_PV_MAINWINDOW_HPP |