From: Soeren Apel Date: Wed, 4 Nov 2015 16:02:47 +0000 (+0100) Subject: Make ExportMenu accept a vector of actions X-Git-Url: http://git.code-monkey.de/?p=pulseview.git;a=commitdiff_plain;h=686d9151feb1c917b85ddb60bf73888e8058e4f4 Make ExportMenu accept a vector of actions --- diff --git a/pv/toolbars/mainbar.cpp b/pv/toolbars/mainbar.cpp index dcc35ec..3b16986 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 4fa9d19..e9fb415 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 1a29128..e3b1f23 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);