#include "toolbars/mainbar.hpp"
#include "view/logicsignal.hpp"
#include "view/view.hpp"
+#include "widgets/exportmenu.hpp"
#ifdef ENABLE_DECODE
#include "widgets/decodermenu.hpp"
#endif
using sigrok::Device;
using sigrok::Error;
using sigrok::HardwareDevice;
+using sigrok::OutputFormat;
namespace pv {
}
}
+void MainWindow::export_file(shared_ptr<OutputFormat> format)
+{
+ using pv::dialogs::StoreProgress;
+
+ // Stop any currently running capture session
+ session_.stop_capture();
+
+ QSettings settings;
+ const QString dir = settings.value(SettingSaveDirectory).toString();
+
+ // Show the dialog
+ const QString file_name = QFileDialog::getSaveFileName(
+ this, tr("Save File"), dir, tr("%1 files (*.*)").arg(
+ QString::fromStdString(format->description())));
+
+ if (file_name.isEmpty())
+ return;
+
+ const QString abs_path = QFileInfo(file_name).absolutePath();
+ settings.setValue(SettingSaveDirectory, abs_path);
+
+ StoreProgress *dlg = new StoreProgress(file_name, format,
+ session_, this);
+ dlg->run();
+}
+
void MainWindow::setup_ui()
{
setObjectName(QString::fromUtf8("MainWindow"));
menu_file->addSeparator();
+ widgets::ExportMenu *menu_file_export = new widgets::ExportMenu(this,
+ device_manager_.context());
+ menu_file_export->setTitle(tr("&Export"));
+ connect(menu_file_export,
+ SIGNAL(format_selected(std::shared_ptr<sigrok::OutputFormat>)),
+ this, SLOT(export_file(std::shared_ptr<sigrok::OutputFormat>)));
+ menu_file->addAction(menu_file_export->menuAction());
+
+ menu_file->addSeparator();
+
action_connect_->setText(tr("&Connect to Device..."));
action_connect_->setObjectName(QString::fromUtf8("actionConnect"));
menu_file->addAction(action_connect_);
void MainWindow::on_actionSaveAs_triggered()
{
- using pv::dialogs::StoreProgress;
-
- // Stop any currently running capture session
- session_.stop_capture();
-
- QSettings settings;
- const QString dir = settings.value(SettingSaveDirectory).toString();
-
- // Show the dialog
- const QString file_name = QFileDialog::getSaveFileName(
- this, tr("Save File"), dir, tr("Sigrok Sessions (*.sr)"));
-
- if (file_name.isEmpty())
- return;
-
- const QString abs_path = QFileInfo(file_name).absolutePath();
- settings.setValue(SettingSaveDirectory, abs_path);
-
- StoreProgress *dlg = new StoreProgress(file_name,
- device_manager_.context()->output_formats()["srzip"],
- session_, this);
- dlg->run();
+ export_file(device_manager_.context()->output_formats()["srzip"]);
}
void MainWindow::on_actionConnect_triggered()
#include <pv/popups/deviceoptions.hpp>
#include <pv/popups/channels.hpp>
#include <pv/util.hpp>
+#include <pv/widgets/exportmenu.hpp>
#include <libsigrokcxx/libsigrokcxx.hpp>
setFloatable(false);
setContextMenuPolicy(Qt::PreventContextMenu);
+ // Save button
+ QToolButton *const save_button = new QToolButton(this);
+
+ widgets::ExportMenu *export_menu = new widgets::ExportMenu(this,
+ session.device_manager().context(),
+ main_window.action_save_as());
+ connect(export_menu,
+ SIGNAL(format_selected(std::shared_ptr<sigrok::OutputFormat>)),
+ &main_window_,
+ SLOT(export_file(std::shared_ptr<sigrok::OutputFormat>)));
+
+ save_button->setMenu(export_menu);
+ save_button->setDefaultAction(main_window.action_save_as());
+ save_button->setPopupMode(QToolButton::MenuButtonPopup);
+
// Device selector menu
connect(&device_selector_, SIGNAL(device_selected()),
this, SLOT(on_device_selected()));
// Setup the toolbar
addAction(main_window.action_open());
- addAction(main_window.action_save_as());
+ addWidget(save_button);
addSeparator();
addAction(main_window.action_view_zoom_in());
addAction(main_window.action_view_zoom_out());