]> sigrok.org Git - pulseview.git/commitdiff
Implement views::trace::StandardBar and derive MainBar from it
authorSoeren Apel <redacted>
Mon, 28 Nov 2016 19:02:17 +0000 (20:02 +0100)
committerSoeren Apel <redacted>
Sun, 4 Dec 2016 13:37:38 +0000 (14:37 +0100)
CMakeLists.txt
pv/mainwindow.cpp
pv/toolbars/mainbar.cpp
pv/toolbars/mainbar.hpp
pv/views/trace/standardbar.cpp [new file with mode: 0644]
pv/views/trace/standardbar.hpp [new file with mode: 0644]

index b70a905ecba381df743972b02e717abcac353ebd..ee58ce2cd6b335f00e272dc172ee79f50ab2b2d5 100644 (file)
@@ -263,6 +263,7 @@ set(pulseview_SOURCES
        pv/view/viewport.cpp
        pv/view/viewwidget.cpp
        pv/views/viewbase.cpp
+       pv/views/trace/standardbar.cpp
        pv/widgets/colourbutton.cpp
        pv/widgets/colourpopup.cpp
        pv/widgets/devicetoolbutton.cpp
@@ -316,6 +317,7 @@ set(pulseview_HEADERS
        pv/view/viewport.hpp
        pv/view/viewwidget.hpp
        pv/views/viewbase.hpp
+       pv/views/trace/standardbar.hpp
        pv/widgets/colourbutton.hpp
        pv/widgets/colourpopup.hpp
        pv/widgets/devicetoolbutton.hpp
index f777bfd6ca932da01450ef000c2e3aad0bd1a7cf..4a98e4081b68e9999a2f07b3f17d78fdd9276951 100644 (file)
@@ -44,6 +44,7 @@
 #include "dialogs/about.hpp"
 #include "toolbars/mainbar.hpp"
 #include "view/view.hpp"
+#include "views/trace/standardbar.hpp"
 
 #include <stdint.h>
 #include <stdarg.h>
@@ -204,12 +205,17 @@ shared_ptr<views::ViewBase> MainWindow::add_view(const QString &title,
 
                        shared_ptr<MainBar> main_bar = session.main_bar();
                        if (!main_bar) {
-                               main_bar = make_shared<MainBar>(session, *this);
+                               /* Initial view, create the main bar */
+                               main_bar = make_shared<MainBar>(session, this, v.get());
                                dock_main->addToolBar(main_bar.get());
                                session.set_main_bar(main_bar);
 
                                connect(main_bar.get(), SIGNAL(new_view(Session*)),
                                        this, SLOT(on_new_view(Session*)));
+                       } else {
+                               /* Additional view, create a standard bar */
+                               dock_main->addToolBar(
+                                       new pv::views::trace::StandardBar(session, this, v.get()));
                        }
                        main_bar->action_view_show_cursors()->setChecked(v->cursors_shown());
 
index b670b75a6c41a2da6a117e4e7a55a205414f46a6..e77f18bb4e7ec861f32c55ccc38377080d9e5724 100644 (file)
@@ -86,20 +86,17 @@ const uint64_t MainBar::DefaultSampleCount = 1000000;
 const char *MainBar::SettingOpenDirectory = "MainWindow/OpenDirectory";
 const char *MainBar::SettingSaveDirectory = "MainWindow/SaveDirectory";
 
-MainBar::MainBar(Session &session, MainWindow &main_window) :
-       QToolBar("Sampling Bar", &main_window),
+MainBar::MainBar(Session &session, QWidget *parent,
+               pv::views::TraceView::View *view) :
+       StandardBar(session, parent, view, false),
        action_new_view_(new QAction(this)),
        action_open_(new QAction(this)),
        action_save_as_(new QAction(this)),
        action_save_selection_as_(new QAction(this)),
        action_connect_(new QAction(this)),
-       action_view_zoom_in_(new QAction(this)),
-       action_view_zoom_out_(new QAction(this)),
-       action_view_zoom_fit_(new QAction(this)),
-       action_view_zoom_one_to_one_(new QAction(this)),
-       action_view_show_cursors_(new QAction(this)),
-       session_(session),
-       device_selector_(&main_window, session.device_manager(),
+       open_button_(new QToolButton()),
+       save_button_(new QToolButton()),
+       device_selector_(parent, session.device_manager(),
                action_connect_),
        configure_button_(this),
        configure_button_action_(nullptr),
@@ -111,15 +108,12 @@ MainBar::MainBar(Session &session, MainWindow &main_window) :
        updating_sample_count_(false),
        sample_count_supported_(false)
 #ifdef ENABLE_DECODE
-       , menu_decoders_add_(new pv::widgets::DecoderMenu(this, true))
+       , add_decoder_button_(new QToolButton()),
+       menu_decoders_add_(new pv::widgets::DecoderMenu(this, true))
 #endif
 {
        setObjectName(QString::fromUtf8("MainBar"));
 
-       setMovable(false);
-       setFloatable(false);
-       setContextMenuPolicy(Qt::PreventContextMenu);
-
        // Actions
        action_new_view_->setText(tr("New &View"));
        action_new_view_->setIcon(QIcon::fromTheme("window-new",
@@ -166,47 +160,7 @@ MainBar::MainBar(Session &session, MainWindow &main_window) :
        connect(action_connect_, SIGNAL(triggered(bool)),
                this, SLOT(on_actionConnect_triggered()));
 
-       action_view_zoom_in_->setText(tr("Zoom &In"));
-       action_view_zoom_in_->setIcon(QIcon::fromTheme("zoom-in",
-               QIcon(":/icons/zoom-in.png")));
-       // simply using Qt::Key_Plus shows no + in the menu
-       action_view_zoom_in_->setShortcut(QKeySequence::ZoomIn);
-       connect(action_view_zoom_in_, SIGNAL(triggered(bool)),
-               this, SLOT(on_actionViewZoomIn_triggered()));
-
-       action_view_zoom_out_->setText(tr("Zoom &Out"));
-       action_view_zoom_out_->setIcon(QIcon::fromTheme("zoom-out",
-               QIcon(":/icons/zoom-out.png")));
-       action_view_zoom_out_->setShortcut(QKeySequence::ZoomOut);
-       connect(action_view_zoom_out_, SIGNAL(triggered(bool)),
-               this, SLOT(on_actionViewZoomOut_triggered()));
-
-       action_view_zoom_fit_->setCheckable(true);
-       action_view_zoom_fit_->setText(tr("Zoom to &Fit"));
-       action_view_zoom_fit_->setIcon(QIcon::fromTheme("zoom-fit",
-               QIcon(":/icons/zoom-fit.png")));
-       action_view_zoom_fit_->setShortcut(QKeySequence(Qt::Key_F));
-       connect(action_view_zoom_fit_, SIGNAL(triggered(bool)),
-               this, SLOT(on_actionViewZoomFit_triggered()));
-
-       action_view_zoom_one_to_one_->setText(tr("Zoom to O&ne-to-One"));
-       action_view_zoom_one_to_one_->setIcon(QIcon::fromTheme("zoom-original",
-               QIcon(":/icons/zoom-original.png")));
-       action_view_zoom_one_to_one_->setShortcut(QKeySequence(Qt::Key_O));
-       connect(action_view_zoom_one_to_one_, SIGNAL(triggered(bool)),
-               this, SLOT(on_actionViewZoomOneToOne_triggered()));
-
-       action_view_show_cursors_->setCheckable(true);
-       action_view_show_cursors_->setIcon(QIcon::fromTheme("show-cursors",
-               QIcon(":/icons/show-cursors.svg")));
-       action_view_show_cursors_->setShortcut(QKeySequence(Qt::Key_C));
-       connect(action_view_show_cursors_, SIGNAL(triggered(bool)),
-               this, SLOT(on_actionViewShowCursors_triggered()));
-       action_view_show_cursors_->setText(tr("Show &Cursors"));
-
        // Open button
-       QToolButton *const open_button = new QToolButton(this);
-
        widgets::ImportMenu *import_menu = new widgets::ImportMenu(this,
                session.device_manager().context(), action_open_);
        connect(import_menu,
@@ -214,13 +168,11 @@ MainBar::MainBar(Session &session, MainWindow &main_window) :
                this,
                SLOT(import_file(std::shared_ptr<sigrok::InputFormat>)));
 
-       open_button->setMenu(import_menu);
-       open_button->setDefaultAction(action_open_);
-       open_button->setPopupMode(QToolButton::MenuButtonPopup);
+       open_button_->setMenu(import_menu);
+       open_button_->setDefaultAction(action_open_);
+       open_button_->setPopupMode(QToolButton::MenuButtonPopup);
 
        // Save button
-       QToolButton *const save_button = new QToolButton(this);
-
        vector<QAction *> open_actions;
        open_actions.push_back(action_save_as_);
        open_actions.push_back(action_save_selection_as_);
@@ -233,9 +185,9 @@ MainBar::MainBar(Session &session, MainWindow &main_window) :
                this,
                SLOT(export_file(std::shared_ptr<sigrok::OutputFormat>)));
 
-       save_button->setMenu(export_menu);
-       save_button->setDefaultAction(action_save_as_);
-       save_button->setPopupMode(QToolButton::MenuButtonPopup);
+       save_button_->setMenu(export_menu);
+       save_button_->setDefaultAction(action_save_as_);
+       save_button_->setPopupMode(QToolButton::MenuButtonPopup);
 
        // Device selector menu
        connect(&device_selector_, SIGNAL(device_selected()),
@@ -247,27 +199,12 @@ MainBar::MainBar(Session &session, MainWindow &main_window) :
        connect(menu_decoders_add_, SIGNAL(decoder_selected(srd_decoder*)),
                this, SLOT(add_decoder(srd_decoder*)));
 
-       QToolButton *add_decoder_button = new QToolButton(this);
-       add_decoder_button->setIcon(QIcon::fromTheme("add-decoder",
+       add_decoder_button_->setIcon(QIcon::fromTheme("add-decoder",
                QIcon(":/icons/add-decoder.svg")));
-       add_decoder_button->setPopupMode(QToolButton::InstantPopup);
-       add_decoder_button->setMenu(menu_decoders_add_);
+       add_decoder_button_->setPopupMode(QToolButton::InstantPopup);
+       add_decoder_button_->setMenu(menu_decoders_add_);
 #endif
 
-       // Setup the toolbar
-       addAction(action_new_view_);
-       addSeparator();
-       addWidget(open_button);
-       addWidget(save_button);
-       addSeparator();
-       addAction(action_view_zoom_in_);
-       addAction(action_view_zoom_out_);
-       addAction(action_view_zoom_fit_);
-       addAction(action_view_zoom_one_to_one_);
-       addSeparator();
-       addAction(action_view_show_cursors_);
-       addSeparator();
-
        connect(&sample_count_, SIGNAL(value_changed()),
                this, SLOT(on_sample_count_changed()));
        connect(&sample_rate_, SIGNAL(value_changed()),
@@ -283,15 +220,7 @@ MainBar::MainBar(Session &session, MainWindow &main_window) :
        channels_button_.setIcon(QIcon::fromTheme("channels",
                QIcon(":/icons/channels.svg")));
 
-       addWidget(&device_selector_);
-       configure_button_action_ = addWidget(&configure_button_);
-       channels_button_action_ = addWidget(&channels_button_);
-       addWidget(&sample_count_);
-       addWidget(&sample_rate_);
-#ifdef ENABLE_DECODE
-       addSeparator();
-       addWidget(add_decoder_button);
-#endif
+       add_toolbar_widgets();
 
        sample_count_.installEventFilter(this);
        sample_rate_.installEventFilter(this);
@@ -305,11 +234,6 @@ MainBar::MainBar(Session &session, MainWindow &main_window) :
        update_device_list();
 }
 
-Session &MainBar::session(void) const
-{
-       return session_;
-}
-
 void MainBar::update_device_list()
 {
        DeviceManager &mgr = session_.device_manager();
@@ -362,31 +286,6 @@ QAction* MainBar::action_connect() const
        return action_connect_;
 }
 
-QAction* MainBar::action_view_zoom_in() const
-{
-       return action_view_zoom_in_;
-}
-
-QAction* MainBar::action_view_zoom_out() const
-{
-       return action_view_zoom_out_;
-}
-
-QAction* MainBar::action_view_zoom_fit() const
-{
-       return action_view_zoom_fit_;
-}
-
-QAction* MainBar::action_view_zoom_one_to_one() const
-{
-       return action_view_zoom_one_to_one_;
-}
-
-QAction* MainBar::action_view_show_cursors() const
-{
-       return action_view_show_cursors_;
-}
-
 void MainBar::update_sample_rate_selector()
 {
        Glib::VariantContainerBase gvar_dict;
@@ -883,53 +782,25 @@ void MainBar::on_actionConnect_triggered()
        update_device_list();
 }
 
-void MainBar::on_actionViewZoomIn_triggered()
+void MainBar::add_toolbar_widgets()
 {
-       views::TraceView::View *trace_view =
-               qobject_cast<views::TraceView::View*>(session_.main_view().get());
-
-       trace_view->zoom(1);
-}
-
-void MainBar::on_actionViewZoomOut_triggered()
-{
-       views::TraceView::View *trace_view =
-               qobject_cast<views::TraceView::View*>(session_.main_view().get());
-
-       trace_view->zoom(-1);
-}
-
-void MainBar::on_actionViewZoomFit_triggered()
-{
-       views::TraceView::View *trace_view =
-               qobject_cast<views::TraceView::View*>(session_.main_view().get());
-
-       trace_view->zoom_fit(action_view_zoom_fit_->isChecked());
-}
-
-void MainBar::on_actionViewZoomOneToOne_triggered()
-{
-       views::TraceView::View *trace_view =
-               qobject_cast<views::TraceView::View*>(session_.main_view().get());
-
-       trace_view->zoom_one_to_one();
-}
-
-void MainBar::on_actionViewShowCursors_triggered()
-{
-       views::TraceView::View *trace_view =
-               qobject_cast<views::TraceView::View*>(session_.main_view().get());
-
-       const bool show = !trace_view->cursors_shown();
-       if (show)
-               trace_view->centre_cursors();
+       addAction(action_new_view_);
+       addSeparator();
+       addWidget(open_button_);
+       addWidget(save_button_);
+       addSeparator();
 
-       trace_view->show_cursors(show);
-}
+       StandardBar::add_toolbar_widgets();
 
-void MainBar::on_always_zoom_to_fit_changed(bool state)
-{
-       action_view_zoom_fit_->setChecked(state);
+       addWidget(&device_selector_);
+       configure_button_action_ = addWidget(&configure_button_);
+       channels_button_action_ = addWidget(&channels_button_);
+       addWidget(&sample_count_);
+       addWidget(&sample_rate_);
+#ifdef ENABLE_DECODE
+       addSeparator();
+       addWidget(add_decoder_button_);
+#endif
 }
 
 bool MainBar::eventFilter(QObject *watched, QEvent *event)
index 95959e1757212ae7d45738a60cdf649ddee9f02a..50c30fd2a0992ded9b45032aae38888579a64fd0 100644 (file)
@@ -35,6 +35,7 @@
 #include <QToolButton>
 
 #include <pv/session.hpp>
+#include <pv/views/trace/standardbar.hpp>
 #include <pv/widgets/devicetoolbutton.hpp>
 #include <pv/widgets/popuptoolbutton.hpp>
 #include <pv/widgets/sweeptimingwidget.hpp>
@@ -54,9 +55,15 @@ namespace pv {
 class MainWindow;
 class Session;
 
+namespace views {
+namespace TraceView {
+class View;
+}
+}
+
 namespace toolbars {
 
-class MainBar : public QToolBar
+class MainBar : public pv::views::trace::StandardBar
 {
        Q_OBJECT
 
@@ -78,9 +85,8 @@ private:
        static const char *SettingSaveDirectory;
 
 public:
-       MainBar(Session &session, pv::MainWindow &main_window);
-
-       Session &session(void) const;
+       MainBar(Session &session, QWidget *parent,
+               pv::views::TraceView::View *view);
 
        void update_device_list();
 
@@ -93,12 +99,6 @@ public:
        QAction* action_save_as() const;
        QAction* action_save_selection_as() const;
        QAction* action_connect() const;
-       QAction* action_quit() const;
-       QAction* action_view_zoom_in() const;
-       QAction* action_view_zoom_out() const;
-       QAction* action_view_zoom_fit() const;
-       QAction* action_view_zoom_one_to_one() const;
-       QAction* action_view_show_cursors() const;
 
        void session_error(const QString text, const QString info_text);
 
@@ -121,11 +121,6 @@ private:
        QAction *const action_save_as_;
        QAction *const action_save_selection_as_;
        QAction *const action_connect_;
-       QAction *const action_view_zoom_in_;
-       QAction *const action_view_zoom_out_;
-       QAction *const action_view_zoom_fit_;
-       QAction *const action_view_zoom_one_to_one_;
-       QAction *const action_view_show_cursors_;
 
 private Q_SLOTS:
        void show_session_error(const QString text, const QString info_text);
@@ -153,26 +148,16 @@ private Q_SLOTS:
 
        void on_actionConnect_triggered();
 
-       void on_actionViewZoomIn_triggered();
-
-       void on_actionViewZoomOut_triggered();
-
-       void on_actionViewZoomFit_triggered();
-
-       void on_actionViewZoomOneToOne_triggered();
-
-       void on_actionViewShowCursors_triggered();
-
-       void on_always_zoom_to_fit_changed(bool state);
-
 protected:
+       void add_toolbar_widgets();
+
        bool eventFilter(QObject *watched, QEvent *event);
 
 Q_SIGNALS:
        void new_view(Session *session);
 
 private:
-       Session &session_;
+       QToolButton *open_button_, *save_button_;
 
        pv::widgets::DeviceToolButton device_selector_;
 
@@ -190,6 +175,7 @@ private:
        bool sample_count_supported_;
 
 #ifdef ENABLE_DECODE
+       QToolButton *add_decoder_button_;
        QMenu *const menu_decoders_add_;
 #endif
 };
diff --git a/pv/views/trace/standardbar.cpp b/pv/views/trace/standardbar.cpp
new file mode 100644 (file)
index 0000000..def3ebc
--- /dev/null
@@ -0,0 +1,170 @@
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2016 Soeren Apel <soeren@apelpie.net>
+ * Copyright (C) 2012-2015 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
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#include <QAction>
+#include <QMessageBox>
+
+#include "standardbar.hpp"
+
+#include <pv/mainwindow.hpp>
+#include <pv/view/view.hpp>
+
+using pv::views::TraceView::View;
+
+namespace pv {
+namespace views {
+
+namespace trace {
+
+StandardBar::StandardBar(Session &session, QWidget *parent,
+       View *view, bool add_default_widgets) :
+       QToolBar("Standard Trace View Toolbar", parent),
+       session_(session),
+       view_(view),
+       action_view_zoom_in_(new QAction(this)),
+       action_view_zoom_out_(new QAction(this)),
+       action_view_zoom_fit_(new QAction(this)),
+       action_view_zoom_one_to_one_(new QAction(this)),
+       action_view_show_cursors_(new QAction(this))
+{
+       setObjectName(QString::fromUtf8("StandardBar"));
+
+       // Actions
+       action_view_zoom_in_->setText(tr("Zoom &In"));
+       action_view_zoom_in_->setIcon(QIcon::fromTheme("zoom-in",
+               QIcon(":/icons/zoom-in.png")));
+       // simply using Qt::Key_Plus shows no + in the menu
+       action_view_zoom_in_->setShortcut(QKeySequence::ZoomIn);
+       connect(action_view_zoom_in_, SIGNAL(triggered(bool)),
+               this, SLOT(on_actionViewZoomIn_triggered()));
+
+       action_view_zoom_out_->setText(tr("Zoom &Out"));
+       action_view_zoom_out_->setIcon(QIcon::fromTheme("zoom-out",
+               QIcon(":/icons/zoom-out.png")));
+       action_view_zoom_out_->setShortcut(QKeySequence::ZoomOut);
+       connect(action_view_zoom_out_, SIGNAL(triggered(bool)),
+               this, SLOT(on_actionViewZoomOut_triggered()));
+
+       action_view_zoom_fit_->setCheckable(true);
+       action_view_zoom_fit_->setText(tr("Zoom to &Fit"));
+       action_view_zoom_fit_->setIcon(QIcon::fromTheme("zoom-fit",
+               QIcon(":/icons/zoom-fit.png")));
+       action_view_zoom_fit_->setShortcut(QKeySequence(Qt::Key_F));
+       connect(action_view_zoom_fit_, SIGNAL(triggered(bool)),
+               this, SLOT(on_actionViewZoomFit_triggered()));
+
+       action_view_zoom_one_to_one_->setText(tr("Zoom to O&ne-to-One"));
+       action_view_zoom_one_to_one_->setIcon(QIcon::fromTheme("zoom-original",
+               QIcon(":/icons/zoom-original.png")));
+       action_view_zoom_one_to_one_->setShortcut(QKeySequence(Qt::Key_O));
+       connect(action_view_zoom_one_to_one_, SIGNAL(triggered(bool)),
+               this, SLOT(on_actionViewZoomOneToOne_triggered()));
+
+       action_view_show_cursors_->setCheckable(true);
+       action_view_show_cursors_->setIcon(QIcon::fromTheme("show-cursors",
+               QIcon(":/icons/show-cursors.svg")));
+       action_view_show_cursors_->setShortcut(QKeySequence(Qt::Key_C));
+       connect(action_view_show_cursors_, SIGNAL(triggered(bool)),
+               this, SLOT(on_actionViewShowCursors_triggered()));
+       action_view_show_cursors_->setText(tr("Show &Cursors"));
+
+       if (add_default_widgets)
+               add_toolbar_widgets();
+}
+
+Session &StandardBar::session(void) const
+{
+       return session_;
+}
+
+void StandardBar::add_toolbar_widgets()
+{
+       // Setup the toolbar
+       addAction(action_view_zoom_in_);
+       addAction(action_view_zoom_out_);
+       addAction(action_view_zoom_fit_);
+       addAction(action_view_zoom_one_to_one_);
+       addSeparator();
+       addAction(action_view_show_cursors_);
+}
+
+QAction* StandardBar::action_view_zoom_in() const
+{
+       return action_view_zoom_in_;
+}
+
+QAction* StandardBar::action_view_zoom_out() const
+{
+       return action_view_zoom_out_;
+}
+
+QAction* StandardBar::action_view_zoom_fit() const
+{
+       return action_view_zoom_fit_;
+}
+
+QAction* StandardBar::action_view_zoom_one_to_one() const
+{
+       return action_view_zoom_one_to_one_;
+}
+
+QAction* StandardBar::action_view_show_cursors() const
+{
+       return action_view_show_cursors_;
+}
+
+void StandardBar::on_actionViewZoomIn_triggered()
+{
+       view_->zoom(1);
+}
+
+void StandardBar::on_actionViewZoomOut_triggered()
+{
+       view_->zoom(-1);
+}
+
+void StandardBar::on_actionViewZoomFit_triggered()
+{
+       view_->zoom_fit(action_view_zoom_fit_->isChecked());
+}
+
+void StandardBar::on_actionViewZoomOneToOne_triggered()
+{
+       view_->zoom_one_to_one();
+}
+
+void StandardBar::on_actionViewShowCursors_triggered()
+{
+       const bool show = !view_->cursors_shown();
+       if (show)
+               view_->centre_cursors();
+
+       view_->show_cursors(show);
+}
+
+void StandardBar::on_always_zoom_to_fit_changed(bool state)
+{
+       action_view_zoom_fit_->setChecked(state);
+}
+
+} // namespace trace
+} // namespace views
+} // namespace pv
diff --git a/pv/views/trace/standardbar.hpp b/pv/views/trace/standardbar.hpp
new file mode 100644 (file)
index 0000000..e41beeb
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2016 Soeren Apel <soeren@apelpie.net>
+ * 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
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#ifndef PULSEVIEW_PV_VIEWS_TRACE_STANDARDBAR_HPP
+#define PULSEVIEW_PV_VIEWS_TRACE_STANDARDBAR_HPP
+
+#include <stdint.h>
+
+#include <QAction>
+#include <QToolBar>
+#include <QWidget>
+
+#include <pv/session.hpp>
+
+namespace pv {
+
+class MainWindow;
+class Session;
+
+namespace views {
+
+namespace TraceView {
+class View;
+}
+
+namespace trace {
+
+class StandardBar : public QToolBar
+{
+       Q_OBJECT
+
+public:
+       StandardBar(Session &session, QWidget *parent,
+               TraceView::View *view, bool add_default_widgets=true);
+
+       Session &session(void) const;
+
+       QAction* action_view_zoom_in() const;
+       QAction* action_view_zoom_out() const;
+       QAction* action_view_zoom_fit() const;
+       QAction* action_view_zoom_one_to_one() const;
+       QAction* action_view_show_cursors() const;
+
+protected:
+       virtual void add_toolbar_widgets();
+
+       Session &session_;
+       TraceView::View *view_;
+
+       QAction *const action_view_zoom_in_;
+       QAction *const action_view_zoom_out_;
+       QAction *const action_view_zoom_fit_;
+       QAction *const action_view_zoom_one_to_one_;
+       QAction *const action_view_show_cursors_;
+
+protected Q_SLOTS:
+       void on_actionViewZoomIn_triggered();
+
+       void on_actionViewZoomOut_triggered();
+
+       void on_actionViewZoomFit_triggered();
+
+       void on_actionViewZoomOneToOne_triggered();
+
+       void on_actionViewShowCursors_triggered();
+
+       void on_always_zoom_to_fit_changed(bool state);
+};
+
+} // namespace trace
+} // namespace views
+} // namespace pv
+
+#endif // PULSEVIEW_PV_VIEWS_TRACE_STANDARDBAR_HPP