2012-09-03 20:20:51 +08:00
|
|
|
/*
|
2012-10-13 04:20:44 +08:00
|
|
|
* This file is part of the PulseView project.
|
2012-09-03 20:20:51 +08:00
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2016-10-20 15:53:43 +08:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2012-09-03 20:20:51 +08:00
|
|
|
*/
|
|
|
|
|
2015-01-18 06:00:52 +08:00
|
|
|
#ifndef PULSEVIEW_PV_MAINWINDOW_HPP
|
|
|
|
#define PULSEVIEW_PV_MAINWINDOW_HPP
|
2012-09-03 20:20:51 +08:00
|
|
|
|
2013-03-08 06:39:55 +08:00
|
|
|
#include <list>
|
2015-03-28 21:25:41 +08:00
|
|
|
#include <map>
|
2014-05-21 05:58:55 +08:00
|
|
|
#include <memory>
|
2013-05-19 17:37:52 +08:00
|
|
|
|
2012-09-03 20:20:51 +08:00
|
|
|
#include <QMainWindow>
|
2017-03-28 14:30:43 +08:00
|
|
|
#include <QShortcut>
|
2016-10-11 01:22:38 +08:00
|
|
|
#include <QSignalMapper>
|
2016-09-30 01:36:48 +08:00
|
|
|
#include <QTabWidget>
|
2017-03-28 14:30:43 +08:00
|
|
|
#include <QToolButton>
|
2012-09-03 20:20:51 +08:00
|
|
|
|
2018-01-21 21:28:27 +08:00
|
|
|
#include "globalsettings.hpp"
|
2014-12-04 06:23:36 +08:00
|
|
|
#include "session.hpp"
|
2016-09-26 14:45:38 +08:00
|
|
|
#include "views/viewbase.hpp"
|
2012-05-14 05:26:02 +08:00
|
|
|
|
2017-03-16 06:16:05 +08:00
|
|
|
using std::list;
|
|
|
|
using std::map;
|
|
|
|
using std::shared_ptr;
|
|
|
|
using std::string;
|
|
|
|
|
2013-12-29 02:29:23 +08:00
|
|
|
struct srd_decoder;
|
|
|
|
|
2012-07-08 17:31:50 +08:00
|
|
|
class QVBoxLayout;
|
|
|
|
|
2012-10-13 05:41:01 +08:00
|
|
|
namespace pv {
|
|
|
|
|
2013-04-28 04:53:21 +08:00
|
|
|
class DeviceManager;
|
2014-02-20 06:18:01 +08:00
|
|
|
|
2013-03-16 16:22:29 +08:00
|
|
|
namespace toolbars {
|
2013-05-04 16:44:22 +08:00
|
|
|
class ContextBar;
|
2014-12-30 22:37:29 +08:00
|
|
|
class MainBar;
|
2013-03-16 16:22:29 +08:00
|
|
|
}
|
2012-10-13 05:41:01 +08:00
|
|
|
|
|
|
|
namespace view {
|
|
|
|
class View;
|
|
|
|
}
|
|
|
|
|
2013-10-26 22:28:59 +08:00
|
|
|
namespace widgets {
|
2015-02-19 00:19:08 +08:00
|
|
|
#ifdef ENABLE_DECODE
|
2013-10-26 22:28:59 +08:00
|
|
|
class DecoderMenu;
|
2015-02-20 18:25:45 +08:00
|
|
|
#endif
|
2013-10-26 22:28:59 +08:00
|
|
|
}
|
|
|
|
|
2018-01-21 21:28:27 +08:00
|
|
|
class MainWindow : public QMainWindow, public GlobalSettingsInterface
|
2012-09-03 20:20:51 +08:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2016-09-04 06:15:42 +08:00
|
|
|
private:
|
|
|
|
static const QString WindowTitle;
|
|
|
|
|
2012-09-03 20:20:51 +08:00
|
|
|
public:
|
2013-04-28 04:53:21 +08:00
|
|
|
explicit MainWindow(DeviceManager &device_manager,
|
2017-03-21 04:26:44 +08:00
|
|
|
QWidget *parent = nullptr);
|
2012-09-03 20:20:51 +08:00
|
|
|
|
2016-08-17 03:31:59 +08:00
|
|
|
~MainWindow();
|
|
|
|
|
2017-03-16 06:16:05 +08:00
|
|
|
shared_ptr<views::ViewBase> get_active_view() const;
|
2016-04-17 05:49:07 +08:00
|
|
|
|
2017-03-16 06:16:05 +08:00
|
|
|
shared_ptr<views::ViewBase> add_view(const QString &title,
|
2016-09-26 14:45:38 +08:00
|
|
|
views::ViewType type, Session &session);
|
2016-08-17 00:11:41 +08:00
|
|
|
|
2017-03-16 06:16:05 +08:00
|
|
|
void remove_view(shared_ptr<views::ViewBase> view);
|
2017-01-18 05:05:41 +08:00
|
|
|
|
2017-03-16 06:16:05 +08:00
|
|
|
shared_ptr<Session> add_session();
|
2016-08-28 03:55:57 +08:00
|
|
|
|
2017-03-16 06:16:05 +08:00
|
|
|
void remove_session(shared_ptr<Session> session);
|
2016-09-03 00:20:41 +08:00
|
|
|
|
2017-06-10 03:57:21 +08:00
|
|
|
void add_session_with_file(string open_file_name, string open_file_format);
|
|
|
|
|
|
|
|
void add_default_session();
|
|
|
|
|
|
|
|
void save_sessions();
|
|
|
|
void restore_sessions();
|
|
|
|
|
2018-01-21 21:28:27 +08:00
|
|
|
void on_setting_changed(const QString &key, const QVariant &value);
|
|
|
|
|
2012-09-03 20:20:51 +08:00
|
|
|
private:
|
2012-07-08 17:31:50 +08:00
|
|
|
void setup_ui();
|
|
|
|
|
2014-09-13 06:43:26 +08:00
|
|
|
void save_ui_settings();
|
2017-06-10 03:57:21 +08:00
|
|
|
void restore_ui_settings();
|
2014-09-13 06:43:26 +08:00
|
|
|
|
2017-03-16 06:16:05 +08:00
|
|
|
shared_ptr<Session> get_tab_session(int index) const;
|
2016-10-10 02:55:19 +08:00
|
|
|
|
2014-09-13 06:43:26 +08:00
|
|
|
void closeEvent(QCloseEvent *event);
|
|
|
|
|
2016-08-17 14:25:03 +08:00
|
|
|
virtual QMenu* createPopupMenu();
|
|
|
|
|
2016-08-19 02:02:18 +08:00
|
|
|
virtual bool restoreState(const QByteArray &state, int version = 0);
|
|
|
|
|
2016-10-11 01:22:38 +08:00
|
|
|
void session_error(const QString text, const QString info_text);
|
|
|
|
|
2016-10-11 21:47:53 +08:00
|
|
|
private Q_SLOTS:
|
2016-10-11 01:22:38 +08:00
|
|
|
void show_session_error(const QString text, const QString info_text);
|
|
|
|
|
2016-09-26 14:45:38 +08:00
|
|
|
void on_add_view(const QString &title, views::ViewType type,
|
2016-08-31 14:19:02 +08:00
|
|
|
Session *session);
|
|
|
|
|
2016-09-04 06:15:42 +08:00
|
|
|
void on_focus_changed();
|
2017-03-16 06:16:05 +08:00
|
|
|
void on_focused_session_changed(shared_ptr<Session> session);
|
2016-09-04 06:15:42 +08:00
|
|
|
|
2016-10-08 21:47:12 +08:00
|
|
|
void on_new_session_clicked();
|
2016-10-11 01:22:38 +08:00
|
|
|
void on_run_stop_clicked();
|
2017-03-07 02:04:47 +08:00
|
|
|
void on_settings_clicked();
|
2016-10-11 01:22:38 +08:00
|
|
|
|
2016-09-04 06:15:42 +08:00
|
|
|
void on_session_name_changed();
|
2016-10-11 01:22:38 +08:00
|
|
|
void on_capture_state_changed(QObject *obj);
|
|
|
|
|
2016-09-02 03:11:18 +08:00
|
|
|
void on_new_view(Session *session);
|
2016-09-03 00:20:41 +08:00
|
|
|
void on_view_close_clicked();
|
2016-09-02 03:11:18 +08:00
|
|
|
|
2016-10-10 02:55:19 +08:00
|
|
|
void on_tab_changed(int index);
|
2016-10-05 01:52:29 +08:00
|
|
|
void on_tab_close_requested(int index);
|
|
|
|
|
2017-03-04 17:06:22 +08:00
|
|
|
void on_view_coloured_bg_shortcut();
|
2017-03-13 04:32:35 +08:00
|
|
|
void on_view_sticky_scrolling_shortcut();
|
2017-03-18 03:47:36 +08:00
|
|
|
void on_view_show_sampling_points_shortcut();
|
2017-03-31 14:27:28 +08:00
|
|
|
void on_view_show_analog_minor_grid_shortcut();
|
2015-12-28 23:15:29 +08:00
|
|
|
|
2017-03-06 02:58:37 +08:00
|
|
|
void on_settingViewColouredBg_changed(const QVariant new_value);
|
2017-03-18 03:47:36 +08:00
|
|
|
void on_settingViewShowSamplingPoints_changed(const QVariant new_value);
|
2017-03-31 14:27:28 +08:00
|
|
|
void on_settingViewShowAnalogMinorGrid_changed(const QVariant new_value);
|
2017-03-06 02:58:37 +08:00
|
|
|
|
2017-03-03 15:31:04 +08:00
|
|
|
void on_close_current_tab();
|
|
|
|
|
2012-07-08 17:31:50 +08:00
|
|
|
private:
|
2014-11-22 16:46:22 +08:00
|
|
|
DeviceManager &device_manager_;
|
2012-06-28 05:24:48 +08:00
|
|
|
|
2017-03-16 06:16:05 +08:00
|
|
|
list< shared_ptr<Session> > sessions_;
|
|
|
|
shared_ptr<Session> last_focused_session_;
|
2013-03-08 06:39:55 +08:00
|
|
|
|
2017-03-16 06:16:05 +08:00
|
|
|
map< QDockWidget*, shared_ptr<views::ViewBase> > view_docks_;
|
2012-07-08 17:31:50 +08:00
|
|
|
|
2017-03-16 06:16:05 +08:00
|
|
|
map< shared_ptr<Session>, QMainWindow*> session_windows_;
|
2016-09-30 01:36:48 +08:00
|
|
|
|
2016-10-10 15:15:04 +08:00
|
|
|
QWidget *static_tab_widget_;
|
2016-10-18 23:27:14 +08:00
|
|
|
QToolButton *new_session_button_, *run_stop_button_, *settings_button_;
|
2016-09-30 01:36:48 +08:00
|
|
|
QTabWidget session_selector_;
|
2016-10-11 01:22:38 +08:00
|
|
|
QSignalMapper session_state_mapper_;
|
2016-09-30 01:36:48 +08:00
|
|
|
|
2016-10-11 01:22:38 +08:00
|
|
|
QIcon icon_red_;
|
|
|
|
QIcon icon_green_;
|
|
|
|
QIcon icon_grey_;
|
2017-03-03 09:55:55 +08:00
|
|
|
|
2017-03-04 17:06:22 +08:00
|
|
|
QShortcut *view_sticky_scrolling_shortcut_;
|
2017-03-18 03:47:36 +08:00
|
|
|
QShortcut *view_show_sampling_points_shortcut_;
|
2017-03-31 14:27:28 +08:00
|
|
|
QShortcut *view_show_analog_minor_grid_shortcut_;
|
2017-03-04 17:06:22 +08:00
|
|
|
QShortcut *view_coloured_bg_shortcut_;
|
2017-03-03 09:55:55 +08:00
|
|
|
QShortcut *run_stop_shortcut_;
|
2017-03-03 15:31:04 +08:00
|
|
|
QShortcut *close_application_shortcut_;
|
|
|
|
QShortcut *close_current_tab_shortcut_;
|
2012-09-03 20:20:51 +08:00
|
|
|
};
|
|
|
|
|
2012-10-13 05:41:01 +08:00
|
|
|
} // namespace pv
|
|
|
|
|
2015-01-18 06:00:52 +08:00
|
|
|
#endif // PULSEVIEW_PV_MAINWINDOW_HPP
|