Commit 14ad277b authored by DreamSourceLab's avatar DreamSourceLab

Add default file name for file save&export

parent b3bd0174
......@@ -814,6 +814,7 @@ void MainWindow::on_screenShot()
{
const QString DIR_KEY("ScreenShotPath");
QSettings settings(QApplication::organizationName(), QApplication::applicationName());
QString default_name = settings.value(DIR_KEY).toString() + "/DSView" + QDateTime::currentDateTime().toString("-yyMMdd-hhmmss");
QPixmap pixmap;
QDesktopWidget *desktop = QApplication::desktop();
pixmap = QPixmap::grabWindow(desktop->winId(), parentWidget()->pos().x(), parentWidget()->pos().y(),
......@@ -821,12 +822,12 @@ void MainWindow::on_screenShot()
QString format = "png";
QString fileName = QFileDialog::getSaveFileName(this,
tr("Save As"),settings.value(DIR_KEY).toString(),
tr("Save As"), default_name,
tr("%1 Files (*.%2);;All Files (*)")
.arg(format.toUpper()).arg(format));
if (!fileName.isEmpty()) {
QDir CurrentDir;
settings.setValue(DIR_KEY, CurrentDir.absoluteFilePath(fileName));
settings.setValue(DIR_KEY, CurrentDir.filePath(fileName));
pixmap.save(fileName, format.toLatin1());
}
}
......
......@@ -1181,6 +1181,8 @@ void SigSession::data_feed_in(const struct sr_dev_inst *sdi,
session_error();
}
frame_ended();
if (get_device()->dev_inst()->mode != LOGIC)
set_session_time(QDateTime::currentDateTime());
break;
}
}
......@@ -1550,14 +1552,14 @@ boost::shared_ptr<view::MathTrace> SigSession::get_math_trace()
return _math_trace;
}
void SigSession::set_trigger_time(QDateTime time)
void SigSession::set_session_time(QDateTime time)
{
_trigger_time = time;
_session_time = time;
}
QDateTime SigSession::get_trigger_time() const
QDateTime SigSession::get_session_time() const
{
return _trigger_time;
return _session_time;
}
uint64_t SigSession::get_trigger_pos() const
......
......@@ -154,8 +154,8 @@ public:
double cur_sampletime() const;
void set_cur_samplerate(uint64_t samplerate);
void set_cur_samplelimits(uint64_t samplelimits);
void set_trigger_time(QDateTime time);
QDateTime get_trigger_time() const;
void set_session_time(QDateTime time);
QDateTime get_session_time() const;
uint64_t get_trigger_pos() const;
void start_capture(bool instant,
......@@ -339,7 +339,7 @@ private:
bool _data_updated;
int _data_auto_lock;
QDateTime _trigger_time;
QDateTime _session_time;
uint64_t _trigger_pos;
bool _trigger_flag;
bool _hw_replied;
......
......@@ -143,10 +143,20 @@ bool StoreSession::save_start(QString session_file)
const QString DIR_KEY("SavePath");
QSettings settings(QApplication::organizationName(), QApplication::applicationName());
QString default_name = settings.value(DIR_KEY).toString() + "/" + _session.get_device()->name() + "-";
for (const GSList *l = _session.get_device()->get_dev_mode_list();
l; l = l->next) {
const sr_dev_mode *mode = (const sr_dev_mode *)l->data;
if (_session.get_device()->dev_inst()->mode == mode->mode) {
default_name += mode->acronym;
break;
}
}
default_name += _session.get_session_time().toString("-yyMMdd-hhmmss");
// Show the dialog
_file_name = QFileDialog::getSaveFileName(
NULL, tr("Save File"), settings.value(DIR_KEY).toString(),
NULL, tr("Save File"), default_name,
tr("DSView Data (*.dsl)"));
if (!_file_name.isEmpty()) {
......@@ -154,7 +164,7 @@ bool StoreSession::save_start(QString session_file)
if(f.suffix().compare("dsl"))
_file_name.append(tr(".dsl"));
QDir CurrentDir;
settings.setValue(DIR_KEY, CurrentDir.absoluteFilePath(_file_name));
settings.setValue(DIR_KEY, CurrentDir.filePath(_file_name));
QString meta_file = meta_gen(snapshot);
#ifdef ENABLE_DECODE
......@@ -502,6 +512,16 @@ bool StoreSession::export_start()
const QString DIR_KEY("ExportPath");
QSettings settings(QApplication::organizationName(), QApplication::applicationName());
QString default_name = settings.value(DIR_KEY).toString() + "/" + _session.get_device()->name() + "-";
for (const GSList *l = _session.get_device()->get_dev_mode_list();
l; l = l->next) {
const sr_dev_mode *mode = (const sr_dev_mode *)l->data;
if (_session.get_device()->dev_inst()->mode == mode->mode) {
default_name += mode->acronym;
break;
}
}
default_name += _session.get_session_time().toString("-yyMMdd-hhmmss");
// Show the dialog
QList<QString> supportedFormats = getSuportedExportFormats();
......@@ -512,7 +532,7 @@ bool StoreSession::export_start()
filter.append(";;");
}
_file_name = QFileDialog::getSaveFileName(
NULL, tr("Export Data"), settings.value(DIR_KEY).toString(),filter,&filter);
NULL, tr("Export Data"), default_name,filter,&filter);
if (!_file_name.isEmpty()) {
QFileInfo f(_file_name);
QStringList list = filter.split('.').last().split(')');
......@@ -520,7 +540,7 @@ bool StoreSession::export_start()
if(f.suffix().compare(_suffix))
_file_name += tr(".") + _suffix;
QDir CurrentDir;
settings.setValue(DIR_KEY, CurrentDir.absoluteFilePath(_file_name));
settings.setValue(DIR_KEY, CurrentDir.filePath(_file_name));
const struct sr_output_module** supportedModules = sr_output_list();
while(*supportedModules){
......
......@@ -467,7 +467,7 @@ void View::repeat_unshow()
void View::frame_began()
{
// if (_session.get_device()->dev_inst()->mode == LOGIC)
// _viewbottom->set_trig_time(_session.get_trigger_time());
// _viewbottom->set_trig_time(_session.get_session_time());
_search_hit = false;
_search_pos = 0;
set_search_pos(_search_pos, _search_hit);
......@@ -476,8 +476,8 @@ void View::frame_began()
void View::set_trig_time()
{
if (!_trig_time_setted && _session.get_device()->dev_inst()->mode == LOGIC) {
_session.set_trigger_time(QDateTime::currentDateTime());
_viewbottom->set_trig_time(_session.get_trigger_time());
_session.set_session_time(QDateTime::currentDateTime());
_viewbottom->set_trig_time(_session.get_session_time());
}
_trig_time_setted = true;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment