From db5641a0a4705e9d873db23a96afedae2ff916d8 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sun, 30 Jun 2019 11:19:20 -0700 Subject: [PATCH] created import and probe tasks --- app/core.cpp | 21 ++---------- app/task/CMakeLists.txt | 3 ++ app/task/import/CMakeLists.txt | 22 ++++++++++++ app/task/import/import.cpp | 63 ++++++++++++++++++++++++++++++++++ app/task/import/import.h | 20 +++++++++++ app/task/probe/CMakeLists.txt | 22 ++++++++++++ app/task/probe/probe.cpp | 20 +++++++++++ app/task/probe/probe.h | 19 ++++++++++ 8 files changed, 172 insertions(+), 18 deletions(-) create mode 100644 app/task/import/CMakeLists.txt create mode 100644 app/task/import/import.cpp create mode 100644 app/task/import/import.h create mode 100644 app/task/probe/CMakeLists.txt create mode 100644 app/task/probe/probe.cpp create mode 100644 app/task/probe/probe.h diff --git a/app/core.cpp b/app/core.cpp index efd6dac09..944699b19 100644 --- a/app/core.cpp +++ b/app/core.cpp @@ -27,10 +27,10 @@ #include #include -#include "decoder/probeserver.h" #include "panel/panelfocusmanager.h" #include "panel/project/project.h" #include "project/item/footage/footage.h" +#include "task/import/import.h" #include "task/taskmanager.h" #include "ui/icons/icons.h" #include "ui/style/style.h" @@ -143,25 +143,10 @@ void Core::ImportFiles(const QStringList &urls) } else { - for (int i=0;iroot(), urls)); - QFileInfo file_info(url); - - f->set_filename(url); - f->set_name(file_info.fileName()); - f->set_timestamp(file_info.lastModified()); - - //olive::ProbeMedia(f); - - active_project->root()->add_child(f); - - } - - // FIXME: Dumb way of resetting the model to update for new information - active_project_panel->set_project(active_project); } } diff --git a/app/task/CMakeLists.txt b/app/task/CMakeLists.txt index f99cf323e..818a928d8 100644 --- a/app/task/CMakeLists.txt +++ b/app/task/CMakeLists.txt @@ -14,6 +14,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +add_subdirectory(import) +add_subdirectory(probe) + set(OLIVE_SOURCES ${OLIVE_SOURCES} task/task.h diff --git a/app/task/import/CMakeLists.txt b/app/task/import/CMakeLists.txt new file mode 100644 index 000000000..ed0fd9842 --- /dev/null +++ b/app/task/import/CMakeLists.txt @@ -0,0 +1,22 @@ +# Olive - Non-Linear Video Editor +# Copyright (C) 2019 Olive Team +# +# 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 3 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, see . + +set(OLIVE_SOURCES + ${OLIVE_SOURCES} + task/import/import.h + task/import/import.cpp + PARENT_SCOPE +) diff --git a/app/task/import/import.cpp b/app/task/import/import.cpp new file mode 100644 index 000000000..0c10d91de --- /dev/null +++ b/app/task/import/import.cpp @@ -0,0 +1,63 @@ +#include "import.h" + +#include +#include +#include + +// FIXME: Only used for test code +#include "panel/panelfocusmanager.h" +#include "panel/project/project.h" +// End test code + +#include "project/item/footage/footage.h" +#include "task/probe/probe.h" +#include "task/taskmanager.h" + +ImportTask::ImportTask(Folder *parent, const QStringList &urls) : + urls_(urls), + parent_(parent) +{ + set_text(tr("Importing %1 files").arg(urls.size())); +} + +bool ImportTask::Action() +{ + for (int i=0;iset_filename(url); + f->set_name(file_info.fileName()); + f->set_timestamp(file_info.lastModified()); + + parent_->add_child(f); + + // Create ProbeTask to analyze this media + ProbeTask* pt = new ProbeTask(f); + + // The task won't work unless it's in the main thread and we're definitely not + // FIXME: Should Tasks check what thread they're in and move themselves to the main thread? + pt->moveToThread(qApp->thread()); + + // Queue task in task manager + olive::task_manager.AddTask(pt); + + emit ProgressChanged(i * 100 / urls_.size()); + + } + + // FIXME: No good very bad test code to update the ProjectExplorer model/view + // A better solution would be for the Project itself to signal that a new row was being added + ProjectPanel* p = olive::panel_focus_manager->MostRecentlyFocused(); + p->set_project(p->project()); + // End test code + + return true; +} diff --git a/app/task/import/import.h b/app/task/import/import.h new file mode 100644 index 000000000..ddfcc63a2 --- /dev/null +++ b/app/task/import/import.h @@ -0,0 +1,20 @@ +#ifndef IMPORT_H +#define IMPORT_H + +#include "project/item/folder/folder.h" +#include "task/task.h" + +class ImportTask : public Task +{ + Q_OBJECT +public: + ImportTask(Folder *parent_, const QStringList& urls); + + virtual bool Action() override; + +private: + QStringList urls_; + Folder* parent_; +}; + +#endif // IMPORT_H diff --git a/app/task/probe/CMakeLists.txt b/app/task/probe/CMakeLists.txt new file mode 100644 index 000000000..55d195d96 --- /dev/null +++ b/app/task/probe/CMakeLists.txt @@ -0,0 +1,22 @@ +# Olive - Non-Linear Video Editor +# Copyright (C) 2019 Olive Team +# +# 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 3 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, see . + +set(OLIVE_SOURCES + ${OLIVE_SOURCES} + task/probe/probe.h + task/probe/probe.cpp + PARENT_SCOPE +) diff --git a/app/task/probe/probe.cpp b/app/task/probe/probe.cpp new file mode 100644 index 000000000..28f325c0b --- /dev/null +++ b/app/task/probe/probe.cpp @@ -0,0 +1,20 @@ +#include "probe.h" + +#include + +#include "decoder/probeserver.h" + +ProbeTask::ProbeTask(Footage *footage) : + footage_(footage) +{ + QString base_filename = QFileInfo(footage_->filename()).fileName(); + + set_text(tr("Probing \"%1\"").arg(base_filename)); +} + +bool ProbeTask::Action() +{ + olive::ProbeMedia(footage_); + + return true; +} diff --git a/app/task/probe/probe.h b/app/task/probe/probe.h new file mode 100644 index 000000000..0c4a5069e --- /dev/null +++ b/app/task/probe/probe.h @@ -0,0 +1,19 @@ +#ifndef PROBE_H +#define PROBE_H + +#include "project/item/footage/footage.h" +#include "task/task.h" + +class ProbeTask : public Task +{ + Q_OBJECT +public: + ProbeTask(Footage* footage); + + virtual bool Action() override; + +private: + Footage* footage_; +}; + +#endif // PROBE_H