From: Joel Holdsworth Date: Sat, 10 Jan 2015 15:53:58 +0000 (+0000) Subject: MainBar: Added menu button X-Git-Tag: pulseview-0.3.0~271 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=87f0df9b4a357ea9e2d838be7663580e94beca68;p=pulseview.git MainBar: Added menu button --- diff --git a/pv/toolbars/mainbar.cpp b/pv/toolbars/mainbar.cpp index 8aeb0254..da0479f1 100644 --- a/pv/toolbars/mainbar.cpp +++ b/pv/toolbars/mainbar.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #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); } diff --git a/pv/toolbars/mainbar.hpp b/pv/toolbars/mainbar.hpp index d5d79c82..d5d42f50 100644 --- a/pv/toolbars/mainbar.hpp +++ b/pv/toolbars/mainbar.hpp @@ -115,6 +115,8 @@ private: QIcon icon_green_; QIcon icon_grey_; QToolButton run_stop_button_; + + QToolButton menu_button_; }; } // namespace toolbars