From 229674f5e2f6076c6b610981c2a20671f375c5d7 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 31 Oct 2018 20:54:15 +1100 Subject: [PATCH] added seeking to import (#113) --- io/config.cpp | 9 +++++++-- io/config.h | 1 + mainwindow.cpp | 5 +++++ mainwindow.h | 2 ++ mainwindow.ui | 9 +++++++++ ui/timelinewidget.cpp | 5 +++++ 6 files changed, 29 insertions(+), 2 deletions(-) diff --git a/io/config.cpp b/io/config.cpp index b874698a4..d7d609497 100644 --- a/io/config.cpp +++ b/io/config.cpp @@ -23,9 +23,10 @@ Config::Config() show_title_safe_area(false), use_custom_title_safe_ratio(false), custom_title_safe_ratio(1), - enable_drag_files_to_timeline(false), + enable_drag_files_to_timeline(true), autoscale_by_default(false), - recording_mode(2) + recording_mode(2), + enable_seek_to_import(false) {} void Config::load(QString path) { @@ -87,6 +88,9 @@ void Config::load(QString path) { } else if (stream.name() == "RecordingMode") { stream.readNext(); recording_mode = stream.text().toInt(); + } else if (stream.name() == "EnableSeekToImport") { + stream.readNext(); + enable_seek_to_import = (stream.text() == "1"); } } } @@ -128,6 +132,7 @@ void Config::save(QString path) { stream.writeTextElement("EnableDragFilesToTimeline", QString::number(enable_drag_files_to_timeline)); stream.writeTextElement("AutoscaleByDefault", QString::number(autoscale_by_default)); stream.writeTextElement("RecordingMode", QString::number(recording_mode)); + stream.writeTextElement("EnableSeekToImport", QString::number(enable_seek_to_import)); stream.writeEndElement(); // configuration stream.writeEndDocument(); // doc diff --git a/io/config.h b/io/config.h index 3d66fde5f..c87b06ee8 100644 --- a/io/config.h +++ b/io/config.h @@ -32,6 +32,7 @@ struct Config { bool enable_drag_files_to_timeline; bool autoscale_by_default; int recording_mode; + bool enable_seek_to_import; void load(QString path); void save(QString path); diff --git a/mainwindow.cpp b/mainwindow.cpp index 9dd0aa214..6201be442 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -646,6 +646,7 @@ void MainWindow::toolMenu_About_To_Be_Shown() { ui->actionRectified_Waveforms->setChecked(config.rectified_waveforms); ui->actionEnable_Drag_Files_to_Timeline->setChecked(config.enable_drag_files_to_timeline); ui->actionAuto_scale_by_Default->setChecked(config.autoscale_by_default); + ui->actionEnable_Seek_to_Import->setChecked(config.enable_seek_to_import); } void MainWindow::on_actionEdit_Tool_Selects_Links_triggered() { @@ -864,3 +865,7 @@ void MainWindow::on_actionEnable_Disable_Clip_triggered() { } } } + +void MainWindow::on_actionEnable_Seek_to_Import_triggered() { + config.enable_seek_to_import = !config.enable_seek_to_import; +} diff --git a/mainwindow.h b/mainwindow.h index d7a8bebd8..7695f9772 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -187,6 +187,8 @@ private slots: void on_actionEnable_Disable_Clip_triggered(); + void on_actionEnable_Seek_to_Import_triggered(); + private: Ui::MainWindow *ui; void setup_layout(); diff --git a/mainwindow.ui b/mainwindow.ui index e7829ef00..3a2ee326e 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -176,6 +176,7 @@ + @@ -797,6 +798,14 @@ Shift+E + + + true + + + Enable Seek to Import + + diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index eb8554e2d..41411cb3f 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -591,9 +591,12 @@ void TimelineWidget::dropEvent(QDropEvent* event) { } // add clips + long earliest_point = LONG_MAX; for (int i=0;ighosts.size();i++) { const Ghost& g = panel_timeline->ghosts.at(i); + earliest_point = qMin(earliest_point, g.in); + Clip* c = new Clip(s); c->media = g.media; c->media_type = g.media_type; @@ -665,6 +668,8 @@ void TimelineWidget::dropEvent(QDropEvent* event) { setFocus(); update_ui(true); + + if (config.enable_seek_to_import) panel_sequence_viewer->seek(earliest_point); } }