pv/data/segment.cpp
pv/dialogs/about.cpp
pv/dialogs/connect.cpp
+ pv/dialogs/inputoutputoptions.cpp
pv/dialogs/storeprogress.cpp
pv/popups/deviceoptions.cpp
pv/popups/channels.cpp
pv/binding/device.hpp
pv/dialogs/about.hpp
pv/dialogs/connect.hpp
+ pv/dialogs/inputoutputoptions.hpp
pv/dialogs/storeprogress.hpp
pv/popups/channels.hpp
pv/popups/deviceoptions.hpp
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "inputoutputoptions.hpp"
+
+#include <pv/prop/property.hpp>
+
+using std::map;
+using std::shared_ptr;
+using std::string;
+
+using Glib::VariantBase;
+
+using sigrok::Option;
+
+namespace pv {
+namespace dialogs {
+
+InputOutputOptions::InputOutputOptions(const QString &title,
+ const map<string, shared_ptr<Option>> &options, QWidget *parent) :
+ QDialog(parent),
+ layout_(this),
+ button_box_(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
+ Qt::Horizontal, this),
+ binding_(options)
+{
+ setWindowTitle(title);
+
+ connect(&button_box_, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(&button_box_, SIGNAL(rejected()), this, SLOT(reject()));
+
+ setLayout(&layout_);
+
+ layout_.addWidget(binding_.get_property_form(this));
+ layout_.addWidget(&button_box_);
+}
+
+const map<string, VariantBase>& InputOutputOptions::options() const
+{
+ return binding_.options();
+}
+
+void InputOutputOptions::accept()
+{
+ QDialog::accept();
+
+ // Commit the properties
+ binding_.commit();
+}
+
+} // namespace dialogs
+} // namespace pv
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2015 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef PULSEVIEW_PV_DIALOGS_INPUTOUTPUTOPTIONS_HPP
+#define PULSEVIEW_PV_DIALOGS_INPUTOUTPUTOPTIONS_HPP
+
+#include <QDialog>
+#include <QDialogButtonBox>
+#include <QGroupBox>
+#include <QVBoxLayout>
+
+#include <pv/binding/inputoutput.hpp>
+
+namespace pv {
+namespace dialogs {
+
+/**
+ * Presents the selection of inpout/output options to the user.
+ */
+class InputOutputOptions : public QDialog
+{
+ Q_OBJECT
+
+public:
+ /**
+ * Constructor.
+ * @param title the title of the dialog.
+ * @param options the map of options to use as a template.
+ * @param parent the parent widget of the dialog.
+ */
+ InputOutputOptions(const QString &title,
+ const std::map<std::string, std::shared_ptr<sigrok::Option>>
+ &options,
+ QWidget *parent);
+
+ /**
+ * Gets the map of selected options.
+ * @return the options.
+ */
+ const std::map<std::string, Glib::VariantBase>& options() const;
+
+protected:
+ void accept();
+
+private:
+ QVBoxLayout layout_;
+ QDialogButtonBox button_box_;
+ pv::binding::InputOutput binding_;
+};
+
+} // namespace dialogs
+} // namespace pv
+
+#endif // PULSEVIEW_PV_INPUTOUTPUTOPTIONS_HPP
#include "storeprogress.hpp"
+using std::map;
+using std::string;
+
+using Glib::VariantBase;
+
namespace pv {
namespace dialogs {
StoreProgress::StoreProgress(const QString &file_name,
const std::shared_ptr<sigrok::OutputFormat> output_format,
+ const map<string, VariantBase> &options,
const Session &session, QWidget *parent) :
QProgressDialog(tr("Saving..."), tr("Cancel"), 0, 0, parent),
- session_(file_name.toStdString(), output_format, session)
+ session_(file_name.toStdString(), output_format, options, session)
{
connect(&session_, SIGNAL(progress_updated()),
this, SLOT(on_progress_updated()));
public:
StoreProgress(const QString &file_name,
const std::shared_ptr<sigrok::OutputFormat> output_format,
+ const std::map<std::string, Glib::VariantBase> &options,
const Session &session, QWidget *parent = 0);
virtual ~StoreProgress();
#include "devicemanager.hpp"
#include "dialogs/about.hpp"
#include "dialogs/connect.hpp"
+#include "dialogs/inputoutputoptions.hpp"
#include "dialogs/storeprogress.hpp"
#include "toolbars/mainbar.hpp"
#include "view/logicsignal.hpp"
QSettings settings;
const QString dir = settings.value(SettingSaveDirectory).toString();
- // Show the dialog
+ // Show the file dialog
const QString file_name = QFileDialog::getSaveFileName(
this, tr("Save File"), dir, tr("%1 files (*.*)").arg(
QString::fromStdString(format->description())));
const QString abs_path = QFileInfo(file_name).absolutePath();
settings.setValue(SettingSaveDirectory, abs_path);
- StoreProgress *dlg = new StoreProgress(file_name, format,
+ // Show the options dialog
+ map<string, Glib::VariantBase> options;
+ if (!format->options().empty()) {
+ dialogs::InputOutputOptions dlg(
+ tr("Export %1").arg(QString::fromStdString(
+ format->description())),
+ format->options(), this);
+ if (!dlg.exec())
+ return;
+ options = dlg.options();
+ }
+
+ StoreProgress *dlg = new StoreProgress(file_name, format, options,
session_, this);
dlg->run();
}
using std::thread;
using std::vector;
+using Glib::VariantBase;
+
using sigrok::ConfigKey;
using sigrok::Error;
using sigrok::OutputFormat;
const size_t StoreSession::BlockSize = 1024 * 1024;
StoreSession::StoreSession(const std::string &file_name,
- const shared_ptr<OutputFormat> &output_format, const Session &session) :
+ const shared_ptr<OutputFormat> &output_format,
+ const map<string, VariantBase> &options, const Session &session) :
file_name_(file_name),
output_format_(output_format),
+ options_(options),
session_(session),
interrupt_(false),
units_stored_(0),
auto context = session_.session()->context();
auto device = session_.device();
- map<string, Glib::VariantBase> options;
+ map<string, Glib::VariantBase> options = options_;
// If the output has the capability to write files, use it.
// Otherwise, open the output stream.
#include <atomic>
#include <fstream>
+#include <map>
#include <memory>
#include <mutex>
#include <string>
#include <thread>
+#include <glibmm/variant.h>
+
#include <QObject>
namespace sigrok {
public:
StoreSession(const std::string &file_name,
const std::shared_ptr<sigrok::OutputFormat> &output_format,
+ const std::map<std::string, Glib::VariantBase> &options,
const Session &session);
~StoreSession();
private:
const std::string file_name_;
const std::shared_ptr<sigrok::OutputFormat> output_format_;
+ const std::map<std::string, Glib::VariantBase> options_;
const Session &session_;
std::shared_ptr<sigrok::Output> output_;