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