name_changed();
}
-QString Session::path() const
+QString Session::save_path() const
{
- return path_;
+ return save_path_;
}
-void Session::set_path(QString path)
+void Session::set_save_path(QString path)
{
- path_ = path;
- set_name(QFileInfo(path).fileName());
+ save_path_ = path;
}
const vector< shared_ptr<views::ViewBase> > Session::views() const
}
- QString path;
+ QString filename;
if ((device_type == "sessionfile") || (device_type == "inputfile")) {
if (device_type == "sessionfile") {
settings.beginGroup("device");
- const QString filename = settings.value("filename").toString();
+ filename = settings.value("filename").toString();
settings.endGroup();
- if (QFileInfo(filename).isReadable()) {
- path = filename;
+ if (QFileInfo(filename).isReadable())
device = make_shared<devices::SessionFile>(device_manager_.context(),
filename.toStdString());
- }
}
if (device_type == "inputfile") {
set_name(QString::fromStdString(
dynamic_pointer_cast<devices::File>(device)->display_name(device_manager_)));
- if (!path.isEmpty())
- set_path(path);
+ if (!filename.isEmpty()) {
+ // Only set the save path if we load an srzip file
+ if (device_type == "sessionfile")
+ set_save_path(QFileInfo(filename).absolutePath());
+
+ set_name(QFileInfo(filename).fileName());
+ }
}
}
start_capture([&, errorMessage](QString infoMessage) {
MainWindow::show_session_error(errorMessage, infoMessage); });
- set_path(file_name);
+ // Only set save path if we loaded an srzip file
+ if (dynamic_pointer_cast<devices::SessionFile>(device_))
+ set_save_path(QFileInfo(file_name).absolutePath());
+
+ set_name(QFileInfo(file_name).fileName());
}
Session::capture_state Session::get_capture_state() const
QString name() const;
void set_name(QString name);
- QString path() const;
- void set_path(QString path);
+ QString save_path() const;
+ void set_save_path(QString path);
const vector< shared_ptr<views::ViewBase> > views() const;
DeviceManager &device_manager_;
shared_ptr<devices::Device> device_;
- QString default_name_, name_, path_;
+ QString default_name_, name_, save_path_;
vector< shared_ptr<views::ViewBase> > views_;
shared_ptr<pv::views::ViewBase> main_view_;
msg.exec();
}
-void MainBar::export_file(shared_ptr<OutputFormat> format, bool selection_only, QString path)
+void MainBar::export_file(shared_ptr<OutputFormat> format, bool selection_only, QString file_name)
{
using pv::dialogs::StoreProgress;
tr("All Files"));
// Show the file dialog
- const QString file_name = path.isEmpty() ?
- QFileDialog::getSaveFileName(this, tr("Save File"), dir, filter) :
- path;
+ if (file_name.isEmpty())
+ file_name = QFileDialog::getSaveFileName(this, tr("Save File"), dir, filter);
if (file_name.isEmpty())
return;
options = dlg.options();
}
- if (!selection_only &&
- format == session_.device_manager().context()->output_formats()["srzip"])
- session_.set_path(file_name);
+ if (!selection_only) {
+ session_.set_name(QFileInfo(file_name).fileName());
+
+ if (format == session_.device_manager().context()->output_formats()["srzip"])
+ session_.set_save_path(QFileInfo(file_name).absolutePath());
+ else
+ session_.set_save_path("");
+ }
StoreProgress *dlg = new StoreProgress(file_name, format, options,
sample_range, session_, this);
void MainBar::on_actionSave_triggered()
{
- export_file(session_.device_manager().context()->output_formats()["srzip"], false, session_.path());
+ // A path is only set if we loaded/saved an srzip file before
+ if (session_.save_path().isEmpty()) {
+ on_actionSaveAs_triggered();
+ return;
+ }
+
+ QFileInfo fi = QFileInfo(session_.save_path(), session_.name());
+ export_file(session_.device_manager().context()->output_formats()["srzip"], false,
+ fi.absoluteFilePath());
}
void MainBar::on_actionSaveAs_triggered()
void show_session_error(const QString text, const QString info_text);
void export_file(shared_ptr<sigrok::OutputFormat> format,
- bool selection_only = false,
- QString path = QString{});
+ bool selection_only = false, QString file_name = "");
void import_file(shared_ptr<sigrok::InputFormat> format);
void on_device_selected();