From 686d9151feb1c917b85ddb60bf73888e8058e4f4 Mon Sep 17 00:00:00 2001 From: Soeren Apel Date: Wed, 4 Nov 2015 17:02:47 +0100 Subject: [PATCH] Make ExportMenu accept a vector of actions --- pv/toolbars/mainbar.cpp | 5 ++++- pv/widgets/exportmenu.cpp | 15 +++++++++++---- pv/widgets/exportmenu.hpp | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/pv/toolbars/mainbar.cpp b/pv/toolbars/mainbar.cpp index dcc35ece..3b169866 100644 --- a/pv/toolbars/mainbar.cpp +++ b/pv/toolbars/mainbar.cpp @@ -110,9 +110,12 @@ MainBar::MainBar(Session &session, MainWindow &main_window) : // Save button QToolButton *const save_button = new QToolButton(this); + vector open_actions; + open_actions.push_back(main_window.action_save_as()); + widgets::ExportMenu *export_menu = new widgets::ExportMenu(this, session.device_manager().context(), - main_window.action_save_as()); + open_actions); connect(export_menu, SIGNAL(format_selected(std::shared_ptr)), &main_window_, diff --git a/pv/widgets/exportmenu.cpp b/pv/widgets/exportmenu.cpp index 4fa9d197..e9fb4150 100644 --- a/pv/widgets/exportmenu.cpp +++ b/pv/widgets/exportmenu.cpp @@ -40,16 +40,23 @@ namespace pv { namespace widgets { ExportMenu::ExportMenu(QWidget *parent, shared_ptr context, - QAction *open_action) : + std::vectoropen_actions) : QMenu(parent), context_(context), mapper_(this) { assert(context); - if (open_action) { - addAction(open_action); - setDefaultAction(open_action); + if (!open_actions.empty()) { + bool first_action = true; + for (auto open_action : open_actions) { + addAction(open_action); + + if (first_action) { + first_action = false; + setDefaultAction(open_action); + } + } addSeparator(); } diff --git a/pv/widgets/exportmenu.hpp b/pv/widgets/exportmenu.hpp index 1a29128d..e3b1f230 100644 --- a/pv/widgets/exportmenu.hpp +++ b/pv/widgets/exportmenu.hpp @@ -40,7 +40,7 @@ class ExportMenu : public QMenu public: ExportMenu(QWidget *parent, std::shared_ptr context, - QAction *open_action = nullptr); + std::vectoropen_actions = std::vector()); private Q_SLOTS: void on_action(QObject *action); -- 2.30.2