]> sigrok.org Git - pulseview.git/commitdiff
Make ExportMenu accept a vector of actions
authorSoeren Apel <redacted>
Wed, 4 Nov 2015 16:02:47 +0000 (17:02 +0100)
committerSoeren Apel <redacted>
Wed, 4 Nov 2015 16:56:17 +0000 (17:56 +0100)
pv/toolbars/mainbar.cpp
pv/widgets/exportmenu.cpp
pv/widgets/exportmenu.hpp

index dcc35ecee8f4e42800354080e0b2b34d047ebbcb..3b1698669a9ac8634a8af1ce87a7786f02cd6833 100644 (file)
@@ -110,9 +110,12 @@ MainBar::MainBar(Session &session, MainWindow &main_window) :
        // Save button
        QToolButton *const save_button = new QToolButton(this);
 
+       vector<QAction *> 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<sigrok::OutputFormat>)),
                &main_window_,
index 4fa9d197726f1c25da09e952da56c7d317ec4dc7..e9fb4150765e76e05eeb049f117aba089e82cba5 100644 (file)
@@ -40,16 +40,23 @@ namespace pv {
 namespace widgets {
 
 ExportMenu::ExportMenu(QWidget *parent, shared_ptr<Context> context,
-       QAction *open_action) :
+       std::vector<QAction *>open_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();
        }
 
index 1a29128db6c7adc0412747f50f00d80b7ae4a0d7..e3b1f230295ab8dd9995bdb99a2c66994bb2b104 100644 (file)
@@ -40,7 +40,7 @@ class ExportMenu : public QMenu
 
 public:
        ExportMenu(QWidget *parent, std::shared_ptr<sigrok::Context> context,
-               QAction *open_action = nullptr);
+               std::vector<QAction *>open_actions = std::vector<QAction *>());
 
 private Q_SLOTS:
        void on_action(QObject *action);