]> sigrok.org Git - pulseview.git/blobdiff - pv/mainwindow.h
Moved all srd commands into decode thread, implemented error messages
[pulseview.git] / pv / mainwindow.h
index ac48852e4949e452c86e64d13051d4ff128f44e2..47704c2fc8f7abe1ab614c33f684ba4a87f1d513 100644 (file)
 
 #include <list>
 
+#include <boost/weak_ptr.hpp>
+
 #include <QMainWindow>
+#include <QSignalMapper>
 
 #include "sigsession.h"
 
@@ -37,7 +40,12 @@ class QWidget;
 
 namespace pv {
 
+class DeviceManager;
+
+namespace toolbars {
+class ContextBar;
 class SamplingBar;
+}
 
 namespace view {
 class View;
@@ -48,17 +56,57 @@ class MainWindow : public QMainWindow
        Q_OBJECT
 
 public:
-       explicit MainWindow(const char *open_file_name = NULL,
+       explicit MainWindow(DeviceManager &device_manager,
+               const char *open_file_name = NULL,
                QWidget *parent = 0);
 
 private:
        void setup_ui();
-       void scan_devices();
+
+       void session_error(const QString text, const QString info_text);
+
+       /**
+        * Updates the device list in the sampling bar, and updates the
+        * selection.
+        * @param selected_device The device to select, or NULL if the
+        * first device in the device list should be selected.
+        */
+       void update_device_list(
+               struct sr_dev_inst *selected_device = NULL);
+
+       static gint decoder_name_cmp(gconstpointer a, gconstpointer b);
+       void setup_add_decoders(QMenu *parent);
+
+private slots:
+       void load_file(QString file_name);
+
+
+       void show_session_error(
+               const QString text, const QString info_text);
+
+       void on_actionOpen_triggered();
+       void on_actionQuit_triggered();
+
+       void on_actionConnect_triggered();
+
+       void on_actionViewZoomIn_triggered();
+
+       void on_actionViewZoomOut_triggered();
+
+       void on_actionViewShowCursors_triggered();
+
+       void on_actionAbout_triggered();
+
+       void add_decoder(QObject *action);
+
+       void run_stop();
+
+       void capture_state_changed(int state);
 
 private:
+       DeviceManager &_device_manager;
 
        SigSession _session;
-       std::list<sr_dev_inst*> _devices;
 
        pv::view::View *_view;
 
@@ -73,6 +121,10 @@ private:
        QAction *_action_view_zoom_out;
        QAction *_action_view_show_cursors;
 
+       QMenu *_menu_decoders;
+       QMenu *_menu_decoders_add;
+       QSignalMapper _decoders_add_mapper;
+
        QMenu *_menu_help;
        QAction *_action_about;
 
@@ -80,27 +132,7 @@ private:
        QVBoxLayout *_vertical_layout;
 
        QToolBar *_toolbar;
-       SamplingBar *_sampling_bar;
-
-private slots:
-       void load_file(QString file_name);
-
-       void on_actionOpen_triggered();
-       void on_actionQuit_triggered();
-
-       void on_actionConnect_triggered();
-
-       void on_actionViewZoomIn_triggered();
-
-       void on_actionViewZoomOut_triggered();
-
-       void on_actionViewShowCursors_triggered();
-
-       void on_actionAbout_triggered();
-
-       void run_stop();
-
-       void capture_state_changed(int state);
+       toolbars::SamplingBar *_sampling_bar;
 };
 
 } // namespace pv