#include "view/logicsignal.hpp"
#include "view/view.hpp"
#include "widgets/exportmenu.hpp"
+#include "widgets/importmenu.hpp"
#ifdef ENABLE_DECODE
#include "widgets/decodermenu.hpp"
#endif
dlg->run();
}
+void MainWindow::import_file(shared_ptr<InputFormat> format)
+{
+ assert(format);
+
+ QSettings settings;
+ const QString dir = settings.value(SettingOpenDirectory).toString();
+
+ // Construct the filter
+ const vector<string> exts = format->extensions();
+ const QString filter = exts.empty() ? "" :
+ tr("%1 files (*.%2)").arg(
+ QString::fromStdString(format->description())).arg(
+ QString::fromStdString(join(exts, ", *.")));
+
+ // Show the file dialog
+ const QString file_name = QFileDialog::getOpenFileName(
+ this, tr("Import File"), dir, tr(
+ "%1 files (*.*);;All Files (*.*)").arg(
+ QString::fromStdString(format->description())));
+
+ if (!file_name.isEmpty()) {
+ load_file(file_name, format);
+
+ const QString abs_path = QFileInfo(file_name).absolutePath();
+ settings.setValue(SettingOpenDirectory, abs_path);
+ }
+}
+
void MainWindow::setup_ui()
{
setObjectName(QString::fromUtf8("MainWindow"));
this, SLOT(export_file(std::shared_ptr<sigrok::OutputFormat>)));
menu_file->addAction(menu_file_export->menuAction());
+ widgets::ImportMenu *menu_file_import = new widgets::ImportMenu(this,
+ device_manager_.context());
+ menu_file_import->setTitle(tr("&Import"));
+ connect(menu_file_import,
+ SIGNAL(format_selected(std::shared_ptr<sigrok::InputFormat>)),
+ this, SLOT(import_file(std::shared_ptr<sigrok::InputFormat>)));
+ menu_file->addAction(menu_file_import->menuAction());
+
menu_file->addSeparator();
action_connect_->setText(tr("&Connect to Device..."));
#include <pv/popups/channels.hpp>
#include <pv/util.hpp>
#include <pv/widgets/exportmenu.hpp>
+#include <pv/widgets/importmenu.hpp>
#include <libsigrokcxx/libsigrokcxx.hpp>
using sigrok::Capability;
using sigrok::ConfigKey;
using sigrok::Error;
+using sigrok::InputFormat;
namespace pv {
namespace toolbars {
setFloatable(false);
setContextMenuPolicy(Qt::PreventContextMenu);
+ // Open button
+ QToolButton *const open_button = new QToolButton(this);
+
+ widgets::ImportMenu *import_menu = new widgets::ImportMenu(this,
+ session.device_manager().context(),
+ main_window.action_open());
+ connect(import_menu,
+ SIGNAL(format_selected(std::shared_ptr<sigrok::InputFormat>)),
+ &main_window_,
+ SLOT(import_file(std::shared_ptr<sigrok::InputFormat>)));
+
+ open_button->setMenu(import_menu);
+ open_button->setDefaultAction(main_window.action_open());
+ open_button->setPopupMode(QToolButton::MenuButtonPopup);
+
// Save button
QToolButton *const save_button = new QToolButton(this);
QIcon(":/icons/menu.svg")));
// Setup the toolbar
- addAction(main_window.action_open());
+ addWidget(open_button);
addWidget(save_button);
addSeparator();
addAction(main_window.action_view_zoom_in());