created import and probe tasks

This commit is contained in:
itsmattkc
2019-06-30 11:19:20 -07:00
parent 823dd6c2e3
commit db5641a0a4
8 changed files with 172 additions and 18 deletions
+3 -18
View File
@@ -27,10 +27,10 @@
#include <QFileInfo>
#include <QMessageBox>
#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;i<urls.size();i++) {
const QString& url = urls.at(i);
// FIXME: Send selected folder for importing into
Footage* f = new Footage();
olive::task_manager.AddTask(new ImportTask(active_project->root(), 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);
}
}
+3
View File
@@ -14,6 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
add_subdirectory(import)
add_subdirectory(probe)
set(OLIVE_SOURCES
${OLIVE_SOURCES}
task/task.h
+22
View File
@@ -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 <http://www.gnu.org/licenses/>.
set(OLIVE_SOURCES
${OLIVE_SOURCES}
task/import/import.h
task/import/import.cpp
PARENT_SCOPE
)
+63
View File
@@ -0,0 +1,63 @@
#include "import.h"
#include <QApplication>
#include <QDebug>
#include <QFileInfo>
// 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;i<urls_.size();i++) {
const QString& url = urls_.at(i);
Footage* f = new Footage();
QFileInfo file_info(url);
// FIXME: Is it possible for a file to go missing between the Import dialog and here?
// And what is the behavior/result of that?
f->set_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<ProjectPanel>();
p->set_project(p->project());
// End test code
return true;
}
+20
View File
@@ -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
+22
View File
@@ -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 <http://www.gnu.org/licenses/>.
set(OLIVE_SOURCES
${OLIVE_SOURCES}
task/probe/probe.h
task/probe/probe.cpp
PARENT_SCOPE
)
+20
View File
@@ -0,0 +1,20 @@
#include "probe.h"
#include <QFileInfo>
#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;
}
+19
View File
@@ -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