]> sigrok.org Git - pulseview.git/commitdiff
MainBar: Added menu button
authorJoel Holdsworth <redacted>
Sat, 10 Jan 2015 15:53:58 +0000 (15:53 +0000)
committerJoel Holdsworth <redacted>
Sat, 10 Jan 2015 16:19:31 +0000 (16:19 +0000)
pv/toolbars/mainbar.cpp
pv/toolbars/mainbar.hpp

index 8aeb0254153ba4c0b558742d09cc41b2508462c3..da0479f11413a06ee62affe18155b151f543056c 100644 (file)
@@ -25,6 +25,7 @@
 #include <QAction>
 #include <QDebug>
 #include <QHelpEvent>
+#include <QMenu>
 #include <QToolTip>
 
 #include "mainbar.hpp"
@@ -73,13 +74,40 @@ MainBar::MainBar(Session &session, MainWindow &main_window) :
        icon_red_(":/icons/status-red.svg"),
        icon_green_(":/icons/status-green.svg"),
        icon_grey_(":/icons/status-grey.svg"),
-       run_stop_button_(this)
+       run_stop_button_(this),
+       menu_button_(this)
 {
        setObjectName(QString::fromUtf8("MainBar"));
 
        setMovable(false);
        setFloatable(false);
 
+       // Setup the menu
+       QMenu *const menu = new QMenu(this);
+
+       QMenu *const menu_help = new QMenu;
+       menu_help->setTitle(tr("&Help"));
+       menu_help->addAction(main_window.action_about());
+
+       menu->addAction(menu_help->menuAction());
+       menu->addSeparator();
+       menu->addAction(main_window.action_quit());
+
+       menu_button_.setMenu(menu);
+       menu_button_.setPopupMode(QToolButton::InstantPopup);
+       menu_button_.setIcon(QIcon::fromTheme("menu",
+               QIcon(":/icons/menu.svg")));
+
+       // Setup the toolbar
+       addAction(main_window.action_open());
+       addAction(main_window.action_save_as());
+       addSeparator();
+       addAction(main_window.action_view_zoom_in());
+       addAction(main_window.action_view_zoom_out());
+       addAction(main_window.action_view_zoom_fit());
+       addAction(main_window.action_view_zoom_one_to_one());
+       addSeparator();
+
        connect(&run_stop_button_, SIGNAL(clicked()),
                this, SLOT(on_run_stop()));
        connect(&device_selector_, SIGNAL(currentIndexChanged (int)),
@@ -106,9 +134,14 @@ MainBar::MainBar(Session &session, MainWindow &main_window) :
        addWidget(&channels_button_);
        addWidget(&sample_count_);
        addWidget(&sample_rate_);
-
        addWidget(&run_stop_button_);
 
+       QWidget *const spacer = new QWidget();
+       spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+       addWidget(spacer);
+
+       addWidget(&menu_button_);
+
        sample_count_.installEventFilter(this);
        sample_rate_.installEventFilter(this);
 }
index d5d79c821c67fcf8d0f7a85e4515368924242df0..d5d42f5080497840eafc95db258f1ea19e4ca628 100644 (file)
@@ -115,6 +115,8 @@ private:
        QIcon icon_green_;
        QIcon icon_grey_;
        QToolButton run_stop_button_;
+
+       QToolButton menu_button_;
 };
 
 } // namespace toolbars