]> sigrok.org Git - pulseview.git/blob - pv/mainwindow.h
Added DeviceManager
[pulseview.git] / pv / mainwindow.h
1 /*
2  * This file is part of the PulseView project.
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
21 #ifndef PULSEVIEW_PV_MAINWINDOW_H
22 #define PULSEVIEW_PV_MAINWINDOW_H
23
24 #include <list>
25
26 #include <QMainWindow>
27
28 #include "sigsession.h"
29
30 class QAction;
31 class QMenuBar;
32 class QMenu;
33 class QVBoxLayout;
34 class QStatusBar;
35 class QToolBar;
36 class QWidget;
37
38 namespace pv {
39
40 class DeviceManager;
41
42 namespace toolbars {
43 class SamplingBar;
44 }
45
46 namespace view {
47 class View;
48 }
49
50 class MainWindow : public QMainWindow
51 {
52         Q_OBJECT
53
54 public:
55         explicit MainWindow(DeviceManager &device_manager,
56                 const char *open_file_name = NULL,
57                 QWidget *parent = 0);
58
59 private:
60         void setup_ui();
61
62         void session_error(const QString text, const QString info_text);
63
64         /**
65          * Updates the device list in the sampling bar, and updates the
66          * selection.
67          * @param selected_device The device to select, or NULL if the
68          * first device in the device list should be selected.
69          */
70         void update_device_list(
71                 struct sr_dev_inst *selected_device = NULL);
72
73 private slots:
74         void load_file(QString file_name);
75
76
77         void show_session_error(
78                 const QString text, const QString info_text);
79
80         void on_actionOpen_triggered();
81         void on_actionQuit_triggered();
82
83         void on_actionConnect_triggered();
84
85         void on_actionViewZoomIn_triggered();
86
87         void on_actionViewZoomOut_triggered();
88
89         void on_actionViewShowCursors_triggered();
90
91         void on_actionAbout_triggered();
92
93         void device_selected();
94
95         void run_stop();
96
97         void capture_state_changed(int state);
98
99 private:
100         DeviceManager &_device_manager;
101
102         SigSession _session;
103
104         pv::view::View *_view;
105
106         QMenuBar *_menu_bar;
107         QMenu *_menu_file;
108         QAction *_action_open;
109         QAction *_action_connect;
110         QAction *_action_quit;
111
112         QMenu *_menu_view;
113         QAction *_action_view_zoom_in;
114         QAction *_action_view_zoom_out;
115         QAction *_action_view_show_cursors;
116
117         QMenu *_menu_help;
118         QAction *_action_about;
119
120         QWidget *_central_widget;
121         QVBoxLayout *_vertical_layout;
122
123         QToolBar *_toolbar;
124         toolbars::SamplingBar *_sampling_bar;
125 };
126
127 } // namespace pv
128
129 #endif // PULSEVIEW_PV_MAINWINDOW_H