2 * This file is part of the PulseView project.
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
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.
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.
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
21 #ifndef PULSEVIEW_PV_MAINWINDOW_HPP
22 #define PULSEVIEW_PV_MAINWINDOW_HPP
28 #include <glibmm/variant.h>
30 #include <QMainWindow>
32 #include "session.hpp"
62 class MainWindow : public QMainWindow
68 * Name of the setting used to remember the directory
69 * containing the last file that was opened.
71 static const char *SettingOpenDirectory;
74 * Name of the setting used to remember the directory
75 * containing the last file that was saved.
77 static const char *SettingSaveDirectory;
80 explicit MainWindow(DeviceManager &device_manager,
81 std::string open_file_name = std::string(),
82 std::string open_file_format = std::string(),
85 QAction* action_open() const;
86 QAction* action_save_as() const;
87 QAction* action_save_selection_as() const;
88 QAction* action_connect() const;
89 QAction* action_quit() const;
90 QAction* action_view_zoom_in() const;
91 QAction* action_view_zoom_out() const;
92 QAction* action_view_zoom_fit() const;
93 QAction* action_view_zoom_one_to_one() const;
94 QAction* action_view_sticky_scrolling() const;
95 QAction* action_view_coloured_bg() const;
96 QAction* action_view_show_cursors() const;
97 QAction* action_about() const;
100 QMenu* menu_decoder_add() const;
105 void select_device(std::shared_ptr<devices::Device> device);
108 void export_file(std::shared_ptr<sigrok::OutputFormat> format,
109 bool selection_only = false);
110 void import_file(std::shared_ptr<sigrok::InputFormat> format);
115 void select_init_device();
117 void load_init_file(const std::string &file_name,
118 const std::string &format);
120 void save_ui_settings();
122 void restore_ui_settings();
124 void session_error(const QString text, const QString info_text);
127 * Updates the device list in the toolbar
129 void update_device_list();
131 void load_file(QString file_name,
132 std::shared_ptr<sigrok::InputFormat> format = nullptr,
133 const std::map<std::string, Glib::VariantBase> &options =
134 std::map<std::string, Glib::VariantBase>());
136 void save_selection_to_file();
139 void closeEvent(QCloseEvent *event);
141 void keyReleaseEvent(QKeyEvent *event);
144 void show_session_error(
145 const QString text, const QString info_text);
147 void on_actionOpen_triggered();
148 void on_actionSaveAs_triggered();
149 void on_actionSaveSelectionAs_triggered();
150 void on_actionQuit_triggered();
152 void on_actionConnect_triggered();
154 void on_actionViewZoomIn_triggered();
156 void on_actionViewZoomOut_triggered();
158 void on_actionViewZoomFit_triggered();
160 void on_actionViewZoomOneToOne_triggered();
162 void on_actionViewStickyScrolling_triggered();
164 void on_actionViewColouredBg_triggered();
166 void on_actionViewShowCursors_triggered();
168 void on_actionAbout_triggered();
170 void add_decoder(srd_decoder *decoder);
172 void capture_state_changed(int state);
173 void device_selected();
175 void sticky_scrolling_changed(bool state);
177 void always_zoom_to_fit_changed(bool state);
180 DeviceManager &device_manager_;
184 pv::view::View *view_;
186 QWidget *central_widget_;
187 QVBoxLayout *vertical_layout_;
189 toolbars::MainBar *main_bar_;
191 QAction *const action_open_;
192 QAction *const action_save_as_;
193 QAction *const action_save_selection_as_;
194 QAction *const action_connect_;
195 QAction *const action_quit_;
196 QAction *const action_view_zoom_in_;
197 QAction *const action_view_zoom_out_;
198 QAction *const action_view_zoom_fit_;
199 QAction *const action_view_zoom_one_to_one_;
200 QAction *const action_view_sticky_scrolling_;
201 QAction *const action_view_coloured_bg_;
202 QAction *const action_view_show_cursors_;
203 QAction *const action_about_;
206 QMenu *const menu_decoders_add_;
212 #endif // PULSEVIEW_PV_MAINWINDOW_HPP