name_changed();
}
+QString Session::path() const
+{
+ return path_;
+}
+
+void Session::set_path(QString path)
+{
+ path_ = path;
+ set_name(QFileInfo(path).fileName());
+}
+
const vector< shared_ptr<views::ViewBase> > Session::views() const
{
return views_;
settings.endGroup();
}
+
+ QString path;
if ((device_type == "sessionfile") || (device_type == "inputfile")) {
if (device_type == "sessionfile") {
settings.beginGroup("device");
settings.endGroup();
if (QFileInfo(filename).isReadable()) {
+ path = filename;
device = make_shared<devices::SessionFile>(device_manager_.context(),
filename.toStdString());
}
set_name(QString::fromStdString(
dynamic_pointer_cast<devices::File>(device)->display_name(device_manager_)));
+
+ if (!path.isEmpty())
+ set_path(path);
}
}
start_capture([&, errorMessage](QString infoMessage) {
MainWindow::show_session_error(errorMessage, infoMessage); });
- set_name(QFileInfo(file_name).fileName());
+ set_path(file_name);
}
Session::capture_state Session::get_capture_state() const
StandardBar(session, parent, view, false),
action_new_view_(new QAction(this)),
action_open_(new QAction(this)),
+ action_save_(new QAction(this)),
action_save_as_(new QAction(this)),
action_save_selection_as_(new QAction(this)),
action_restore_setup_(new QAction(this)),
connect(action_restore_setup_, SIGNAL(triggered(bool)),
this, SLOT(on_actionRestoreSetup_triggered()));
- action_save_as_->setText(tr("&Save As..."));
+ action_save_->setText(tr("&Save..."));
+ action_save_->setIcon(QIcon::fromTheme("document-save-as",
+ QIcon(":/icons/document-save-as.png")));
+ action_save_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
+ connect(action_save_, SIGNAL(triggered(bool)),
+ this, SLOT(on_actionSave_triggered()));
+
+ action_save_as_->setText(tr("Save &As..."));
action_save_as_->setIcon(QIcon::fromTheme("document-save-as",
QIcon(":/icons/document-save-as.png")));
- action_save_as_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
connect(action_save_as_, SIGNAL(triggered(bool)),
this, SLOT(on_actionSaveAs_triggered()));
// Save button
vector<QAction*> save_actions;
+ save_actions.push_back(action_save_);
save_actions.push_back(action_save_as_);
save_actions.push_back(action_save_selection_as_);
QAction* separator_s = new QAction(this);
this, SLOT(export_file(shared_ptr<sigrok::OutputFormat>)));
save_button_->setMenu(export_menu);
- save_button_->setDefaultAction(action_save_as_);
+ save_button_->setDefaultAction(action_save_);
save_button_->setPopupMode(QToolButton::MenuButtonPopup);
// Device selector menu
return action_open_;
}
+QAction* MainBar::action_save() const
+{
+ return action_save_;
+}
+
QAction* MainBar::action_save_as() const
{
return action_save_as_;
msg.exec();
}
-void MainBar::export_file(shared_ptr<OutputFormat> format, bool selection_only)
+void MainBar::export_file(shared_ptr<OutputFormat> format, bool selection_only, QString path)
{
using pv::dialogs::StoreProgress;
tr("All Files"));
// Show the file dialog
- const QString file_name = QFileDialog::getSaveFileName(
- this, tr("Save File"), dir, filter);
+ const QString file_name = path.isEmpty() ?
+ QFileDialog::getSaveFileName(this, tr("Save File"), dir, filter) :
+ path;
if (file_name.isEmpty())
return;
options = dlg.options();
}
- if (!selection_only)
- session_.set_name(QFileInfo(file_name).fileName());
+ if (!selection_only &&
+ format == session_.device_manager().context()->output_formats()["srzip"])
+ session_.set_path(file_name);
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());
+}
+
void MainBar::on_actionSaveAs_triggered()
{
export_file(session_.device_manager().context()->output_formats()["srzip"]);
QAction* action_new_view() const;
QAction* action_open() const;
+ QAction* action_save() const;
QAction* action_save_as() const;
QAction* action_save_selection_as() const;
QAction* action_restore_setup() const;
void show_session_error(const QString text, const QString info_text);
void export_file(shared_ptr<sigrok::OutputFormat> format,
- bool selection_only = false);
+ bool selection_only = false,
+ QString path = QString{});
void import_file(shared_ptr<sigrok::InputFormat> format);
void on_device_selected();
void on_actionNewView_triggered(QAction* action = nullptr);
void on_actionOpen_triggered();
+ void on_actionSave_triggered();
void on_actionSaveAs_triggered();
void on_actionSaveSelectionAs_triggered();
private:
QAction *const action_new_view_;
QAction *const action_open_;
+ QAction *const action_save_;
QAction *const action_save_as_;
QAction *const action_save_selection_as_;
QAction *const action_restore_setup_;